:root {
    --primary: #208070;
    --primary-light: #2da18f;
    --accent: #e2e8f0;
    --bg: #ffffff;
    --bg-light: #f8fafc;
    --keypad: #f1f5f9;
    --keypad-action: #cbd5e1;
    --keypad-text: #0f172a;
    --text: #0f172a;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    overflow-x: hidden;
    touch-action: manipulation;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    color: var(--primary);
    margin: 10px 0;
    font-size: 2.5em;
    /* Safari 12 paint fix */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.nav-bar h1 {
    font-size: 1.4em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 450px;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    box-sizing: border-box;
    position: relative;
}

.screen.active {
    display: flex;
    /* Force GPU acceleration for Safari 12 ghost rendering fix */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    z-index: 1;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    row-gap: 12px;
    flex-grow: 1;
    padding: 10px 5px;
    overflow-y: auto;
    touch-action: manipulation;
    max-width: none;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    box-sizing: border-box;
    align-content: start;
    /* Prevents excessive vertical stretching */
    /* Safari 12 paint fix */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.grid button {
    background: var(--primary-light);
    color: white;
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    /* Safari 12 fallback for clamp */
    padding: 18px 10px;
    padding: min(max(14px, 4vw), 24px) min(max(8px, 2vw), 12px);
    /* margin-bottom fallback for gap */
    margin-bottom: 0px;
    min-height: 110px;
    /* Safari 12 fallback for clamp */
    font-size: 1.8rem;
    font-size: min(max(1.6rem, 5vw), 2.2rem);
    line-height: 1.3;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.grid button strong {
    /* Safari 12 fallback for clamp */
    font-size: 1.8rem;
    font-size: min(max(1.6rem, 4.8vw), 2.1rem);
    font-weight: bold;
}

/* Stock level indicator dot - top right corner of product tile */
.stock-dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.7);
}

.stock-dot.low {
    background: #f97316;
}

.stock-dot.out {
    background: #ef4444;
}

/* Zero-stock tile: greyed out but still tappable */
.grid button.out-of-stock {
    background: #a0aec0;
    opacity: 0.72;
    box-shadow: none;
}


.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 8px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 100;
    /* Safari 12 paint fix */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn,
.cart-btn,
.menu-btn {
    font-size: 2.5em;
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    margin: 0;
    z-index: 10;
}

.back-btn {
    /* Flex-based navigation - contextual (hidden by default) */
    cursor: pointer;
    margin-right: 15px !important;
    display: none;
}

/* Hamburger Menu Container */
.menu-container {
    position: relative;
    display: inline-block;
}

.menu-btn {
    cursor: pointer;
    display: flex;
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: scale(1.1);
}


/* Links inside the dropdown */
.dropdown-content {
    background-color: var(--primary);
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dropdown-content a {
    color: white; /* Accent text on primary bg */
    padding: 16px 20px;
    text-decoration: none;
    display: block;
    font-size: 1.4em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); 
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.1); /* Lighter accent for hover */
    border-radius: 0; 
}

.dropdown-content a:first-child:hover {
    border-radius: 12px 12px 0 0;
}

.dropdown-content a:last-child:hover {
    border-radius: 0 0 12px 12px;
}


.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Centered Navigation Helper */
.nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 5;
    color: var(--primary);
    font-weight: 600;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.cart-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

/* Removed legacy logout-btn */

#staff-name {
    font-size: 1.4em;
    color: var(--primary);
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
    margin-left: 10px;
}

/* Removed legacy logout-btn hover */

/* Cart item count badge */
.cart-btn::after {
    content: attr(data-count);
    font-size: 0.5em;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    padding: 4px 8px;
    min-width: 20px;
    position: absolute;
    top: -8px;
    right: -12px;
    display: none;
}

/* Receipt interactive items - moved out of nesting */
.receipt-item-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
}

