/* POS Styles - Optimized for Tablet/Kiosk */
/* Uses unified design tokens */
@import url('../css/design-tokens.css');

/* POS-specific overrides */
:root {
    --primary-dark: var(--color-primary-dark);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    background: var(--color-gray-100);
    color: var(--color-gray-900);
    height: 100vh;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: 60px 1fr;
    height: 100vh;
}

/* Header */
#posHeader {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--gray-800);
    color: white;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
}

.header-select {
    background: var(--gray-700);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.order-type-btn {
    background: transparent;
    border: 1px solid var(--gray-600);
    color: var(--gray-400);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.order-type-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
}

.btn-icon:hover {
    background: var(--gray-700);
}

#currentTime {
    font-size: 14px;
    color: var(--gray-400);
}

/* Main Content */
#posMain {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Category Bar */
#categoryBar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--card, white);
    border-bottom: 1px solid var(--border, #e5e7eb);
    overflow-x: auto;
    flex-shrink: 0;
}

.category-btn {
    background: var(--gray-100);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.08s, color 0.08s;
}

.category-btn.active {
    background: var(--primary);
    color: white;
}

/* Products Grid */
#productsGrid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    align-content: start;
}

.product-card {
    background: var(--card, white);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.08s;
    border: 2px solid transparent;
}

.product-card:active {
    border-color: var(--primary);
}

.product-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.product-emoji {
    font-size: 40px;
    margin-bottom: 8px;
}

.product-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    height: 2.4em;
    overflow: hidden;
    margin-bottom: 4px;
}

.product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
}

/* Cart Panel */
#cartPanel {
    display: flex;
    flex-direction: column;
    background: var(--card, white);
    border-left: 1px solid var(--border, #e5e7eb);
    padding-top: 12px;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.cart-header h3 {
    font-size: 18px;
}

#orderNumber {
    color: var(--gray-500);
    font-size: 14px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px 8px 8px 8px;
}

.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-400);
    gap: 8px;
}

.empty-icon {
    font-size: 48px;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg, #f9fafb);
    border-radius: 8px;
    margin-bottom: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    font-size: 14px;
}

