/* Print KOT: focus on order modal content */
@media print {
    @page {
        size: auto;
        margin: 6mm;
    }

    html,
    body {
        height: auto;
    }

    body {
        margin: 0;
        background: #fff;
    }

    body * {
        visibility: hidden;
    }

    #orderModal,
    #orderModal * {
        visibility: visible;
    }

    #orderModal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .modal {
        box-shadow: none;
        border: none;
    }

    .modal-content {
        margin: 0;
        width: 100%;
        max-width: none;
        border-radius: 0;
    }

    .modal-body {
        padding: 10px;
    }

    .modal-actions {
        display: none !important;
    }

    .item-entry,
    .bill-extra,
    .order-summary-actions,
    #orderItems {
        display: none !important;
    }

    #kotPrint {
        display: block !important;
    }

    .kot-header {
        font-weight: 700;
        margin-bottom: 8px;
        font-size: 13px;
    }

    .kot-table {
        width: 100%;
        border-collapse: collapse;
    }

    .kot-table th,
    .kot-table td {
        border-bottom: 1px solid #ddd;
        padding: 4px 6px;
        font-size: 12px;
    }

    .kot-table th {
        text-align: left;
    }
}

/* Prevent content overflow in order modal/table */
.order-header-row {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 90px 0.8fr 60px;
    gap: 12px;
    padding: 10px 16px;
    background: white;
    color: #263238;
    font-weight: 600;
    font-size: 13px;
    border-radius: 4px 4px 0 0;
    margin-bottom: 8px;
    position: relative;
    /* ensure .saved-indicator anchors to the card */
    border-bottom: 2px solid #e0e0e0;
    width: 100%;
}

.order-header-item,
.order-header-unit,
.order-header-price,
.order-header-qty,
.order-header-subtotal,
.order-header-action {
    display: flex;
    align-items: center;
}

.order-header-qty,
.order-header-subtotal,
.order-header-action {
    justify-content: center;
}

.order-row {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 90px 0.8fr 60px;
    gap: 12px;
    align-items: center;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 8px;
    width: 100%;
}

.order-row-item {
    font-weight: 600;
    font-size: 14px;
    color: #212121;
}

.order-row-unit,
.order-row-price {
    font-size: 13px;
    color: #757575;
}

.order-row-qty {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.order-row-qty span {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

.order-row-subtotal {
    font-weight: 600;
    font-size: 14px;
    color: #212121;
    text-align: center;
}

.order-row-action {
    display: flex;
    justify-content: center;
}

.qty-ctrl-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    width: 26px;
    height: 26px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    color: #212121;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-ctrl-btn:hover {
    background: #e8e8e8;
}

.remove-link {
    background: transparent;
    border: none;
    color: #757575;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.remove-link:hover {
    color: #212121;
    text-decoration: underline;
}

.order-table {
    table-layout: fixed;
    width: 100%;
}

.order-table th,
.order-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.order-table th:nth-child(1),
.order-table td:nth-child(1) {
    width: 40%;
}

.order-table th:nth-child(2),
.order-table td:nth-child(2) {
    width: 12%;
}

.order-table th:nth-child(3),
.order-table td:nth-child(3) {
    width: 16%;
}

.order-table th:nth-child(4),
.order-table td:nth-child(4) {
    width: 16%;
}

.order-table th:nth-child(5),
.order-table td:nth-child(5) {
    width: 16%;
}

.quantity-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.quantity-controls button {
    flex: 0 0 auto;
}

.modal-content {
    max-width: 98vw;
    width: 98%;
}

.modal-body {
    overflow-y: auto;
}

#orderForm {
    width: 100%;
}

.item-entry .entry-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-wrapper {
    flex: 1;
    position: relative;
    /* Ensure dropdown positions correctly relative to this */
}

.entry-search {
    flex: 1;
    /* Takes remaining space */
    min-width: 0;
}

.entry-select,
input.entry-select {
    width: 80px !important;
    flex-shrink: 0;
}

