:root {
  --navy: #001535;
  --navyDark: #000b1e;
  --red: #DA291C;
  --gold: #FFC72C;
  --ink: #27251F;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #d4d4d4;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  padding: 24px;
}

#appShell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  width: 100%;
  height: 100%;
}

/* ── kiosk card (camera + device) ───────────────────────────────────────── */
#pageLayout {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.15);
}

/* ── face recognition terminal (left of kiosk) ───────────────────────────── */
#camFloat {
  width: 180px;
  background: #0a0a0a;
  overflow: hidden;
  flex-shrink: 0;
  border-right: 1px solid #1e1e1e;
  display: flex;
  flex-direction: column;
}

#camFloatTitle {
  background: #111;
  color: rgba(255,255,255,0.35);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1.8px;
  padding: 9px 10px 9px 12px;
  text-transform: uppercase;
  border-bottom: 1px solid #1e1e1e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  display: flex;
  align-items: center;
  gap: 7px;
}

#camView {
  position: relative;
  height: 170px;
  background: #000;
  overflow: hidden;
}

#video, #overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
#video  { transform: scaleX(-1); }
#overlay { transform: scaleX(-1); }

#scanDot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #2ecc40;
  box-shadow: 0 0 6px #2ecc40;
  animation: blink 1.2s infinite;
  flex-shrink: 0;
}
#scanDot.off { background: #444; box-shadow: none; animation: none; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

#camMatch {
  background: #0d0d0d;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 9px 12px;
  border-top: 1px solid #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  min-height: 34px;
}


#camFloatFoot {
  background: #080808;
  color: rgba(255,255,255,0.18);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-align: center;
  padding: 7px;
  border-top: 1px solid #1a1a1a;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ── kiosk device frame ───────────────────────────────────────────────────── */
#device {
  width: 560px;
  background: #1c1c1c;
  padding: 6px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* ── screen (inside bezel) ───────────────────────────────────────────────── */
#kiosk {
  background: #f4f4f4;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── welcome screen (absolute overlay) ──────────────────────────────────── */
#welcome {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease;
}
#welcome.out { opacity: 0; pointer-events: none; }

#loadingScreen {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
#loadingScreen.show { display: flex; }
#loadingMsg { font-size: 15px; color: #555; font-weight: 500; }
#loadBar {
  width: 180px; height: 3px;
  background: #e8e8e8; border-radius: 2px; overflow: hidden;
}
#loadFill {
  height: 100%; width: 0;
  background: var(--red); border-radius: 2px;
  transition: width 1.6s ease;
}
#loadFill.go { width: 100%; }

#welcomeInner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 0 32px;
  text-align: center;
}
#welcomeQ {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}
#orderOptions {
  display: flex;
  gap: 18px;
  width: 100%;
}
.orderOpt {
  flex: 1;
  background: #fff;
  border: 1.5px solid #e0e0e0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  border-radius: 14px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.1s;
}
.orderOpt:hover { border-color: var(--red); transform: translateY(-2px); box-shadow: 0 4px 18px rgba(0,0,0,0.12); }
.optIcon {
  padding: 28px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.optIcon svg {
  width: 72px;
  height: 72px;
}
.optLabel {
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  padding: 14px;
  letter-spacing: 0.3px;
}
.arr { font-size: 18px; }
#langRow { display: flex; gap: 10px; }
.langBtn {
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 30px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  cursor: pointer;
}
.langBtn.active { background: rgba(255,255,255,0.2); border-color: #fff; }

/* ── confirm screen (absolute overlay) ──────────────────────────────────── */
#confirmScreen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--navyDark);
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
}
#confirmScreen.show { display: flex; }
#confirmInner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 0 32px;
}
#confirmInner h2 { font-size: 32px; font-weight: 900; color: #fff; }
#confirmMsg { font-size: 14px; color: rgba(255,255,255,0.6); line-height: 1.5; }
#confirmBack {
  background: var(--red);
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 13px 32px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

