/* RusaPOS Customer — persistent dine-in workspace.
   Mobile: fixed thumb dock + contextual bottom sheet.
   Desktop: anchored contextual inspector; menu stays visible.
   No client-side payment authority or duplicated menu data. */
.app-shell {
  max-width: 1040px;
  background: #fff;
}
.app-shell .masthead {
  position: sticky;
  top: 0;
  z-index: 51;
  min-height: 64px;
  padding: 9px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid #e0e8f2;
  box-shadow: 0 3px 14px rgba(17,27,43,.035);
}
.app-shell .masthead .brand-logo {
  width: 38px;
  height: 38px;
}
.app-shell .welcome { display: none; }
.app-shell .tabs { top: 64px; z-index: 45; }
.app-shell .body { padding-top: 16px; }
.app-shell .table-hub-hero { min-height: 168px !important; }
.app-shell .table-hub-art { max-height: 168px; }
.app-shell .table-hub { margin-bottom: 20px; }
.app-shell #menu-catalog { scroll-margin-top: 172px; }
.app-shell .category-dock {
  position: sticky;
  top: 139px;
  z-index: 39;
  margin: 8px -4px 16px;
  padding: 8px 4px 5px;
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid #e7edf5;
  box-shadow: 0 6px 12px -14px rgba(17,27,43,.5);
}
.app-shell .category-dock .categories {
  margin: 0;
  padding: 3px 2px 5px;
  scroll-padding-inline: 12px;
}
.app-shell .category-dock .chip { min-height: 39px; }
.app-shell.has-workspace .floating-cart { display: none; }

.customer-workspace {
  position: fixed;
  inset: 0;
  z-index: 58;
  pointer-events: none;
}
.customer-workspace .workspace-scrim {
  position: absolute;
  inset: 0;
  top: 145px; /* Keep the desktop tab rail visible and clickable. */
  width: 100%;
  border: 0;
  padding: 0;
  background: rgba(9,25,43,.33);
  cursor: default;
  pointer-events: auto;
}
.customer-workspace .workspace-panel {
  position: absolute;
  top: 148px;
  bottom: 18px;
  right: max(18px, calc((100vw - 1040px) / 2 + 18px));
  width: min(480px, calc(100vw - 28px));
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2eaf3;
  border-radius: 22px;
  box-shadow: 0 26px 72px rgba(10,28,46,.24);
  overflow: hidden;
  pointer-events: auto;
}
.customer-workspace .workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex: none;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #e6edf5;
}
.customer-workspace .workspace-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .115em;
  color: #667f97;
}
.customer-workspace .workspace-head h2 {
  margin: 4px 0 0;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: -.035em;
  font-weight: 850;
  color: #111b2b;
}
.customer-workspace .workspace-close {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid #dbe5ef;
  background: #f4f7fa;
  color: #233e59;
  font-size: 26px;
  cursor: pointer;
}
.customer-workspace .workspace-close:hover {
  background: #e9f2fb;
  border-color: #b6d2ef;
}
.customer-workspace .workspace-close:focus-visible {
  outline: 3px solid #0066cd;
  outline-offset: 2px;
}
.customer-workspace .workspace-content {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px calc(26px + env(safe-area-inset-bottom,0px));
  scrollbar-gutter: stable;
}
.customer-workspace .workspace-content > .page-title:first-child { display: none; }
.customer-workspace .workspace-content > .page-title.orders-heading:first-child {
  display: flex;
  margin: 0 0 16px;
}
.customer-workspace .workspace-content .checkout-ui {
  max-width: 100%;
  padding: 0 0 24px;
}
.customer-workspace .workspace-content .checkout {
  margin-bottom: 18px;
}
/* Checkout lives in a 480px inspector even on a 1440px desktop.
   Scope these rules to the workspace instead of viewport media queries:
   the full-page receipt layout must never squeeze payment choices to 80px. */
