.bq-order-surface {
    min-height: 100vh;
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr);
    color: #212529;
    background: #f5f6f8;
    font-family: Arial, Helvetica, sans-serif;
}

.bq-order-header {
    min-height: 76px;
    display: grid !important;
    grid-template-columns: minmax(200px, 1fr) minmax(300px, auto) minmax(280px, 1fr);
    align-items: center;
    gap: 18px;
    padding: 8px 16px;
    border-bottom: 1px solid #d7dbe0;
    background: #fff;
}

.bq-order-header__left,
.bq-order-header__right {
    display: flex !important;
    align-items: center;
    gap: 12px;
}

.bq-order-header__left {
    justify-content: flex-start;
}

.bq-order-header__center {
    display: flex !important;
    justify-self: center;
    align-self: center;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.bq-order-header__right {
    justify-self: flex-end;
    align-self: center;
    justify-content: flex-end;
    align-items: center !important;
    gap: 12px;
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-left: auto;
    padding-right: 8px;
    height: 100%;
}

.bq-order-header__logo {
    height: 56px;
    max-width: 210px;
    width: auto;
    object-fit: contain;
    display: block;
}

.bq-order-header__title,
.bq-order-header__time,
.bq-order-header__site-name {
    font-size: 18px;
    font-weight: 800;
    color: #212529;
    line-height: 1.2;
}

.bq-order-header__time {
    font-size: 22px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin: 0 !important;
    white-space: nowrap;
}

.bq-order-header__site-icon {
    color: #e24a4a;
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    align-self: center;
}

.bq-order-header__site {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1.2;
    align-self: center;
}

.bq-order-header__site-name,
.bq-order-header__site-address {
    margin: 0 !important;
    line-height: 1.1;
}

.bq-order-header__site-address {
    color: #5f6873;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bq-category-rail {
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 6px 4px 10px;
}

.bq-category-pill {
    min-height: 40px;
    flex: 0 0 auto;
    white-space: nowrap;
    border: 1px solid #212529;
    border-radius: 4px;
    background: #fff;
    color: #212529;
    padding: 8px 14px;
    font-weight: 800;
    cursor: pointer;
}

.bq-category-pill.is-selected {
    background: #212529;
    color: #fff;
}

/* Product group pills — visually distinct from category pills */
.bq-group-pill {
    border-style: dashed;
    border-color: #6c757d;
    font-weight: 600;
}

.bq-group-pill.is-selected {
    background: #6c757d;
    color: #fff;
}

.bq-product-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-content: start;
    gap: 10px;
    overflow: auto;
    padding: 6px;
}

/* ---- Virtualize container (matches Touch ProductsGrid pattern) ---- */
.bq-product-grid-virtual {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
}

.bq-product-tile {
    width: 250px;
    height: 250px;
    display: inline-flex;
    margin-right: 6px;
    margin-bottom: 10px;
}

.bq-product-card {
    position: relative;
    min-height: 236px;
    max-height: 250px;
    display: grid !important;
    border: 0;
    border-radius: 4px;
    background: #d7dbe0;
    color: #212529;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 1px 2px rgba(33, 37, 41, 0.12);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.bq-product-card .rz-button-box {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
    justify-items: center;
    align-items: start;
    width: 100%;
    height: 100%;
}

.bq-product-card:hover:not(:disabled) {
    background: #c5c9d1;
    transform: scale(1.02);
}

.bq-product-card:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.bq-product-card__image-wrap {
    position: relative;
    width: 100%;
    display: block !important;
}

.bq-product-card__image {
    width: 100%;
    height: 142px;
    object-fit: cover;
    border-radius: 3px;
    background: #eef0f2;
}

.bq-product-card__body {
    display: grid !important;
    gap: 4px;
    padding-top: 8px;
    justify-items: center;
    width: 100%;
}

.bq-product-card__name {
    min-height: 42px;
    font-size: 15px;
    line-height: 1.25;
    font-weight: 800;
}

.bq-product-card__price {
    font-weight: 800;
}

.bq-product-card__quantity {
    color: #263238;
    font-size: 11px;
}

