:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e2e6ee;
  --accent: #005bff; --accent-2: #e8f0ff; --ok: #12924f; --ok-bg: #e6f6ed; --warn: #b26a00;
  --warn-bg: #fff4e0; --bad: #c62a2a; --bad-bg: #fdeaea; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
[x-cloak] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { max-width: 1400px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 17px; color: var(--accent); }
.store-sel { font-weight: 600; max-width: 260px; padding: 5px 8px; }
.form-grid { display: grid; grid-template-columns: 120px minmax(0, 420px); gap: 8px 12px; align-items: center; }
.form-grid input { width: 100%; }
nav { display: flex; gap: 4px; }
nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; font: inherit; cursor: pointer; color: var(--muted); }
nav button.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px;
  border-radius: 8px; cursor: pointer; white-space: nowrap; display: inline-block; }
button:hover:not(:disabled), .btn:hover { border-color: #b9c2d3; text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #004ad1; }
button.danger { color: var(--bad); border-color: #f0c4c4; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
button:disabled { opacity: .5; cursor: default; }
button.sm, .btn.sm { padding: 3px 9px; font-size: 12px; }

input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
input.num { width: 76px; text-align: right; padding: 5px 7px; }
input.num-sm { width: 60px; text-align: right; padding: 3px 5px; }
input.date { padding: 4px 6px; width: 140px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8f9fb; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { background: #f8f9fb; font-weight: 600; }
td.r, th.r { text-align: right; }
td.c, th.c { text-align: center; }
/* вертикальные линии между колонками */
th:not(:last-child), td:not(:last-child) { border-right: 1px solid var(--line); }
/* подсветка строки под мышкой — поверх любого фона (в т.ч. зелёных и красных строк); на сенсорных экранах не нужна */
@media (hover: hover) {
  tbody tr:hover > td { box-shadow: inset 0 0 0 9999px rgba(0, 91, 255, .07); }
}
tr.click { cursor: pointer; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
th.sticky-col { background: #f8f9fb; }
.stat { font-size: 11px; color: var(--muted); white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--accent-2); color: var(--accent); }
.badge.gray { background: #eef0f4; color: var(--muted); }

.alert { padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--accent-2); color: #1b3f8f; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.product { display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; align-items: flex-start; }
.product img { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; background: #f3f4f6; flex: none; }
.product .name { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* карточки ассортимента */
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.acard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; background: #fff; min-width: 0; }
.acard.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: #fafcff; }
.acheck { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--muted); user-select: none; }
.acheck input { width: 20px; height: 20px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.acard.on .acheck { color: var(--accent); font-weight: 600; }
.aimg { aspect-ratio: 3 / 4; background: #f3f4f6; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.aimg img { width: 100%; height: 100%; object-fit: contain; }
.aoffer { font-weight: 700; overflow-wrap: anywhere; }
.aname { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.abc { font-size: 12px; font-family: Consolas, "Courier New", monospace; overflow-wrap: anywhere; }
.abc.bad, .abc .badge, .abc button { color: var(--bad); font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.abc button { color: var(--accent); }
.abc select { width: 100%; font-family: inherit; padding: 3px 6px; font-size: 12px; }
.aact { display: flex; margin-top: auto; padding-top: 4px; }
/* фото товаров в поставке: миниатюра, плитка (фото + артикул + шт), просмотр крупно */
.pimg { width: 72px; height: 72px; flex: none; border-radius: 8px; background: #f3f4f6; border: 1px solid var(--line); overflow: hidden;
        display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.pimg img { width: 100%; height: 100%; object-fit: contain; }
.pimg.xs { width: 34px; height: 34px; border-radius: 6px; }
.pimg.sm { width: 48px; height: 48px; }
.pimg.lg { width: 110px; height: 110px; }
.ptiles { display: flex; flex-wrap: wrap; gap: 12px; }
.ptile { width: 128px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ptile .pimg { width: 128px; height: 128px; }
.ptile.lg { width: 168px; }
.ptile.lg .pimg { width: 168px; height: 168px; }
.ptiles.sm { gap: 10px; }
.ptiles.sm .ptile { width: 100px; }
.ptiles.sm .ptile .pimg { width: 100px; height: 100px; }
.ptile-offer { font-size: 14px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.ptile-name { font-size: 12px; color: var(--muted); line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ptile-qty { font-size: 16px; font-weight: 700; }
.ptiles.sm .ptile-offer { font-size: 13px; }
.ptiles.sm .ptile-qty { font-size: 14px; }
.ptile-more { align-self: center; color: var(--muted); font-size: 13px; }
.orders-t td.c-cluster { min-width: 150px; }
.orders-t td.c-rm { white-space: nowrap; text-align: right; }
.tiles-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; justify-content: space-between; }
.poffer { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.th-prod { vertical-align: bottom; }
.th-prod .pimg { margin: 0 0 6px auto; }
.td-img { display: none; }
.box-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; }
.overlay.zoom { z-index: 60; }
.zoom-box { position: relative; background: #fff; border-radius: 12px; padding: 12px; max-width: min(92vw, 900px); max-height: 92vh; display: flex; flex-direction: column; gap: 8px; }
.zoom-box img { max-width: 100%; max-height: calc(92vh - 90px); object-fit: contain; display: block; margin: 0 auto; }
.zoom-x { position: absolute; top: 8px; right: 8px; font-size: 18px; padding: 4px 10px; }
.zoom-cap { padding-right: 40px; }
.ast { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.ast .badge { font-size: 11px; padding: 1px 7px; }
.aerr { font-size: 12px; }
.aerr summary { cursor: pointer; font-weight: 600; user-select: none; }
.aerr ul { margin: 4px 0 0; padding-left: 16px; max-height: 180px; overflow-y: auto; overflow-wrap: anywhere; }
.aerr li { margin: 2px 0; }
.aerr li.warning { color: var(--warn); }
.aact button { flex: 1; min-width: 0; white-space: normal; }

.progress { height: 6px; background: #e8ebf1; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid #c7d4f5; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }


.files { display: flex; flex-wrap: wrap; gap: 6px; }
.files a { border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; }

.toast { position: fixed; right: 16px; bottom: 16px; max-width: 460px; padding: 12px 16px; border-radius: 10px; z-index: 50;
  background: #1d2330; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.overlay { position: fixed; inset: 0; background: rgba(20, 25, 35, .45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 20px; max-width: 480px; width: 100%; }
.modal p { white-space: pre-line; }

.login { max-width: 360px; margin: 12vh auto; }
.login input { width: 100%; margin-bottom: 10px; }

.supply { border-left: 4px solid var(--accent); }
.box-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
td.ok-cell { color: var(--ok); } td.bad-cell { color: var(--bad); }
.table-wrap.dist { max-width: 520px; }

/* мастер «Создать поставки» */
.steps { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; border-radius: 20px; background: #eef0f4; color: var(--muted); font-size: 13px; }
.steps span.on { background: var(--accent); color: #fff; font-weight: 600; }
.steps span.done { background: var(--ok-bg); color: var(--ok); }
.aact input.grow { min-width: 0; width: 0; }
.aact { gap: 6px; align-items: center; }
.wz-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.card.wz-foot { margin-top: 0; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.bad-text { color: var(--bad); } .ok-text { color: var(--ok); }
.wz-table td { vertical-align: top; }
.slot-box { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; display: flex; flex-direction: column; gap: 6px; }
.card.card-done { border-left: 4px solid var(--ok); }
.box-labels { margin: 6px 0 2px; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.wz-table tr.grp td { border-top: 2px solid #d5dbe6; }
.wz-table td.cl-cell { background: #fafbfd; min-width: 160px; }
.wz-table tr.row-ok td:not(.cl-cell) { background: var(--ok-bg); }
.wz-table tr.row-bad td:not(.cl-cell) { background: var(--bad-bg); }
td.nowrap { white-space: nowrap; }

/* ============================== производство ============================== */
nav .nav-sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 6px; flex: none; }
.prod-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.prod-head h2 { margin: 0; }
.subnav, .seg { display: flex; gap: 6px; flex-wrap: wrap; }
.subnav { margin-bottom: 12px; }
.subnav button, .seg button { border-radius: 20px; }
.subnav button.active, .seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fbfcfe; min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.ok .v { color: var(--ok); } .kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }
.warn-text { color: var(--warn); }
td.warn-cell { color: var(--warn); }
td.strike { text-decoration: line-through; color: var(--muted); }
tr.arch td { color: var(--muted); }
.cal-head h2 { min-width: 150px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { font-size: 12px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal .cell { min-height: 84px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; cursor: pointer; background: #fff;
             font-size: 12px; min-width: 0; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.cal .cell.empty { visibility: hidden; cursor: default; }
.cal .cell-in { display: flex; flex-direction: column; height: 100%; }
.cal .cell .n { font-weight: 700; font-size: 13px; }
.cal .cell.we .n { color: #b04a4a; }
.cal .cell .lns { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.cal .cell .ln { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .cell .pct { margin-top: auto; font-weight: 700; }
.cal .cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal .cell.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) { .cal .cell:not(.empty):hover { border-color: #9db4e6; } }
.c-ok { background: var(--ok-bg) !important; } .c-warn { background: var(--warn-bg) !important; }
.c-bad { background: var(--bad-bg) !important; } .c-plan { background: var(--accent-2) !important; }
.cal .cell.c-ok .pct { color: var(--ok); } .cal .cell.c-warn .pct { color: var(--warn); } .cal .cell.c-bad .pct { color: var(--bad); }
.cal-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.cal-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; border: 1px solid var(--line); }
.ed-t select { max-width: 100%; }
.ed-t td.c-item select { width: 100%; min-width: 180px; }
/* кнопка выбора изделия в строке плана/факта и окно выбора с фото */
.item-pick { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 220px; padding: 4px 10px 4px 4px; text-align: left; background: #fff; font-weight: 600; white-space: normal; }
.item-pick.empty { color: var(--muted); font-weight: 400; }
.ipk-img { width: 52px; height: 52px; flex: none; border-radius: 6px; background: #f3f4f6; overflow: hidden; display: inline-flex; }
.ipk-img img { width: 100%; height: 100%; object-fit: contain; }
.ipk-name { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.ipk-arrow { color: var(--muted); flex: none; }
/* филамент: кружок цвета, набор цветов, кнопка и окно выбора */
.cdot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); flex: none; vertical-align: -3px; }
.cdot.sm { width: 12px; height: 12px; vertical-align: -1px; }
.cdot.lg { width: 26px; height: 26px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 20px; font-size: 13px; background: #fff; white-space: nowrap; }
.swatch .cdot { width: 18px; height: 18px; }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: #f3f7ff; font-weight: 600; }
.mat-seg { display: flex; gap: 6px; }
.mat-seg button { min-width: 80px; }
.custom-color input[type=color] { width: 48px; height: 36px; padding: 2px; flex: none; }
.fil-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 160px; text-align: left; background: #fff; white-space: normal; }
.fil-btn.empty { color: var(--muted); }
.fil-btn .fb-name { flex: 1; min-width: 0; line-height: 1.25; }
.overlay.over-modal { z-index: 55; }
.modal.pick-modal.fpick-modal { max-width: 560px; }
/* несколько филаментов: состав изделия и расход в факте */
.use-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.use-row .fil-btn { flex: 1; min-width: 0; }
.use-row input.num { width: 84px; flex: none; }
.use-x { font-size: 15px; padding: 2px 6px; flex: none; }
.c-uses { min-width: 300px; }
.comps { min-width: 0; }
.need-line { white-space: nowrap; line-height: 1.6; }
/* детали: что печатаем в строке плана/факта */
.part-seg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.part-seg button { padding: 3px 10px; font-size: 12px; border-radius: 14px; background: #fff; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.part-seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.part-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: #eef3fb; color: var(--accent); font-size: 12px; font-weight: 600; }
.comp-row .comp-name { width: 150px; flex: none; min-width: 0; }
.wip-line { display: block; margin-top: 2px; }
/* отчёт: строки «Итого» сверху */
.rep-h { margin: 6px 0 6px; }
.rep-h.mt { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.rep-t tr.total-row td { background: #eef3fb; font-weight: 700; border-bottom: 2px solid #c9d6ea; }
.rep-t tr.sub-row td { background: #f7f9fc; font-weight: 600; }
.rep-t .it-img { width: 44px; height: 44px; }
.modal.modal-wide { max-width: 760px; }
.fpick-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; margin-bottom: 6px; text-align: left; background: #fff; white-space: normal; }
.fpick-row.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: #fafcff; }
.fpick-row .fp-name { flex: 1; min-width: 0; font-size: 15px; }
.fpick-row .fp-stock { font-weight: 600; white-space: nowrap; }
.modal.pick-modal { max-width: 820px; max-height: 88vh; display: flex; flex-direction: column; gap: 10px; }
.pick-x { font-size: 18px; padding: 2px 8px; }
.pick-q { width: 100%; }
.pick-list { overflow-y: auto; min-height: 0; }
.pick-group { font-weight: 700; margin: 6px 0 8px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.pick-tile { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; text-align: left; white-space: normal; background: #fff; min-width: 0; }
.pick-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: #fafcff; }
.pt-img { aspect-ratio: 1 / 1; border-radius: 6px; background: #f3f4f6; overflow: hidden; display: flex; }
.pt-img img { width: 100%; height: 100%; object-fit: contain; }
.pt-name { font-weight: 600; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.pt-sub { font-size: 12px; color: var(--muted); }
.ed-t td.c-del { width: 1%; }
.day-head h2 { min-width: 260px; }
.day-sum { display: flex; gap: 6px 18px; flex-wrap: wrap; padding: 8px 10px; background: #f8f9fb; border-radius: 8px; }
.acts { white-space: nowrap; }
.acts button + button { margin-left: 4px; }
.it-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.it-img { width: 36px; height: 36px; flex: none; border-radius: 6px; background: #f3f4f6; overflow: hidden; display: inline-flex; }
.it-img img { width: 100%; height: 100%; object-fit: contain; }
.form-grid.wide { grid-template-columns: 150px minmax(0, 1fr); }
.form-grid label.chk { display: flex; gap: 6px; align-items: center; }
.imp-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.imp-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.imp-row:last-child { border-bottom: 0; }
.imp-row input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }


/* ============================== мобильная версия ============================== */
.m-only { display: none !important; }
@media (max-width: 760px) {
  .d-only { display: none !important; }
  .m-only { display: inline !important; }
  html, body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  /* iPhone не увеличивает страницу при вводе, если шрифт поля не меньше 16px */
  input, select, textarea { font-size: 16px; }
  button, .btn { padding: 9px 14px; -webkit-tap-highlight-color: transparent; }
  button.sm, .btn.sm { padding: 7px 11px; font-size: 13px; }
  h2 { font-size: 16px; }

  /* шапка: магазин и статус сверху, вкладки — лентой с прокруткой пальцем */
  header .bar { padding: 8px 12px 0; gap: 8px; flex-wrap: wrap; }
  .logo { font-size: 15px; }
  .store-sel { flex: 1 1 auto; min-width: 0; max-width: none; padding: 6px 8px; }
  .conn .dot { margin: 0 2px; }
  nav { order: 10; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; gap: 6px; margin: 0 -12px; padding: 4px 12px 8px;
        scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: none; padding: 8px 14px; border-radius: 20px; background: #f1f3f7; color: var(--text); scroll-snap-align: center; }
  nav button.active { background: var(--accent); color: #fff; }

  main { padding: 10px 10px 40px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .card-head { gap: 6px 10px; }
  .row > input.grow, .row > select { min-width: 0; }
  .row > input[type=search] { flex: 1 1 100%; }
  .alert { padding: 10px; }

  /* карточки товаров — по две в ряд */
  .agrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .acard { padding: 8px; }
  .acheck { font-size: 13px; min-height: 28px; }
  .acheck input { width: 24px; height: 24px; }
  .aimg { aspect-ratio: 1 / 1; }

  /* формы — подписи над полями */
  .form-grid { grid-template-columns: 1fr; gap: 4px; }
  .form-grid label { margin-top: 6px; font-size: 13px; color: var(--muted); }

  /* таблицы-списки превращаются в карточки */
  table.mcards thead { display: none; }
  table.mcards, table.mcards tbody { display: block; }
  table.mcards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 12px;
                    border-bottom: 1px solid var(--line); }
  table.mcards tr:last-child { border-bottom: 0; }
  table.mcards td { border: 0 !important; padding: 0; text-align: left !important; min-width: 0; overflow-wrap: anywhere; }
  table.mcards td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.mcards td.c-title { grid-column: 1 / span 2; font-size: 15px; }
  table.mcards td.c-status { grid-column: 3; grid-row: 1; justify-self: end; }
  table.mcards td.c-span2 { grid-column: span 2; }
  table.mcards td.c-wide { grid-column: 1 / -1; }
  table.mcards td.c-rm { grid-column: 1 / -1; justify-self: end; }
  table.mcards td.c-rm:not(:has(button)) { display: none; }
  table.drop-t td.c-title { grid-column: 1 / -1; }

  /* распределение по кластерам: кластер — заголовок, под ним артикулы с остатком, рекомендацией и полем */
  .wz-table thead { display: none; }
  .wz-table, .wz-table tbody, .wz-table tfoot { display: block; }
  .wz-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; padding: 8px 12px;
                 border-bottom: 1px solid var(--line); align-items: end; }
  .wz-table td { border: 0 !important; padding: 0; text-align: left !important; background: none !important; min-width: 0; }
  .wz-table td.cl-cell { grid-column: 1 / -1; padding-bottom: 2px; font-size: 15px; min-width: 0; }
  .wz-table td.c-offer { grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
  .wz-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  .wz-table tr.grp { border-top: 3px solid #d5dbe6; }
  .wz-table tr.row-ok { background: var(--ok-bg); }
  .wz-table tr.row-bad { background: var(--bad-bg); }
  .wz-table tfoot tr { background: #f8f9fb; }
  .wz-table input.num { width: 100%; text-align: left; }
  .wz-table td.nowrap { white-space: normal; }

  /* таблицы коробок — карточка на каждую коробку: количества по артикулам, итог, наклейка */
  .table-wrap:has(> table.box-t) { overflow: visible; }
  table.box-t, table.box-t thead, table.box-t tbody, table.box-t tfoot { display: block; }
  table.box-t thead tr { display: flex; flex-direction: column; padding: 0; border: 0; }
  table.box-t thead:not(:has(th.art)) { display: none; }
  table.box-t thead th { display: none; }
  table.box-t thead th.art { display: block; text-align: left; white-space: normal; border: 0; border-bottom: 1px solid var(--line); }
  table.box-t thead th.art .row { justify-content: flex-start !important; }
  table.box-t tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 12px;
                   border-bottom: 1px solid var(--line); position: relative; }
  table.box-t td { border: 0 !important; padding: 0; text-align: left !important; min-width: 0; overflow-wrap: anywhere; }
  table.box-t td.sticky-col { grid-column: 1 / -1; position: static; font-weight: 600; background: none; }
  table.box-t td:empty { display: none; }
  table.box-t td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  table.box-t td.c-label { grid-column: 1 / -1; white-space: normal; }
  table.box-t td.c-label .btn { display: block; text-align: center; padding: 9px 12px; font-size: 14px; }
  table.box-t td.c-del { position: absolute; top: 6px; right: 8px; }
  table.box-t td.c-del button { font-size: 18px; padding: 4px 8px; }
  table.box-t input.num, table.box-t input.date { width: 100%; text-align: left; }
  table.box-t tfoot tr { background: #f8f9fb; }
  table.box-t thead th.art .pimg { margin: 0 0 6px; }
  table.box-t td.c-qimg { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 4px 8px; align-items: center; align-content: start; }
  table.box-t td.c-qimg::before { grid-column: 1 / -1; }
  table.box-t .td-img { display: block; }
  table.box-t .td-img .pimg { width: 52px; height: 52px; }
  .overlay.zoom { align-items: center; padding: 10px; }
  .zoom-box { max-width: 100%; border-radius: 12px; }
  .ptile { width: calc((100% - 24px) / 3); }
  .ptile .pimg { width: 100%; height: auto; aspect-ratio: 1 / 1; }
  .ptile.lg { width: calc((100% - 12px) / 2); }
  .ptile.lg .pimg { width: 100%; height: auto; }
  .ptiles.sm .ptile { width: calc((100% - 20px) / 3); }
  .ptiles.sm .ptile .pimg { width: 100%; height: auto; }
  .wz-table td.c-offer .pimg { width: 64px; height: 64px; }
  .rep-t tr.total-row { background: #eef3fb; border-bottom: 2px solid #c9d6ea; }
  .rep-t tr.sub-row { background: #f7f9fc; }
  .rep-t tr.total-row td, .rep-t tr.sub-row td { background: none; }

  /* кнопки шагов — снизу экрана, под большим пальцем */
  .wz-foot { position: sticky; bottom: 0; z-index: 6; background: var(--card); margin: 12px -12px -12px;
             padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
             border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 16px rgba(20, 25, 35, .08); }
  .card.wz-foot { margin: 0; border-radius: var(--radius); }
  .wz-foot .spacer { display: none; }
  .wz-foot .bad-text { flex: 1 0 100%; order: -1; }
  .wz-foot button { white-space: normal; }
  .wz-foot button.primary { flex: 1 1 0; }
  /* три кнопки — главная (последняя) отдельной строкой во всю ширину */
  .wz-foot:has(> button:nth-of-type(3)) > button.primary:last-of-type { flex: 1 0 100%; }
  .steps { gap: 4px; }
  .steps span { padding: 5px 10px; font-size: 12px; }
  .slot-box .row select { flex: 1 1 140px; min-width: 0; }

  /* производство */
  nav .nav-sep { margin: 6px 2px; }
  .subnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .subnav button { flex: 1 0 auto; }
  .seg { flex: 1 1 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg button { padding: 7px 10px; font-size: 13px; }
  .form-grid.wide { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .kpi { padding: 7px 9px; }
  .kpi .v { font-size: 15px; }
  .cal-head { flex-wrap: nowrap; }
  .cal-head h2 { min-width: 0; flex: 1; font-size: 15px; }
  .cal { gap: 3px; margin: 0 -4px; }
  .cal .cell { min-height: 60px; padding: 3px 3px 4px; font-size: 10.5px; border-radius: 6px; line-height: 1.3; }
  .cal .cell .n { font-size: 12px; }
  .cal .cell.sel { outline-width: 2px; }
  table.mcards tfoot { display: block; }
  table.mcards tfoot tr { background: #f8f9fb; }
  table.mcards td.c-date { grid-column: 1 / -1; color: var(--muted); }
  table.mcards td.acts { white-space: normal; display: flex; gap: 6px; flex-wrap: wrap; }
  table.mcards td.acts button { margin: 0; flex: 1 1 auto; }
  table.mcards td.c-del { grid-column: 3; justify-self: end; }
  table.jr-t td.c-title { grid-column: 1 / -1; }
  table.items-t td.c-del { display: none; }
  /* строки плана и факта — карточки: изделие во всю ширину, поля под ним */
  table.ed-t thead { display: none; }
  table.ed-t, table.ed-t tbody { display: block; }
  .table-wrap:has(> table.ed-t) { overflow: visible; }
  table.ed-t tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 12px;
                  border-bottom: 1px solid var(--line); position: relative; }
  table.ed-t tr:last-child { border-bottom: 0; }
  table.ed-t td { border: 0 !important; padding: 0; text-align: left !important; min-width: 0; }
  table.ed-t td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.ed-t td.c-item { grid-column: 1 / -1; padding-right: 36px; }
  table.ed-t td.c-item select { min-width: 0; font-weight: 600; }
  .item-pick { min-width: 0; }
  .fil-btn { min-width: 0; }
  .c-uses { min-width: 0; }
  .need-line { white-space: normal; }
  .use-row input.num, table.ed-t td .use-row input.num { width: 76px; flex: none; }
  .comp-row { flex-wrap: wrap; }
  .comp-row .comp-name { width: 100%; }
  .modal .row.fil-pick button.fil-btn { flex: 1 1 auto; width: auto; min-width: 0; }
  .swatch { font-size: 13px; padding: 6px 10px 6px 6px; }
  .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pt-name { font-size: 13px; }
  table.ed-t td.c-fil { grid-column: 1 / -1; order: 5; }
  table.ed-t td.nowrap > span.small { display: none; }
  table.ed-t td input.num { min-width: 0; }
  table.ed-t td select, table.ed-t td input.num { width: 100%; text-align: left; }
  table.ed-t td.nowrap { white-space: nowrap; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
  table.ed-t td.nowrap::before { flex: 1 0 100%; }
  table.ed-t td.nowrap input.num { flex: 1; width: auto; }
  table.ed-t td.c-del { position: absolute; top: 10px; right: 6px; width: auto; }
  table.ed-t td.c-del button { font-size: 18px; padding: 4px 8px; }
  .day-sum { font-size: 13px; }
  .day-head h2 { min-width: 0; }
  .wz-foot .foot-msg { flex: 1 0 100%; order: -1; }
  .wz-foot .foot-msg:empty { display: none; }
  .modal .fil-pick { flex-wrap: nowrap; }
  .modal .fil-pick select { min-width: 0; }
  .modal .row.fil-pick button { flex: none; }

  /* окна — снизу, как на телефоне привычно */
  .overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
  .modal .row button { flex: 1 1 0; }
  .toast { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: none; }
  .login { margin: 8vh 12px; }
}

/* безопасность */
.tg-wait { text-align: center; }
.tg-wait .tg-icon { font-size: 40px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login .link { align-self: center; }
.sec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.sec-grid > div { display: flex; flex-direction: column; gap: 6px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; font-size: 18px; padding: 10px; background: #f6f8fb; border-radius: 8px; }
table.audit-t tr.row-bad td { background: var(--bad-bg); }
@media (max-width: 760px) {
  .codes { font-size: 16px; }
  table.mcards.audit-t tr.row-bad { background: var(--bad-bg); }
}