.receipt-item-row:hover {
    background: rgba(var(--primary-rgb, 216, 27, 96), 0.05);
    transform: scale(1.01);
}

.receipt-item-row:active {
    background: rgba(var(--primary-rgb, 216, 27, 96), 0.1);
    transform: scale(0.99);
}

.receipt-item-row .desc {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-btn[data-count]:not([data-count=""])::after {
    display: block;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.badge.retail {
    background: #f0f4f8;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge.wholesale {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.2);
}

/* Sync Badge States */
.badge.sync-online {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge.sync-offline {
    background: #fff3e0;
    color: #ef6c00;
    border: 1px solid #ffe0b2;
}

.badge.sync-pending {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.badge.sync-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
    flex-shrink: 0;
    padding: 0 10px;
}

.keypad button {
    /* Safari 12 fallback for clamp */
    font-size: 2.8rem;
    font-size: min(max(2.5rem, 8vw), 3.5rem);
    padding: 24px 20px;
    padding: min(max(20px, 6vw), 30px);
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Subtle shadow for depth */
}

.keypad button.backspace {
    background: #ff4400;
    /* Lighter Orange */
    color: white;
    border: none;
}

.keypad button.add {
    background: #54bf5a;
    /* Lighter Green */
    color: white;
    border: none;
}

.keypad button.equals {
    /* Safari 12 fallback for clamp */
    font-size: 2.8rem;
    font-size: min(max(2.5rem, 8vw), 3.5rem);
    background: var(--primary) !important;
    color: var(--bg);
    /* color: #f44336; */
    /* Red */
    border: 1px solid #f44336;
    grid-column: span 3;
}

/* Split Key Container (0 and .) */
.key-split-container {
    display: flex;
    gap: 8px; /* Match grid gap slightly closer */
    width: 100%;
}

.key-split-container button {
    margin: 0; /* Override any margins */
    height: 100%; /* Ensure full height */
}

/* 0 Key takes available space */
.key-split-container button[data-value="0"] {
    flex: 1;
}

/* Decimal Key takes fixed small width */
.key-split-container button.decimal {
    width: auto;
    flex: 0 0 15%; /* Start with 15% as requested (10-20% range) */
    padding: 0; /* Remove padding to fit text */
    display: flex; /* Ensure centering */
    align-items: center;
    justify-content: center;
    min-width: 40px; /* Minimum touch target */
}

#current-qty {
    font-size: 4em;
    text-align: center;
    margin: 20px 0;
    color: var(--accent);
    font-weight: bold;
    flex-shrink: 0;
}

#cart-header {
    display: block !important;
    z-index: 110;
    position: relative;
    /* Prevents being obscured by fixed navbars if any */
}

#cart-items {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.8em;
    margin-bottom: 10px;
}

.cart-item {
    background: var(--bg-light);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    /* Space optimization */
    padding: 10px 15px;
    font-size: 0.8em;
    margin: 4px 0;
    align-items: center;
}

.cart-item-qty-badge {
    font-weight: bold;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 32px;
    text-align: center;
    margin-right: 12px;
}

.cart-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    font-weight: 600;
    margin-left: 15px;
    opacity: 0.9;
}

/* Search specific additions */
.search-category-header {
    font-size: 14px;
    font-weight: bold;
    color: var(--primary);
    padding: 12px 10px 6px;
    background: var(--bg-light);
    border-bottom: 1px solid #eee;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-item {
    background: var(--bg);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    padding: 15px;
    font-size: 1.4em;
    margin: 4px 0;
    align-items: center;
    border: 1px solid #eee;
    transition: background 0.2s;
}

.search-result-item:active {
    background: var(--bg-light);
}

.search-result-name {
    flex: 1;
    color: var(--text);
}

.search-result-price {
    font-weight: bold;
    color: var(--primary);
}

#total {
    font-size: 2.5em;
    text-align: center;
    color: var(--accent);
    margin: 10px 0;
}