.bq-product-card__stock-badge,
.bq-product-card__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    border-radius: 5px;
    padding: 5px 9px;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.bq-product-card__stock-badge {
    background: #e2401c;
}

.bq-product-card__badge {
    left: 8px;
    right: auto;
    background: #1f7a35;
}

.bq-cart-panel {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    height: 100%;
    align-self: stretch;
    border-left: 1px solid #d7dbe0;
    background: #fff;
}

.bq-cart-title {
    min-height: 51px;
    display: grid;
    place-items: center;
    text-align: center;
    border-bottom: 1px solid #d7dbe0;
}

.bq-cart-close-btn {
    display: none;
}

.bq-cart-title .rz-text-h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    text-align: center;
}

.bq-cart-lines {
    overflow-y: auto;
    padding: 0.5rem;
}

/* ---- Cart line — matches Touch TransactionItemsGrid row style ---- */
.bq-cart-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 65px 90px 75px 36px;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    border-bottom: 1px solid #e2e5e8;
    font-size: 13px;
}

.bq-cart-line--editable {
    cursor: pointer;
}

.bq-cart-line--editable:hover {
    background: #f8f9fa;
}

.bq-cart-line__info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bq-cart-line__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    line-height: 1.3;
}

.bq-cart-line__detail {
    color: #6c757d;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.bq-cart-line__price {
    text-align: center;
    white-space: nowrap;
}

.bq-cart-line__qty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.bq-cart-line__qty-value {
    min-width: 30px;
    text-align: center;
}

.bq-cart-line__total {
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
}

.bq-cart-summary {
    border-top: 1px solid #d7dbe0;
    padding: 12px;
}

.bq-cart-summary__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
}

.bq-cart-summary__row.is-total {
    font-size: 20px;
    font-weight: 800;
}

.bq-empty-state {
    border: 1px dashed #c5c9d1;
    border-radius: 4px;
    color: #6c757d;
    padding: 18px;
    text-align: center;
}

