* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: #07111f;
    color: #fff;
    overflow: hidden;
}

body {
    position: fixed;
    inset: 0;
}

.app {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: clamp(12px, 2vw, 26px);
    background: linear-gradient(135deg, #07111f, #10243f);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: clamp(12px, 1.6vw, 22px);
    flex-shrink: 0;
}

.logo {
    font-size: clamp(22px, 3vw, 36px);
    font-weight: 1000;
    cursor: pointer;
    user-select: none;
}

.store {
    margin-top: 5px;
    font-size: clamp(13px, 1.4vw, 17px);
    opacity: .8;
    font-weight: 800;
}

.time-box {
    text-align: right;
    font-size: clamp(12px, 1.5vw, 16px);
    font-weight: 800;
    opacity: .9;
}

.mini-btn {
    margin-top: 8px;
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.search-box {
    display: flex;
    gap: clamp(8px, 1vw, 12px);
    margin-bottom: clamp(12px, 1.6vw, 22px);
    flex-shrink: 0;
}

.barcode-input {
    flex: 1;
    min-width: 0;
    height: clamp(56px, 8vh, 74px);
    border-radius: clamp(15px, 2vw, 22px);
    border: 0;
    outline: none;
    padding: 0 clamp(14px, 2vw, 24px);
    font-size: clamp(18px, 3vw, 30px);
    font-weight: 900;
    color: #111;
    background: #fff;
}

.search-btn,
.clear-btn {
    height: clamp(56px, 8vh, 74px);
    border: 0;
    border-radius: clamp(15px, 2vw, 22px);
    padding: 0 clamp(16px, 2vw, 28px);
    font-size: clamp(14px, 1.8vw, 18px);
    font-weight: 1000;
    cursor: pointer;
    white-space: nowrap;
}

.search-btn {
    background: #fff;
    color: #07111f;
}

.clear-btn {
    background: #d71920;
    color: #fff;
}

.result {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    font-size: clamp(26px, 4vw, 48px);
    font-weight: 1000;
    opacity: .9;
}

.product-grid {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(260px, 36%) minmax(0, 1fr);
    gap: clamp(12px, 1.8vw, 24px);
    min-height: 0;
}

.card {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: clamp(18px, 2vw, 28px);
    padding: clamp(14px, 2vw, 24px);
    box-shadow: 0 20px 50px rgba(0,0,0,.28);
    min-height: 0;
    overflow: hidden;
}

.image-card {
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img {
    width: 100%;
    height: 100%;
    max-height: calc(100dvh - 175px);
    object-fit: contain;
    background: #fff;
    border-radius: clamp(16px, 2vw, 26px);
    padding: 12px;
}

.info-card {
    overflow-y: auto;
    scrollbar-width: thin;
}

.name-eng {
    font-size: clamp(28px, 4vw, 54px);
    font-weight: 1000;
    line-height: 1.08;
    margin-bottom: 8px;
}

.name-ar {
    font-size: clamp(22px, 3vw, 38px);
    font-weight: 900;
    line-height: 1.25;
    margin-bottom: 14px;
    direction: rtl;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: clamp(12px, 1.5vw, 20px);
}

.pill {
    background: rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 8px 13px;
    font-size: clamp(12px, 1.3vw, 16px);
    font-weight: 900;
}

.price-box {
    background: #f7f7f7;
    color: #111;
    border-radius: clamp(20px, 2.4vw, 32px);
    padding: clamp(16px, 2.4vw, 30px);
    margin: clamp(12px, 1.5vw, 18px) 0;
}

.price-label {
    color: #087a34;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight: 1000;
}

.sale-price {
    color: #087a34;
    font-size: clamp(46px, 8vw, 102px);
    font-weight: 1000;
    line-height: .95;
    word-break: keep-all;
}

.original-price {
    color: #777;
    font-size: clamp(22px, 3vw, 36px);
    font-weight: 1000;
    text-decoration: line-through;
    margin-top: 10px;
}

.no-promo-price {
    color: #087a34;
    font-size: clamp(46px, 8vw, 102px);
    font-weight: 1000;
    line-height: .95;
}

.discount {
    display: inline-block;
    background: #d71920;
    color: #fff;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: clamp(16px, 2vw, 25px);
    font-weight: 1000;
    margin-top: 14px;
}

.desc {
    background: rgba(255,255,255,.11);
    border-radius: 18px;
    padding: 15px;
    margin-top: 14px;
    line-height: 1.55;
    font-size: clamp(14px, 1.5vw, 18px);
    font-weight: 700;
}

.desc-ar {
    direction: rtl;
    text-align: right;
}

.stock-box {
    margin-top: 16px;
    background: rgba(255,255,255,.14);
    border-radius: 18px;
    padding: 15px;
}

.stock-title {
    font-size: clamp(18px, 2vw, 24px);
    font-weight: 1000;
    margin-bottom: 6px;
}

.stock-value {
    font-size: clamp(26px, 4vw, 44px);
    font-weight: 1000;
}

.error-box {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-message {
    background: #d71920;
    color: #fff;
    border-radius: 24px;
    padding: 30px;
    font-size: clamp(24px, 4vw, 38px);
    font-weight: 1000;
    text-align: center;
}

.access-lock {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.access-box,
.modal-box {
    background: #fff;
    color: #111;
    width: min(460px, 94vw);
    border-radius: 26px;
    padding: 26px;
    box-shadow: 0 22px 60px rgba(0,0,0,.35);
}

.access-box h1,
.modal-box h2 {
    margin: 0 0 8px;
    font-weight: 1000;
}

.access-box p,
.modal-box p {
    color: #6b7280;
    margin-bottom: 18px;
    font-weight: 700;
}

.access-box label,
.modal-box label {
    display: block;
    font-weight: 900;
    margin-bottom: 7px;
}

.access-box input,
.modal-box input {
    width: 100%;
    height: 56px;
    border: 2px solid #111;
    border-radius: 14px;
    padding: 0 13px;
    font-size: 20px;
    margin-bottom: 14px;
    outline: none;
}

.access-box button,
.modal-box button {
    width: 100%;
    height: 56px;
    border: 0;
    border-radius: 14px;
    background: #07111f;
    color: #fff;
    font-size: 18px;
    font-weight: 1000;
    cursor: pointer;
}

.access-error {
    margin-top: 12px;
    color: #dc2626;
    font-weight: 900;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.82);
    z-index: 18000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

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

.modal-actions button {
    flex: 1;
}

.modal-actions .danger {
    background: #dc2626;
}

@media (pointer: coarse) {
    #barcodeInput {
        caret-color: transparent;
    }
}

@media (max-width: 900px), (max-height: 650px) {
    body {
        overflow: auto;
        position: static;
    }

    .app {
        min-height: 100dvh;
        height: auto;
        overflow: visible;
    }

    .search-box {
        flex-wrap: wrap;
    }

    .barcode-input {
        flex-basis: 100%;
    }

    .search-btn,
    .clear-btn {
        flex: 1;
    }

    .product-grid {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .product-img {
        height: min(280px, 36vh);
    }

    .result {
        overflow: visible;
    }
}

.product-grid.no-image-grid {
    grid-template-columns: 1fr;
}

.product-grid.no-image-grid {
    grid-template-columns: 1fr;
}

/* Idle Ads */
.idle-ads {
    position: fixed;
    inset: 0;
    z-index: 15000;
    background: #000;
    display: none;
    align-items: center;
    justify-content: center;
}

.idle-ads.show {
    display: flex;
}

.idle-ads-media {
    position: absolute;
    inset: 0;
}

.idle-ads-media img,
.idle-ads-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.idle-scan-text {
    position: fixed;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.68);
    color: #fff;
    padding: 14px 28px;
    border-radius: 999px;
    font-size: clamp(18px, 2.4vw, 28px);
    font-weight: 1000;
    z-index: 15002;
    white-space: nowrap;
    box-shadow: 0 12px 35px rgba(0,0,0,.35);
}

/* =========================================
   LICENSE ERROR UI
========================================= */

.license-error-wrap {
    width: 100%;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
}

.license-error-card {
    width: min(760px, 95%);
    background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    border-radius: 24px;
    padding: 34px 28px;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.12);
}

.license-error-icon {
    width: 78px;
    height: 78px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    line-height: 1;
}

.license-error-title {
    font-size: 34px;
    font-weight: 900;
    margin-bottom: 14px;
    color: #ffffff;
}

.license-error-text {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 18px;
    color: #fff5f5;
}

.license-error-support {
    display: inline-block;
    background: rgba(255,255,255,0.18);
    color: #ffffff;
    border-radius: 999px;
    padding: 12px 20px;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.4;
}

/* Mobile */
@media (max-width: 768px) {
    .license-error-wrap {
        min-height: 240px;
        padding: 20px 14px;
    }

    .license-error-card {
        border-radius: 18px;
        padding: 24px 18px;
    }

    .license-error-icon {
        width: 64px;
        height: 64px;
        font-size: 28px;
        margin-bottom: 14px;
    }

    .license-error-title {
        font-size: 26px;
    }

    .license-error-text {
        font-size: 18px;
    }

    .license-error-support {
        display: block;
        font-size: 15px;
        padding: 10px 14px;
    }
}

/* =========================================
   PUBLIC BACKGROUND IMAGE FIX
   The background is applied on body by app.js.
   This keeps the app layer transparent enough so the image is visible.
========================================= */
body.public-bg-enabled {
    background-color: #07111f;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body.public-bg-enabled .app {
    background: rgba(7, 17, 31, .42);
    backdrop-filter: none;
}

body.public-bg-enabled .topbar,
body.public-bg-enabled .search-box,
body.public-bg-enabled .result {
    position: relative;
    z-index: 1;
}

/* =========================================
   RESPONSIVE PRODUCT SCREEN FIX
   Keeps image + price/details visible on small-height screens.
========================================= */
.product-grid {
    align-items: stretch;
}

.image-card,
.info-card {
    min-height: 0;
}

.info-card {
    overscroll-behavior: contain;
}

@media (max-height: 680px) and (min-width: 700px) {
    body {
        overflow: hidden;
        position: fixed;
        inset: 0;
    }

    .app {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
        padding: clamp(10px, 1.4vw, 18px);
    }

    .topbar {
        margin-bottom: 10px;
    }

    .logo {
        font-size: clamp(22px, 2.5vw, 30px);
    }

    .store {
        font-size: clamp(12px, 1.2vw, 15px);
        margin-top: 2px;
    }

    .time-box {
        font-size: clamp(11px, 1.2vw, 14px);
    }

    .company-logo,
    .company-logo.logo-horizontal-wide,
    .company-logo.logo-horizontal-standard {
        max-width: 90px;
        max-height: 58px;
    }

    .search-box {
        margin-bottom: 10px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .barcode-input {
        flex-basis: auto;
        height: 48px;
        border-radius: 14px;
        font-size: clamp(18px, 2.2vw, 26px);
        padding: 0 16px;
    }

    .search-btn,
    .clear-btn {
        height: 48px;
        border-radius: 14px;
        padding: 0 16px;
        font-size: 14px;
        flex: 0 0 auto;
    }

    .result {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .product-grid {
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(190px, 32%) minmax(0, 1fr);
        gap: 10px;
        overflow: hidden;
    }

    .product-grid.no-image-grid {
        grid-template-columns: 1fr;
    }

    .card {
        border-radius: 16px;
        padding: 10px;
        overflow: hidden;
    }

    .image-card {
        height: 100%;
        max-height: none;
    }

    .product-img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: contain;
        border-radius: 14px;
        padding: 8px;
    }

    .info-card {
        height: 100%;
        overflow-y: auto;
        padding: 12px 14px;
    }

    .name-eng {
        font-size: clamp(24px, 3vw, 38px);
        line-height: 1.05;
        margin-bottom: 6px;
    }

    .name-ar {
        font-size: clamp(18px, 2.2vw, 26px);
        line-height: 1.15;
        margin-bottom: 8px;
    }

    .meta {
        gap: 6px;
        margin-bottom: 8px;
    }

    .pill {
        padding: 6px 10px;
        font-size: 12px;
    }

    .price-box {
        border-radius: 16px;
        padding: 12px 14px;
        margin: 8px 0;
    }

    .price-label {
        font-size: clamp(14px, 1.6vw, 18px);
    }

    .sale-price,
    .no-promo-price {
        font-size: clamp(38px, 5.7vw, 72px);
        line-height: .94;
    }

    .original-price {
        font-size: clamp(18px, 2.2vw, 26px);
        margin-top: 6px;
    }

    .discount {
        padding: 7px 12px;
        font-size: 14px;
        margin-top: 8px;
    }

    .stock-box {
        margin-top: 8px;
        border-radius: 14px;
        padding: 10px;
    }

    .stock-title {
        font-size: clamp(14px, 1.7vw, 18px);
        margin-bottom: 3px;
    }

    .stock-value {
        font-size: clamp(22px, 3vw, 34px);
    }

    .desc {
        border-radius: 14px;
        padding: 10px;
        margin-top: 8px;
        font-size: clamp(12px, 1.25vw, 15px);
        line-height: 1.35;
    }
}

@media (max-width: 699px) {
    body {
        overflow: auto;
        position: static;
    }

    .app {
        min-height: 100dvh;
        height: auto;
        overflow: visible;
        padding: 12px;
    }

    .topbar {
        align-items: flex-start;
    }

    .company-logo,
    .company-logo.logo-horizontal-wide,
    .company-logo.logo-horizontal-standard {
        max-width: 86px;
        max-height: 54px;
    }

    .time-box {
        font-size: 11px;
    }

    .search-box {
        gap: 8px;
        margin-bottom: 10px;
    }

    .barcode-input {
        height: 48px;
        font-size: 18px;
        border-radius: 14px;
    }

    .search-btn,
    .clear-btn {
        height: 46px;
        border-radius: 14px;
        font-size: 13px;
    }

    .product-grid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 10px;
        overflow: visible;
    }

    .image-card {
        max-height: 230px;
    }

    .product-img {
        height: 210px;
        max-height: 210px;
        padding: 8px;
    }

    .info-card {
        overflow: visible;
    }

    .name-eng {
        font-size: clamp(22px, 7vw, 34px);
    }

    .name-ar {
        font-size: clamp(18px, 5.5vw, 26px);
    }

    .sale-price,
    .no-promo-price {
        font-size: clamp(40px, 13vw, 70px);
    }
}


/* =========================================
   COMPACT SCREEN FIT FIX - 690x473 / small POS display
========================================= */

/* User requested full background image fit, not crop */
body.public-bg-enabled {
    background-size: contain !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-color: #07111f !important;
}

body.public-bg-enabled .app {
    background: rgba(7, 17, 31, .28) !important;
}

/* Strong compact-landscape rule: keep product + details visible */
@media (max-width: 760px) and (max-height: 560px) {
    html,
    body {
        overflow: hidden !important;
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

    .app {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 0 !important;
        overflow: hidden !important;
        padding: 8px 12px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .topbar {
        min-height: 48px !important;
        margin-bottom: 6px !important;
        gap: 8px !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }

    .brand-wrap {
        gap: 8px !important;
    }

    .company-logo,
    .company-logo.logo-horizontal-wide,
    .company-logo.logo-horizontal-standard {
        max-width: 68px !important;
        max-height: 46px !important;
    }

    .logo {
        font-size: 24px !important;
        line-height: 1.05 !important;
    }

    .store {
        font-size: 13px !important;
        margin-top: 2px !important;
    }

    .time-box {
        font-size: 12px !important;
        line-height: 1.1 !important;
        flex: 0 0 auto !important;
    }

    .mini-btn {
        display: none !important;
    }

    .search-box {
        margin-bottom: 7px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        flex-shrink: 0 !important;
    }

    .barcode-input {
        height: 42px !important;
        flex-basis: auto !important;
        border-radius: 13px !important;
        font-size: 19px !important;
        padding: 0 13px !important;
    }

    .search-btn,
    .clear-btn {
        height: 42px !important;
        border-radius: 13px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
        flex: 0 0 auto !important;
    }

    .result {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .empty-state {
        font-size: 28px !important;
        padding: 12px !important;
    }

    .product-grid,
    .product-grid.no-image-grid {
        height: 100% !important;
        min-height: 0 !important;
        display: grid !important;
        grid-template-columns: minmax(140px, 34%) minmax(0, 1fr) !important;
        gap: 7px !important;
        overflow: hidden !important;
        align-items: stretch !important;
    }

    .product-grid.no-image-grid {
        grid-template-columns: 1fr !important;
    }

    .card {
        border-radius: 13px !important;
        padding: 7px !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .image-card {
        height: 100% !important;
        max-height: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .product-img {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        object-fit: contain !important;
        border-radius: 12px !important;
        padding: 6px !important;
    }

    .info-card {
        height: 100% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding: 10px 11px !important;
    }

    .name-eng {
        font-size: clamp(24px, 4.4vw, 34px) !important;
        line-height: 1.02 !important;
        margin-bottom: 4px !important;
    }

    .name-ar {
        font-size: clamp(17px, 3vw, 23px) !important;
        line-height: 1.1 !important;
        margin-bottom: 5px !important;
    }

    .meta {
        gap: 4px !important;
        margin-bottom: 5px !important;
    }

    .pill {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    .price-box {
        border-radius: 13px !important;
        padding: 9px 10px !important;
        margin: 6px 0 !important;
    }

    .price-label {
        font-size: 13px !important;
        line-height: 1 !important;
    }

    .sale-price,
    .no-promo-price {
        font-size: clamp(34px, 8vw, 58px) !important;
        line-height: .9 !important;
    }

    .original-price {
        font-size: clamp(16px, 3vw, 22px) !important;
        margin-top: 4px !important;
    }

    .discount {
        padding: 5px 10px !important;
        font-size: 12px !important;
        margin-top: 6px !important;
    }

    .stock-box {
        margin-top: 6px !important;
        border-radius: 11px !important;
        padding: 7px !important;
    }

    .stock-title {
        font-size: 13px !important;
        margin-bottom: 2px !important;
    }

    .stock-value {
        font-size: 22px !important;
    }

    .desc {
        border-radius: 10px !important;
        padding: 7px !important;
        margin-top: 6px !important;
        font-size: 12px !important;
        line-height: 1.25 !important;
    }
}

/* Very small screen: reduce image column more but keep both visible */
@media (max-width: 620px) and (max-height: 500px) {
    .product-grid {
        grid-template-columns: minmax(115px, 30%) minmax(0, 1fr) !important;
    }

    .logo {
        font-size: 20px !important;
    }

    .barcode-input {
        height: 38px !important;
        font-size: 16px !important;
    }

    .name-eng {
        font-size: 22px !important;
    }

    .sale-price,
    .no-promo-price {
        font-size: 40px !important;
    }
}


/* =========================================
   BARCODE FIELD VISIBILITY
   Visible field can be hidden while scanner remains active.
========================================= */
.barcode-input.scanner-hidden-active {
    position: fixed !important;
    left: -10000px !important;
    top: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    padding: 0 !important;
    border: 0 !important;
}

.search-box.search-box-hidden-clean {
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}


/* =========================================
   Idle Ads Display Fit
   cover = full screen/crop edges
   contain = no crop/black bars
   fill = stretch/fill screen
========================================= */
.idle-ads-media img.fit-cover,
.idle-ads-media video.fit-cover { object-fit: cover; }

.idle-ads-media img.fit-contain,
.idle-ads-media video.fit-contain { object-fit: contain; }

.idle-ads-media img.fit-fill,
.idle-ads-media video.fit-fill { object-fit: fill; }


/* ==========================================================
   Public Screen Small-Height Kiosk Fit Fix
   Target: 1024x768, 800x600, 746x564, tablet/devtools kiosk.
   Goal: no scroll and no clipped stock/details.
   ========================================================== */

@media (max-height: 620px) {
    html,
    body {
        overflow: hidden !important;
        height: 100% !important;
        position: fixed !important;
        inset: 0 !important;
    }

    .app {
        height: 100vh !important;
        height: 100dvh !important;
        padding: 8px 12px !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    .topbar {
        height: 82px !important;
        min-height: 82px !important;
        margin-bottom: 6px !important;
        gap: 8px !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }

    .brand-wrap {
        gap: 8px !important;
    }

    .company-logo,
    .company-logo.logo-horizontal-wide,
    .company-logo.logo-horizontal-standard {
        max-width: 180px !important;
        max-height: 62px !important;
    }

    .logo {
        font-size: 24px !important;
        line-height: 1.05 !important;
    }

    .store {
        margin-top: 2px !important;
        font-size: 12px !important;
        line-height: 1.1 !important;
    }

    .time-box {
        font-size: 11px !important;
        line-height: 1.15 !important;
    }

    .mini-btn {
        margin-top: 4px !important;
        padding: 6px 12px !important;
        font-size: 12px !important;
    }

    .search-box {
        height: 48px !important;
        min-height: 48px !important;
        margin-bottom: 6px !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
    }

    .barcode-input,
    .search-btn,
    .clear-btn {
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 14px !important;
    }

    .barcode-input {
        font-size: 18px !important;
        padding: 0 14px !important;
        flex-basis: auto !important;
    }

    .search-btn,
    .clear-btn {
        font-size: 13px !important;
        padding: 0 16px !important;
        flex: 0 0 auto !important;
    }

    .result {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .product-grid {
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
        grid-template-columns: minmax(170px, 36%) minmax(0, 1fr) !important;
        gap: 8px !important;
    }

    .card {
        border-radius: 14px !important;
        padding: 8px !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .image-card {
        min-height: 0 !important;
    }

    .product-img {
        height: 100% !important;
        width: 100% !important;
        max-height: none !important;
        object-fit: contain !important;
        border-radius: 12px !important;
        padding: 6px !important;
    }

    .info-card {
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        overflow: hidden !important;
        min-height: 0 !important;
    }

    .name-eng {
        font-size: 24px !important;
        line-height: 1.02 !important;
        margin: 0 !important;
        max-height: 28px !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    .name-ar {
        font-size: 18px !important;
        line-height: 1.05 !important;
        margin: 0 !important;
        max-height: 22px !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    .meta {
        gap: 4px !important;
        margin: 0 !important;
        max-height: 52px !important;
        overflow: hidden !important;
        flex: 0 0 auto !important;
    }

    .pill {
        padding: 5px 9px !important;
        font-size: 11px !important;
        line-height: 1 !important;
    }

    .price-box {
        min-height: 120px !important;
        max-height: 132px !important;
        padding: 8px 12px !important;
        margin: 0 !important;
        border-radius: 16px !important;
        flex: 0 0 126px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }

    .price-label {
        font-size: 13px !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    .sale-price,
    .no-promo-price {
        font-size: 40px !important;
        line-height: .92 !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    .original-price {
        font-size: 17px !important;
        line-height: 1 !important;
        margin-top: 4px !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    .discount {
        font-size: 13px !important;
        padding: 6px 12px !important;
        margin-top: 6px !important;
    }

    .stock-box {
        margin: 0 !important;
        padding: 8px 10px !important;
        border-radius: 12px !important;
        flex: 0 0 58px !important;
        min-height: 58px !important;
        overflow: hidden !important;
    }

    .stock-title {
        font-size: 14px !important;
        line-height: 1 !important;
        margin-bottom: 4px !important;
    }

    .stock-value {
        font-size: 24px !important;
        line-height: .95 !important;
    }

    .desc {
        margin: 0 !important;
        padding: 7px 10px !important;
        border-radius: 12px !important;
        font-size: 11px !important;
        line-height: 1.25 !important;
        min-height: 34px !important;
        flex: 1 1 auto !important;
        overflow: hidden !important;
    }
}

/* Extra tight mode for very small preview windows */
@media (max-height: 580px) {
    .topbar {
        height: 72px !important;
        min-height: 72px !important;
    }

    .company-logo,
    .company-logo.logo-horizontal-wide,
    .company-logo.logo-horizontal-standard {
        max-width: 150px !important;
        max-height: 54px !important;
    }

    .logo {
        font-size: 21px !important;
    }

    .search-box,
    .barcode-input,
    .search-btn,
    .clear-btn {
        height: 44px !important;
        min-height: 44px !important;
    }

    .product-grid {
        grid-template-columns: minmax(150px, 34%) minmax(0, 1fr) !important;
        gap: 6px !important;
    }

    .name-eng {
        font-size: 22px !important;
        max-height: 24px !important;
    }

    .name-ar {
        font-size: 16px !important;
        max-height: 18px !important;
    }

    .meta {
        max-height: 44px !important;
    }

    .price-box {
        flex-basis: 112px !important;
        min-height: 106px !important;
        max-height: 116px !important;
    }

    .sale-price,
    .no-promo-price {
        font-size: 34px !important;
    }

    .original-price {
        font-size: 15px !important;
    }

    .stock-box {
        flex-basis: 50px !important;
        min-height: 50px !important;
        padding: 6px 9px !important;
    }

    .stock-title {
        font-size: 12px !important;
    }

    .stock-value {
        font-size: 20px !important;
    }

    .desc {
        font-size: 10px !important;
        min-height: 28px !important;
        padding: 6px 9px !important;
    }
}

/* Keep 2-column layout for preview/tablet widths unless very narrow */
@media (max-width: 760px) and (max-height: 620px) {
    .product-grid {
        grid-template-columns: minmax(150px, 35%) minmax(0, 1fr) !important;
        grid-template-rows: 1fr !important;
    }
}

@media (max-width: 560px) and (max-height: 620px) {
    .product-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: minmax(110px, 30%) minmax(0, 1fr) !important;
    }
}
