/* ReStar POS на телефоне (до 760 px): закреплённый верх, нижняя панель «Столы · Меню · Чек», чек окном снизу, экран столов.
   Разметку панели, окна и экрана столов добавляет pos.js (раздел «телефон»). На планшете и компьютере эти элементы скрыты. */
.m-bar, .m-back, .m-tables, .m-grip, .m-x { display: none; }

@media (max-width: 760px) {
  /* --- закреплённый верх: шапка, категории, поиск --- */
  body { height: auto; min-height: 100%; }
  .top { position: sticky; top: 0; z-index: 30; }
  .pos { display: block; }
  .menu { overflow: visible; }
  .cats { position: sticky; top: var(--top); z-index: 26; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: none; scroll-padding: 0 8px; }
  .cats::-webkit-scrollbar { display: none; }
  .search { position: sticky; top: calc(var(--top) + var(--m-cats, 58px)); z-index: 25; margin: 0; padding: 8px 10px; background: var(--bg); }
  .search > i { left: 24px; }
  .search .search-btn.kb { right: 16px; }
  .search .search-btn.scan { right: 58px; }
  .search .search-btn.clear { right: 100px; }
  .grid { padding: 6px 10px calc(100px + env(safe-area-inset-bottom)); gap: 10px; }
  body.has-tabs .tabs-bar { display: none; }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }

  /* --- нижняя панель --- */
  .m-bar { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 44; display: flex; align-items: center; gap: 4px; padding: 6px;
    border-radius: 22px; background: rgba(31, 31, 34, .94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .55); }
  body.is-login .m-bar, body.booting .m-bar { display: none; }
  .m-tab { position: relative; flex: none; width: 62px; height: 54px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #9ea4ab; font-size: 11px; font-weight: 500; transition: color .15s, background .15s; }
  .m-tab i { font-size: 22px; line-height: 1; }
  .m-tab.on { color: #fff; background: rgba(255, 255, 255, .08); }
  .m-tab.on i { color: var(--accent-2); }
  .m-badge { position: absolute; top: 4px; right: 9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-style: normal;
    font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #1f1f22; }
  .m-check { flex: 1; min-width: 0; height: 54px; border-radius: 16px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 8px; color: #fff; text-align: left;
    background: linear-gradient(160deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 18px -10px rgba(247, 103, 7, .8); transition: background .2s, transform .1s; }
  .m-check:active { transform: scale(.98); }
  .m-cnt { flex: none; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 11px; background: rgba(255, 255, 255, .22); display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .m-ct { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
  .m-ct b { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-ct small { font-size: 11.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-sum { flex: none; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .m-check > i { flex: none; font-size: 20px; opacity: .9; }
  .m-check.empty { background: rgba(255, 255, 255, .08); box-shadow: none; color: #ced4da; }
  .m-check.empty .m-cnt { background: rgba(255, 255, 255, .1); }
  .m-check.bump { animation: m-bump .35s ease-out; }
  @keyframes m-bump { 0% { transform: scale(1); } 35% { transform: scale(1.04); } 100% { transform: scale(1); } }

  /* --- чек окном снизу (тот же блок .check, что справа на компьютере) --- */
  .check { position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; max-height: 90vh; max-height: 90dvh; border: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px -10px rgba(0, 0, 0, .35); transform: translateY(105%); visibility: hidden; transition: transform .25s ease-out, visibility 0s .25s; padding-bottom: env(safe-area-inset-bottom); }
  body.m-sheet .check { transform: none; visibility: visible; transition: transform .25s ease-out; }
  .m-grip { display: flex; justify-content: center; padding: 8px 0 2px; flex: none; touch-action: none; }
  .m-grip span { width: 40px; height: 4px; border-radius: 2px; background: #dee2e6; }
  .check-head { padding: 6px 10px 10px 16px; touch-action: none; }
  .m-x { display: inline-flex; }
  .lines { max-height: none; flex: 1 1 auto; min-height: 80px; overscroll-behavior: contain; }
  .m-back { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(20, 20, 24, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.m-sheet .m-back { opacity: 1; pointer-events: auto; }
  body.m-sheet, body.m-tables-on { overflow: hidden; }

  /* --- экран столов --- */
  .m-tables { position: fixed; top: var(--top); left: 0; right: 0; bottom: 0; z-index: 43; overflow-y: auto; overscroll-behavior: contain; background: var(--bg);
    padding: 16px 12px calc(100px + env(safe-area-inset-bottom)); }
  body.m-tables-on .m-tables { display: block; }
  .mt-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
  .mt-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
  .mt-h { display: flex; align-items: center; gap: 8px; margin: 18px 2px 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
  .mt-h em { font-style: normal; font-size: 12px; padding: 1px 8px; border-radius: 8px; background: var(--accent-soft); color: #c2410c; }
  .mt-open { display: flex; flex-direction: column; gap: 8px; }
  .mt-o { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); text-align: left; transition: transform .1s; }
  .mt-o:active, .mt-t:active { transform: scale(.98); }
  .mt-o.on { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2), 0 8px 18px -12px rgba(247, 103, 7, .6); }
  .mt-oi { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
  .mt-ot { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .mt-ot b { font-size: 15px; font-weight: 500; color: var(--text); }
  .mt-ot b i { font-size: 14px; color: var(--accent); }
  .mt-ot small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mt-os { flex: none; font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
  .mt-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mt-t { min-height: 64px; padding: 9px 8px; border-radius: 14px; background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 4px; text-align: left; transition: transform .1s; }
  .mt-t b { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; }
  .mt-t small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mt-t.busy { background: var(--amber-soft); border-color: #ffd8a8; }
  .mt-t.busy b { color: #c2410c; }
  .mt-t.busy small { color: #b5651d; }
  .mt-t.mine { box-shadow: 0 0 0 2px var(--accent-2); border-color: transparent; }
  .mt-guest { display: flex; gap: 8px; }
  .mt-guest input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; outline: none; }
  .mt-guest input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(247, 103, 7, .12); }
  .mt-guest .btn { flex: none; height: 48px; }
  .mt-free { margin-top: 12px; width: 100%; height: 48px; border-radius: 12px; border: 1px dashed #ced4da; background: none; color: #495057; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
  .mt-free i { font-size: 18px; color: var(--muted); }
}
@media (max-width: 380px) {
  .mt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m-tab { width: 54px; }
  .m-sum { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) { .check, .m-back { transition: none !important; } .m-check.bump { animation: none; } }

/* --- клавиатура телефона вместо своей и все категории плитками (12.11) --- */
.cat-all, .m-cats, .m-cats-back { display: none; }
@media (max-width: 760px) {
  .search .search-btn.kb { display: none; }
  .search .search-btn.scan { right: 16px; }
  .search .search-btn.clear { right: 58px; }
  /* кнопка в конце ленты категорий — всегда видна у правого края */
  .cats .cat-all { display: inline-flex; position: sticky; right: 0; flex: none; margin-left: auto; width: 46px; min-height: 42px; border-radius: 12px; align-items: center; justify-content: center;
    background: #fff; color: #495057; font-size: 21px; box-shadow: -16px 0 12px -2px #fff, inset 0 0 0 1px var(--line); z-index: 1; }
  .cats .cat-all.on { background: var(--accent-soft); color: var(--accent); box-shadow: -16px 0 12px -2px #fff, inset 0 0 0 1.5px var(--accent-2); }
  .m-cats { position: fixed; left: 0; right: 0; top: calc(var(--top) + var(--m-cats, 58px)); z-index: 29; overflow-y: auto; overscroll-behavior: contain;
    max-height: calc(100vh - var(--top) - var(--m-cats, 58px) - 96px); max-height: calc(100dvh - var(--top) - var(--m-cats, 58px) - 96px);
    background: #fff; border-radius: 0 0 22px 22px; padding: 10px 10px 14px; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .35); }
  body.m-cats-on .m-cats { display: block; animation: mc-in .18s ease-out; }
  .m-cats-back { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--top) + var(--m-cats, 58px)); z-index: 28; background: rgba(20, 20, 24, .35); }
  body.m-cats-on .m-cats-back { display: block; }
  body.m-cats-on { overflow: hidden; }
  .mc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mc-t { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; min-height: 98px; padding: 10px 4px 8px; border-radius: 16px; background: var(--bg); text-align: center; transition: transform .1s; }
  .mc-t:active { transform: scale(.96); }
  .mc-i { flex: none; width: 42px; height: 42px; border-radius: 13px; background: #fff; color: #495057; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
  .mc-t b { font-size: 12px; font-weight: 500; line-height: 1.2; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
  .mc-t small { margin-top: auto; font-size: 11px; color: var(--muted); }
  .mc-t.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent-2); }
  .mc-t.on .mc-i { color: var(--accent); }
  .mc-t.on b { color: #c2410c; }
  .mc-h { margin: 14px 4px 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
  @keyframes mc-in { from { transform: translateY(-10px); } to { transform: none; } }
}
@media (max-width: 340px) { .mc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { body.m-cats-on .m-cats { animation: none; } }

/* --- меню одним списком: заголовки категорий-якоря (12.11) --- */
@media (max-width: 760px) {
  .grid-sec { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 14px 2px -2px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
  .grid-sec:first-child { margin-top: 4px; }
  .grid-sec i { font-size: 19px; color: var(--accent); }
  .grid-sec em { font-style: normal; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 8px; background: #e9ecef; color: var(--muted); }
}

/* --- окно блюда (размер, вес, добавки) не шире экрана (12.11) --- */
@media (max-width: 760px) {
  .cfg { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 100vw; }
  .cfg-main, .cfg-body, .cfg-foot, .cfg-sec { min-width: 0; }
  .adds { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  /* выбранная добавка: счётчик переносится под название, если рядом не помещается */
  .add { flex-wrap: wrap; row-gap: 6px; min-width: 0; padding: 8px 8px 8px 12px; }
  .add .an { flex: 1 1 88px; overflow-wrap: anywhere; }
  .add .actr { margin-left: auto; }
  .actr button { width: 34px; height: 36px; }
  .seg { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .cfg-foot { gap: 8px; }
  .qty.big button { width: 44px; height: 52px; }
  .cfg-go { flex: 1; min-width: 0; height: 56px; padding: 0 16px; font-size: 16px; gap: 8px; }
  .cfg-go > * { min-width: 0; white-space: nowrap; }
  .wt-disp { min-width: 0; }
}

/* --- окно «Покупатель» и другие окна не шире экрана (12.11) --- */
@media (max-width: 760px) {
  .modal { max-width: calc(100vw - 16px); }
  .modal-body { overflow-x: hidden; padding: 14px 14px; }
  .cl-modal { grid-template-columns: minmax(0, 1fr); gap: 12px; min-height: 0; }
  .cl-left, .cl-right { min-width: 0; }
  .cl-phone { height: 52px; font-size: 20px; letter-spacing: 0; }
  .cl-pad .key { height: 54px; font-size: 22px; }
  .cl-tools .btn { flex: 1; min-width: 0; padding: 0 10px; }
  .cl-row { min-width: 0; gap: 10px; padding: 9px 10px; }
  .cl-row .cl-info { flex: 1; min-width: 0; }
  .cl-row .cl-info small, .cl-row .cl-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cl-row .cl-bal { flex: none; }
}
@media (max-width: 760px) {
  /* окно «Покупатель»: камера или поиск по имени — цифры прячутся, окно короче */
  .cl-modal.cam-on .cl-left, .cl-modal.name-on .cl-left { display: none; }
  .cl-modal .cam-box video, .cl-modal .cam-box canvas { max-height: 46vh; object-fit: cover; }
  .cl-modal .cam-box { max-height: 46vh; overflow: hidden; border-radius: 14px; }
  .cl-tools .btn.on { background: #212529; color: #fff; }
}
@media (max-width: 760px) {
  /* окно «Покупатель»: переключатель «Номер · QR камерой · По имени» всегда сверху */
  .cl-right { display: contents; }
  .cl-modal .cl-tools { order: -1; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .cl-modal .cl-tools .btn { height: 44px; font-size: 13.5px; gap: 5px; padding: 0 6px; }
  .cl-modal .cl-left { order: 0; }
  .cl-modal .cl-name-inp, .cl-modal .cam-box, .cl-modal .cl-list { order: 1; }
}
