:root {
  --bg: #f3f5f8; --card: #fff; --line: #e3e6ea; --text: #1c2430; --muted: #7a8494;
  --primary: #1a56db; --primary-dark: #1447b8; --danger: #d92d20; --warn: #f79009; --ok: #12b76a;
  --r: 12px;
  --row-h: 46px;      /* высота строки таблицы (компактно, как в Excel) */
  --thumb: 44px;      /* размер миниатюры */
  --grid-line: #eef0f3;
  --grid-vline: #f4f5f8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 18px; }
.spacer { flex: 1; }
.hint { margin: 10px 2px; line-height: 1.5; }

/* ---------- вход ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--card); padding: 36px 32px; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.12); width: 360px; text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 6px; }
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card input { width: 100%; margin: 18px 0 12px; }

/* переключатель роли на входе: «Склад» / «Офис» */
.role-seg { display: flex; gap: 4px; margin: 20px 0 0; padding: 4px; background: #f0f2f5; border: 1px solid var(--line); border-radius: 12px; }
.seg-btn { flex: 1; min-height: 44px; border: none; background: transparent; border-radius: 9px; padding: 9px 6px; font-family: inherit; font-size: 14.5px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, box-shadow .12s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(16,24,40,.14); }
.login-card .role-seg + input { margin-top: 14px; }

/* ---------- шапка ---------- */
.topbar { display: flex; align-items: center; gap: 16px; background: #101828; color: #fff; padding: 10px 18px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand-ico { font-size: 20px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; color: #cbd5e1; border: none; padding: 8px 13px; border-radius: 10px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.tab span { margin-left: 4px; }
.tab.active, .tab:hover { background: #1f2b3e; color: #fff; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cbd5e1; }
.role-chip { background: #1f2b3e; padding: 5px 12px; border-radius: 10px; white-space: nowrap; }
.btn.small.ghost { background: transparent; border-color: #334155; color: #cbd5e1; }
.btn.small.ghost:hover { background: #1f2b3e; }

main { max-width: 1240px; margin: 18px auto; padding: 0 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text); white-space: nowrap; cursor: pointer; }

input, select, textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; color: var(--text); font-family: inherit; }
input:focus, select:focus { outline: 2px solid #b2ccff; border-color: var(--primary); }
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 460px; }
.search-wrap .s-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .55; }
.search-wrap input { width: 100%; padding-left: 34px; }

/* ---------- полоса статистики склада ---------- */
.stats-strip { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; margin-bottom: 12px; font-size: 14px; }
.stats-strip b { font-size: 16px; }
.ss-sep { width: 1px; height: 18px; background: var(--line); }
.ss-low { color: var(--danger); cursor: pointer; background: none; border: none; font: inherit; padding: 3px 8px; border-radius: 8px; }
.ss-low b { font-size: 16px; }
.ss-low:hover { background: #fee4e2; }
.ss-low.ok { color: var(--ok); }

/* ---------- кнопки ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-size: 14px; color: var(--text); font-family: inherit; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fecdca; }
.btn.danger:hover { background: #fef3f2; }
.btn.ok { color: var(--ok); border-color: #a6f4c5; }
.btn.ok:hover { background: #ecfdf3; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.ibtn { border: none; background: transparent; cursor: pointer; padding: 6px; border-radius: 8px; font-size: 14px; line-height: 1; color: #8a93a3; font-family: inherit; }
.ibtn.del:hover { background: #fee4e2; color: var(--danger); }
.ibtn.cfg:hover, .ibtn.hist:hover { background: #eef2f7; color: var(--text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-title { margin: 0 0 12px; font-size: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 15px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- главная ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: box-shadow .15s; min-width: 0; }
.stat-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.09); }
.stat-ico { font-size: 22px; }
.stat-card b { font-size: 30px; line-height: 1.1; }
.stat-card span:last-child { color: var(--muted); font-size: 13px; }
.stat-card.alarm { border-color: #fecdca; background: #fff8f7; }
.stat-card.alarm b { color: var(--danger); }
.stat-card.warn { border-color: #fedf89; background: #fffcf3; }
.stat-card.warn b { color: #b54708; }
.home-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }

.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.cat-tile { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; font-family: inherit; font-size: 14px; transition: box-shadow .15s; min-width: 0; }
.cat-tile:hover { box-shadow: 0 3px 10px rgba(16,24,40,.08); }
.tile-ico { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex: none; }
.tile-body { display: flex; flex-direction: column; min-width: 0; }
.tile-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { color: var(--muted); font-size: 12.5px; }
.tile-sub .bad { color: var(--danger); font-weight: 700; }

.recent-list { display: flex; flex-direction: column; min-width: 0; }
.recent-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 14px; min-width: 0; }
.recent-row:last-child { border-bottom: none; }
.rec-thumb { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.rec-delta { font-weight: 700; min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.rec-delta.pos { color: var(--ok); }
.rec-delta.neg { color: var(--danger); }
.rec-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-kind { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: none; max-width: 45%; }
.rec-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 0; flex: none; }
.home-actions .qa-row { display: flex; gap: 10px; flex-wrap: wrap; }
.home-actions .btn { font-size: 15px; padding: 11px 16px; }

/* ---------- чипы категорий ---------- */
.chip-row { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: thin; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 20px; padding: 7px 13px; font-size: 13.5px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.chip b { opacity: .6; font-weight: 600; margin-left: 2px; }
.chip[data-cat]:not(.on) { background: var(--cbg, #fff); color: var(--cfg, var(--text)); border-color: transparent; }
.chip.on { background: #101828; color: #fff; border-color: #101828; }

/* ==========================================================
   ТАБЛИЦА-СЕТКА (Excel-режим)
   ========================================================== */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 330px); min-height: 260px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; min-width: 980px; border-collapse: separate; border-spacing: 0; table-layout: fixed; background: #fff; }

/* колонки склада */
col.c-photo { width: 56px; }
col.c-name { width: 34%; }
col.c-qty { width: 116px; }
col.c-min { width: 92px; }
col.c-unit { width: 84px; }
col.c-cat { width: 168px; }
col.c-notes { width: 21%; }
col.c-act { width: 64px; }

/* шапка */
.grid thead th { position: sticky; top: 0; z-index: 5; background: #f0f2f5; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; padding: 0 10px; height: 34px; vertical-align: middle; }
.grid thead th.num { text-align: right; }
.grid thead th.c-photo { text-align: center; }

/* ячейки */
.grid td { border-bottom: 1px solid var(--grid-line); border-right: 1px solid var(--grid-vline); height: var(--row-h); padding: 0; font-size: 14px; vertical-align: middle; background: #fff; }
.grid td:last-child { border-right: none; }
.grid td.num, .grid th.num { text-align: right; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid td.empty-cell { padding: 40px 10px; text-align: center; color: var(--muted); }

/* закреплённые колонки: Фото + Название */
.grid td.c-photo, .grid th.c-photo { position: sticky; left: 0; z-index: 2; text-align: center; }
.grid td.c-name, .grid th.c-name { position: sticky; left: 56px; z-index: 2; }
.grid th.c-photo, .grid th.c-name { z-index: 6; }
.grid td.c-photo { box-shadow: 1px 0 0 var(--grid-line); }

/* рамка-фокус ячейки (как в Google Sheets) */
.grid td:not(.ro-cell):focus-within { background: #f0f6ff; box-shadow: inset 0 0 0 2px #84adff; }

/* инпуты внутри ячеек: без рамок, «как напечатано» */
.cell-input { width: 100%; height: var(--row-h); border: none; background: transparent; padding: 0 8px; font-family: inherit; font-size: 14px; color: var(--text); outline: none; border-radius: 0; }
.cell-input::placeholder { color: #c3c9d4; }
.cell-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input[readonly] { color: var(--text); cursor: default; }
.cell-input[type=number]::-webkit-outer-spin-button, .cell-input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell-input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.c-name .cell-input { font-weight: 600; }
.c-notes .cell-input { color: #5b6575; }
.c-cat .cell-input, .c-unit .cell-input { font-size: 13.5px; }

/* подсветка поиска: подложка с <mark> под инпутом */
.name-cell { position: relative; height: var(--row-h); }
.name-hl { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 8px; font-family: 'Segoe UI', Roboto, Arial, sans-serif; font-size: 14px; font-weight: 600; white-space: pre; overflow: hidden; pointer-events: none; color: transparent; }
.name-hl mark { background: #ffe08a; color: transparent; border-radius: 2px; }

/* количество: инпут + кнопки −/+ */
.qty-wrap { display: flex; align-items: stretch; height: var(--row-h); }
.qty-wrap .cell-input { flex: 1; min-width: 0; }
.stepper { width: 26px; flex: none; border: none; background: transparent; font-size: 16px; line-height: 1; cursor: pointer; color: #8a93a3; padding: 0; font-family: inherit; border-radius: 6px; }
.stepper:hover { background: #e8f0fe; color: var(--primary); }
.stepper:active { transform: scale(.9); }
@media (hover: hover) {
  .stepper { opacity: 0; transition: opacity .12s; }
  tr.item-row:hover .stepper, .c-qty:focus-within .stepper { opacity: 1; }
}

/* статусы строк */
tr.item-row:hover td { background: #f7fafd; }
tr.st-low td.c-qty { background: #fdebe9; }
tr.st-low td.c-photo { box-shadow: inset 3px 0 0 var(--danger), 1px 0 0 var(--grid-line); }
tr.st-zero td.c-qty { background: #fbd7d2; }
tr.st-zero td.c-qty .cell-input { font-weight: 700; }
tr.st-zero td.c-photo { box-shadow: inset 3px 0 0 var(--danger), 1px 0 0 var(--grid-line); }
tr.st-low:hover td.c-qty { background: #fbdfdb; }

/* анимации сохранения / ошибки */
@keyframes flashok { from { background: #bdf0cf; } to { background: transparent; } }
@keyframes flasherr { 0%, 100% { translate: 0 0; } 20%, 60% { translate: -3px 0; } 40%, 80% { translate: 3px 0; } }
td.flash-ok { animation: flashok 1s ease-out; }
td.flash-err { animation: flasherr .3s ease-in-out 2; background: #fee4e2 !important; }

/* групповые строки категорий */
.group-row td { padding: 0; background: #f4f6f9; border-bottom: 1px solid var(--line); border-right: none; }
.grp { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 6px 12px; background: none; border: none; font-family: inherit; font-size: 13px; font-weight: 700; color: #3a465a; cursor: pointer; text-align: left; }
.grp:hover { background: #eceff4; }
.chev { color: var(--muted); font-size: 11px; width: 14px; flex: none; transition: transform .15s; }
tbody.collapsed .chev { transform: rotate(-90deg); }
.grp-ico { width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.grp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-n { color: var(--muted); font-weight: 600; }
.grp-low { background: #fee4e2; color: var(--danger); border-radius: 10px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.grp-buy { color: var(--muted); font-weight: 600; font-size: 12px; }
tbody.collapsed tr.item-row { display: none; }

/* фото-ячейка */
.photo-cell { position: relative; width: var(--thumb); height: var(--thumb); margin: 0 auto; border-radius: 10px; overflow: hidden; cursor: pointer; }
.photo-cell .thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-init { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border-radius: 10px; letter-spacing: .3px; }
.ph-void { background: #f1f5f9; color: #b6bfcc; }
.ph-cam { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(16,24,40,.45); color: #fff; font-size: 14px; opacity: 0; transition: opacity .12s; }
.photo-cell:hover .ph-cam { opacity: 1; }
.ph-del { position: absolute; top: -1px; right: -1px; width: 17px; height: 17px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 9px; line-height: 1; cursor: pointer; opacity: 0; display: flex; align-items: center; justify-content: center; padding: 0; }
.photo-cell:hover .ph-del { opacity: 1; }
@media (hover: none) {
  .ph-del { opacity: 1; }
  .ph-cam { display: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-cell.uploading::before { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.55); z-index: 1; }
.photo-cell.uploading::after { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid #b7c0ce; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; z-index: 2; }

/* колонка действий */
.c-act { text-align: right; }
.row-act { display: flex; justify-content: flex-end; align-items: center; }
@media (hover: hover) {
  .row-act .ibtn { opacity: 0; transition: opacity .12s; }
  tr:hover .row-act .ibtn, .row-act .ibtn:focus-visible { opacity: 1; }
}

/* кнопка добавления позиции под таблицей */
.add-row { display: block; width: 100%; margin-top: 10px; padding: 12px; border: 1.5px dashed #c9d2de; border-radius: var(--r); background: #fff; color: var(--muted); font-size: 14.5px; cursor: pointer; font-family: inherit; }
.add-row:hover { border-color: var(--primary); color: var(--primary); background: #f5f8ff; }

/* ---------- таблица монтажа ---------- */
.proj-grid { min-width: 900px; }
col.c-need, col.c-given, col.c-stock, col.c-buy2 { width: 110px; }
.proj-grid .c-name .cell-input { font-weight: 400; }
.prow .c-name b { font-weight: 600; }
.prj-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.prj-title { font-size: 18px; }
.qty-low { color: var(--danger); font-weight: 700; }

/* ---------- закупки ---------- */
.purch-grid { min-width: 900px; }
col.c-need2 { width: 120px; }
col.c-short2 { width: 110px; }
col.c-mingap { width: 190px; }
col.c-buy3 { width: 110px; }
.purch-grid .c-name b { font-weight: 600; }
.purch-grid td { height: 44px; }
.purch-grid .grp { cursor: default; }
.purch-grid .grp:hover { background: none; }

/* ---------- монтажи: список ---------- */
.project-card { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.project-card:hover { box-shadow: 0 3px 12px rgba(16,24,40,.08); }
.prj-ico { width: 46px; height: 46px; border-radius: 12px; background: #f0f2f5; display: flex; align-items: center; justify-content: center; font-size: 24px; flex: none; }
.prj-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.prj-info b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 12px; padding: 4px 11px; border-radius: 10px; white-space: nowrap; flex: none; }
.status.сборка { background: #eff8ff; color: #175cd3; }
.status.на-монтаже { background: #fff6e5; color: #b54708; }
.status.закрыт { background: #ecfdf3; color: #067647; }

/* выбор позиции в монтаж */
.pick-list { max-height: 280px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.pick-row:hover { background: #f0f5ff; }
.pick-row .photo-cell { cursor: pointer; flex: none; }
.pick-body { min-width: 0; }
.pick-body b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- модалки / тосты ---------- */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; z-index: 50; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 620px; }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.modal-card input, .modal-card select, .modal-card textarea { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.item-head .photo-cell { cursor: default; }
.mi-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px; }
.photo-preview { text-align: center; margin: 6px 0 12px; }
.photo-preview img { max-width: 100%; max-height: 300px; border-radius: 14px; }
.ph-big { width: 150px; height: 150px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; }
.history-list { max-height: 340px; overflow-y: auto; }
.history-list .hrow { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 13.5px; }
.history-list .hrow:last-child { border-bottom: none; }
.copy-area { font-family: Consolas, Menlo, monospace; font-size: 13px; white-space: pre; }

#toasts { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #101828; color: #fff; padding: 11px 20px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: tin .18s ease-out; max-width: 90vw; }
.toast.t-err { background: var(--danger); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ========================================================== */
@media (max-width: 640px) {
  :root { --row-h: 48px; --thumb: 44px; }

  body { font-size: 15px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-t { display: none; }
  .userbox .role-chip { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .topbar nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: #101828; display: flex; gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0,0,0,.3);
  }
  .topbar .userbox { margin-left: auto; }
  .tab { flex: 1; text-align: center; padding: 8px 2px 9px; font-size: 19px; border-radius: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .tab span { margin-left: 0; font-size: 11px; }

  main { margin: 12px 0; padding: 0 10px 96px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar .chk { padding: 4px 2px; }
  .toolbar .btn { text-align: center; }

  input, select, textarea { font-size: 16px; padding: 11px 12px; border-radius: 10px; }
  .btn { font-size: 15px; padding: 11px 14px; border-radius: 10px; }
  .btn.small { padding: 8px 11px; font-size: 14px; }
  .search-wrap { max-width: none; }

  .stats-strip { font-size: 13px; padding: 10px 12px; gap: 4px 12px; }
  .stats-strip b { font-size: 14px; }
  .ss-sep { display: none; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card b { font-size: 24px; }
  .home-cols { grid-template-columns: 1fr; }
  .home-actions .qa-row { display: grid; grid-template-columns: 1fr 1fr; }
  .rec-time { display: none; }
  .rec-kind { max-width: 55%; }

  /* таблица: вертикально скроллится страница, горизонтально — сетка */
  .tbl-wrap { max-height: none; overflow-x: auto; min-height: 0; }
  table.grid { min-width: 990px; }
  col.c-name { width: 232px; }
  col.c-notes { width: 168px; }
  .grid thead th { font-size: 11px; padding: 0 8px; height: 32px; }

  /* 16px в инпутах — iOS не зумит при фокусе */
  .cell-input { font-size: 16px; padding: 0 8px; }
  .c-cat .cell-input, .c-unit .cell-input { font-size: 15px; }
  .name-hl { font-size: 16px; padding: 0 8px; }
  .ph-init { font-size: 15px; }

  /* на телефоне кнопки всегда видны и крупные — палец попадает (≥44px) */
  .stepper { width: 32px; opacity: 1; font-size: 18px; }
  .row-act .ibtn { opacity: 1; font-size: 17px; padding: 8px; min-width: 42px; min-height: 44px; }
  col.c-act { width: 132px; }        /* 3 кнопки по 42px в строке склада */
  .proj-grid col.c-act, .purch-grid col.c-act { width: 64px; }

  .proj-grid, .purch-grid { min-width: 760px; }
  .purch-grid td { height: 48px; }

  /* модалки — нижние шторки */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; }
  .modal-actions .btn.danger { flex: none; }
  .mi-row { grid-template-columns: 1fr 1fr; }
  .login-card { width: min(360px, 94vw); padding: 28px 22px; }

  #toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .hint { font-size: 12.5px; }
}