.big-btn {
    font-size: 2.2em;
    padding: 20px;
    margin: 10px 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 15px;
}

#receipt-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background: white;
    margin: 10px 0;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 1.6em;
    line-height: 1.6;
}

#receipt-content h1 {
    text-align: center;
    color: var(--primary);
    font-size: 2.8em;
    margin: 10px 0 20px;
}

#receipt-content .date {
    text-align: center;
    font-size: 1.8em;
    margin: 10px 0;
    color: #555;
}

#receipt-content .customer {
    text-align: center;
    font-size: 1.6em;
    margin: 15px 0;
}

#receipt-content hr {
    border: none;
    border-top: 2px dashed var(--primary);
    margin: 20px 0;
}

#receipt-content .items div {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1.7em;
}

#receipt-content .total {
    text-align: center;
    font-size: 2.6em;
    color: var(--accent);
    font-weight: bold;
    margin: 20px 0;
}

#receipt-content .thanks {
    text-align: center;
    font-size: 1.8em;
    margin: 30px 0 10px;
    color: var(--primary);
}

.receipt-actions .full-width {
    width: 100%;
    margin: 0;
    font-size: 2.2em;
    padding: 25px;
    background: var(--primary);
}

.receipt-actions {
    padding: 20px;
}

#receipt-content h1 {
    font-size: 2.8em;
    text-align: center;
    color: var(--primary);
    margin: 0 0 15px 0;
    font-weight: bold;
}

#receipt-content .date {
    text-align: center;
    font-size: 1.6em;
    color: #777;
    margin: 10px 0 20px 0;
}

#receipt-content .customer {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: center;
    font-size: 1.4em;
}

#receipt-content .customer strong {
    color: var(--accent);
}

#receipt-content hr {
    border: none;
    border-top: 3px dashed var(--primary);
    margin: 30px 0;
}

#receipt-content .category {
    font-size: 1.6em;
    font-weight: bold;
    color: var(--primary);
    margin: 15px 0 5px 0;
    text-align: left;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--primary-light);
}

#receipt-content .items div {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 1.5em;
    border-bottom: 1px dotted #eee;
}

#receipt-content .items .desc {
    flex: 1;
    padding-right: 20px;
    word-wrap: break-word;
}

#receipt-content .items .amount {
    font-weight: bold;
    color: var(--accent);
    min-width: 120px;
    text-align: right;
}

#receipt-content .total {
    font-size: 2.2em !important;
    font-weight: bold;
    color: var(--accent);
    text-align: right !important;
    margin: 10px 0 5px 0;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 10px;
}

#receipt-content .thanks {
    text-align: center;
    font-size: 1.4em;
    color: var(--primary);
    margin: 10px 0;
    font-style: italic;
}



/* Ensure full content in PDF generation */
#receipt-content * {
    max-width: 100%;
    word-wrap: break-word;
    page-break-inside: avoid;
}

@media print {
    @page {
        size: a4 portrait;
        margin: 0.5in;
    }

    body,
    html {
        margin: 0;
        padding: 0;
        background: white;
    }

    #receipt-content {
        width: 100%;
        font-size: 0.9em !important;
        line-height: 1.2 !important;
        padding: 0.5in !important;
        margin: 0 auto;
    }

    #receipt-content h1 {
        font-size: 2.2em;
    }

    #receipt-content .date {
        font-size: 1.4em;
    }

    #receipt-content .category {
        font-size: 1.6em;
        margin: 15px 0 5px 0;
    }

    #receipt-content .items div {
        padding: 6px 0;
        font-size: 1.5em;
    }

    #receipt-content .total {
        font-size: 2.5em !important;
        margin: 20px 0 10px 0;
        padding: 10px;
    }

    #receipt-content .thanks {
        font-size: 1.5em;
        margin: 20px 0 0 0;
    }

    /* Ensure no page breaks inside groups */
    .category,
    .items div {
        page-break-inside: avoid;
    }
}