/* ── golden arches (css) ─────────────────────────────────────────────────── */
.arches { display: flex; }
.arches::before, .arches::after {
  content: '';
  display: block;
  width: 52px;
  height: 104px;
  border: 14px solid var(--gold);
  border-bottom: none;
  border-radius: 52px 52px 0 0;
}
.archesSmall { display: flex; }
.archesSmall::before, .archesSmall::after {
  content: '';
  display: block;
  width: 16px;
  height: 32px;
  border: 5px solid var(--gold);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
}

/* ── topbar (no camera slot) ─────────────────────────────────────────────── */
#topbar {
  background: #fff;
  display: flex;
  align-items: center;
  height: 68px;
  flex-shrink: 0;
  border-bottom: 2.5px solid var(--gold);
  padding: 0 16px;
  gap: 12px;
}

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
#brandName { font-size: 18px; font-weight: 900; color: #1a1a1a; line-height: 1; }
#tagline { font-size: 10px; color: #888; font-style: italic; margin-top: 2px; }

#headerRight {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
#orderBadge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  empty-cells: show;
}
#orderBadge:empty { display: none; }
#profileTag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  max-width: 130px;
}
#activeAvatar { font-size: 18px; flex-shrink: 0; }
#activeName {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cartBtn {
  background: var(--red);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
#cartCount {
  background: var(--gold);
  color: var(--ink);
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
}

/* ── horizontal category tabs ────────────────────────────────────────────── */
#tabs {
  background: #fff;
  display: flex;
  flex-shrink: 0;
  border-bottom: 2px solid #e8e8e8;
  overflow-x: auto;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(0,0,0,0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  height: 46px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.tab.active {
  color: var(--red);
  background: rgba(218,41,28,0.05);
  border-bottom-color: var(--red);
}
.tab:not(.active):hover { color: rgba(0,0,0,0.7); }

/* ── scrollable menu content ─────────────────────────────────────────────── */
#menuArea {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.18) transparent;
}
#menuArea::-webkit-scrollbar { width: 4px; }
#menuArea::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 2px; }

/* 2-column card grid */
#menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

/* ── item card ───────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.1s;
}
.card:hover { transform: scale(1.02); }

/* food photo — background-image set inline per item via spritePos() */
.itemPhoto {
  width: 100%;
  height: 160px;
  background-repeat: no-repeat;
  background-color: #fff;
  flex-shrink: 0;
}

