/* Панель заведения.
   Нейтральная основа + цвет заведения только в акцентах (кнопки, выбор,
   переключатели): панель остаётся читаемой при любой палитре. */

:root {
  --brand: #ca130e;
  --on-brand: #fff;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);

  --bg: #f5f5f4;
  --surface: #fff;
  --surface-2: #fafaf9;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(28 25 23 / .06);
  --shadow: 0 1px 3px rgb(28 25 23 / .08), 0 8px 24px rgb(28 25 23 / .06);
  --shadow-lg: 0 24px 64px rgb(28 25 23 / .22);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ── Каркас ─────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand img, .brand .ph { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); }
.brand b { font-size: 15px; line-height: 1.2; }
.brand small { display: block; color: var(--text-3); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--warn);
  background: var(--warn-soft); border-radius: 99px; padding: 0 7px; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px;
  border-top: 1px solid var(--line); }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small { color: var(--text-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 12px; color: var(--text-2); }
.main { min-width: 0; padding: 28px 36px 60px; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.head .sub { color: var(--text-2); margin-top: 2px; }
.head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Элементы ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, box-shadow .12s;
}
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(.95); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; height: 32px; padding: 0; background: transparent; color: var(--text-3); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; margin: 0 0 14px; }

.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search input { padding-left: 34px; }
.input, .field input[type=text], .field input[type=tel], .field input[type=number], .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 76px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field { margin-bottom: 16px; }
.field > label:not(.switch):not(.drop), .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.field .err, .errorlist { color: var(--danger); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

/* Переключатель */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-soft); }