/* Custom POS Modal - Mobile-Friendly */
/* Custom POS Modal - Mobile-Friendly with Full Scrolling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    /* Bottom-aligned on mobile */
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    height: 90vh;
    /* Fixed height for consistent scrolling */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    background: var(--primary);
    color: white;
    margin: 0;
    padding: 18px;
    text-align: center;
    font-size: 2em;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
    flex: 1;
    /* Takes available space */
    overflow-y: auto;
    /* Always scrollable */
    -webkit-overflow-scrolling: touch;
}

.modal-body label {
    display: block;
    margin: 15px 0 6px 0;
    font-size: 1.5em;
    color: var(--accent);
    font-weight: bold;
}

.modal-body input {
    width: 100%;
    padding: 14px;
    font-size: 1.6em;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    box-sizing: border-box;
}

#existing-customer-info {
    background: rgba(var(--primary-rgb), 0.1);
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    font-size: 1.4em;
}

.modal-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: var(--bg);
    flex-shrink: 0;
    /* Buttons always visible */
    border-radius: 0 0 20px 20px;
}

.modal-actions button {
    flex: 1;
    font-size: 1.8em;
    padding: 16px;
}

/* On larger screens (tablets+), center the modal */
@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 20px;
        height: auto;
        max-height: 85vh;
    }

    .modal-actions {
        border-radius: 0 0 20px 20px;
    }
}


/* Custom POS Modal */
/* .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-content h2 {
    background: #d81b60;
    color: white;
    margin: 0;
    padding: 20px;
    text-align: center;
    font-size: 2.2em;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin: 15px 0 8px 0;
    font-size: 1.6em;
    color: #c51162;
    font-weight: bold;
}

.modal-body input {
    width: 100%;
    padding: 15px;
    font-size: 1.8em;
    border: 2px solid #f06292;
    border-radius: 12px;
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: #f8bbd0;
}

.modal-actions button {
    flex: 1;
    font-size: 1.8em;
    padding: 18px;
} */