.entry-price {
    width: 80px !important;
    flex-shrink: 0;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.entry-qty {
    width: 50px !important;
    flex-shrink: 0;
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.btn-add-item {
    flex-shrink: 0;
    white-space: nowrap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

/* Top Bar */
.top-bar {
    background: white;
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.restaurant-name {
    font-size: 20px;
    font-weight: 700;
    color: #263238;
    display: flex;
    align-items: center;
    gap: 10px;
}

.today-sales {
    padding: 4px 12px;
    background: #e8f5e9;
    border: 2px solid #4caf50;
    border-radius: 25px;
    font-weight: 600;
    color: #2e7d32;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logout-btn {
    color: #37474f;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 18px;
    transition: background 0.2s, color 0.2s;
    background: #eceff1;
}

.logout-btn:hover {
    background: #cfd8dc;
    color: #000;
}

.settings-dropdown {
    position: relative;
}

.settings-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #555;
    padding: 4px 8px;
    line-height: 1;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.settings-menu {
    position: absolute;
    right: 0;
    top: 38px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    min-width: 250px;
    z-index: 1001;
}

.settings-menu a {
    display: block;
    padding: 10px 12px;
    text-decoration: none;
    color: #333;
}

.settings-menu a:hover {
    background: #fff2e6;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* Left Section */
.left-section {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafafa;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-bar input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: #4caf50;
}

.clear-btn {
    padding: 10px 20px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

.clear-btn:hover {
    background: #e0e0e0;
}

/* Menu Section */
.category-section {
    margin-bottom: 30px;
}

.category-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.favorites-section {
    margin-bottom: 16px;
    background: #fffdf7;
    border: 1px solid #ffe0b2;
    padding: 12px;
    border-radius: 10px;
}

.favorites-title {
    font-weight: 700;
    color: #ff6f00;
    margin-bottom: 8px;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.menu-item {
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.item-info {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-start;
}

.no-image-box {
    width: 48px;
    height: 48px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
}

.item-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.item-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.4;
}

.item-category {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.item-subcategory {
    font-size: 11px;
    color: #999;
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.item-price {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.item-unit-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.unit-label {
    font-size: 11px;
    color: #666;
}

.item-unit-select {
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
}

.add-btn {
    padding: 6px 12px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

/* Favorite star button */
.fav-btn {
    display: inline-block;
    cursor: pointer;
    margin-left: 6px;
    background: none;
    border: none;
    padding: 0;
}

.fav-btn .fav-star {
    font-size: 16px;
    line-height: 1;
    display: inline-block;
}

.add-btn:hover {
    background: #45a049;
}

/* Right Section - Tables */
.right-section {
    width: 380px;
    background: white;
    border-left: 1px solid #e0e0e0;
    padding: 20px;
    overflow-y: auto;
}

.right-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
}

.tables-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.table-group-section {
    background: #fafafa;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: #37474f;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ff9800;
}

.section-tables {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.table-card {
    /* Empty table: light green */
    background: #e8f5e9;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.table-card:hover {
    border-color: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
}

/* Table has any order: light pink */
.table-card.has-order {
    background: #ffe6e6;
    border-color: #ff8a80;
}

/* Print-only KOT: hide everything except the KOT block when printing */
@media print {
    body.printing-kot * {
        display: none !important;
        visibility: hidden !important;
    }

    body.printing-kot #kotPrint,
    body.printing-kot #kotPrint * {
        display: block !important;
        visibility: visible !important;
    }
}

/* Saved table: light yellow */
.table-card.saved {
    background: #fff9c4;
    border-color: #ffd54f;
    position: relative;
    /* padding-top removed for inline layout */
}

.saved-indicator {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 8px;
    background: #28a745;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    /* Slightly larger for readability */
    font-weight: bold;
    white-space: nowrap;
}

.table-card.selected {
    border-color: #2196F3;
    box-shadow: 0 0 0 2px #2196F3;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.table-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.table-timer {
    display: none;
    /* Hidden by default */
    font-size: 11px;
    color: #555;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
    border: 1px solid #ddd;
}

.table-status {
    font-size: 11px;
    color: #666;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
}

.table-amount {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 1% auto;
    width: 98%;
    max-width: 98vw;
    height: 95vh;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #ffffff;
}

.modal-title h2 {
    font-size: 15px;
    color: #333;
    margin: 0;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    gap: 8px;
}

.btn-chip {
    padding: 8px 12px;
    border-radius: 16px;
    font-weight: 700;
    border: none;
}

.btn-chip.upi {
    background: #00c853;
    color: #fff;
}

.btn-outline {
    padding: 10px 20px;
    border: 1px solid #2196f3;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    color: #2196f3;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-outline.danger {
    border-color: #f44336;
    color: #f44336;
    background: #ffebee;
}

.btn-outline:hover {
    background: rgba(33, 150, 243, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.2);
}

.btn-outline.danger:hover {
    background: #ffcdd2;
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.2);
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

/* Payment Modal styles */
.payment-options {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.payment-options label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
    padding: 6px 8px;
    border-radius: 6px;
}

.payment-options input[type="radio"] {
    accent-color: #2e7d32;
}

#dueFields input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}

#dueFields input[type="text"]::placeholder {
    color: #9e9e9e;
}

#dueFields input[type="text"]:focus {
    border-color: #42a5f5;
    box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.15);
}

/* Improve payment modal input sizing */
#paymentModal input[type="number"],
#paymentModal input[type="text"] {
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
}

#paymentModal label {
    font-size: 13px;
    color: #455a64;
}

#paymentModal .modal-content {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.payment-options label:hover {
    background: #f7f7f7;
}

#paymentModal .modal-content {
    border-radius: 10px;
    height: auto !important;
    min-height: 0;
}

#paymentModal .modal-header h3 {
    margin: 0;
    font-size: 18px;
}

#paymentModal .modal-title p {
    margin: 4px 0 0;
    font-size: 14px;
}

#paymentTotal {
    font-weight: 700;
}

#paymentModal .btn-pay {
    background: #2e7d32;
    border-radius: 6px;
    padding: 8px 16px;
}

#paymentModal .btn-pay:hover {
    filter: brightness(1.05);
}

.close-modal:hover {
    color: #333;
}

#paymentModal .form-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.split-summary {
    margin-top: 8px;
    font-size: 12px;
    color: #333;
    display: flex;
    gap: 8px;
}

#splitError {
    margin-top: 6px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4caf50;
}

