/* App shell: only the catalogue, ticket and open dialogs may scroll.
   Do not rely on body > .app: embedded viewers may add a wrapper. */
html, body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }
#vendes-app {
  position: fixed;
  inset: var(--vendes-top, 0px) 0 auto;
  width: 100%;
  max-width: none;
  height: 100%;
  height: var(--vendes-height, 100dvh);
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 340px;
  grid-template-rows: 82px minmax(0, 1fr);
  overflow: hidden;
  isolation: isolate;
}
#vendes-app *, #modal, #modal * { box-sizing: border-box; }
#vendes-app > *, #vendes-app .products-shell, #grid {
  min-width: 0;
  min-height: 0;
}
#vendes-app .workspace, #vendes-app .products-shell { overflow: hidden; }
#grid {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y pinch-zoom;
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  scroll-padding-block: 8px 16px;
}
/* Intrinsic image dimensions must not size the card or squeeze out controls. */
#grid .product { display: flex; flex-direction: column; height: auto; min-height: max-content; }
#grid .visual { flex: none; min-width: 0; min-height: 0; }
#grid .visual img { min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; }
#grid .product-info { flex: none; height: auto; min-height: max-content; }
#grid .counter { display: grid; height: 44px; min-height: 44px; }
#grid .counter button { min-width: 44px; min-height: 44px; }
#vendes-app .checkout { min-height: 0; }
#ticketLines, #drawer, #modal .dialog {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#modal {
  top: var(--vendes-top, 0px);
  bottom: auto;
  height: 100%;
  height: var(--vendes-height, 100dvh);
  overflow: hidden;
}
#modal .dialog { min-height: 0; max-height: 100%; overflow: auto; }
#drawer { max-height: calc(var(--vendes-height, 100dvh) - 96px); overflow-y: auto; }
@media (min-width: 1400px) {
  #vendes-app { grid-template-columns: 100px minmax(0, 1fr) 380px !important; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  #vendes-app { grid-template-columns: 76px minmax(0, 1fr) 280px; }
}
@media (max-width: 760px) {
  #vendes-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  #vendes-app .topbar { grid-area: 1 / 1; }
  #vendes-app .workspace { grid-area: 2 / 1; }
  #vendes-app .checkout { grid-area: 3 / 1; }
  #vendes-app[data-compact="true"] .summary-head { display: none; }
  #vendes-app[data-compact="true"] .workspace { grid-template-rows: auto minmax(0, 1fr); padding-top: 9px; gap: 8px; }
  #vendes-app[data-compact="true"] .metric { padding: 8px; }
  #vendes-app[data-compact="true"] .metric small { display: none; }
  #vendes-app[data-compact="true"] .metric b { margin-bottom: 0; }
  #vendes-app[data-compact="true"] .product .visual { height: 75px; }
  #vendes-app[data-compact="true"] .product-info { padding: 10px; }
  #modal {
    padding-top: max(12px, calc(env(safe-area-inset-top) + 12px));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(10px, calc(env(safe-area-inset-bottom) - 18px));
    padding-left: max(12px, env(safe-area-inset-left));
  }
  #modal .dialog { max-height: 100%; }
}