@media (max-width: 1199px) {
    .bq-order-header {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto;
        gap: 8px;
        justify-items: center !important;
        padding: 8px 12px;
    }

    .bq-order-header__left {
        order: 1;
        justify-content: center !important;
        width: 100%;
    }

    .bq-order-header__center {
        display: none !important;
    }

    .bq-order-header__title {
        display: none !important;
    }

    .bq-order-header__right {
        order: 2;
        justify-content: center !important;
        justify-self: center !important;
        margin-left: 0 !important;
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .bq-order-header__logo {
        height: 48px;
    }

    .bq-order-header__site {
        align-items: center;
    }

    /* ---- Product grid: responsive columns ---- */
    .bq-product-grid-virtual {
        padding: 4px;
    }

    .bq-product-tile {
        width: calc(25% - 8px);
    }

    /* ---- Cart: hidden by default, overlay when toggled ---- */
    .bq-cart-panel {
        display: none !important;
    }

    .bq-cart-panel.is-open {
        display: grid !important;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85%;
        max-width: 400px;
        z-index: 1000;
        box-shadow: -4px 0 20px rgba(0,0,0,0.25);
    }

    .bq-cart-line {
        grid-template-columns: 34px minmax(0, 1fr) 55px 72px 58px 28px;
        gap: 4px;
        padding: 6px 2px;
        font-size: 12px;
    }

    .bq-cart-line__price,
    .bq-cart-line__total {
        font-size: 11px;
    }

    .bq-cart-line__qty {
        gap: 2px;
    }

    .bq-cart-line__qty-value {
        min-width: 22px;
        font-size: 12px;
    }

    .bq-cart-title {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 12px;
    }

    .bq-cart-close-btn {
        display: inline-flex;
    }

    .bq-cart-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(33, 37, 41, 0.45);
        z-index: 999;
    }

    .bq-cart-toggle {
        display: flex !important;
    }

    .web-order-main {
        grid-template-columns: 1fr;
        overflow: hidden;
    }

    .web-order-products {
        min-height: 0;
        overflow: hidden;
    }

    .bq-product-grid-virtual {
        flex: 1;
        min-height: 0;
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    .bq-product-card {
        min-height: 220px;
    }

    .bq-product-card__image {
        height: 128px;
    }
}

/* ---- Tablets: 3 columns ---- */
@media (max-width: 960px) {
    .bq-product-tile {
        width: calc(33.333% - 8px);
    }
}

/* ---- Phablets: 2 columns ---- */
@media (max-width: 640px) {
    .bq-product-tile {
        width: calc(50% - 8px);
    }
}

/* ---- Small phones (iPhone SE, etc.) 375-480px ---- */
@media (max-width: 480px) {
    .bq-order-header {
        padding: 6px 8px;
        gap: 4px;
    }

    .bq-order-header__logo {
        height: 36px;
        max-width: 140px;
    }

    .bq-order-header__right {
        gap: 4px;
    }

    .bq-order-header__site-icon {
        font-size: 22px;
    }

    .bq-order-header__site-name,
    .bq-order-header__site-address {
        font-size: 13px;
    }

    .bq-order-header__time {
        font-size: 16px;
    }

    /* Shrink header buttons on tiny screens */
    .bq-order-header__right .rz-button {
        font-size: 12px !important;
        padding: 4px 8px !important;
        min-height: 32px !important;
    }

    .bq-order-header__right .rz-button .rz-icon {
        font-size: 16px !important;
    }

    /* Search toolbar */
    .web-order-product-toolbar {
        gap: 4px;
        padding: 2px;
    }

    .web-order-product-toolbar .rz-textbox {
        font-size: 14px !important;
    }

    .web-order-product-toolbar .rz-button {
        padding: 6px 10px !important;
        min-width: 40px !important;
    }

    /* Category rail — tighter pills */
    .bq-category-rail {
        gap: 4px;
        padding: 4px 2px 8px;
    }

    .bq-category-pill {
        min-height: 32px;
        padding: 4px 10px;
        font-size: 13px;
    }

    /* Product grid — ensure fit at narrow widths */
    .bq-product-grid-virtual {
        padding: 2px;
    }

    .bq-product-tile {
        width: calc(50% - 6px);
        height: auto;
        margin-right: 4px;
        margin-bottom: 8px;
    }

    .bq-product-card {
        min-height: 196px;
        padding: 6px;
    }

    .bq-product-card__image {
        height: 110px;
    }

    .bq-product-card__name {
        font-size: 13px;
        min-height: 34px;
    }

    .bq-product-card__price {
        font-size: 14px;
    }

    /* Cart panel — full width on tiny screens */
    .bq-cart-panel.is-open {
        width: 92%;
        max-width: none;
    }

    .bq-cart-line {
        grid-template-columns: 26px minmax(0, 1fr) 46px 60px 48px 24px;
        gap: 3px;
        padding: 5px 1px;
        font-size: 11px;
    }

    .bq-cart-line__qty-value {
        min-width: 18px;
        font-size: 11px;
    }

    .bq-cart-line__price,
    .bq-cart-line__total {
        font-size: 10px;
    }

    .bq-cart-toggle {
        width: 48px;
        height: 48px;
        bottom: 12px;
        right: 10px;
    }

    .bq-cart-title .rz-text-h2 {
        font-size: 20px;
    }
}

/* ---- Cart toggle button (hidden on desktop, visible on mobile) ---- */
.bq-cart-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 16px;
    z-index: 998;
    background: #212529;
    color: white;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 12px rgba(33,37,41,0.35);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
}

.bq-cart-toggle .rz-icon {
    color: white;
    font-size: 24px;
}

.bq-cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e24a4a;
    color: white;
    font-size: 12px;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ── Invoice Viewer Dialog ── */
.bq-invoice-viewer {
    height: 85vh;
    display: flex !important;
    flex-direction: column !important;
}

.bq-invoice-viewer-toolbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid #d7dbe0;
    background: #fff;
    flex-shrink: 0;
}

.bq-invoice-viewer-body {
    flex: 1;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}

.bq-invoice-pdf-frame {
    flex: 1;
    width: 100%;
    border: none;
}

@media (max-width: 600px) {
    .bq-invoice-viewer {
        height: 90vh;
    }
}