.cart-item-price {
    font-size: 12px;
    color: var(--gray-500);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin: 0 8px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border, #d1d5db);
    background: var(--card, white);
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

.qty-btn:active {
    background: var(--gray-100);
}

.cart-item-qty {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

.cart-item-total {
    min-width: 80px;
    text-align: right;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Cart Footer */
.cart-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
}

.cart-footer.compact {
    padding: 10px 12px;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.total-row {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.discount-row {
    color: var(--success);
}

.cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.cart-actions-compact {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.btn {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.08s, color 0.08s;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 16px;
}

.btn-ghost {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.btn-ghost:active {
    background: var(--gray-200);
}

.btn-outline {
    background: var(--card, white);
    border: 1px solid var(--border, #d1d5db);
}

.btn-outline:active {
    background: var(--gray-100);
}

.btn-pay {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 700;
    background: var(--success);
    color: white;
}

.btn-pay-sm {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    background: var(--success);
    color: white;
    border-radius: 8px;
}

.btn-kitchen-sm {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    background: #f59e0b;
    color: white;
    border-radius: 8px;
}

.btn-kitchen-sm:disabled,
.btn-pay-sm:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-pay:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-pay:not(:disabled):active {
    background: #059669;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 100;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card, white);
    border-radius: 16px;
    padding: 24px;
    min-width: 320px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    display: none;
    z-index: 101;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* B13: When modal has flex layout for table move, contain overflow */
.modal.modal--flex {
    overflow: hidden;
    display: none;
    padding: 0;
}

.modal.modal--flex.active {
    display: flex;
    flex-direction: column;
}

.modal.active {
    display: block;
}

/* When OSK keyboard is open, modal floats to top and shrinks */
body.osk-active .modal.active {
    top: auto;
    bottom: 260px;
    transform: translateX(-50%);
    max-height: calc(100vh - 290px);
}

.modal h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

/* Payment Modal */
.payment-total {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
}

.payment-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.payment-method-btn {
    padding: 24px 16px;
    border: 2px solid var(--border, #e5e7eb);
    background: var(--card, white);
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    text-align: center;
}

.payment-method-btn.active {
    border-color: var(--primary);
    background: #eef2ff;
}

.payment-method-btn span {
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
}

.cash-input {
    margin-bottom: 16px;
}

.cash-input input {
    width: 100%;
    padding: 16px;
    font-size: 24px;
    text-align: center;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
}

.change-display {
    text-align: center;
    font-size: 18px;
    margin-bottom: 16px;
}

.change-display.positive {
    color: var(--success);
}

.change-display.negative {
    color: var(--danger);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 200;
}

.toast {
    background: var(--gray-800);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Discount List */
.discount-list {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}

.discount-option {
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.discount-option:hover {
    border-color: var(--primary);
}

.discount-option.active {
    border-color: var(--primary);
    background: #eef2ff;
}

/* Responsive */
@media (max-width: 900px) {
    #app {
        grid-template-columns: 1fr 320px;
    }

    #productsGrid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

@media (max-width: 700px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr 50vh;
    }

    #cartPanel {
        border-left: none;
        border-top: 1px solid var(--gray-200);
    }
}

/* ========== SQUARE SCREEN OPTIMIZATION (POS Terminals) ========== */
/* Targets 4:3 and square aspect ratios common on POS hardware */
@media (max-aspect-ratio: 5/4) {

    /* Narrower cart panel */
    #app {
        grid-template-columns: 1fr 280px;
        grid-template-rows: 48px 1fr;
    }

    /* Compact header */
    #posHeader {
        padding: 0 12px;
    }

    .logo {
        font-size: 16px;
    }

    .order-type-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .header-select {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* Smaller category buttons */
    #categoryBar {
        padding: 8px 12px;
        gap: 6px;
    }

    .category-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Denser product grid */
    #productsGrid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        padding: 10px;
    }

    .product-card {
        padding: 8px;
        border-radius: 10px;
    }

    .product-emoji {
        font-size: 32px;
        margin-bottom: 4px;
    }

    .product-img {
        width: 48px;
        height: 48px;
        margin-bottom: 4px;
    }

    .product-name {
        font-size: 12px;
        height: 2.2em;
    }

    .product-price {
        font-size: 13px;
    }

    /* Compact cart */
    .cart-header {
        padding: 10px 12px;
    }

    .cart-header h3 {
        font-size: 15px;
    }

    .cart-items {
        padding: 10px 6px 6px 6px;
    }

    .cart-item {
        padding: 8px 10px;
        margin-bottom: 6px;
    }

    .cart-item-name {
        font-size: 13px;
    }

    .cart-item-price {
        font-size: 11px;
    }

    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .cart-item-total {
        font-size: 13px;
        min-width: 60px;
    }

    /* Compact footer */
    .cart-footer {
        padding: 10px 12px;
    }

    .cart-row {
        font-size: 13px;
    }

    .total-row {
        font-size: 17px;
        margin-bottom: 10px;
    }

    .btn-pay {
        padding: 14px;
        font-size: 16px;
    }

    /* Guest/Course selectors */
    .guest-selector-row,
    .course-selector-row {
        padding: 6px 10px;
    }

    .gc-btn {
        min-width: 38px;
        min-height: 38px;
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* Extra compact for very square screens (1:1) */
@media (max-aspect-ratio: 1/1) {
    #app {
        grid-template-columns: 1fr 240px;
    }

    #productsGrid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 6px;
        padding: 8px;
    }

    .product-card {
        padding: 6px;
    }

    .product-emoji {
        font-size: 28px;
    }

    .product-name {
        font-size: 11px;
    }

    .product-price {
        font-size: 12px;
    }
}

/* ========== GUEST/COURSE SELECTORS ========== */
.guest-selector-row,
.course-selector-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--gray-100);
    border-radius: 10px;
    margin-bottom: 8px;
}

.guest-selector-row span,
.course-selector-row span {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    min-width: 50px;
}

.gc-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    background: white;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.gc-btn:active {
    transform: scale(0.95);
}

.gc-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.gc-btn.add {
    background: var(--gray-100);
    border-style: dashed;
    color: var(--gray-500);
}

.gc-btn.add:active {
    background: var(--gray-200);
}

/* Course-specific colors */
.gc-btn.small {
    min-width: 40px;
    padding: 8px 12px;
}

.gc-btn.course-1.active {
    background: #10b981;
    border-color: #10b981;
}

.gc-btn.course-2.active {
    background: #3b82f6;
    border-color: #3b82f6;
}

.gc-btn.course-3.active {
    background: #f59e0b;
    border-color: #f59e0b;
}

.gc-btn.course-4.active {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

/* ========== CART GUEST HEADERS ========== */
.cart-guest-header {
    padding: 8px 12px;
    background: linear-gradient(90deg, var(--gray-200), transparent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-600);
    margin: 8px 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== CART ITEM COURSE COLORS ========== */
.cart-item {
    border-left: 4px solid transparent;
}

.cart-item.course-1 {
    border-left-color: #10b981;
}

.cart-item.course-2 {
    border-left-color: #3b82f6;
}

.cart-item.course-3 {
    border-left-color: #f59e0b;
}

.cart-item.course-4 {
    border-left-color: #8b5cf6;
}

.cart-item.current-guest {
    background: #e0f2fe;
}

.cart-course-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    color: white;
}

.cart-course-badge.c1 {
    background: #10b981;
}

.cart-course-badge.c2 {
    background: #3b82f6;
}

.cart-course-badge.c3 {
    background: #f59e0b;
}

.cart-course-badge.c4 {
    background: #8b5cf6;
}

/* ========== CART COURSE DIVIDER ========== */
.cart-course-divider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 6px 0 2px 0;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.fire-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 6px 16px;
    cursor: pointer;
    text-transform: uppercase;
}

.fire-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #d97706, #b45309);
}

/* Cart empty state */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--gray-400);
}

.cart-empty-text {
    font-size: 16px;
}

/* Cart item comment */
.cart-item-comment {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.cart-item-meta {
    font-size: 12px;
    color: var(--gray-500);
}

/* ========== CART ITEM LIFECYCLE STATES ========== */
/* New: default styling (no printed_at) — full controls */

/* Sent: printed_at set, waiting for kitchen */
.cart-item.item-sent {
    border-left-color: #f59e0b !important;
    background: #fffbeb;
}

.cart-item.item-sent .cart-item-name {
    color: #92400e;
}

.cart-item.item-sent .cart-item-time {
    color: #d97706;
    font-weight: 600;
}

/* Ready: kitchen finished, waiting to serve */
.cart-item.item-ready {
    border-left-color: #10b981 !important;
    background: #ecfdf5;
}

.cart-item.item-ready .cart-item-name {
    color: #065f46;
}

/* Served: delivered to guest */
/* Optimistic UI: syncing state */
.cart-item.item-syncing {
    opacity: 0.6;
    animation: syncPulse 1s ease-in-out infinite;
}

@keyframes syncPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 0.85;
    }
}

