:root {
    --primary: #0d9488; --primary-dark: #0a7a70; --primary-light: #e6faf8; --primary-rgb: 13,148,136;
    --dark: #1a1a2e; --darker: #0f0f1a;
    --success: #06d6a0; --accent: #ef233c;
    --text: #2b2d42; --text-muted: #8d99ae; --border: #edf2f4; --bg: #fafafa;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--darker); color: #fff; overflow: hidden; height: 100vh; height: 100dvh; position: relative; touch-action: pan-x pan-y pinch-zoom; }
html { touch-action: pan-x pan-y pinch-zoom; }
.bg-image { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-size: cover; background-position: center; z-index: 0; }
.bg-image + * { position: relative; z-index: 1; }
.navbar-top, .main, .bottom-cart, .order-overlay, .order-panel, .zoom-overlay, .toast-msg { position: relative; z-index: auto; }

/* ===== NAVBAR ===== */
.navbar-top {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: #0f0f1a;
    padding: 6px 12px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.nav-logo { width: 34px; height: 34px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; transition: transform 0.2s; }
.nav-logo:hover { transform: scale(1.1); }
.nav-name { font-size: 16px; font-weight: 800; }
.nav-center { display: flex; gap: 4px; direction: ltr; }
.lang-btn { padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); background: transparent; color: rgba(255,255,255,0.5); font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.nav-right { display: flex; align-items: center; gap: 14px; }

/* Book / Grid toggle pill */
.view-toggle {
    display: flex; border-radius: 8px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}
.vt-btn {
    padding: 4px 10px; border: none; cursor: pointer;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5);
    transition: all 0.15s; white-space: nowrap;
}
.vt-btn.active {
    background: var(--primary); color: #fff;
}
.vt-btn:not(.active):active { background: rgba(255,255,255,0.12); }
.nav-order-btn { position: relative; padding: 6px 14px; border-radius: 10px; border: none; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.nav-order-count { position: absolute; top: -5px; right: -5px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.nav-link-sm { color: rgba(255,255,255,0.6); font-size: 20px; text-decoration: none; display: flex; align-items: center; gap: 3px; }
.nav-link-sm:hover { color: #fff; }

/* ===== MAIN ===== */
.main { padding-top: 42px; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* Categories in navbar */
.nav-cats { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; justify-content: center; padding: 0 10px; max-width: 600px; }
.nav-cats::-webkit-scrollbar { display: none; }
@media (max-width: 767px) {
    .nav-cats { max-width: 200px; justify-content: flex-start; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
    .cat-chip { scroll-snap-align: start; }
}
@media (min-width: 768px) and (max-width: 1439px) {
    .nav-cats { max-width: 450px; }
}
.cat-chip { flex-shrink: 0; padding: 3px 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); font-size: 10px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 3px; white-space: nowrap; }

/* PWA standalone mode */
@media (display-mode: standalone) {
    .cat-chip { padding: 6px 16px; font-size: 14px; border-radius: 16px; gap: 5px; }
    .nav-cats { gap: 6px; max-width: none; flex: 1; padding: 0 16px; }
    .navbar-top { padding: 8px 16px; }
}
.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== BOOK CONTAINER ===== */
.book-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2px; position: relative; overflow: hidden; min-height: 0; }
.book-container { width: 100%; max-width: 800px; margin: 0 auto; position: relative; overflow: hidden; }
.book-container > .stf__parent { position: relative !important; }
.book-container .stf__block { position: absolute !important; }
.book-container .stf__item { backface-visibility: hidden; -webkit-backface-visibility: hidden; }

/* Page content inside book */
.menu-page {
    background: #fff; color: var(--text); padding: 0;
    display: flex; flex-direction: column; overflow: hidden;
    border-radius: 0; user-select: none;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}
.mp-image { width: 100%; object-fit: cover; display: block; background: #f0f0f0; }
.mp-emoji { width: 100%; display: flex; align-items: center; justify-content: center; font-size: 80px; background: linear-gradient(135deg, #f8f8f8, #eee); }
.mp-body { padding: 8px 12px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mp-cat { font-size: 9px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.mp-name { font-size: 14px; font-weight: 800; margin-bottom: 2px; line-height: 1.2; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mp-desc { font-size: 11px; color: var(--text-muted); line-height: 1.3; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mp-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.mp-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.mp-price small { font-size: 10px; color: var(--text-muted); }
.mp-add { padding: 6px 12px; border-radius: 10px; border: none; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.mp-add:hover { background: var(--primary-dark); }
.mp-add.disabled { opacity: 0.35; pointer-events: none; cursor: not-allowed; }
.mp-zoom { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary-light); color: var(--primary); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mp-zoom:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Image zoom modal */
.zoom-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; z-index: 99999; display: none; align-items: center; justify-content: center; }
.zoom-overlay.show { display: flex; }
.zoom-overlay img { max-width: 94vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
.zoom-close { position: fixed; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100000; backdrop-filter: blur(4px); touch-action: manipulation; }
.zoom-close:hover { background: rgba(255,255,255,0.25); }

/* ===== Item Detail Overlay ===== */
#itemDetail {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
#itemDetail.show { opacity: 1; pointer-events: auto; }
.detail-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
}
.detail-content {
    position: relative; z-index: 1;
    width: 70vw; height: 80vh;
    border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 60px rgba(0,0,0,0.6);
    animation: detail-in 0.2s ease-out;
}
@keyframes detail-in { from { transform: scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }
.detail-close {
    position: absolute; top: 14px; right: 14px; z-index: 10;
    width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(0,0,0,0.45); color: #fff;
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}
body[dir="rtl"] .detail-close { right: auto; left: 14px; }
.detail-img-area { position: absolute; inset: 0; background: #1a1a2e; }
.detail-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-emoji {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 120px; background: linear-gradient(135deg, #f8f8f8, #eee);
}
.detail-zoom-btn {
    position: absolute; top: 14px; left: 14px; z-index: 10;
    width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(0,0,0,0.45); color: #fff;
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}
body[dir="rtl"] .detail-zoom-btn { left: auto; right: 14px; }
.detail-zoom-btn:active { background: rgba(0,0,0,0.7); }
.detail-body {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
    padding: 40px 24px 20px;
    display: flex; align-items: flex-end; gap: 16px;
}
.detail-info { flex: 1; min-width: 0; }
.detail-cat {
    font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.7);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px;
}
.detail-name { font-size: 24px; font-weight: 800; color: #fff; line-height: 1.2; margin-bottom: 4px; }
.detail-desc {
    font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.detail-low-stock { font-size: 12px; color: #ff6b6b; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.detail-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.detail-price { font-size: 26px; font-weight: 800; color: #fff; white-space: nowrap; }
.detail-price small { font-size: 13px; font-weight: 600; opacity: 0.6; }
.detail-add {
    padding: 14px 28px; border: none; border-radius: 14px;
    background: var(--primary); color: #fff;
    font-size: 15px; font-weight: 800; cursor: pointer;
    min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px;
    white-space: nowrap;
}
.detail-add:hover { background: var(--primary-dark); }
.detail-add:active { transform: scale(0.95); transition: transform 0.1s; }
.detail-add.disabled { opacity: 0.35; pointer-events: none; }

/* Cover pages */
.menu-page-cover {
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 50%, var(--dark) 100%);
    color: #fff; padding: 24px; user-select: none; overflow: hidden;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    transform: translateZ(0); will-change: transform;
}
.menu-page-cover .cover-inner {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center;
    width: 100%; height: 100%; position: relative;
}
.menu-page-cover::before {
    content: ''; position: absolute; top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(var(--primary-rgb),0.15) 0%, transparent 50%);
}
.cover-logo { font-size: 60px; margin-bottom: 12px; filter: drop-shadow(0 4px 12px rgba(var(--primary-rgb),0.4)); }
.cover-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.3px; }
.cover-subtitle { font-size: 14px; color: rgba(255,255,255,0.6); margin-bottom: 16px; }
.cover-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--primary); padding: 8px 18px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.cover-divider { width: 60px; height: 3px; background: var(--primary); border-radius: 2px; margin: 14px auto; opacity: 0.6; }
.cover-hint { font-size: 12px; color: rgba(255,255,255,0.35); margin-top: 10px; }
.cover-arrows { display: flex; justify-content: center; gap: 2px; margin-top: 8px; direction: ltr; }
.cover-arrows i { font-size: 16px; color: var(--primary); opacity: 0.3; animation: arrowWave 2s infinite; }
.cover-arrows i:nth-child(1) { animation-delay: 0s; }
.cover-arrows i:nth-child(2) { animation-delay: 0.15s; }
.cover-arrows i:nth-child(3) { animation-delay: 0.3s; }
.cover-arrows i:nth-child(4) { animation-delay: 0.45s; }
.cover-arrows i:nth-child(5) { animation-delay: 0.6s; }
@keyframes arrowWave { 0%,100%{ opacity: 0.15; transform: translateX(0); } 50%{ opacity: 1; transform: translateX(-4px); } }

/* Back page */
.menu-page-back {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1a 100%);
    color: #fff; padding: 24px; user-select: none;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    transform: translateZ(0); will-change: transform;
}
.menu-page-back .back-inner {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center;
    width: 100%; height: 100%;
}
.back-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.back-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.back-subtitle { font-size: 13px; color: rgba(255,255,255,0.4); }
.back-cat { color: var(--primary); font-weight: 700; }

/* Navigation arrows */
.book-nav { display: none; }
.book-arrow { width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); color: #fff; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.book-arrow:hover { background: var(--primary); border-color: var(--primary); }
.book-counter { font-size: 15px; color: rgba(255,255,255,0.7); font-weight: 700; min-width: 70px; text-align: center; }

/* In-page pagination */
.mp-pagination { display: flex; align-items: center; gap: 8px; margin-inline-end: 20px; }
.mp-page-arrow { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary-light); color: var(--primary); font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mp-page-arrow:hover { background: var(--primary); color: #fff; }
.mp-page-counter { font-size: 10px; color: var(--text-muted); font-weight: 700; min-width: 20px; text-align: center; }

/* ===== BOTTOM CART BAR ===== */
.bottom-cart {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--dark); border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 16px; display: none; align-items: center; justify-content: space-between; z-index: 90;
}
.bottom-cart.show { display: flex; }
.bc-left { display: flex; align-items: center; gap: 8px; }
.bc-count { background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.bc-total { font-size: 16px; font-weight: 800; }
.bc-btn { padding: 10px 20px; border-radius: 12px; border: none; background: var(--primary); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }

/* ===== ORDER PANEL ===== */
.order-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; }
.order-overlay.show { display: block; }
.order-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg); color: var(--text); border-radius: 20px 20px 0 0;
    max-height: 85vh; overflow-y: auto; z-index: 201;
    transform: translateY(100%); transition: transform 0.3s;
}
.order-panel.show { transform: translateY(0); }
.op-drag-handle { display: none; padding: 10px 0 4px; text-align: center; cursor: grab; }
.op-drag-bar { width: 40px; height: 4px; background: rgba(0,0,0,0.2); border-radius: 2px; margin: 0 auto; }
.op-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); border-radius: 20px 20px 0 0; z-index: 1; }
.op-header h3 { font-size: 16px; font-weight: 800; margin: 0; }
.op-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--border); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.op-items { padding: 8px 0; flex: 1; overflow-y: auto; }
.op-item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.op-item-img { width: 50px; height: 50px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.op-item-emoji { width: 50px; height: 50px; border-radius: 10px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.op-item-info { flex: 1; }
.op-item-name { font-size: 14px; font-weight: 700; }
.op-item-price-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 1px; }
.op-item-price { font-size: 13px; font-weight: 700; color: var(--primary); }
.op-item-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.op-qty { display: flex; align-items: center; background: var(--border); border-radius: 8px; }
.op-qty button { width: 28px; height: 28px; border: none; background: transparent; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--text); }
.op-qty span { width: 24px; text-align: center; font-size: 13px; font-weight: 700; }
.op-remove { border: none; background: none; color: var(--accent); font-size: 14px; cursor: pointer; padding: 4px; }
.op-empty { text-align: center; padding: 30px 16px; color: var(--text-muted); }
.op-footer { padding: 14px 16px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg); }
.op-table-select { width: 100%; padding: 10px; border: 2px solid var(--primary); border-radius: 10px; font-size: 14px; font-weight: 600; margin-bottom: 8px; outline: none; background: #fff; color: var(--text); }
.op-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.op-submit { width: 100%; padding: 14px; border: none; border-radius: 14px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Order tracking in panel */
.track-header { text-align: center; padding: 16px; }
.track-order-num { font-size: 12px; color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.track-title { font-size: 18px; font-weight: 800; color: var(--text); margin: 4px 0; }
.track-status-bar { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 16px 12px; }
.track-step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.track-time { font-size: 8px; font-weight: 700; color: transparent; margin-bottom: 2px; font-variant-numeric: tabular-nums; min-height: 11px; }
.track-step.done .track-time { color: var(--success); }
.track-step.active .track-time { color: var(--primary); }
.track-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; z-index: 1; }
.track-step.done .track-dot { background: var(--success); }
.track-step.active .track-dot { background: var(--primary); animation: tpulse 2s infinite; }
@keyframes tpulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(var(--primary-rgb),0.3); } 50%{ box-shadow: 0 0 0 6px rgba(var(--primary-rgb),0); } }
.track-label { font-size: 9px; font-weight: 600; color: var(--text-muted); margin-top: 4px; text-align: center; line-height: 1.2; }
.track-step.done .track-label { color: var(--success); }
.track-step.active .track-label { color: var(--primary); font-weight: 700; }
.track-line { flex: 1; height: 2px; background: var(--border); margin-top: -33px; }
.track-line.done { background: var(--success); }
.track-items { border-top: 1px solid var(--border); }
.track-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
.track-item > span:first-child { display: inline-flex; align-items: center; }
.track-item-qty { background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-inline-end: 6px; }
.track-total { display: flex; justify-content: space-between; padding: 10px 16px; font-size: 16px; font-weight: 800; border-top: 2px solid var(--border); }
.track-again { text-align: center; padding: 12px 16px 24px; }
.track-again-btn { padding: 10px 24px; border-radius: 12px; border: none; background: var(--primary); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.track-waiting { text-align: center; padding: 8px; font-size: 12px; color: var(--primary); font-weight: 600; }
.track-waiting i { animation: spin 1.5s linear infinite; display: inline-block; margin-right: 4px; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Toast */
.toast-msg { position: fixed; top: 50px; right: 16px; background: var(--success); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 700; z-index: 9999; display: none; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.toast-msg.show { display: flex; align-items: center; gap: 8px; animation: toastSlide 0.3s ease; }
@keyframes toastSlide { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

/* Gallery viewer */
.gallery-viewer { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.gallery-expanded .gv-img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; opacity: 0; transition: opacity 0.5s ease; position: absolute; top: 0; left: 0; }
.gallery-contained .gv-img { max-width: 90%; max-height: 75%; object-fit: contain; border-radius: 12px; opacity: 0; transition: opacity 0.5s ease; }
.gallery-viewer .gv-img.visible { opacity: 1; }
.gallery-expanded .gv-title { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 14px; font-weight: 600; background: rgba(0,0,0,0.5); padding: 6px 18px; border-radius: 16px; z-index: 2; white-space: nowrap; }
.gallery-contained .gv-title { color: rgba(255,255,255,0.7); font-size: 14px; font-weight: 600; margin-top: 8px; }
.gallery-viewer .gv-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.3); border: none; color: #fff; font-size: 24px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; }
.gallery-viewer .gv-nav:hover { background: rgba(0,0,0,0.5); }
.gallery-viewer .gv-nav.prev { left: 8px; }
.gallery-viewer .gv-nav.next { right: 8px; }
.gallery-expanded .gv-dots { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 2; }
.gallery-contained .gv-dots { display: flex; gap: 6px; margin-top: 8px; }
.gallery-viewer .gv-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.4); border: none; cursor: pointer; transition: background 0.3s; }
.gallery-viewer .gv-dot.active { background: var(--primary); }
.gallery-expanded .gv-back { position: absolute; top: 10px; right: 10px; padding: 6px 14px; border-radius: 8px; border: none; background: rgba(0,0,0,0.4); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; z-index: 2; }
.gallery-expanded .gv-back:hover { background: rgba(0,0,0,0.6); }
.gallery-contained .gv-back { margin-top: 10px; padding: 6px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: transparent; color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 600; cursor: pointer; }
.gallery-contained .gv-back:hover { background: rgba(255,255,255,0.1); color: #fff; }
.gallery-empty { text-align: center; color: rgba(255,255,255,0.4); padding: 40px; }
.gallery-empty i { font-size: 48px; display: block; margin-bottom: 10px; opacity: 0.3; }
.gallery-empty .gv-back { margin-top: 16px; padding: 8px 20px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: transparent; color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 600; cursor: pointer; }
.gallery-empty .gv-back:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Gallery expand button */
.gv-expand {
    position: absolute; z-index: 3;
    top: 10px; width: 36px; height: 36px;
    border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.4); color: rgba(255,255,255,0.8);
    font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; touch-action: manipulation;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
[dir="rtl"] .gv-expand { left: 10px; right: auto; }
[dir="ltr"] .gv-expand { right: 10px; left: auto; }
.gv-expand:hover { background: rgba(0,0,0,0.6); color: #fff; border-color: rgba(255,255,255,0.4); }

/* Gallery fullscreen overlay */
.gallery-fs {
    position: fixed; inset: 0; z-index: 99999;
    background: #000; display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.gallery-fs-img {
    width: 100%; height: 100%; object-fit: contain;
    opacity: 0; transition: opacity 0.5s ease;
    pointer-events: none;
}
.gallery-fs-exit {
    position: absolute; top: 20px; z-index: 100000;
    width: 44px; height: 44px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.5); color: rgba(255,255,255,0.8);
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
    touch-action: manipulation;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
[dir="rtl"] .gallery-fs-exit { left: 20px; right: auto; }
[dir="ltr"] .gallery-fs-exit { right: 20px; left: auto; }
.gallery-fs-exit.visible { opacity: 1; }
.gallery-fs-exit:hover { background: rgba(0,0,0,0.7); color: #fff; }

/* Gallery button in sidebar */
.gallery-side-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; font-size: 13px; border: 1px dashed rgba(var(--primary-rgb),0.3); background: transparent; color: rgba(255,255,255,0.6); cursor: pointer; transition: all 0.2s; width: 100%; white-space: nowrap; }
.gallery-side-btn:hover { background: rgba(var(--primary-rgb),0.12); color: rgba(255,255,255,0.9); border-color: rgba(var(--primary-rgb),0.5); }

/* Login view */
.login-view {
    padding-top: 42px; height: 100vh; height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1;
}
.login-container { width: 100%; max-width: 420px; padding: 16px; }
.login-card {
    background: rgba(26,26,46,0.95); backdrop-filter: blur(12px);
    border-radius: 20px; padding: 28px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.06);
}
.login-header { text-align: center; margin-bottom: 18px; }
.login-icon { font-size: 44px; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 800; color: #fff; }
.login-view .nav-pills .nav-link { color: rgba(255,255,255,0.5); font-weight: 600; font-size: 13px; border-radius: 10px; padding: 8px; }
.login-view .nav-pills .nav-link.active { background: var(--primary); color: #fff; }
.login-view .form-label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.5); }
.login-view .form-control {
    background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.1);
    color: #fff; border-radius: 10px; padding: 10px 14px; font-size: 14px;
}
.login-view .form-control:focus { background: rgba(255,255,255,0.08); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.15); }
.login-view .form-control::placeholder { color: rgba(255,255,255,0.2); }
.btn-login { width: 100%; padding: 12px; border: none; border-radius: 12px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-login:hover { background: var(--primary-dark); color: #fff; }
.pin-input { font-size: 28px; letter-spacing: 12px; font-weight: 800; text-align: center; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 260px; margin: 0 auto; }
.pin-btn { height: 56px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }
.pin-btn:hover { background: rgba(255,255,255,0.1); }
.pin-btn:active { background: var(--primary); border-color: var(--primary); }
.pin-btn-clear { color: #ef233c; }
.pin-btn-back { color: #ffd166; }
.login-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.login-tab { flex: 1; padding: 8px; border-radius: 10px; border: none; background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5); font-size: 13px; font-weight: 600; cursor: pointer; }
.login-tab.active { background: var(--primary); color: #fff; }

/* Side categories panel */
.cat-side-panel { display: none; }
.cat-panel-title {
    display: none; font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
    color: var(--primary); text-align: center; margin-bottom: 4px; font-weight: 700; opacity: 0.7;
}
.cat-panel-divider {
    display: none; height: 1px; margin: 4px 8px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb),0.3), transparent);
}
/* ===== DESKTOP & TABLET (>=768px) ===== */
@media (min-width: 768px) {
    .main { flex-direction: row; padding-bottom: 0; }
    .bottom-cart { display: none !important; }
    .nav-cats { display: none !important; }
    .order-overlay { display: none !important; }
    .op-drag-handle { display: none; }

    .cat-side-panel {
        display: flex; flex-direction: column; gap: 6px;
        width: 10%; flex-shrink: 0; padding: 14px 10px;
        overflow-y: auto; scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.15) transparent;
        z-index: 1;
        /* Painted Canvas */
        background: linear-gradient(165deg, rgba(15,15,26,0.85) 0%, rgba(15,15,26,0.75) 40%, rgba(15,15,26,0.82) 100%);
        border: 2px solid rgba(var(--primary-rgb),0.5);
        border-radius: 24px 8px 24px 8px;
        box-shadow: inset 0 0 30px rgba(var(--primary-rgb),0.08), 0 0 50px rgba(0,0,0,0.4), 0 0 20px rgba(var(--primary-rgb),0.12);
        position: relative;
        margin: 8px 0 8px 8px;
        align-self: flex-start;
        max-height: calc(100% - 16px);
    }
    .cat-side-panel::after {
        content: '';
        position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
        width: 30px; height: 3px;
        background: var(--primary);
        border-radius: 3px;
        opacity: 0.2;
    }
    .cat-panel-title { display: block; }
    .cat-panel-divider { display: block; }
    .cat-side-panel::-webkit-scrollbar { width: 4px; }
    .cat-side-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
    [dir="ltr"] .cat-side-panel { padding-right: 8px; }
    [dir="rtl"] .cat-side-panel { padding-left: 8px; margin: 8px 8px 8px 0; margin-left: 0; }
    [dir="rtl"] .cat-side-panel { margin-right: 8px; margin-left: 0; }
    .cat-side-panel .cat-chip { padding: 8px 12px; border-radius: 12px; font-size: 13px; gap: 6px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; transition: all 0.2s; }
    .cat-side-panel .cat-chip:hover { background: rgba(var(--primary-rgb),0.15); color: rgba(255,255,255,0.8); }
    .cat-side-panel .cat-chip.active, .cat-side-panel .cat-chip.active:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

    .book-wrapper {
        flex: 1; min-width: 0; display: flex; flex-direction: column;
        /* Painted Canvas */
        background: linear-gradient(180deg, rgba(15,15,26,0.85) 0%, rgba(15,15,26,0.75) 50%, rgba(15,15,26,0.82) 100%);
        border: 2px solid rgba(var(--primary-rgb),0.5);
        border-radius: 16px;
        box-shadow: inset 0 0 30px rgba(var(--primary-rgb),0.08), 0 0 50px rgba(0,0,0,0.4), 0 0 20px rgba(var(--primary-rgb),0.12);
        margin: 8px 0; position: relative;
    }
    .book-container { max-width: 100%; }
    .book-area { flex: 1; min-height: 0; }
    .order-panel {
        position: static; width: 26%; flex-shrink: 0;
        max-height: none; transform: none; z-index: auto;
        display: none; flex-direction: column;
        overflow-y: auto;
        /* Painted Canvas */
        background: linear-gradient(195deg, rgba(15,15,26,0.85) 0%, rgba(15,15,26,0.75) 40%, rgba(15,15,26,0.82) 100%);
        border: 2px solid rgba(var(--primary-rgb),0.5);
        border-radius: 8px 24px 8px 24px;
        box-shadow: inset 0 0 30px rgba(var(--primary-rgb),0.08), 0 0 50px rgba(0,0,0,0.4), 0 0 20px rgba(var(--primary-rgb),0.12);
        margin: 8px 8px 8px 0; color: #fff;
    }
    .order-panel::after {
        content: ''; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
        width: 30px; height: 3px; background: var(--primary); border-radius: 3px; opacity: 0.2;
    }
    .order-panel.show { display: flex; }
    .op-header { background: transparent; border-bottom: 1px solid rgba(var(--primary-rgb),0.15); border-radius: 0; }
    .op-header h3 { color: #fff; }
    .op-close { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); }
    .op-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
    .op-item { border-bottom: 1px solid rgba(var(--primary-rgb),0.1); transition: background 0.2s; }
    .op-item:hover { background: rgba(var(--primary-rgb),0.06); }
    .op-item-img { border: 1px solid rgba(var(--primary-rgb),0.2); }
    .op-item-emoji { background: rgba(var(--primary-rgb),0.12); border: 1px solid rgba(var(--primary-rgb),0.2); }
    .op-item-name { color: rgba(255,255,255,0.9); }
    .op-item-price { color: #ffd166; font-weight: 800; }
    .op-qty { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,209,102,0.3); border-radius: 10px; }
    .op-qty button { color: #ffd166; border-radius: 10px; transition: background 0.15s; }
    .op-qty button:hover { background: rgba(255,209,102,0.15); }
    .op-qty span { color: #fff; }
    .op-remove { background: rgba(239,35,60,0.1); color: #ef233c; border-radius: 8px; padding: 5px 8px; transition: background 0.15s; }
    .op-remove:hover { background: rgba(239,35,60,0.2); }
    .op-empty { color: rgba(255,255,255,0.4); }
    .op-footer { background: transparent; border-top: 1px solid rgba(var(--primary-rgb),0.15); }
    .op-table-select { background: rgba(var(--primary-rgb),0.08); border: 1.5px solid rgba(var(--primary-rgb),0.35); color: #fff; border-radius: 10px; }
    .op-table-select option { background: #1a1a2e; color: #fff; }
    .op-total { color: #fff; }
    .op-submit { background: var(--primary); box-shadow: 0 4px 16px rgba(var(--primary-rgb),0.3); transition: all 0.2s; }
    .op-submit:hover { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(var(--primary-rgb),0.4); }
    /* Order tracking — match tablet menu (dark order panel) */
    .track-title { color: #fff; }
    .track-label { color: rgba(255,255,255,0.5); }
    .track-dot { background: rgba(255,255,255,0.15); color: #fff; }
    .track-line { background: rgba(255,255,255,0.1); }
    .track-items { border-top: 1px solid rgba(var(--primary-rgb),0.15); }
    .track-item { border-bottom: 1px solid rgba(var(--primary-rgb),0.1); color: rgba(255,255,255,0.85); }
    .track-item-qty { background: rgba(var(--primary-rgb),0.15); color: var(--primary); }
    .track-total { border-top: 2px solid rgba(var(--primary-rgb),0.2); color: #fff; }
    .track-again-btn { min-height: 44px; width: 100%; touch-action: manipulation; }
    [dir="rtl"] .order-panel { margin: 8px 0 8px 8px; }
}

/* ===== TABLET adjustments (768-1439px) ===== */
@media (min-width: 768px) and (max-width: 1439px) {
    .cat-side-panel { width: 14%; padding: 14px 8px; }
    .cat-side-panel .cat-chip { padding: 10px 10px; font-size: 12px; }
    .book-area { padding: 2px 1px; }
    .order-panel { width: 26%; }

    .mp-name { font-size: 16px; }
    .mp-desc { font-size: 12px; }
    .mp-price { font-size: 18px; }
    .mp-body { padding: 6px 10px 4px; }
    .mp-add { padding: 8px 14px; font-size: 12px; min-height: 40px; }
    .mp-zoom { width: 42px; height: 42px; font-size: 18px; }
    .mp-page-arrow { width: 36px; height: 36px; font-size: 16px; min-width: 36px; touch-action: manipulation; }
    .mp-page-counter { font-size: 12px; }
    .book-arrow { width: 56px; height: 56px; font-size: 24px; }
    .book-counter { font-size: 16px; }

    .op-header h3 { font-size: 14px; }
    .op-item-name { font-size: 13px; }
    .op-item-price { font-size: 12px; }
    .op-total { font-size: 15px; }
    .op-submit { font-size: 14px; padding: 12px; }
    .op-table-select { font-size: 13px; padding: 8px; }
    .op-qty button { width: 32px; height: 32px; }
    .op-item-emoji { width: 44px; height: 44px; font-size: 19px; }
    .op-item-img { width: 44px; height: 44px; }
}

/* ===== MOBILE (<768px) ===== */
@media (max-width: 767px) {
    .nav-center { display: none; }
    #langDropdown { display: block !important; }
    .book-container { max-width: 360px; }
    .mp-image, .mp-emoji { height: 45%; }
    .mp-name { font-size: 16px; }
    .mp-desc { font-size: 12px; }
    .mp-price { font-size: 18px; }
    .mp-add { padding: 10px 16px; font-size: 13px; touch-action: manipulation; min-height: 44px; }
    .mp-zoom { width: 44px; height: 44px; font-size: 16px; touch-action: manipulation; }
    .mp-body { padding: 12px; }
    .mp-page-arrow { width: 36px; height: 36px; font-size: 14px; touch-action: manipulation; }
    .book-arrow { width: 44px; height: 44px; font-size: 16px; touch-action: manipulation; }
    body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }

    .nav-cats { max-width: 220px; }
    .cat-chip { padding: 5px 12px; font-size: 12px; }

    .navbar-top { padding-top: max(6px, env(safe-area-inset-top, 0px)); }
    .bottom-cart { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
    .order-panel { padding-bottom: env(safe-area-inset-bottom, 0px); }

    [dir="rtl"] #landingLangMenu { left: 0; right: auto; }

    .mp-image, .mp-emoji { touch-action: manipulation; cursor: pointer; }
    .nav-order-btn { min-height: 44px; min-width: 44px; touch-action: manipulation; }
    .bc-btn { padding: 12px 24px; min-height: 44px; touch-action: manipulation; }
    .op-close { min-width: 44px; min-height: 44px; touch-action: manipulation; }
    .op-qty button { min-width: 36px; min-height: 36px; touch-action: manipulation; }

    .mp-add:active, .mp-zoom:active, .mp-page-arrow:active, .book-arrow:active, .bc-btn:active, .cat-chip:active {
        opacity: 0.7; transform: scale(0.95); transition: all 0.1s;
    }

    body.panel-open { overflow: hidden; }
    .toast-msg { top: 50px; right: 16px; }
    .op-drag-handle { display: block; }
}

/* Confirm modal buttons */
.btn-confirm {
    background: var(--primary); color: #fff; border: none;
    padding: 12px; border-radius: 10px; font-weight: 700; touch-action: manipulation;
}
.btn-confirm:hover { background: var(--primary-dark); color: #fff; }
.btn-confirm:focus { box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb),0.4); color: #fff; }
.btn-confirm:active { background: #086560; color: #fff; }
.btn-cancel-outline {
    background: #fff; color: var(--text); border: 2px solid var(--border);
    padding: 12px; border-radius: 10px; font-weight: 700; touch-action: manipulation;
}
.btn-cancel-outline:hover { background: var(--border); color: var(--text); }
.btn-cancel-outline:active { background: #dde1e3; }
.confirm-modal .modal-content { border-radius: 16px; overflow: hidden; border: none; color: var(--text); touch-action: manipulation; }
.confirm-modal .modal-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border: none; padding: 20px; color: #fff; }
.confirm-modal .modal-footer { border: none; padding: 12px 16px; gap: 10px; }
.confirm-total-bar { display: flex; justify-content: space-between; padding: 14px 16px; border-top: 2px solid var(--primary); font-size: 18px; font-weight: 800; }

/* PWA close button */
.pwa-close-btn {
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.3); font-size: 10px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    margin-inline-start: 12px; transition: all 0.2s;
    touch-action: manipulation; min-width: 24px; min-height: 24px;
}
.pwa-close-btn:hover { background: rgba(239,35,60,0.15); color: #ef233c; border-color: rgba(239,35,60,0.3); }
.swal-cancel-dark { color: rgba(255,255,255,0.7) !important; border: 1px solid rgba(255,255,255,0.15) !important; }

/* PWA fullscreen toggle button */
.pwa-fs-btn {
    position: fixed; bottom: 6px; left: 6px; z-index: 9999;
    width: 20px; height: 20px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(15,15,26,0.7); color: rgba(255,255,255,0.35);
    font-size: 9px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation; transition: all 0.2s;
}
[dir="rtl"] .pwa-fs-btn { left: auto; right: 6px; }
.pwa-fs-btn:active { background: var(--primary); color: #fff; }

/* Canvas-style Swal popup */
.swal-canvas-popup {
    border: 2px solid rgba(var(--primary-rgb),0.5) !important;
    border-radius: 20px !important;
    box-shadow: 0 0 50px rgba(0,0,0,0.5), 0 0 20px rgba(var(--primary-rgb),0.15) !important;
    padding: 28px 24px !important;
}
.swal-canvas-popup .swal2-html-container { margin: 0 !important; padding: 0 !important; }
.swal-canvas-popup .swal2-confirm {
    border-radius: 12px !important; font-weight: 700 !important;
    padding: 10px 32px !important; font-size: 14px !important;
    min-height: 44px; touch-action: manipulation;
}

/* Paid Swal popup */
.swal-paid-popup { border-radius: 20px !important; padding: 32px 24px !important; }
.swal-paid-btn { border-radius: 12px !important; font-size: 16px !important; font-weight: 700 !important; padding: 12px 48px !important; min-height: 48px; touch-action: manipulation; }

/* API error state */
.api-error { text-align: center; padding: 60px 20px; color: rgba(255,255,255,0.6); }
.api-error i { font-size: 48px; display: block; margin-bottom: 16px; opacity: 0.4; }
.api-error .retry-btn { margin-top: 16px; padding: 10px 24px; border-radius: 12px; border: 1px solid var(--primary); background: transparent; color: var(--primary); font-size: 14px; font-weight: 700; cursor: pointer; }
.api-error .retry-btn:hover { background: var(--primary); color: #fff; }

/* Dynamic viewport height override */
body, .main { height: var(--app-height, 100dvh) !important; }