/* Метки-переключатели */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips label, .chip-toggle {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line-strong); cursor: pointer; font-weight: 500; color: var(--text-2); user-select: none;
}
.chips input { display: none; }
.chips label:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 11px; font-weight: 600; }
.tag.hit { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.tag.spicy { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.tag.veg { background: var(--ok-soft); border-color: #bbf7d0; color: var(--ok); }
.tag.new { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.badge { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.stop { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; padding: 56px 20px; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; color: var(--text-3); margin: 0 auto 10px; stroke-width: 1.4; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.muted { color: var(--text-3); }

/* ── Меню: категории + блюда ───────────────────────────────────────────── */
.menu-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.cats { padding: 8px; position: sticky; top: 20px; }
.cats-list { list-style: none; margin: 0; padding: 0; }
.cat {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 4px; height: 38px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
}
.cat:hover { background: var(--surface-2); }
.cat.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cat a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 38px; display: flex; align-items: center; }
.cat .n { font-size: 12px; color: var(--text-3); }
.cat .more { opacity: 0; width: 26px; height: 26px; }
.cat:hover .more, .cat.on .more { opacity: 1; }
.cat.hidden-cat a { text-decoration: line-through; color: var(--text-3); }
.handle { cursor: grab; color: var(--text-3); display: grid; place-items: center; width: 18px; opacity: .55; }
.handle:hover { opacity: 1; }
.handle svg { width: 14px; height: 14px; }
.cat-add { display: flex; gap: 6px; padding: 8px 4px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.cat-add input { height: 34px; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { background: var(--surface-2); }

.products-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.products-head h2 { margin: 0; font-size: 16px; }
.products-head .muted { font-size: 13px; }
.products-head .actions { margin-left: auto; display: flex; gap: 6px; }
.plist { list-style: none; margin: 0; padding: 0; }
.prow {
  display: grid; grid-template-columns: 18px 56px minmax(0, 1fr) 110px 132px; align-items: center; gap: 14px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s;
}
.prow:last-child { border-bottom: 0; }
.prow:hover { background: var(--surface-2); }
.prow .thumb { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }
.prow .thumb.none { display: grid; place-items: center; color: var(--text-3); }
.prow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .meta { display: flex; gap: 6px; align-items: center; color: var(--text-3); font-size: 13px; margin-top: 2px; flex-wrap: wrap; }
.prow .price { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.prow .price small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }
.prow .stock { display: flex; justify-content: flex-end; }
.prow .stock .switch span.lbl { font-size: 12px; color: var(--text-2); width: 72px; }
.prow.inactive .name, .prow.inactive .thumb { opacity: .45; }
.prow.stopped .thumb { filter: grayscale(1); opacity: .6; }

/* ── Стоп-лист ─────────────────────────────────────────────────────────── */
.stop-search { max-width: 520px; margin-bottom: 18px; }
.stop-search input { height: 46px; font-size: 16px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .thumb { width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-2); }
.srow .name { flex: 1; min-width: 0; font-weight: 500; }
.srow .name small { display: block; color: var(--text-3); font-weight: 400; font-size: 12px; }
.srow.stopped .name { color: var(--danger); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin: 22px 4px 8px; }

/* ── Часы ──────────────────────────────────────────────────────────────── */
.hours { border-collapse: collapse; }
.hours td { padding: 5px 10px 5px 0; vertical-align: middle; }
.hours td.dash { color: var(--text-3); padding-right: 10px; }
.hours td.day { width: 48px; font-weight: 600; }
.hours input[type=time] { height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 8px; background: var(--surface); }
.hours tr.closed input[type=time] { opacity: .35; pointer-events: none; }
.hours .closed-lbl { color: var(--text-3); }
.branch-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }

/* ── Таблицы ───────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 10px; }

/* ── Боковая панель (drawer) ───────────────────────────────────────────── */
/* Выше слоёв карты Leaflet (у них z-index до 1000). */
.drawer-backdrop { position: fixed; inset: 0; background: rgb(28 25 23 / .35); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 2000; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface);
  transform: translateX(100%); visibility: hidden;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .22s;
  z-index: 2010; display: flex; flex-direction: column;
}
body.drawer-open .drawer { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition-delay: 0s; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer > form, .drawer > div { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-head .btn-icon { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-foot .spacer { flex: 1; }

/* Фото: перетащить или нажать */
.drop {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; border-radius: var(--r);
  border: 1.5px dashed var(--line-strong); background: var(--surface-2); overflow: hidden; cursor: pointer;
  color: var(--text-3); text-align: center; transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .change { position: absolute; right: 10px; bottom: 10px; background: rgb(0 0 0 / .6); color: #fff; padding: 5px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.drop .placeholder svg { width: 32px; height: 32px; margin: 0 auto 6px; stroke-width: 1.4; }

.radio-cards { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.radio-cards label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r); cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio-cards input { margin-top: 3px; accent-color: var(--brand); }
.radio-cards b { display: block; }
.radio-cards small { color: var(--text-2); }

/* ── Уведомления ───────────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 2100; align-items: center; }
.toast { background: #1c1917; color: #fff; padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow); font-weight: 500; display: flex; gap: 8px; align-items: center; animation: toast-in .2s ease-out; }
.toast.error { background: var(--danger); }
.toast svg { color: #4ade80; }
.toast.error svg { color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Платформа ─────────────────────────────────────────────────────────── */
.facts { display: grid; grid-template-columns: 180px 1fr; gap: 10px 18px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: -3px; border: 1px solid var(--line); margin-right: 6px; }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

/* ── Вход ──────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 400px; text-align: center; padding: 32px 28px; }
.login .logo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login .qr { width: 232px; height: 232px; margin: 20px auto 12px; image-rendering: pixelated; border-radius: var(--r); border: 1px solid var(--line); padding: 8px; background: #fff; }
.login .steps { text-align: left; color: var(--text-2); margin: 16px 0 0; padding-left: 20px; }
.login .steps li { margin: 4px 0; }
.login .state { margin-top: 14px; font-weight: 500; color: var(--text-2); }
.login .state.err { color: var(--danger); }

/* ── Телефон и планшет ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .prow { grid-template-columns: 18px 48px minmax(0, 1fr) 90px 52px; }
  .prow .stock .lbl { display: none; }
  .branch-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; gap: 8px; }
  .brand { padding: 0 6px 0 0; }
  .brand small, .nav-sep, .me .who { display: none; }
  .nav { flex-direction: row; }
  .nav a span { display: none; }
  .me { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 18px 14px 60px; }
  .menu-layout { grid-template-columns: 1fr; }
  .cats { position: static; }
  .cats-list { display: flex; overflow-x: auto; gap: 4px; }
  .cat { flex: none; }
  .cat .handle, .cat .more, .cat-add { display: none; }
  .prow { grid-template-columns: 48px minmax(0, 1fr) 70px 46px; padding: 10px 12px; gap: 10px; }
  .prow .handle { display: none; }
  .row2 { grid-template-columns: 1fr; }
}

/* ── Навигация: группы ─────────────────────────────────────────────────── */
.side { overflow-y: auto; }
.nav-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 4px; }
.nav .count.live { background: var(--danger); color: #fff; animation: pulse-badge 1.6s infinite; }
@keyframes pulse-badge { 50% { box-shadow: 0 0 0 4px var(--danger-soft); } }
.sound-banner { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.sound-banner .btn { margin-left: auto; }

/* ── Доска заказов ─────────────────────────────────────────────────────── */
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 14px; }
.kpi b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--text-3); }
.board { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(250px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; }
.col { background: #efeeec; border-radius: var(--r-lg); padding: 10px; min-height: 160px; }
.col-head { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 6px 10px; }
.col-head .n { background: var(--surface); border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--text-2); }
.col.new .col-head { color: var(--danger); }
.ocard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-sm); cursor: pointer; }
.ocard:hover { border-color: var(--line-strong); }
.ocard.fresh { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: fresh 1.4s ease-in-out 3; }
@keyframes fresh { 50% { box-shadow: 0 0 0 6px var(--danger-soft); } }
.ocard .top { display: flex; align-items: center; gap: 8px; }
.ocard .num { font-weight: 700; font-size: 15px; }
.ocard .ago { margin-left: auto; color: var(--text-3); font-size: 12px; }
.ocard .ago.late { color: var(--danger); font-weight: 600; }
.ocard .items { color: var(--text-2); font-size: 13px; margin: 6px 0; line-height: 1.35; }
.ocard .addr { font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.ocard .addr svg { width: 14px; height: 14px; margin-top: 2px; color: var(--text-3); }
.ocard .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ocard .sum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ocard .foot .muted { font-size: 12px; white-space: nowrap; }
.ocard .foot .btn { margin-left: auto; }
.kind { display: inline-flex; height: 20px; align-items: center; padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.kind.delivery { background: #eff6ff; color: #1d4ed8; }
.kind.pickup { background: #f5f3ff; color: #6d28d9; }
.kind.preorder { background: #fff7ed; color: #c2410c; }
.col-empty { color: var(--text-3); text-align: center; padding: 22px 6px; font-size: 13px; }
.items-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.items-table td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.items-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 14px; }
.totals .grand { font-weight: 700; font-size: 16px; }
.alert { padding: 12px 14px; border-radius: var(--r); margin-bottom: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--text-2); }
.timeline li { padding: 3px 0; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a .badge { margin-left: 4px; }

/* ── Карта зон ─────────────────────────────────────────────────────────── */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.map { position: relative; z-index: 0; isolation: isolate; height: calc(100vh - 170px); min-height: 460px; border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; }
.zone-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.zone-item:hover { background: var(--surface-2); }
.zone-item .dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.zone-item small { display: block; color: var(--text-3); }
.zone-label { background: rgb(255 255 255 / .92); border: 0; border-radius: 6px; box-shadow: var(--shadow-sm); font: 600 12px var(--font); padding: 3px 7px; }
.colors { display: flex; gap: 6px; }
.colors label { width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.colors input { display: none; }
.colors label:has(input:checked) { border-color: var(--text); }

/* ── Сетка карточек (акции) и отчёты ───────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; cursor: pointer; }
.pcard img, .pcard .ph { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }
.pcard .b { padding: 12px 14px; }
.pcard .b b { display: block; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .map-layout, .grid2 { grid-template-columns: 1fr; } .map { height: 60vh; } }

/* ── Отчёты: показатели и воронка ──────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.stat small { color: var(--text-2); }
.stat b { display: block; font-size: 24px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .of { font-size: 14px; font-weight: 500; color: var(--text-3); }
.funnel { display: grid; gap: 12px; }
.frow { display: grid; grid-template-columns: 170px minmax(0, 1fr) 56px; align-items: center; gap: 12px; }
.flabel { color: var(--text-2); }
.ftrack { height: 14px; display: block; }
/* Тонкая полоса от общей базы, скруглён только конец со значением. */
.ftrack i { display: block; height: 14px; background: var(--brand); border-radius: 0 4px 4px 0; }
.ftrack:hover i { filter: brightness(.9); }
.fval { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.grid2 > .card + .card, .grid2 > .card { margin-top: 0; }
.notify-toggle { display: flex; align-items: center; gap: 8px; margin: 12px 4px 0; padding: 9px 10px; border-radius: var(--r-sm);
  border: 1px dashed var(--warn); background: var(--warn-soft); color: var(--warn); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.notify-toggle svg { width: 16px; height: 16px; }

/* ══ Мобильная версия: как приложение ════════════════════════════════════
   Снизу — вкладки, сверху — шапка с названием экрана; карточки открываются
   на весь экран; доска заказов листается свайпом; таблицы — карточками. */
.mbar, .tabbar, .board-tabs { display: none; }
.more .nav-group:first-child { padding-top: 4px; }

/* Плавные переходы между экранами (View Transitions; где не поддерживается — без них). */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: vt-out .16s ease-in both; }
  ::view-transition-new(root) { animation: vt-in .22s cubic-bezier(.2, .8, .2, 1) both; }
}
@keyframes vt-out { to { opacity: 0; transform: translateX(-12px); } }
@keyframes vt-in { from { opacity: 0; transform: translateX(16px); } }

@media (max-width: 820px) {
  html { -webkit-tap-highlight-color: transparent; }
  body { font-size: 15px; overscroll-behavior-y: none; }
  .app { display: block; }
  .side { display: none; }
  .main { padding: 0 0 calc(76px + env(safe-area-inset-bottom)); max-width: none; }

  /* Шапка */
  .mbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    height: calc(54px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
    background: rgb(255 255 255 / .86); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
    border-bottom: 1px solid var(--line); }
  .mbar-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
  .mbar-back { width: 36px; height: 36px; display: grid; place-items: center; margin-left: -6px; color: var(--brand); }
  .mbar-back svg { width: 24px; height: 24px; stroke-width: 2.2; }
  .mbar-title { font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mbar-actions { display: flex; gap: 6px; }
  .mbar-actions .btn { height: 34px; padding: 0 12px; }
  .mbar-actions .btn span.lbl { display: none; }

  /* Вкладки снизу */
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgb(255 255 255 / .92); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
    border-top: 1px solid var(--line); }
  .tabbar a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 0; font-size: 11px; font-weight: 500; color: var(--text-3); }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a.on { color: var(--brand); }
  .tabbar .count { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 99px; font-size: 11px; font-style: normal; font-weight: 700; display: grid; place-items: center;
    background: var(--warn-soft); color: var(--warn); }
  .tabbar .count.live { background: var(--danger); color: #fff; }

  /* Заголовок страницы — в шапке; на месте остаются только действия */
  .head { padding: 12px 14px 0; margin-bottom: 10px; gap: 8px; }
  .head h1, .head .sub { display: none; }
  .head > div:first-child { display: none; }
  .head .actions { margin: 0; width: 100%; flex-wrap: wrap; }
  .head .actions .search, .head .actions .search input { flex: 1; width: 100% !important; }
  .head .kpis { width: 100%; }
  .head .kpi { flex: 1; padding: 6px 10px; }
  .head .kpi b { font-size: 16px; }
  .card { border-radius: 14px; }
  .main > .card, .main > form.card, .main > .grid2, .main > .cards, .main > .stat-row, .main > .tabs,
  .main > .menu-layout, .main > .map-layout, .main > div > .card { margin-left: 12px; margin-right: 12px; }
  .card-pad { padding: 16px; }
  .btn { height: 42px; }
  .btn-sm { height: 36px; }
  .input, .field input[type=text], .field input[type=tel], .field input[type=number], .field select { height: 44px; font-size: 16px; }

  /* Доска заказов: колонки — экраны, листаются свайпом */
  .board-wrap { margin: 0; }
  .board-tabs { display: flex; gap: 6px; position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 20;
    padding: 8px 12px; background: var(--bg); overflow-x: auto; scrollbar-width: none; }
  .board-tabs::-webkit-scrollbar { display: none; }
  .board-tabs button { flex: none; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px;
    border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-weight: 600; color: var(--text-2); }
  .board-tabs button b { font-size: 12px; background: var(--surface-2); border-radius: 99px; padding: 1px 7px; }
  .board-tabs button.on { background: var(--text); border-color: var(--text); color: #fff; }
  .board-tabs button.on b { background: rgb(255 255 255 / .2); }
  .board-tabs button.hot:not(.on) { border-color: var(--danger); color: var(--danger); }
  .board { display: flex; gap: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
  .board::-webkit-scrollbar { display: none; }
  .col { flex: 0 0 100%; scroll-snap-align: start; background: none; border-radius: 0; padding: 4px 12px 12px; min-height: 60vh; }
  .col-head { display: none; }
  .ocard { padding: 14px; border-radius: 14px; }
  .ocard .num { font-size: 17px; }
  .ocard .items { font-size: 14px; }
  .ocard .foot { flex-wrap: wrap; }
  .ocard .foot .btn { flex: 1 0 100%; margin: 6px 0 0; height: 44px; font-size: 15px; }
  .col-empty { padding: 60px 10px; font-size: 15px; }

  /* Карточки (заказ, блюдо, бронь…) — на весь экран, снизу вверх */
  .drawer { width: 100vw; top: auto; height: calc(100dvh - env(safe-area-inset-top) - 8px); border-radius: 16px 16px 0 0;
    transform: translateY(100%); }
  body.drawer-open .drawer { transform: none; }
  .drawer-head { padding: 14px 16px; }
  .drawer-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 99px; background: var(--line-strong); }
  .drawer-body { padding: 16px; }
  .drawer-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .drawer-foot .btn { flex: 1; }
  .drawer-foot .spacer { display: none; }
  .drawer-foot .input { flex: 1 0 100%; }
  .facts { grid-template-columns: 1fr !important; gap: 2px 0; }
  .facts dt { font-size: 12px; margin-top: 8px; }

  /* Таблицы → карточки */
  .table.cards-on-mobile, .table.cards-on-mobile tbody { display: block; }
  .table.cards-on-mobile tr:first-child:has(th) { display: none; }
  .table.cards-on-mobile tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table.cards-on-mobile td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .table.cards-on-mobile td::before { content: attr(data-label); color: var(--text-3); text-align: left; flex: none; }
  .table.cards-on-mobile td[data-label=""]::before { content: none; }
  .table.cards-on-mobile td:first-child { text-align: left; font-size: 16px; padding-bottom: 6px; }
  .table.cards-on-mobile td:first-child::before { content: none; }
  .table.cards-on-mobile td .action-row { justify-content: stretch !important; width: 100%; }
  .table.cards-on-mobile td .action-row .btn { flex: 1; }

  /* Меню: категории — лентой, строки блюд крупнее */
  .menu-layout { grid-template-columns: 1fr; gap: 10px; margin: 0 !important; }
  .cats { position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 15; border-radius: 0; border-left: 0; border-right: 0; padding: 6px 0; box-shadow: none; }
  .cats-list { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px; scrollbar-width: none; }
  .cats-list::-webkit-scrollbar { display: none; }
  .cat { flex: none; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); }
  .cat a { height: 34px; }
  .cat.on { border-color: var(--brand); }
  .cat .n, .cat .handle, .cat .more, .cat-add { display: none; }
  #products { margin: 0 12px; }
  .products-head { padding: 12px 14px; }
  .prow { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "img name stock" "img price stock"; gap: 2px 12px; padding: 12px 14px; }
  .prow .handle { display: none; }
  .prow .thumb { grid-area: img; width: 56px; height: 56px; }
  .prow > div:nth-of-type(1) { grid-area: name; }
  .prow .price { grid-area: price; text-align: left; font-size: 14px; }
  .prow .stock { grid-area: stock; }

  /* Стоп-лист */
  .stop-search { margin: 0 12px 12px; max-width: none; }
  .srow { padding: 12px 14px; }
  .srow .thumb { width: 44px; height: 44px; }
  .section-title { margin: 18px 16px 8px; }

  /* Прочее */
  .map-layout { grid-template-columns: 1fr; margin: 0 12px; }
  .map { height: 55vh; min-height: 320px; }
  .branch-grid { grid-template-columns: 1fr; gap: 12px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; margin: 0 12px; }
  .tabs { overflow-x: auto; padding: 0 12px; margin-left: 0 !important; margin-right: 0 !important; }
  .tabs a { white-space: nowrap; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .toast { width: 100%; justify-content: center; }

  /* «Ещё» — список разделов, как настройки телефона */
  .more { padding: 12px; }
  .more-me { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
  .more-me .avatar { width: 44px; height: 44px; font-size: 15px; }
  .more-me small { display: block; color: var(--text-3); }
  .more .nav { display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
  .more .nav a { padding: 14px; border-radius: 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 16px; }
  .more .nav a::after { content: "›"; margin-left: auto; color: var(--text-3); font-size: 20px; line-height: 1; }
  .more .nav a .count + ::after, .more .nav a .count { margin-left: auto; }
  .more .nav a.on { background: none; color: var(--text); }
  .more .nav-group { background: var(--bg); padding: 16px 14px 6px; border-bottom: 1px solid var(--line); }
  .more .notify-toggle { width: 100%; margin: 12px 0 0; padding: 14px; font-size: 15px; }
  .more-logout { margin-top: 12px; }
  .more-logout .btn { width: 100%; height: 48px; }
}
@media (min-width: 821px) { .more { max-width: 520px; } .more-me, .more .notify-toggle, .more-logout { display: none; } }
@media (max-width: 820px) {
  .more .nav a span { display: inline; }
  .head .actions .moved { display: none; }
  label.search, .stop-search { display: block; }
  .stop-search input { width: 100%; }
  .tag, .badge, .kind { white-space: nowrap; }
}
@media (max-width: 820px) {
  .more .nav a span { flex: 1; }
  .more .nav a .count { margin-left: 0; }
  .more .nav a::after { margin-left: 10px; }
}

/* Выбор категории меню на телефоне: кнопка + список снизу */
.cat-picker { display: none; }
.menu-layout > * { min-width: 0; }
@media (max-width: 820px) {
  .menu-layout { grid-template-columns: minmax(0, 1fr); }
  .menu-layout .cats { display: none; }
  .cat-picker { display: block; position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 15;
    padding: 0 12px 10px; background: var(--bg); }
  .cat-select { width: 100%; height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; font: inherit; font-weight: 600;
    color: var(--text); box-shadow: var(--shadow-sm); cursor: pointer; }
  .cat-select:active { background: var(--surface-2); }
  .cat-select-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cat-select-n { font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 99px; padding: 2px 8px; }
  .cat-select-n:empty { display: none; }
  .cat-select svg.down { transform: rotate(90deg); color: var(--text-3); }
  .drawer.sheet-short { height: auto; max-height: 80dvh; }
  .sheet-list { padding: 6px 0 calc(12px + env(safe-area-inset-bottom)); }
  .sheet-item { display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-size: 16px; border-bottom: 1px solid var(--line); }
  .sheet-item span { flex: 1; min-width: 0; }
  .sheet-item b { font-size: 13px; font-weight: 600; color: var(--text-3); }
  .sheet-item svg.tick { color: var(--brand); visibility: hidden; stroke-width: 2.4; }
  .sheet-item.on { color: var(--brand); font-weight: 600; }
  .sheet-item.on svg.tick { visibility: visible; }
  .sheet-item.off span { color: var(--text-3); }
  .sheet-add { display: flex; gap: 8px; padding: 14px 18px 4px; }
}