.cart-item.item-served {
    border-left-color: #94a3b8 !important;
    background: #f1f5f9;
    opacity: 0.7;
}

.cart-item.item-served .cart-item-name {
    text-decoration: line-through;
    color: #94a3b8;
}

.cart-item.item-served .cart-item-controls .qty-btn {
    pointer-events: none;
    opacity: 0.3;
}

/* Status badge inline */
.cart-status-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    background: none;
    flex-shrink: 0;
}

/* B29: Prevent Lucide SVG icons from deforming */
.cart-status-badge svg,
.cart-status-badge i {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
}

.cart-status-badge.sent {
    color: #f59e0b;
}

.cart-status-badge.ready {
    color: #10b981;
}

.cart-status-badge.served {
    color: #94a3b8;
}

/* Item time display */
.cart-item-time {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: 4px;
}

.comment-btn {
    font-size: 14px !important;
}

/* Burger Menu */
.burger-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
}

.burger-menu-btn:hover {
    background: var(--gray-700);
}

.burger-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

.pos-menu-dropdown {
    display: none;
    position: absolute;
    top: 56px;
    left: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

.pos-menu-dropdown.open {
    display: block;
}

.pos-menu-item {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: none;
    text-align: left;
    font-size: 15px;
    cursor: pointer;
    color: var(--gray-700);
}

.pos-menu-item:hover {
    background: var(--gray-50);
}

.pos-menu-item.danger {
    color: var(--danger);
}

.pos-menu-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* Cart panel without header */
.cart-panel.no-header {
    padding-top: 0;
}

.cart-panel.no-header .cart-items {
    padding-top: 12px;
}

/* Fix footer buttons row */
.cart-actions-compact {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

/* ========== WRITEOFF MODAL (above OSK keyboard) ========== */
.modal.writeoff-active {
    z-index: 10001 !important;
}

.modal-overlay.writeoff-active {
    z-index: 10000 !important;
    background: rgba(0, 0, 0, 0.4);
}

.writeoff-modal {
    min-width: 340px;
    max-width: 440px;
    text-align: center;
}

.writeoff-modal h3 {
    color: var(--danger, #ef4444);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.writeoff-item-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--gray-900, #0f172a);
}

.writeoff-warning {
    color: var(--warning, #f59e0b);
    font-size: 13px;
    margin-bottom: 20px;
}

.writeoff-reason {
    margin-bottom: 20px;
}

.writeoff-reason input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--gray-300, #cbd5e1);
    border-radius: 12px;
    background: var(--gray-50, #f8fafc);
    text-align: center;
}

.writeoff-reason input:focus {
    border-color: var(--primary, #3b82f6);
    outline: none;
    background: white;
}

.writeoff-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.writeoff-actions .btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.writeoff-actions .btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.writeoff-actions .btn-secondary {
    background: var(--gray-100, #f1f5f9);
    color: var(--gray-700, #334155);
    border: 2px solid var(--gray-200, #e2e8f0);
}

.writeoff-actions .btn-ghost {
    background: none;
    color: var(--gray-500, #64748b);
}

/* ========== TERMINAL NAME BADGE ========== */
.terminal-name-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    letter-spacing: 0.3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ========== DELIVERY PANEL V2 (Sales→Orders Style) ========== */
.delivery-panel-v2 {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
    position: relative;
}

.delivery-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.delivery-header-v2 h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.delivery-refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    transition: all 0.2s;
}

.delivery-refresh-btn:active {
    background: var(--bg);
}

/* Status Tabs */
.delivery-status-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 4px 0 8px;
    min-height: 40px;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}


.dlv-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 20px;
    background: var(--card);
    color: var(--text-secondary, #475569);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.dlv-tab:active {
    background: var(--border);
}

.dlv-tab.active {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.dlv-tab-count {
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.08);
}

.dlv-tab.active .dlv-tab-count {
    background: rgba(255, 255, 255, 0.25);
}

.dlv-tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Order Cards Grid */
.delivery-grid-v2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 16px 2px;
    align-content: start;
}

/* Order Card */
.dlv-order-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.dlv-order-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--card-border, linear-gradient(180deg, #f59e0b, #d97706));
}

.dlv-order-card:active {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.dlv-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-left: 8px;
}

.dlv-order-number {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.dlv-status-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.dlv-customer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    padding-left: 8px;
}

.dlv-address {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    margin-bottom: 6px;
    padding-left: 8px;
}

.dlv-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 10px;
    padding-left: 8px;
}

.dlv-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.dlv-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    padding-left: 8px;
    border-top: 1px solid var(--border);
}

.dlv-total {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.dlv-time {
    font-size: 12px;
    color: #94a3b8;
}

/* Action buttons on cards */
.dlv-card-actions {
    margin-top: 10px;
    padding-left: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.dlv-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: white;
}

.dlv-action-confirm {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.dlv-action-ready {
    background: linear-gradient(135deg, #10b981, #059669);
}

.dlv-action-complete {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.dlv-action-cancel {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.dlv-action-btn:active {
    opacity: 0.85;
    transform: scale(0.97);
}

/* ========== DELIVERY DETAIL PANEL ========== */
.delivery-detail-panel {
    position: absolute;
    inset: 0;
    background: var(--bg);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.delivery-detail-content {
    padding: 20px;
    flex: 1;
}

.dlv-detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.dlv-detail-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 10px;
    cursor: pointer;
    color: #475569;
    flex-shrink: 0;
}

.dlv-detail-back:active {
    background: var(--bg);
}

.dlv-detail-order-num {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.dlv-detail-section {
    margin-bottom: 20px;
}

.dlv-detail-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.dlv-detail-customer-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dlv-detail-phone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #3b82f6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.dlv-detail-phone:active {
    color: #1d4ed8;
}

/* Order Lines */
.dlv-detail-lines {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.dlv-detail-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.dlv-detail-line:last-child {
    border-bottom: none;
}

.dlv-line-qty {
    font-weight: 700;
    color: #3b82f6;
    font-size: 14px;
    min-width: 30px;
}

.dlv-line-name {
    flex: 1;
    font-size: 14px;
    color: var(--text);
}

.dlv-line-price {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

/* Totals */
.dlv-detail-totals {
    margin-top: 12px;
}

.dlv-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: #64748b;
}

.dlv-total-final {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    padding-top: 10px;
    margin-top: 6px;
    border-top: 2px solid var(--border);
}

/* Guest info */
.dlv-guest-info {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}

.dlv-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 4px;
}

/* Detail Actions */
.dlv-detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.dlv-detail-actions .dlv-action-btn {
    flex: 1;
    justify-content: center;
    padding: 14px;
    font-size: 14px;
    border-radius: 10px;
}

/* Spin animation for loader */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== HORIZONTAL DELIVERY MODAL (for POS terminals) ========== */
.delivery-modal-horizontal {
    width: 720px !important;
    max-width: 95vw !important;
    padding: 24px 28px !important;
}

.delivery-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}

.delivery-modal-grid .customer-input-group {
    gap: 5px;
}

.delivery-modal-grid .customer-input-group label {
    font-size: 13px;
}

.delivery-modal-grid .customer-input-group input,
.delivery-modal-grid .customer-input-group select {
    font-size: 15px !important;
    padding: 10px 12px !important;
}

/* Delivery panel fills available height and spans full width */
.delivery-panel-v2 {
    grid-column: 1 / 3;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 16px;
}

/* ==================== SPLIT BILL OVERLAY ==================== */
.split-bill-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.split-bill-container {
    background: #1a1d23;
    border-radius: 16px;
    width: 100%;
    max-width: 1200px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.split-bill-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 8px;
}

.split-bill-top h2 {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    margin: 0;
}

.split-bill-top-actions {
    display: flex;
    gap: 8px;
}

.split-add-bill,
.split-equal-btn {
    background: #2a2d35;
    color: #a5b4c8;
    border: 1px solid #3a3d45;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.15s;
}

.split-add-bill:hover,
.split-equal-btn:hover {
    background: #3a3d45;
    color: #fff;
}

.split-equal-btn {
    background: #2d1f5e;
    border-color: #8b5cf6;
    color: #c4b5fd;
}

.split-equal-btn:hover {
    background: #3b2580;
    color: #fff;
}

.split-bill-hint {
    padding: 0 24px 12px;
    color: #6b7280;
    font-size: 14px;
}

.split-bills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    padding: 0 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.split-bill-column {
    background: #22252d;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    border: 2px solid #2a2d35;
    min-height: 200px;
}

.split-bill-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #2a2d35;
}

.split-bill-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.split-remove-bill {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.split-remove-bill:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.split-bill-items {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    min-height: 80px;
}

.split-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #2a2d35;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    gap: 10px;
}

.split-item:hover {
    background: #353840;
    transform: translateX(2px);
}

.split-item:active {
    transform: scale(0.97);
}

.split-item-name {
    flex: 1;
    color: #e5e7eb;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-item-qty {
    color: #9ca3af;
    font-size: 15px;
    min-width: 30px;
    text-align: center;
}

.split-item-price {
    color: #10b981;
    font-size: 16px;
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

.split-empty {
    color: #4b5563;
    font-size: 13px;
    text-align: center;
    padding: 24px 8px;
    font-style: italic;
}

.split-bill-footer {
    padding: 12px 14px;
    border-top: 1px solid #2a2d35;
}

.split-bill-total {
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.split-pay-methods {
    display: flex;
    gap: 4px;
}

.split-pay-btn {
    flex: 1;
    padding: 10px 0;
    border: 1px solid #3a3d45;
    border-radius: 6px;
    background: #2a2d35;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.split-pay-btn:hover {
    background: #353840;
    color: #fff;
}

.split-pay-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.split-bill-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid #2a2d35;
    background: #15171c;
}

.split-grand-total {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
}

.split-bill-actions {
    display: flex;
    gap: 10px;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .split-bills-grid {
        grid-template-columns: 1fr;
    }

    .split-bill-container {
        max-height: 95vh;
        border-radius: 12px;
    }

    .split-bill-overlay {
        padding: 8px;
    }

    .split-bill-bottom {
        flex-direction: column;
        gap: 12px;
    }

    .split-bill-actions {
        width: 100%;
    }

    .split-bill-actions .modal-btn {
        flex: 1;
    }
}

/* ==================== UNIFIED MODAL SYSTEM ==================== */
/* posModal() — touch-optimized, always above OSK */

.pos-modal__header {
    padding: 14px 16px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pos-modal__header-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 10px;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pos-modal__body {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 380px);
    /* room for header + actions + OSK */
}

.pos-modal__actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
}

.pos-modal__btn {
    flex: 1;
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s;
}

.pos-modal__btn:active {
    background: #f1f5f9;
    transform: scale(0.97);
}

.pos-modal__btn--primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    border-color: transparent;
}

.pos-modal__btn--primary:active {
    background: linear-gradient(135deg, #2563eb, #1e40af);
}

.pos-modal__btn--success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-color: transparent;
}

.pos-modal__btn--danger {
    background: #ef4444;
    color: #fff;
    border-color: transparent;
}

.pos-modal__btn--danger:active {
    background: #dc2626;
}

.pos-modal__btn--ghost {
    background: transparent;
    border-color: #e2e8f0;
    color: #64748b;
}

.pos-modal__btn--w2 {
    flex: 2;
}

.pos-modal__btn--w3 {
    flex: 3;
}

.pos-modal__input {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.pos-modal__input:focus {
    border-color: #3b82f6;
    outline: none;
}

.pos-modal__input--sm {
    min-height: 40px;
    font-size: 16px;
    padding: 8px 12px;
}

/* Stat blocks for info modals */
.pos-modal__stat {
    text-align: center;
}

.pos-modal__stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
}

.pos-modal__stat-label {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

/* Preset button grid (loyalty redeem, qty select) */
.pos-modal__presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pos-modal__preset {
    flex: 1;
    min-width: 55px;
    min-height: 48px;
    padding: 12px 4px;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.pos-modal__preset.active {
    background: #10b981;
    color: #fff;
    border-color: #059669;
}

/* Responsive: make modal body shorter when OSK is active */
body.osk-active .pos-modal__body {
    max-height: calc(45vh - 120px);
}

/* ==================== OFFLINE KDS BANNER ==================== */
.offline-kds-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: offlinePulse 2s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

@keyframes offlinePulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.85;
    }
}

/* ==================== FIX #11: POS CUSTOM SLIM SCROLLBARS ==================== */
#posApp ::-webkit-scrollbar,
.pos-modal__body ::-webkit-scrollbar,
.split-bills-grid ::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

#posApp ::-webkit-scrollbar-track,
.pos-modal__body ::-webkit-scrollbar-track,
.split-bills-grid ::-webkit-scrollbar-track {
    background: transparent;
}

#posApp ::-webkit-scrollbar-thumb,
.pos-modal__body ::-webkit-scrollbar-thumb,
.split-bills-grid ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}

#posApp ::-webkit-scrollbar-thumb:hover,
.pos-modal__body ::-webkit-scrollbar-thumb:hover,
.split-bills-grid ::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Firefox scrollbar */
#posApp *,
.pos-modal__body,
.split-bills-grid {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

/* ==================== FIX #8: DARK THEME PAYMENT BUTTONS ==================== */
[data-theme="dark"] .payment-method-btn {
    background: var(--card, #1e293b);
    border-color: var(--border, #334155);
    color: var(--text, #e2e8f0);
}

[data-theme="dark"] .payment-method-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #93c5fd;
}

[data-theme="dark"] .payment-method-btn span {
    filter: none;
}

/* ==================== FIX #7: 2-ROW CART BUTTONS ON SQUARE MONITORS ==================== */
@media (min-aspect-ratio: 3/4) and (max-aspect-ratio: 5/4) {
    .cart-action-buttons,
    #cartFooter .cart-actions,
    #cartFooter > div:last-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .cart-action-buttons > button,
    #cartFooter .cart-actions > button,
    #cartFooter > div:last-child > button {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: calc(50% - 4px) !important;
    }
}