/* Phones (small screens) - 2 columns */
@media (max-width: 600px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        row-gap: 10px;
    }

    .cart-btn {
        font-size: 2.2em;
        top: 8px;
        right: 8px;
        gap: 6px;
    }

    .grid button {
        min-height: 100px;
        padding: 12px 8px;
        /* Safari 12 fallback for clamp */
        font-size: 1.4rem;
        font-size: min(max(1.3rem, 4.5vw), 1.6rem);
    }

    .grid button strong {
        /* Safari 12 fallback for clamp */
        font-size: 1.5rem;
        font-size: min(max(1.4rem, 5vw), 1.7rem);
    }

    .keypad {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
        padding: 0 16px;
    }

    .keypad button {
        font-size: 2.8rem !important;
        padding: 18px !important;
        min-height: 70px;
        line-height: 1.1;
        width: 100%;
        box-sizing: border-box;
    }

    .keypad button.backspace {
        font-size: 2.5rem !important;
    }

    .keypad button.equals {
        padding: 20px !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 10px 0;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    .back-btn,
    .cart-btn {
        font-size: 2.2em !important;
    }

    .modal {
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        height: 90vh;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        /* prevents growth */
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-actions {
        flex-shrink: 0;
    }
}

/* Large desktops only (iMac etc.) - Still 3 columns but centered */
@media (min-width: 1200px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* Extra large text on tablets/old iPads */
/* @media (min-width: 481px) and (max-width: 1024px) {
    .grid button {
        font-size: clamp(2rem, 7vw, 3rem) !important;
        padding: clamp(20px, 6vw, 40px) clamp(12px, 4vw, 20px) !important;
        min-height: 140px !important;
    }
    .grid button strong {
        font-size: clamp(2.4rem, 8vw, 3.6rem) !important;
    }
} */

/* Old iPads – PORTRAIT (768 × 1024) */
@media (orientation: portrait) and (max-width: 820px) and (min-width: 700px) {

    .grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 16px;
        gap: 16px;
    }

    .grid button {
        min-height: 150px !important;
        padding: 24px 20px !important;
        font-size: 1.8rem !important;
        line-height: 1.25;
    }

    .grid button strong {
        font-size: 1.8rem !important;
    }

    .keypad {
        gap: 15px;
        margin: 25px 0;
        padding: 0 20px;
    }

    .keypad button {
        font-size: 3.5rem !important;
        padding: 30px !important;
        min-height: 90px;
    }

    .keypad button.backspace {
        font-size: 3rem !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 10px 0;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    .back-btn,
    .cart-btn {
        font-size: 2.2em !important;
    }
}

/* Old iPads – LANDSCAPE font lock */
@media (orientation: landscape) and (max-width: 1025px) {

    .grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 16px;
        gap: 16px;
    }

    .grid button {
        min-height: 150px !important;
        padding: 24px 20px !important;
        font-size: 1.8rem !important;
        line-height: 1.25;
    }

    .grid button strong {
        font-size: 1.8rem !important;
    }

    .keypad {
        gap: 10px;
        margin: 15px 0;
        padding: 0 16px;
    }

    .keypad button {
        font-size: 2.8rem !important;
        padding: 18px !important;
        min-height: 70px;
        line-height: 1.1;
    }

    .keypad button.backspace {
        font-size: 2.5rem !important;
    }

    .keypad button.equals {
        padding: 20px !important;
    }

    #current-qty {
        font-size: 3.0rem !important;
        margin: 6px 0 !important;
    }

    #product-title {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    #product-title strong {
        font-size: 2.2rem !important;
    }

    #screen-quantity {
        padding: 10px;
    }

    /* Aggressive Space Saving for Receipt Screen */
    #screen-receipt.active {
        padding: 0 10px !important;
        /* Minimal vertical padding */
        overflow: hidden !important;
        /* Ensure height is strictly 100vh */
        display: flex;
        flex-direction: column;
    }

    #screen-receipt>h1 {
        display: block !important;
        font-size: 1.8em !important;
        margin: 5px 0 !important;
    }

    #screen-receipt .nav-bar {
        padding: 5px 10px !important;
        /* Tighter nav */
        flex-shrink: 0 !important;
    }

    #receipt-content {
        padding: 8px !important;
        margin: 2px 0 5px 0 !important;
        /* Minimal vertical margins */
        font-size: 1.25em !important;
        flex: 1 1 0% !important;
        /* Strict flex growth to fill available height */
        min-height: 0 !important;
        /* REQUIRED for content to shrink and scroll within flex */
        overflow-y: auto !important;
    }

    #receipt-content h1 {
        display: block !important;
        /* Store name inside receipt */
        font-size: 1.6em !important;
        margin: 2px 0 5px 0 !important;
    }

    #receipt-content .date {
        font-size: 1.1em !important;
        margin: 0 0 10px 0 !important;
    }

    #receipt-content hr {
        margin: 10px 0 !important;
    }

    #receipt-content .category {
        font-size: 1.3em !important;
        margin: 8px 0 2px 0 !important;
    }

    #receipt-content .items div {
        font-size: 1.25em !important;
        padding: 2px 0 !important;
    }

    #receipt-content .total {
        font-size: 1.8em !important;
        margin: 10px 0 !important;
        padding: 8px !important;
    }

    #receipt-content .thanks {
        font-size: 1.1em !important;
        margin: 2px 0 !important;
    }

    .receipt-actions {
        padding: 5px 20px !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        /* Never let buttons be hidden */
        display: flex;
        flex-direction: column;
    }

    .receipt-actions .big-btn {
        padding: 12px 15px !important;
        font-size: 1.6em !important;
        margin: 0 !important;
        height: auto !important;
    }

    .back-btn,
    .cart-btn,
    .menu-btn {
        font-size: 2.0em !important;
    }
}