.order-items {
    margin: 12px 0 20px;
    min-height: 120px;
}

.empty-order {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.order-table th {
    background: #fafafa;
    color: #333;
    padding: 10px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.order-table td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-controls button {
    width: 24px;
    height: 24px;
    border: none;
    background: #4caf50;
    color: white;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

.quantity-controls button:hover {
    background: #45a049;
}

.quantity-controls span {
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}

.btn-remove {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.btn-remove:hover {
    background: #d32f2f;
}

.order-summary {
    background: #fff;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 13px;
}

.summary-row.total {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 16px;
    color: #4caf50;
}

/* Entry row below items */
.item-entry {
    background: #fff;
    border: 1px dashed #e0e0e0;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.entry-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 0.8fr 0.6fr auto;
    gap: 8px;
    align-items: center;
}

.entry-search,
.entry-select,
.entry-qty {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.btn-add-item {
    padding: 8px 14px;
    background: #1e88e5;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-add-item:hover {
    background: #1976d2;
}

/* Discount and extras */
.bill-extra {
    background: #fffdf7;
    border: 1px solid #ffe0b2;
    padding: 8px;
    border-radius: 6px;
    margin: 8px 0;
}

.extra-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.extra-group {
    flex: 1 1 120px;
    min-width: 0;
}


.extra-group label {
    font-size: 11px;
    color: #777;
    display: block;
    margin-bottom: 2px;
}

.extra-group select,
.extra-group input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

/* Footer actions */
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-save {
    background: #ffb300;
    color: #fff;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-print {
    background: #667eea;
    color: #fff;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-pay {
    background: #43a047;
    color: #fff;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-save:hover {
    background: #ffa000;
}

.btn-print:hover {
    background: #5a67d8;
}

.btn-pay:hover {
    background: #388e3c;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn-clear,
.btn-submit {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-clear {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.btn-clear:hover {
    background: #e0e0e0;
}

.btn-submit {
    background: #4caf50;
    color: white;
}

.btn-submit:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

/* Orders Page Styles */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    margin-top: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

nav {
    display: flex;
    justify-content: center;
    gap: 20px;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 10px 25px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

nav a:hover,
nav a.active {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
}

.content {
    padding: 30px;
}

.orders-container {
    padding: 30px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.orders-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.orders-table th,
.orders-table td {
    padding: 15px;
    text-align: left;
}

.orders-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.3s ease;
}

.orders-table tbody tr:hover {
    background: #f8f9fa;
}

.amount {
    font-weight: bold;
    color: #28a745;
}

.btn-view {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.btn-view:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

.no-orders {
    text-align: center;
    font-size: 1.2em;
    color: #666;
    padding: 50px;
}

.no-orders a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
    opacity: 0.9;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
}

/* Receipt Styles */
.receipt-container {
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.receipt {
    background: white;
    border: 2px solid #333;
    padding: 40px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.receipt-header {
    text-align: center;
    margin-bottom: 30px;
}

.restaurant-name {
    font-size: 1.5em;
    font-weight: bold;
    margin: 10px 0;
}

.receipt hr {
    border: none;
    border-top: 2px dashed #333;
    margin: 20px 0;
}

.receipt-details p {
    margin: 10px 0;
}

.receipt-items {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.receipt-items th {
    border-bottom: 2px solid #333;
    padding: 10px;
    text-align: left;
}

.receipt-items td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.receipt-totals {
    margin-top: 20px;
}

.receipt-totals p {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
}

.total-line {
    font-size: 1.3em;
    font-weight: bold;
}

.receipt-footer {
    text-align: center;
    margin-top: 30px;
    font-style: italic;
    color: #666;
}

.receipt-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-print,
.btn-new-order,
.btn-back {
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: bold;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-print {
    background: #fff;
    color: #2196F3;
    border: 1px solid #2196F3;
}

.btn-new-order {
    background: #28a745;
    color: white;
    display: inline-block;
}

.btn-back {
    background: #6c757d;
    color: white;
    display: inline-block;
}

.btn-print:hover,
.btn-new-order:hover,
.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }

    .right-section {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }

    .tables-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .section-tables {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {

    /* Hide menu section on mobile - only show tables */
    .left-section {
        display: none !important;
    }

    /* Make right section (tables) full width on mobile */
    .right-section {
        width: 100% !important;
        border-left: none !important;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .tables-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .section-tables {
        grid-template-columns: repeat(3, 1fr);
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .top-bar {
        flex-wrap: wrap;
        gap: 10px;
        overflow: visible !important;
        position: relative;
        z-index: 1000;
    }

    .user-info {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    /* Fix settings dropdown being cut off on mobile */
    .settings-dropdown {
        position: relative;
        z-index: 1002;
    }

    .settings-menu {
        position: fixed !important;
        right: 10px !important;
        top: 60px !important;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        z-index: 9999 !important;
    }

    /* ===== MOBILE ORDER PANEL IMPROVEMENTS ===== */

    /* Modal takes full screen on mobile */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .modal-body {
        padding: 12px !important;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }

    /* Modal header - make buttons larger and more touch-friendly */
    .modal-header {
        padding: 12px 15px !important;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-title h2 {
        font-size: 18px !important;
    }

    .modal-actions {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }

    .modal-actions button,
    .btn-outline,
    .btn-chip {
        padding: 8px 12px !important;
        font-size: 13px !important;
        min-height: 40px;
    }

    /* Order header row - stack on mobile */
    .order-header-row {
        display: none !important;
        /* Hide header on mobile for cleaner look */
    }

    /* Order items - card-based layout for mobile */
    .order-row {
        display: flex !important;
        flex-direction: column !important;
        background: #f8f9fa;
        padding: 12px !important;
        border-radius: 8px;
        margin-bottom: 10px;
        gap: 8px;
        border: 1px solid #e0e0e0;
    }

    .order-row-item {
        font-size: 15px !important;
        font-weight: 600 !important;
        color: #212121;
        grid-column: unset !important;
    }

    .order-row-unit,
    .order-row-price {
        display: inline-block;
        font-size: 13px !important;
        color: #666;
    }

    .order-row-qty {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 8px;
    }

    .order-row-qty .quantity-controls {
        gap: 10px;
    }

    .qty-ctrl-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
        border: 2px solid #ddd !important;
    }

    .order-row-subtotal {
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #2e7d32;
        text-align: right;
    }

    .order-row-action {
        margin-top: 8px;
    }

    .remove-link {
        padding: 6px 12px !important;
        background: #ffebee;
        border-radius: 4px;
        color: #c62828 !important;
        font-size: 13px !important;
    }

    /* Item entry - better mobile layout */
    .item-entry {
        margin-bottom: 16px !important;
    }

    .entry-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .entry-search,
    .entry-select,
    .entry-qty {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
        min-height: 44px;
    }

    .btn-add-item {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important;
        min-height: 48px;
        font-weight: 600;
    }



    /* Bill extras - stack on mobile */
    .bill-extra {
        padding: 12px !important;
    }

    .extra-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .extra-group {
        width: 100%;
    }

    .extra-group label {
        font-size: 13px !important;
        margin-bottom: 6px;
    }

    .extra-group select,
    .extra-group input {
        padding: 10px !important;
        font-size: 15px !important;
        min-height: 44px;
    }

    /* Order summary - larger text */
    .order-summary {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    .summary-row {
        padding: 8px 0 !important;
        font-size: 15px !important;
    }

    .summary-row.total {
        font-size: 20px !important;
        padding-top: 12px !important;
    }

    /* Modal footer - stack buttons vertically on mobile */
    .modal-footer {
        padding: 12px 15px !important;
        flex-direction: column !important;
        gap: 10px !important;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #e0e0e0;
    }

    .modal-footer button {
        width: 100% !important;
        padding: 14px !important;
        font-size: 16px !important;
        min-height: 50px;
        font-weight: 600;
    }

    .btn-save,
    .btn-print,
    .btn-pay {
        border-radius: 8px !important;
    }
}

/* Colorful Theme Overrides */
.top-bar {
    background: linear-gradient(90deg, #ffecd2 0%, #fcb69f 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(252, 182, 159, 0.35);
}

.restaurant-name {
    font-weight: 700;
    color: #263238;
}

.today-sales {
    background: #fff8e1;
    border: 2px solid #ffb300;
    color: #f57c00;
    font-weight: 700;
}

.menu-dropdown .menu-btn {
    border-color: #ffd2c1;
    color: #d84315;
}

.menu-dropdown .menu-btn:hover {
    background: #ffe9df;
}

.left-section {
    background: linear-gradient(180deg, #fafafa 0%, #f5f9ff 100%);
}

.search-bar {
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.clear-btn {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
    border-radius: 6px;
    font-weight: 600;
}

.clear-btn:hover {
    background: #bbdefb;
    transform: translateY(-1px);
}

.menu-item {
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
}

.menu-item:hover {
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.12);
    border-color: #ffe0b2;
}

.no-image-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #fce4ec 100%);
    border-radius: 8px;
    color: #607d8b;
}

.item-name {
    color: #37474f;
    font-weight: 700;
}

.item-category {
    color: #8e24aa;
}

.item-subcategory {
    color: #9e9e9e;
}

.item-price {
    color: #1b5e20;
    font-weight: 800;
}

.add-btn {
    background: linear-gradient(90deg, #43a047 0%, #1e88e5 100%);
    border-radius: 20px;
    font-weight: 600;
}

.add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(30, 136, 229, 0.3);
}

.right-section {
    background: linear-gradient(180deg, #ffffff 0%, #fdf6e3 100%);
    border-left-color: #ffe0b2;
}

.tables-grid {
    gap: 14px;
}

.table-card {
    border-radius: 10px;
}

.table-card:hover {
    border-color: #00c853;
    box-shadow: 0 6px 12px rgba(0, 200, 83, 0.25);
}

/* Override legacy colors to ensure new scheme applies */
.table-card.has-order {
    background: #ffe6e6;
    border-color: #ff8a80;
}

.table-card.saved {
    background: #fff9c4;
    border-color: #ffd54f;
}

.table-card.selected {
    border-color: #2196F3;
    box-shadow: 0 0 0 2px #2196F3;
}


/* Orders Page Styles */
.orders-container {
    padding: 30px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.orders-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.orders-table th,
.orders-table td {
    padding: 15px;
    text-align: left;
}

.orders-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.3s ease;
}

.orders-table tbody tr:hover {
    background: #f8f9fa;
}

.amount {
    font-weight: bold;
    color: #28a745;
}

.btn-view {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.btn-view:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

.no-orders {
    text-align: center;
    font-size: 1.2em;
    color: #666;
    padding: 50px;
}

.no-orders a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
    opacity: 0.9;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
}

/* Receipt Styles */
.receipt-container {
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.receipt {
    background: white;
    border: 2px solid #333;
    padding: 40px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.receipt-header {
    text-align: center;
    margin-bottom: 30px;
}

.restaurant-name {
    font-size: 1.5em;
    font-weight: bold;
    margin: 10px 0;
}

.receipt hr {
    border: none;
    border-top: 2px dashed #333;
    margin: 20px 0;
}

.receipt-details p {
    margin: 10px 0;
}

.receipt-items {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.receipt-items th {
    border-bottom: 2px solid #333;
    padding: 10px;
    text-align: left;
}

.receipt-items td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.receipt-totals {
    margin-top: 20px;
}

.receipt-totals p {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
}

.total-line {
    font-size: 1.3em;
    font-weight: bold;
}

.receipt-footer {
    text-align: center;
    margin-top: 30px;
    font-style: italic;
    color: #666;
}

.receipt-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-print,
.btn-new-order,
.btn-back {
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: bold;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-print {
    background: #667eea;
    color: white;
}

.btn-new-order {
    background: #28a745;
    color: white;
    display: inline-block;
}

.btn-back {
    background: #6c757d;
    color: white;
    display: inline-block;
}

.btn-print:hover,
.btn-new-order:hover,
.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content {
        grid-template-columns: 1fr;
    }

    .order-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: 1fr;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .receipt-actions {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.8em;
    }

    .orders-table {
        font-size: 0.85em;
    }

    .orders-table th,
    .orders-table td {
        padding: 10px 5px;
    }
}

/* Keyboard Navigation Accessibility */
.table-card {
    outline: none;
}

.table-card:focus {
    box-shadow: 0 0 0 3px #43a047 !important;
    transform: translateY(-2px);
    z-index: 10;
}

.table-card:focus .table-name {
    text-decoration: underline;
}

/* Global Autocomplete Styles */
#autocompleteDropdown {
    max-height: 200px !important;
    font-size: 14px;
}

.autocomplete-item {
    padding: 10px 12px;
    /* Adjusted padding for general use */
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}


.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #e3f2fd !important;
    /* Light blue */
}

/* =========================================
   PURCHASE ENTRY DESKTOP STYLES
   ========================================= */

/* Main Background */
.desktop-container {
    background-color: #f0f4f7;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 10px;
}

/* Header */
.desktop-header {
    background: #4a6b77;
    color: white;
    padding: 8px 15px;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Form Rows */
.desktop-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

/* Labels */
.desktop-label {
    font-size: 13px;
    font-weight: 600;
    color: #1a434b;
    /* Dark teal */
    width: 100px;
    /* Fixed width mostly */
    text-align: right;
    margin-right: 5px;
}

/* Inputs Common */
.desktop-input {
    padding: 4px 8px;
    border: 1px solid #78909c;
    font-size: 13px;
    height: 28px;
    outline: none;
    transition: border-color 0.2s;
}

.desktop-input:focus {
    border-color: #00bcd4;
    box-shadow: 0 0 0 1px #00bcd4;
}

/* Specific Input Colors */
.input-cyan {
    background-color: #e0f7fa;
}

.input-pink {
    background-color: #fce4ec;
}

.input-white {
    background-color: #ffffff;
}

/* Buttons */
.btn-desktop {
    border: 1px solid #546e7a;
    background: #cfd8dc;
    color: #263238;
    padding: 4px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    height: 28px;
    transition: all 0.2s;
}

.btn-desktop:hover {
    background: #b0bec5;
}

.btn-search {
    background: #4dd0e1;
    color: #006064;
    border-color: #00acc1;
}

.btn-upload {
    background: #ffca28;
    color: #3e2723;
    border-color: #ffb300;
}

.btn-save {
    background: #66bb6a;
    color: white;
    border-color: #43a047;
}

.btn-clear {
    background: #ef5350;
    color: white;
    border-color: #e53935;
}

.btn-print {
    background: #42a5f5;
    color: white;
    border-color: #1e88e5;
}

.btn-delete {
    background: #d32f2f;
    color: white;
    border-color: #b71c1c;
}

/* Grid / Table Container */
.desktop-table-container {
    height: calc(100vh - 280px);
    /* Adjust based on header/footer height */
    overflow-y: auto;
    background: white;
    border: 1px solid #90a4ae;
    margin-top: 5px;
}

/* Table */
.desktop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.desktop-table th {
    background: #5d7e89;
    color: white;
    padding: 6px 4px;
    position: sticky;
    top: 0;
    font-weight: normal;
    text-align: left;
    border-right: 1px solid #78909c;
}

.desktop-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #eceff1;
    border-right: 1px solid #eceff1;
}

.desktop-table tr:nth-child(even) {
    background: #f9fbfc;
}

.desktop-table input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 12px;
    padding: 2px;
}

.desktop-table input:focus {
    background: #e1f5fe;
    outline: 1px solid #29b6f6;
}

/* Search Dropdown */
.search-results {
    position: absolute;
    background: white;
    border: 1px solid #78909c;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: none;
}

.search-item {
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-item:hover {
    background-color: #1e88e5;
    color: white;
}

/* Footer Panel */
.footer-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #eceff1;
    border-top: 1px solid #b0bec5;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.totals-group {
    display: flex;
    gap: 15px;
}

.total-box {
    text-align: center;
    background: #fff;
    border: 1px solid #cfd8dc;
    padding: 4px 10px;
    min-width: 80px;
}

.total-label {
    font-size: 10px;
    color: #78909c;
    text-transform: uppercase;
}

.total-value {
    font-size: 14px;
    font-weight: bold;
    color: #37474f;
}

.btn-toolbar {
    display: flex;
    gap: 8px;
}

/* Modal Desktop Style */
.desktop-modal {
    background: white;
    border: 2px solid #5d7e89;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Re-use .desktop-input inside modal */

.search-item.highlight {
    background-color: #1e88e5;
    color: white;
}

/* Full Screen Order Modal */
#orderModal .modal-content {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
}

#orderModal .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0 !important;
}

.menu-view-panel .items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.menu-view-panel .menu-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bill-panel {
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

/* Fix Modal Layout Ratio (2/3 Menu, 1/3 Bill) */
.modal-body>.menu-view-panel {
    flex: 2 !important;
}

.modal-body>.bill-panel {
    flex: 1 !important;
    min-width: 320px !important;
    height: 100% !important;
    display: flex;
    flex-direction: column;
}


/* Ensure Bill Form takes full height */
.bill-panel form#orderForm {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Make Order Items scrollable specifically */
.bill-panel .order-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: none !important;
    /* Remove any previous max-height */
}

/* Ensure Footer sticks to bottom */
.bill-panel .modal-footer {
    flex-shrink: 0;
    margin-top: auto;
    background: #fff;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}


/* FORCE 65:35 Ratio */
.modal-body>.menu-view-panel {
    flex: 65 !important;
}

.modal-body>.bill-panel {
    flex: 35 !important;
}

/* FIX BUTTON VISIBILITY - FLEX COLUMN LAYOUT */
.bill-panel {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
    /* Prevent main panel scroll */
}

.bill-panel form#orderForm {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Scrollable area includes items and extra inputs, BUT NOT FOOTER */
/* We wrap items and extra inputs in a scroll container if possible, 
   OR let order-items grow and scroll, and bill-extra fixed? 
   Let's try making the middle scrollable. */

.bill-panel .order-items {
    flex: 1 1 auto !important;
    /* Grow and shrink */
    overflow-y: auto !important;
    min-height: 0 !important;
}

.bill-panel .item-entry,
.bill-panel .bill-extra,
.bill-panel .order-summary {
    flex-shrink: 0 !important;
    /* Don't shrink these */
}

.bill-panel .modal-footer {
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    background: #fff;
    padding: 10px;
    border-top: 2px solid #eee;
    z-index: 50;
    position: sticky !important;
    bottom: 0 !important;
}

/* Fix Table Header Layout */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.saved-indicator {
    background: #4caf50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    display: inline-block;
}

/* =========================================
   MOBILE LAYOUT OVERRIDES (Max-width: 768px)
   ========================================= */
@media (max-width: 768px) {

    /* 1. Modal Body - Stack Vertical */
    #orderModal .modal-body {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
    }

    /* 2. Menu Panel - HIDDEN on Mobile */
    #orderModal .menu-view-panel {
        display: none !important;
    }

    /* 3. Bill Panel - Full Screen */
    #orderModal .bill-panel {
        flex: 1 !important;
        height: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 10px !important;
    }

    /* 4. Top Bar adjustments */
    .top-bar {
        padding: 6px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .restaurant-name {
        font-size: 16px;
    }

    /* Hide non-essential info to save space */
    .today-sales,
    #todaySales {
        display: block !important;
        /* Show Today Sales */
        font-size: 11px !important;
        padding: 2px 8px !important;
        white-space: nowrap;
    }

    .user-info {
        gap: 8px;
    }

    .user-info span {
        display: none !important;
        /* Hide User Name */
    }

    /* 5. Compact Item Grid in Menu */
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 6px !important;
    }

    .menu-item {
        padding: 8px !important;
    }

    .item-name {
        font-size: 12px !important;
    }

    .item-footer .add-btn {
        padding: 4px 10px !important;
        font-size: 12px !important;
    }

    /* 6. Compact Bill Rows - Force Single Line (All Columns) */
    .order-header-row,
    .order-row {
        /* Layout: Item (1fr) | Unit (35px) | Price (55px) | Qty (65px) | Subtotal (60px) | Action (25px) */
        display: grid !important;
        grid-template-columns: 1fr 35px 55px 65px 60px 25px !important;
        gap: 2px !important;
        padding: 4px 1px !important;
        font-size: 10px !important;
        align-items: center !important;
        min-height: 32px;
    }

    /* Show All Columns */
    .order-header-unit,
    .order-row-unit,
    .order-header-subtotal,
    .order-row-subtotal,
    .order-header-price,
    .order-row-price {
        display: flex !important;
        align-items: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Alignments */
    .order-header-price,
    .order-row-price,
    .order-header-subtotal,
    .order-row-subtotal {
        justify-content: flex-end !important;
        padding-right: 2px !important;
    }

    .order-header-unit,
    .order-row-unit {
        justify-content: center !important;
        color: #666;
    }

    .order-row-item {
        font-size: 11px !important;
        font-weight: 600;
        white-space: normal !important;
        overflow: visible !important;
        word-break: break-word;
        line-height: 1.2;
    }

    /* Iconize Remove Button */
    .order-row-action .remove-link {
        font-size: 0 !important;
        width: 100% !important;
        height: 24px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        color: #d32f2f !important;
    }

    .order-row-action .remove-link::after {
        content: '✕';
        font-size: 12px !important;
        font-weight: bold !important;
    }

    /* Make numeric inputs larger for touch - RESIZED to avoid overlap */
    .qty-ctrl-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 14px !important;
        line-height: 1 !important;
        padding: 0 !important;
    }

    /* COMPACT INPUT ROW */
    .bill-panel .item-entry .entry-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 4px !important;
        margin-top: 5px;
    }

    .entry-search {
        flex: 1 !important;
        width: auto !important;
        font-size: 13px !important;
    }

    .entry-qty {
        width: 40px !important;
        flex: 0 0 40px !important;
        font-size: 13px !important;
        padding: 4px !important;
        text-align: center;
    }

    .btn-add-item {
        width: auto !important;
        flex: 0 0 auto !important;
        padding: 4px 8px !important;
        font-size: 12px !important;
        height: auto !important;
    }

    .qty-ctrl-btn {
        width: 30px !important;
        height: 30px !important;
    }

    /* Reduce height of all inputs in bill panel for mobile */
    .entry-row input,
    .bill-extra input,
    .bill-extra select {
        height: 32px !important;
        padding: 4px 6px !important;
    }

    /* Make Bill Extra Section Compact (2 cols) */
    .bill-extra .extra-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px !important;
    }

    .bill-extra .extra-group {
        margin-bottom: 0 !important;
    }

    .bill-extra label {
        font-size: 10px !important;
    }

    /* Ensure order list takes available space */
    .order-items {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        max-height: 40vh !important;
        /* Limit height to ensure other parts visible */
    }

    /* 7. Modal Buttons - Row Layout on Mobile */
    .bill-panel .modal-footer {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }

    .modal-footer button {
        flex: 1 !important;
        width: auto !important;
        padding: 0 !important;
        height: 34px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* 8. Table Grid Mobile - FORCE 2 COLUMNS */
    .section-tables {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Ensure content inside cards doesn't overflow */
    .table-card {
        padding: 10px !important;
        min-height: 80px;
    }

    .table-header {
        flex-wrap: wrap;
        /* Allow header items to wrap if needed */
        gap: 4px;
    }

    /* Bill pill adjustments for mobile */
    .saved-indicator {
        font-size: 10px;
        padding: 2px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* 9. Search Bar Compact */
    .search-bar {
        padding: 8px !important;
        margin-bottom: 10px !important;
    }

    .search-bar input {
        font-size: 14px;
        padding: 8px;
    }

    /* COMPACT CONTROLS - Aggressive Vertical Space Saving */
    .bill-panel form#orderForm {
        gap: 0 !important;
    }

    .bill-panel .item-entry {
        padding: 4px 0 !important;
        border-bottom: 1px solid #f0f0f0;
    }

    /* COMPACT INPUT ROW - FILL SPACE */
    .bill-panel .item-entry .entry-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 3px !important;
        margin-top: 5px;
        width: 100% !important;
        padding-right: 2px !important;
    }

    .entry-search {
        flex: 2 1 auto !important;
        /* Take more space but share */
        min-width: 40px !important;
        width: auto !important;
        font-size: 12px !important;
        height: 28px !important;
    }

    /* Constraint Unit/Price inputs TO GROW */
    input.entry-select,
    select.entry-select,
    input.entry-price {
        width: auto !important;
        min-width: 35px !important;
        flex: 1 1 auto !important;
        /* Grow to fill space */
        padding: 0 2px !important;
        font-size: 11px !important;
        /* restore readability */
        height: 28px !important;
        text-align: center !important;
    }

    .entry-qty {
        width: auto !important;
        min-width: 25px !important;
        flex: 0.8 1 auto !important;
        /* Grow slightly less */
        font-size: 12px !important;
        padding: 0 !important;
        text-align: center !important;
        height: 28px !important;
    }



    /* Shorten "Add Item" to "Add" to save space */
    .btn-add-item {
        width: auto !important;
        flex: 0 0 auto !important;
        padding: 0 8px !important;
        height: 28px !important;
        font-size: 0 !important;
        line-height: 28px !important;
        /* Vertically Center */
        min-width: 36px !important;
        position: relative;
        margin: 0 !important;
    }

    .btn-add-item::after {
        content: 'Add';
        font-size: 11px !important;
        visibility: visible;
        display: inline-block;
        font-weight: bold;
    }

    /* Extra Small for Discount Section */
    .bill-extra input,
    .bill-extra select {
        height: 24px !important;
        /* Even smaller for discount */
        font-size: 11px !important;
        padding: 0 4px !important;
    }

    .btn-add-item {
        line-height: 1 !important;
    }

    /* Compact Bill Extra */
    .bill-extra {
        padding: 4px 0 !important;
        border-bottom: 1px solid #f0f0f0;
    }

    .bill-extra .extra-row {
        margin: 0 !important;
    }

    /* Compact Totals */
    .order-summary {
        margin-top: 0 !important;
        padding: 4px 0 !important;
    }

    .summary-row {
        padding: 2px 0 !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .summary-row.total {
        font-size: 14px !important;
        margin-top: 2px !important;
        padding-top: 2px !important;
    }

    /* Footer Compaction */
    .bill-panel .modal-footer {
        padding: 4px 6px !important;
    }

    .modal-footer button {
        padding: 4px !important;
        font-size: 11px !important;
        height: 28px !important;
        /* Smaller height */
        line-height: 1 !important;
    }

    /* COMPACT HEADER */
    #orderModal .modal-header {
        padding: 6px 10px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
    }

    #orderModal .modal-title h2 {
        font-size: 14px !important;
        /* Smaller title */
        margin: 0 !important;
    }

    #orderModal .modal-title p {
        display: none !important;
        /* Hide bill number status line if needed to save space */
    }

    /* Arrange Top Buttons in a row */
    #orderModal .modal-actions {
        display: flex !important;
        justify-content: space-between !important;
        gap: 6px !important;
        margin-top: 4px;
    }

    #orderModal .modal-actions button {
        flex: 1 !important;
        padding: 4px !important;
        font-size: 11px !important;
        height: 26px !important;
        /* Compact Actions */
    }

    /* Show Date/Time but Compact - In Line */
    .bill-panel .bill-extra .extra-group:nth-child(3) {
        display: block !important;
        margin-top: 0 !important;
    }

    /* Make date input very short */
    .bill-panel .bill-extra .extra-group:nth-child(3) input {
        height: 24px !important;
        font-size: 11px !important;
        padding: 0 4px !important;
        width: 100% !important;
    }

    /* Make DiscountCompact - Single Line */
    .bill-panel .bill-extra .extra-row {
        grid-template-columns: 0.8fr 0.8fr 1.4fr !important;
        gap: 4px !important;
    }

    .bill-panel .bill-extra label {
        display: none !important;
        /* Hide labels, rely on placeholders/context */
    }

    /* Ensure Order List Visibility */
    .order-items {
        flex: 1 1 0% !important;
        /* Force grow */
        overflow-y: auto !important;
        min-height: 100px !important;
        background: #fff;
        border: 1px solid #eee;
        /* Visual cue */
        margin-bottom: 5px;
    }


    .empty-order {
        padding-top: 10px;
        font-size: 12px;
    }
}

/* Stylish Logout Button */
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #ff5252 0%, #d32f2f 100%);
    color: white !important;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    border-radius: 20px;
    box-shadow: 0 4px 6px rgba(211, 47, 47, 0.2);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #ff1744 0%, #b71c1c 100%);
    box-shadow: 0 6px 12px rgba(211, 47, 47, 0.3);
    transform: translateY(-1px);
    text-decoration: none;
}

.logout-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(211, 47, 47, 0.2);
}

/* Animated RGB Border for Today Sales */
@keyframes spinBorder {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.today-sales {
    position: relative;
    padding: 6px 14px !important;
    background: transparent !important;
    color: #e65100 !important;
    font-weight: 700 !important;
    border-radius: 50px !important;
    border: none !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1;
    margin-right: 15px;
    isolation: isolate;
    overflow: hidden;
}

/* animated continuous flowing rgb border */
.today-sales::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(#ff0000,
            #ff8000,
            #ffff00,
            #80ff00,
            #00ff00,
            #00ff80,
            #00ffff,
            #0080ff,
            #0000ff,
            #8000ff,
            #ff00ff,
            #ff0080,
            #ff0000);
    animation: spinBorder 4s linear infinite;
    z-index: -2;
}

.today-sales::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #fff;
    border-radius: 48px;
    z-index: -1;
}

/* Action Button Colors - User Requested */
.btn-save {
    background: #FF9933 !important;
    /* Saffron */
    color: white !important;
    border: none !important;
}

.btn-print {
    background: white !important;
    color: #2196F3 !important;
    /* Blue Text */
    border: 1px solid #2196F3 !important;
}

.btn-pay {
    background: #4CAF50 !important;
    /* Green */
    color: white !important;
    border: none !important;

}

/* Button Interaction Enhancements */
.btn-save,
.btn-print,
.btn-pay,
.btn-submit,
.btn-new-order,
.btn-back,
.btn-primary,
.btn-add-item {
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    font-weight: 600 !important;
    cursor: pointer;
}

.btn-save:hover,
.btn-print:hover,
.btn-pay:hover,
.btn-submit:hover,
.btn-new-order:hover,
.btn-back:hover,
.btn-primary:hover,
.btn-add-item:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
    filter: brightness(1.05);
}