.customer-workspace .workspace-content .checkout-content-grid,
.customer-workspace .workspace-content .checkout-content-with-receipt {
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}
.customer-workspace .workspace-content .checkout-payment-column,
.customer-workspace .workspace-content .checkout-methods,
.customer-workspace .workspace-content .checkout-method-copy,
.customer-workspace .workspace-content .checkout-receipt {
  min-width: 0;
}
.customer-workspace .workspace-content .checkout-method {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas: "icon copy" ". state";
  align-items: center;
  gap: 5px 12px;
  padding: 13px 15px;
}
.customer-workspace .workspace-content .checkout-method-icon {
  grid-area: icon;
  width: 42px;
  height: 42px;
}
.customer-workspace .workspace-content .checkout-method-copy {
  grid-area: copy;
  overflow-wrap: break-word;
}
.customer-workspace .workspace-content .checkout-method-state {
  grid-area: state;
  justify-self: start;
  max-width: 100%;
  white-space: normal;
}
.customer-workspace .workspace-content .checkout-balance-top,
.customer-workspace .workspace-content .checkout-receipt-header,
.customer-workspace .workspace-content .checkout-receipt-total,
.customer-workspace .workspace-content .checkout-receipt-row {
  flex-wrap: wrap;
}
.customer-workspace .workspace-content .checkout-receipt-price {
  min-width: 0;
  margin-left: auto;
}
.customer-workspace .workspace-content .checkout-receipt-total strong {
  font-size: clamp(18px, 4vw, 22px);
}
.customer-workspace .workspace-content .checkout-method-preview > div {
  min-width: 0;
  overflow-wrap: break-word;
}
.customer-workspace .workspace-content .checkout-actions,
.customer-workspace .workspace-content .checkout-cashier-options {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell .modal-backdrop { z-index: 95; }

/* Tablets & Wide screens */
@media (min-width: 720px) and (max-width: 999px) {
  .app-shell .products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .customer-workspace .workspace-panel {
    top: auto;
    bottom: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(580px, calc(100vw - 32px));
    max-height: min(82dvh, 780px);
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    box-shadow: 0 -18px 48px rgba(10,28,46,.22);
  }
}

@media (min-width: 1000px) {
  .app-shell.has-workspace .body { padding-right: 515px; }
  .app-shell.has-workspace .category-dock { z-index: 39; }
}

/* Mobile: Phones & small devices */
@media (max-width: 719px) {
  .app-shell .masthead {
    min-height: 59px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: 8px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    gap: 8px;
  }
  .app-shell .masthead .brand-logo { width: 33px; height: 33px; }
  .app-shell .tabs {
    top: auto;
    z-index: 76;
    border-radius: 19px 19px 0 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .app-shell .body {
    padding: 10px 14px calc(145px + env(safe-area-inset-bottom,0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }
  .app-shell .table-hub { margin-bottom: 14px; }
  .app-shell .table-hub-hero { min-height: 146px !important; }
  .app-shell .table-hub-art { max-height: 146px; }
  .app-shell #menu-catalog { scroll-margin-top: 74px; }
  .app-shell .category-dock {
    top: 59px;
    margin: 8px -14px 14px;
    padding: 7px 14px 4px;
    border-bottom-color: #e0e8f3;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .app-shell .category-dock .categories {
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .app-shell .category-dock .chip {
    min-height: 41px;
    padding: 8px 15px;
    font-size: 12px;
    flex: none;
    scroll-snap-align: start;
  }
  .app-shell .products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(9px, 2.8vw, 14px);
  }
  .app-shell .product {
    border-radius: clamp(14px, 3.8vw, 18px);
  }
  .app-shell .product-copy {
    padding: clamp(10px, 2.9vw, 14px);
  }
  .app-shell .product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-top: auto;
  }
  .app-shell .product-footer strong {
    font-size: clamp(12px, 3.2vw, 15px);
  }
  .customer-workspace {
    bottom: calc(72px + env(safe-area-inset-bottom,0px));
    z-index: 58;
  }
  .customer-workspace .workspace-scrim { top: 0; }
  .customer-workspace .workspace-panel {
    position: absolute;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(82dvh, 780px);
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    box-shadow: 0 -16px 42px rgba(10,28,46,.2);
  }
  .customer-workspace .workspace-panel::before {
    content: '';
    align-self: center;
    width: 38px;
    height: 4px;
    border-radius: 6px;
    background: #d9e4ef;
    margin-top: 9px;
  }
  .customer-workspace .workspace-head { padding: 12px 16px; }
  .customer-workspace .workspace-content {
    overflow-y: auto;
    padding: 12px 16px 28px;
    scrollbar-gutter: auto;
  }
  .customer-workspace .workspace-content .checkout-ui { padding: 0 0 30px; }
  .app-shell .modal-backdrop {
    z-index: 110;
    padding: clamp(8px, 3vw, 16px);
  }
  .app-shell .modal {
    max-height: min(90dvh, 660px);
    width: min(520px, 100%);
  }
}

/* Medium to small phones (iPhone 12/13/14 mini, small Androids <= 400px) */
@media (max-width: 400px) {
  .app-shell .masthead { padding-inline: 10px; }
  .app-shell .cart-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .app-shell .cart-row .stepper {
    margin-left: auto;
  }
  .app-shell .checkout-receipt-header strong {
    font-size: 15px;
  }
}

/* Compact phones (iPhone SE, Galaxy Fold cover, <= 360px) */
@media (max-width: 360px) {
  .app-shell .masthead {
    min-height: 55px;
    padding-inline: 8px;
    gap: 6px;
  }
  .app-shell .masthead .brand strong {
    font-size: 12px;
    max-width: clamp(70px, 25vw, 110px);
  }
  .app-shell .masthead .brand-logo {
    width: 30px;
    height: 30px;
  }
  .app-shell .tabs {
    padding-inline: 4px;
    gap: 2px;
  }
  .app-shell .tab {
    font-size: 10px;
    padding: 4px 1px;
    min-height: 49px;
  }
  .app-shell .tab-icon svg {
    width: 19px;
    height: 19px;
  }
  .app-shell .body {
    padding-inline: 10px;
  }
  .app-shell .products {
    gap: 9px;
  }
  .app-shell .product-copy {
    padding: 10px 9px 8px;
    min-height: 104px;
  }
  .app-shell .product h3 {
    font-size: 12.5px;
    line-height: 1.32;
    margin: 4px 0 6px;
  }
  .app-shell .product-footer strong {
    font-size: 12px;
  }
  .app-shell .round-add {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 22px;
    border-radius: 12px;
  }
  .customer-workspace .workspace-head { padding: 10px 12px; }
  .customer-workspace .workspace-head h2 { font-size: 19px; }
  .customer-workspace .workspace-content { padding-inline: 12px; }
  .order-card--tracking { padding: 16px 12px; }
  .order-card--tracking .order-head h3 { font-size: 22px; }
  .order-card--tracking .status { font-size: 10.5px; padding: 7px 10px; }
  .order-timeline { margin-top: 24px; }
  .milestone-dot { width: 28px; height: 28px; font-size: 12px; }
  .order-timeline::before { top: 14px; }
  .milestone-label { font-size: 9.5px; }
  .landing-steps { gap: 10px; }
  .landing-step { padding: 14px 12px; }
  .landing-step--qr > summary { column-gap: 10px; }
  .landing-step-number { width: 38px; height: 38px; font-size: 14px; }
  .landing-step strong { font-size: 15px; }
  .landing-step p { font-size: 12px; }
  .landing-step-cta { font-size: 12px; }
  .landing-step-extra { padding-left: 48px; }
}

/* Ultra-compact phones (320px, e.g. iPhone SE 1st gen) */
@media (max-width: 330px) {
  .app-shell .masthead { padding-inline: 6px; }
  .app-shell .masthead .brand strong { max-width: 82px; font-size: 11px; }
  .app-shell .tab { font-size: 9px; letter-spacing: -0.01em; }
  .app-shell .tab-icon svg { width: 17px; height: 17px; }
  .app-shell .products { gap: 7px; }
  .app-shell .product-copy { padding: 8px 7px 7px; min-height: 98px; }
  .app-shell .product h3 { font-size: 12px; }
  .app-shell .product-footer strong { font-size: 11px; }
  .customer-workspace .workspace-head h2 { font-size: 17px; }
  .customer-workspace .workspace-content { padding-inline: 9px; }
  .landing-step { padding: 12px 10px; }
  .landing-step--qr > summary { column-gap: 8px; }
  .landing-step-number { width: 34px; height: 34px; font-size: 13px; }
  .landing-step strong { font-size: 14px; }
  .landing-step p { font-size: 11.5px; }
  .landing-step-cta { font-size: 11.5px; }
  .landing-step-extra { padding-left: 42px; }
}

/* Landscape on mobile devices (short viewport height) */
@media (max-height: 520px) and (orientation: landscape) {
  .app-shell .masthead {
    min-height: 48px;
    padding-block: 5px;
  }
  .app-shell .category-dock {
    top: 48px;
    margin-bottom: 8px;
    padding-block: 4px;
  }
  .app-shell .category-dock .chip {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 11.5px;
  }
  .customer-workspace .workspace-panel {
    max-height: 92dvh;
  }
  .customer-workspace .workspace-head {
    padding: 8px 14px;
  }
  .customer-workspace .workspace-content {
    padding: 8px 14px 20px;
  }
  .app-shell .modal {
    max-height: 92dvh;
  }
  .app-shell .tabs {
    min-height: 46px;
    padding-block: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .customer-workspace * { scroll-behavior: auto !important; }
}
