/* The till and the points-of-sale page on phones and small tablets (≤ 860px — M 2026-11-21: no cart under the products,
   two looks only: this one and the wide one). Wider screens keep styles.css as is:
   outside the phone query the cart bar and the cart sheet header are simply hidden. */
.cart-bar, .cart-head { display: none; }

@keyframes cb-bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }

@media (max-width: 860px) {
  /* ── Till top bar: one row, icon buttons, the name shortens ── */
  .pos-bar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); min-height: 50px; }
  .pos-bar > * { flex-shrink: 0; }
  .pos-bar .pos-title { flex: 1 1 auto; flex-shrink: 1; min-width: 0; }
  .pos-bar .pos-title strong { max-width: none; font-size: 15px; }
  .pos-bar .back-btn, .pos-bar .btn.danger { width: 40px; height: 40px; min-height: 40px; padding: 0; }
  .till-rail { display: none; }
  .pos-bar .bar-rail { display: flex; gap: 2px; }
  .till .pos-bar .pos-title > .ic, .till .pos-bar .pos-title > .pt-logo { display: none; } /* (room for the name beside them) */
  .pos-bar .switch-chip { padding: 4px 8px; font-size: 12px; max-width: 34vw; }
  .pos-bar .switch-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── Products: search and categories stay at the top, the grid scrolls under them ── */
  .pos { display: flex !important; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
  .catalog { flex: 1; min-height: 0; gap: 8px; padding: 8px 8px calc(72px + env(safe-area-inset-bottom)); } /* (the window ends over the cart bar: its last row is never under it) */
  .catalog .search-wrap, .catalog .cats { flex-shrink: 0; }
  .cats { scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px; /* (= .catalog's here) */
    padding: 0;
    margin: 0;
    overscroll-behavior: contain;
  }
  .tile { padding: 7px 8px; border-radius: 10px; gap: 2px; min-width: 0; }
  .grid:not(.style-list) > .tile:not(.has-img) { height: 72px; }
  .tile:hover { transform: none; }
  .tile-name { font-size: 13px; line-height: 1.3; }
  .grid:not(.style-list) .tile-name.long { font-size: 12px; -webkit-line-clamp: 2; }
  .grid:not(.style-list) .tile-name.longer { font-size: 11px; -webkit-line-clamp: 2; }
  .grid:not(.style-list) > .tile.has-img { grid-template-rows: auto 42px auto; }
  .tile-price { font-size: 13px; }
  .tile-variants { font-size: 11px; }
  .tile-stock { font-size: 10px; padding: 0 4px; }
  .tile.has-img .tile-name, .tile.has-img .tile-foot { padding: 0 7px; }
  .tile.has-img .tile-foot { padding-bottom: 5px; }
  .grid > .tile { --thumb: 44px; }
  .grid.thumbs:not(.style-list) > .tile:not(.has-img) { height: 92px; }
  .grid.covers:not(.style-list) > .tile:not(.has-img) { height: 104px; }

  /* ── The cart folds into a bar at the bottom ── */
  .pos > .cart { display: none; }
  .cart-bar {
    display: flex; align-items: center; gap: 8px;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
    padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px #0b1b3314;
  }
  .cart-bar .cb-open {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--tint);
    color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: start;
  }
  .cart-bar .cb-open .ic, .cart-bar .cb-open svg { color: var(--primary); flex-shrink: 0; }
  .cart-bar .cb-count {
    min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
    background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; direction: ltr; flex-shrink: 0;
  }
  .cart-bar .cb-label { font-size: 14px; }
  .cart-bar .cb-total { margin-inline-start: auto; font-size: 16px; white-space: nowrap; direction: ltr; }
  .cart-bar .cb-pay { height: 48px; min-height: 48px; padding: 0 18px; font-size: 16px; flex-shrink: 0; }
  .cart-bar.empty .cb-open { background: var(--card); color: var(--muted); }
  .cart-bar.empty .cb-count { background: var(--line-strong, #c5ccd6); }
  .cart-bar.bump .cb-count { animation: cb-bump .32s var(--ease, ease-out); }

  /* ── Tapping the bar opens the cart full screen ── */
  .pos.cart-open > .cart-bar { display: none; }
  .pos.cart-open > .cart {
    display: flex; flex-direction: column;
    position: fixed; inset: 0; z-index: 40; max-height: none; height: 100%;
    background: var(--card); border: 0;
    padding-top: env(safe-area-inset-top);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    animation: cart-up .2s var(--ease, ease-out);
  }
  .pos.cart-open > .cart .cart-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); min-height: 52px; flex-shrink: 0;
  }
  .pos.cart-open > .cart .cart-head strong { font-size: 17px; }
  .pos.cart-open > .cart .cart-close { width: 42px; height: 42px; }
  .pos.cart-open > .cart .cust-bar { flex-shrink: 0; }
  .pos.cart-open > .cart .lines { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .pos.cart-open > .cart .sums, .pos.cart-open > .cart .pay { flex-shrink: 0; }
  .pos.cart-open > .cart .pay { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

  /* ── Points-of-sale page: two compact tiles per row ── */
  .picker-page { padding: 12px 10px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .reg-branches { gap: 6px; margin-bottom: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .reg-branches::-webkit-scrollbar { display: none; }
  .reg-branches > * { flex-shrink: 0; }
  .reg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .reg-card { min-height: 0; padding: 14px 8px 10px; gap: 4px; border-radius: 14px; min-width: 0; align-content: start; }
  .reg-card:hover { transform: none; }
  .reg-card .reg-ic { width: 38px; height: 38px; border-radius: 11px; }
  .reg-card .reg-ic svg { width: 20px; height: 20px; }
  .reg-card strong { font-size: 14px; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reg-card small { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reg-card .pill { font-size: 11px; padding: 1px 8px; }
  .reg-card > .btn, .reg-card .reg-actions .btn { width: 100%; min-height: 38px; height: 38px; padding: 0 8px; font-size: 13px; margin-top: 4px; }
  .reg-card .reg-actions { gap: 4px; margin-top: 2px; }
  .reg-card > .btn.reg-gear { position: absolute; top: 6px; inset-inline-end: 6px; width: 30px; height: 30px; min-height: 30px; padding: 0; margin: 0; }
  .reg-card.reg-add { justify-content: center; align-content: center; }
  .reg-card.reg-add small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

@keyframes cart-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Retail on a phone: no tiles and no cart bar — the search on top, the cart's lines under it, the totals and Pay below. */
@media (max-width: 860px) {
  .style-pick { grid-template-columns: repeat(2, 1fr); }
  .pos.retail > .catalog { flex: 0 0 auto; padding-bottom: 8px; }
  .pos.retail > .cart-bar { display: none; }
  .pos.retail > .cart { display: flex; flex: 1; min-height: 0; margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
  .pos.retail > .cart .lines { flex: 1; min-height: 0; overscroll-behavior: contain; }
  .pos.retail .lines-head { display: none; }
  .pos.retail .line { grid-template-columns: 24px minmax(0, 1fr) auto auto; grid-template-areas: 'no name total del' 'no unit qty del'; gap: 4px 10px; }
  .pos.retail .line-no { grid-area: no; }
  .pos.retail .line-code { display: none; }
  .pos.retail .line-name { grid-area: name; }
  .pos.retail .line-unit { grid-area: unit; }
  .pos.retail .line > .qty { grid-area: qty; justify-self: end; }
  .pos.retail .line-total { grid-area: total; justify-self: end; }
  .pos.retail .line > .icon-btn { grid-area: del; }
  /* (one under the other, as on the other looks) */
  .pos.retail .cart-foot { display: contents; }
  .pos.retail .cart-foot > .sums { padding: 10px 14px; border-top: 1px solid var(--line); }
  .pos.retail .cart-foot > .pay { padding: 0 14px max(12px, env(safe-area-inset-bottom)); }
}

/* A small tablet (641–860px) in the phone look: more tiles to a row than a phone's three */
@media (min-width: 641px) and (max-width: 860px) {
  .grid:not(.style-list) { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