.cardBody {
  padding: 9px 10px 11px;
  display: flex;
  flex-direction: column;
  flex: 1;
  color: var(--ink);
}
.cardName {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 6px;
}
.priceRow {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.dynPrice { font-size: 18px; font-weight: 900; color: var(--ink); }
.basePrice { color: #bbb; text-decoration: line-through; font-size: 12px; }
.saveBadge {
  background: #1a9e2c;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
}
.addBtn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  margin-top: auto;
}
.addBtn:hover { background: #bf1e14; }
.addBtn:active { transform: scale(0.97); }

/* ── bottom cart bar ─────────────────────────────────────────────────────── */
#cartBar {
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-shrink: 0;
  transition: background 0.2s;
}
#cartBar.empty { background: #fff; border-top: 1px solid #e8e8e8; }
#cartBar.empty #cartBarItems { color: #aaa; }
#cartBar.empty #cartBarTotal { color: #aaa; }
#cartBarItems { color: #fff; font-size: 13px; font-weight: 700; }
#cartBarRight { display: flex; align-items: center; gap: 12px; }
#cartBarTotal { color: #fff; font-size: 17px; font-weight: 900; }
#viewOrderBtn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 7px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

/* ── cart sidebar (kiosk-level overlay) ──────────────────────────────────── */
#cartBackdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  display: none;
}
#cartBackdrop.open { display: block; }
#cartPanel {
  position: absolute;
  top: 0; right: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 50;
  transform: translateX(105%);
  transition: transform 0.26s ease;
  display: flex;
  flex-direction: column;
  border-left: 3px solid var(--red);
}
#cartPanel.open { transform: translateX(0); }
#cartHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--red);
  border-bottom: 1px solid #ececec;
}
#cartClose { background: none; border: none; color: #aaa; font-size: 17px; cursor: pointer; }
#cartOrderType {
  padding: 8px 18px;
  font-size: 10px;
  color: #999;
  border-bottom: 1px solid #ececec;
  font-weight: 700;
  letter-spacing: 1px;
}
#cartItems { flex: 1; overflow-y: auto; padding: 10px 16px; }
.emptyCart { color: #bbb; text-align: center; padding: 50px 0; font-size: 14px; }
.cartItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid #f0f0f0;
}
.cartItemPhoto {
  width: 58px; height: 44px;
  background-repeat: no-repeat;
  border-radius: 6px;
  flex-shrink: 0;
  background-color: #f8f8f8;
}
.cartItemInfo { flex: 1; min-width: 0; }
.cartItemName { font-size: 12px; font-weight: 700; color: #1a1a1a; }
.cartItemPrice { font-size: 11px; color: var(--red); font-weight: 700; margin-top: 2px; }
.qtyRow { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.qtyBtn {
  background: #f2f2f2;
  border: none; color: #333;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.qtyBtn:hover { background: #e8e8e8; }
.qtyNum { color: #1a1a1a; font-weight: 800; font-size: 13px; min-width: 16px; text-align: center; }
#cartFooter {
  padding: 14px 18px;
  border-top: 1px solid #ececec;
  background: #fff;
}
#cartSubtotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  margin-bottom: 12px;
}
#cartTotal { color: var(--red); font-size: 20px; font-weight: 900; }
#placeOrderBtn {
  width: 100%;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 14px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

/* ── pricing admin panel (separate floating card) ────────────────────────── */
#debugPanel {
  width: 620px;
  flex-shrink: 0;
  background: #fafafa;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#debugHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-bottom: 1px solid #e8e8e8;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  letter-spacing: 0;
}
/* ── Revenue bar ─────────────────────────────────────────────────────────── */
#revenueBar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px; background: #f7f7f7;
  border-bottom: 1px solid #e8e8e8;
  font-size: 11px; color: rgba(0,0,0,0.5);
  font-family: "SFMono-Regular", Consolas, monospace;
}
.rev-stat { display: flex; align-items: center; gap: 5px; }
.rev-divider { color: rgba(0,0,0,0.2); }
.rev-pos { color: #10b981; }
.rev-neg { color: var(--red); }

#debugCols { display: flex; flex: 1; overflow: hidden; }
#debugLeft { width: 240px; flex-shrink: 0; padding: 18px 20px; overflow-y: auto; border-right: 1px solid #e8e8e8; background: #fff; }

/* ── Event log ───────────────────────────────────────────────────────────── */
#eventLogWrap { margin-top: 18px; }
#eventLog {
  margin-top: 6px; max-height: 220px; overflow-y: auto;
  border: 1px solid #ebebeb; border-radius: 6px; background: #fafafa;
}
.ev-empty { padding: 10px 10px; font-size: 10px; color: rgba(0,0,0,0.3); font-style: italic; }
.ev-row {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 9px; border-bottom: 1px solid #f0f0f0;
  font-size: 10px; font-family: "SFMono-Regular", Consolas, monospace;
  line-height: 1.4;
}
.ev-row:last-child { border-bottom: none; }
.ev-time { color: rgba(0,0,0,0.28); flex-shrink: 0; font-size: 9px; }
.ev-msg  { color: #1a1a1a; flex: 1; }
.ev-match { color: #10b981; font-weight: 700; }
.ev-new   { color: var(--red); font-weight: 700; }
.ev-order { color: #6366f1; font-weight: 700; }
.ev-up    { color: var(--red); font-weight: 700; }
.ev-dn    { color: #2563eb;   font-weight: 700; }
#debugRight { flex: 1; padding: 18px 20px; overflow-y: auto; background: #fafafa; }
.ctlLabel { font-size: 11px; color: #888; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
#profileSelect {
  width: 100%; margin: 6px 0 20px; padding: 7px 9px;
  background: #fff; color: #1a1a1a;
  border: 1px solid #d0d0d0; border-radius: 6px;
  font-family: inherit; font-size: 13px;
}
.slider { margin-bottom: 14px; }
.slider label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; color: #555; }
.slider label span { color: var(--red); font-weight: 700; }
.slider input[type=range] { width: 100%; accent-color: var(--red); }
#ctlButtons { display: flex; gap: 8px; margin-top: 20px; }
#ctlButtons button {
  flex: 1; padding: 9px;
  border: 1px solid #d8d8d8;
  background: #f5f5f5; color: #333;
  border-radius: 6px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500;
}
#ctlButtons button:hover { background: #ebebeb; border-color: #ccc; }
#breakdownTitle { font-size: 12px; font-weight: 600; color: #555; margin-bottom: 10px; }
#pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--red); opacity: 0; }
#pulse.on { animation: pulse 0.8s infinite; }
@keyframes pulse { 0%,100%{opacity:0.2} 50%{opacity:1} }
#breakdown { margin: 0 0 22px; }

.bd-section { margin-bottom: 14px; }

.bd-sec-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  color: rgba(0,0,0,0.3); margin-bottom: 5px; text-transform: uppercase;
}

.bd-row {
  display: flex; align-items: baseline; gap: 6px;
  padding: 2.5px 0; font-size: 11px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.bd-lbl  { width: 76px; flex-shrink: 0; color: rgba(0,0,0,0.45); font-size: 10px; }
.bd-val  { font-weight: 700; color: #1a1a1a; min-width: 44px; }
.bd-val-plain { font-weight: 500; color: #1a1a1a; }
.bd-small { font-size: 10px !important; }
.bd-note { color: rgba(0,0,0,0.38); font-size: 10px; flex: 1; }

.bd-up   { color: var(--red); font-weight: 700; }
.bd-dn   { color: #2563eb;    font-weight: 700; }
.bd-flat { color: rgba(0,0,0,0.3); }

.bd-divider { border-top: 1px solid rgba(0,0,0,0.09); margin: 7px 0; }

.bd-final-row {
  display: flex; align-items: baseline; gap: 8px; padding: 2px 0;
}
.bd-final-num {
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
  color: #1a1a1a; line-height: 1;
}
.bd-final-up { color: var(--red); }
.bd-final-dn { color: #2563eb; }
.bd-cap { font-size: 9px; font-weight: 600; letter-spacing: 0.06em;
          color: rgba(0,0,0,0.35); vertical-align: middle; margin-left: 2px; }

.bd-badge {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.bd-badge-vip     { background: #f59e0b; color: #fff; }
.bd-badge-loyal   { background: var(--red); color: #fff; }
.bd-badge-regular { background: #6366f1; color: #fff; }
.bd-badge-casual  { background: #64748b; color: #fff; }
.bd-badge-new     { background: #10b981; color: #fff; }
.bd-badge-danger  { background: #ef4444; color: #fff; }
.bd-badge-warn    { background: #f59e0b; color: #1a1a1a; }
.bd-badge-med     { background: #94a3b8; color: #fff; }
.bd-badge-ok      { background: #10b981; color: #fff; }
.bd-badge-flat    { background: rgba(0,0,0,0.1); color: rgba(0,0,0,0.5); }

.bd-bar {
  display: inline-block; width: 52px; height: 4px;
  background: rgba(0,0,0,0.1); border-radius: 2px;
  vertical-align: middle; margin-right: 5px;
}
.bd-bar-fill { display: block; height: 100%; background: var(--red); border-radius: 2px; }
.bd-bar-num  { font-size: 10px; color: rgba(0,0,0,0.4); vertical-align: middle; }

.bd-reasoning {
  margin-top: 9px; font-size: 10.5px; line-height: 1.6;
  color: rgba(0,0,0,0.65); font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  padding: 9px 11px; background: rgba(218,41,28,0.05);
  border-radius: 5px; border-left: 3px solid var(--red);
}
#sparkLabel { font-size: 11px; color: #888; font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
#spark { width: 100%; height: 150px; background: #f0f0f0; border: 1px solid #e0e0e0; border-radius: 6px; }
