* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

html, body { touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; background-color: #f4f6f8; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
button, .item-card, .key-btn { touch-action: manipulation; }

/* HORIZONTAL CATEGORY BAR (Now a direct child of body, spanning 100vw) */
.category-topbar { width: 100%; background: #fff; border-bottom: 2px solid #e1e4e8; padding: 15px 20px; display: grid; grid-template-rows: 1fr 1fr; grid-auto-columns: minmax(180px, auto); grid-auto-flow: column; gap: 12px; overflow-x: auto; overflow-y: hidden; z-index: 5; flex-shrink: 0; }
.category-topbar::-webkit-scrollbar { height: 10px; }
.category-topbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.category-topbar::-webkit-scrollbar-track { background: #f0f2f5; border-radius: 10px; }
.category-btn { background: #f0f2f5; border: none; padding: 16px 20px; font-size: 1.1rem; font-weight: 700; border-radius: 12px; cursor: pointer; text-align: center; transition: all 0.2s; white-space: nowrap; color: #444; border-bottom: 4px solid transparent; }
.category-btn:active { transform: scale(0.97); }
.category-btn.active { background: #e6f0ff; color: #0052cc; border-bottom: 4px solid #0052cc; box-shadow: 0 4px 10px rgba(0,82,204,0.1); }

/* MAIN WRAPPER (Now flexes to fill remaining space UNDER the category bar) */
.page-wrapper { display: flex; flex: 1; width: 100vw; overflow: hidden; }
.left-panel { flex: 2.3; display: flex; flex-direction: column; overflow: hidden; }

/* SCANNER DISPLAY BAR */
.scanner-display-bar { background: linear-gradient(135deg, #001f4d, #0052cc); color: white; padding: 16px 30px; display: flex; align-items: center; justify-content: flex-start; gap: 15px; box-shadow: inset 0 -5px 10px rgba(0,0,0,0.2); z-index: 10; border-bottom: 4px solid #00d2ff; flex-shrink: 0; }

.green-dot { width: 24px; height: 24px; background-color: #2ecc71; border-radius: 50%; box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.8); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); } 70% { box-shadow: 0 0 0 20px rgba(46, 204, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); } }

/* NEW RED DOT FOR ERRORS */
.red-dot { width: 24px; height: 24px; background-color: #ff4757; border-radius: 50%; box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.8); animation: pulse-red 2s infinite; }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); } 70% { box-shadow: 0 0 0 20px rgba(255, 71, 87, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); } }

.scanner-text { font-size: 1.5rem; font-weight: 900; letter-spacing: 1px; color: #00d2ff; text-transform: uppercase; text-shadow: 0 2px 5px rgba(0,0,0,0.3); flex: 1; }
.scanner-icon-container { background: rgba(0, 0, 0, 0.2); padding: 10px; border-radius: 10px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255, 255, 255, 0.3); }

/* CATALOG GRID */
.catalog-section { flex: 1; padding: 25px; background: #f4f6f8; overflow-y: auto; display: flex; flex-direction: column; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; align-content: start; }
.item-card { background: #fff; border: 1px solid #e1e4e8; border-radius: 12px; padding: 18px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.03); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: space-between; transition: transform 0.1s; }
.item-card:active { transform: scale(0.96); }
.item-img { width: 100%; height: 160px; object-fit: contain; margin-bottom: 12px; border-radius: 8px; }
.item-name { font-size: 1.05rem; font-weight: 500; margin-bottom: 8px; color: #111; }
.item-price { font-weight: 900; color: #2ecc71; font-size: 1.3rem; }

/* CART SECTION (Right side, full height of page-wrapper) */
.cart-section { flex: 1.1; background: #fff; padding: 25px; display: flex; flex-direction: column; border-left: 3px solid #001f4d; box-shadow: -5px 0 15px rgba(0,0,0,0.08); z-index: 5; height: 100%; }
.cart-header { display: flex; justify-content: space-between; align-items: center; font-size: 1.8rem; font-weight: 900; margin-bottom: 15px; border-bottom: 2px solid #e1e4e8; padding-bottom: 15px; color: #111; }
.start-over-btn { background: rgba(255, 71, 87, 0.1); color: #ff4757; border: 2px solid #ff4757; padding: 10px 18px; border-radius: 30px; font-weight: 900; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; text-transform: uppercase; }
.start-over-btn:active { background: #ff4757; color: white; transform: scale(0.95); }
.cart-items { flex: 1; overflow-y: auto; padding-right: 10px; }
.cart-item-row { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #eee; font-size: 1.2rem; }
.cart-item-info { display: flex; justify-content: space-between; flex: 1; margin-right: 15px; font-weight: 600; color: #333;}
.delete-btn { background: #ff4757; color: white; border: none; border-radius: 8px; width: 50px; height: 50px; font-size: 1.6rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.delete-btn:active { background: #ff6b81; transform: scale(0.95); }
.cart-summary { border-top: 2px solid #e1e4e8; padding-top: 15px; margin-bottom: 25px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 1.2rem; font-weight: 600; color: #555; }
.total-row { font-size: 1.8rem; font-weight: 900; color: #111; margin-top: 15px; border-top: 2px dashed #ccc; padding-top: 15px; }
.checkout-btn { background: #2ecc71; color: white; border: none; padding: 22px; border-radius: 12px; font-size: 1.5rem; font-weight: 900; cursor: pointer; width: 100%; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px; }
.checkout-btn:not(:disabled) { animation: pulse-green 2s infinite; }
.checkout-btn:active { transform: scale(0.98); }
.checkout-btn:disabled { background: #cbd5e1; cursor: not-allowed; box-shadow: none; animation: none; transform: none; }
@keyframes pulse-green { 0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); } 70% { box-shadow: 0 0 0 20px rgba(46, 204, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); } }
#checkout-status-display { margin-top: 12px; font-weight: bold; text-align: center; font-size: 1.1rem; color: #333; }

/* MODALS & SCREENSAVER */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-box { background: white; padding: 30px; border-radius: 16px; width: 650px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-title { font-size: 1.8rem; font-weight: bold; margin-bottom: 10px; color: #111; }
.modal-subtitle { font-size: 1.1rem; color: #666; margin-bottom: 20px; }
.name-input-display { width: 100%; font-size: 2.2rem; padding: 15px; text-align: center; margin-bottom: 25px; border: 3px solid #0052cc; border-radius: 8px; background: #f4f6f8; min-height: 70px; font-weight: bold; letter-spacing: 2px; }
.keyboard { display: flex; flex-direction: column; gap: 10px; margin-bottom: 25px; }
.key-row { display: flex; justify-content: center; gap: 8px; }
.key-btn { background: #e1e4e8; border: none; padding: 18px 22px; font-size: 1.4rem; font-weight: bold; border-radius: 8px; cursor: pointer; transition: transform 0.1s; }
.key-btn:active { background: #cbd5e1; transform: scale(0.92); }
.key-space { flex: 1; max-width: 300px; }
.key-bksp { background: #ff4757; color: white; padding: 18px 30px; }
.modal-actions { display: flex; gap: 15px; }
.btn-cancel { flex: 1; padding: 20px; font-size: 1.2rem; font-weight: bold; border: none; border-radius: 8px; background: #f0f2f5; color: #333; cursor: pointer; }
.btn-proceed { flex: 2; padding: 20px; font-size: 1.3rem; font-weight: bold; border: none; border-radius: 8px; background: #2ecc71; color: white; cursor: pointer; transition: all 0.2s; }
.btn-proceed:not(:disabled) { animation: pulse-green 2s infinite; }
.btn-proceed:disabled { background: #cbd5e1; cursor: not-allowed; animation: none; }
.screensaver { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: linear-gradient(135deg, #001f4d, #0052cc); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 2000; opacity: 0; pointer-events: none; transition: opacity 0.8s ease-in-out; }
.screensaver.active { opacity: 1; pointer-events: auto; }
.screensaver-title { font-size: 5rem; font-weight: 900; color: #00d2ff; text-align: center; margin-bottom: 20px; text-shadow: 0 10px 20px rgba(0,0,0,0.4); line-height: 1.1; }
.screensaver-title span { color: #fff; display: block; font-size: 3rem; font-weight: 300; }
.screensaver-prompt { font-size: 2.5rem; color: #fff; margin-top: 40px; animation: float 3s ease-in-out infinite; font-weight: bold; background: rgba(0,0,0,0.2); padding: 20px 40px; border-radius: 50px; border: 2px solid rgba(255,255,255,0.2); }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-15px); } 100% { transform: translateY(0px); } }
.terminal-img { width: 220px; margin: 20px auto; display: block; animation: gentle-bounce 2s infinite ease-in-out; }
@keyframes gentle-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#success-modal .modal-box { background: #2ecc71; border: none; transform: scale(0.9); animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes popIn { to { transform: scale(1); } }