/* DroneCRM — светлая тема. Один акцентный цвет, мягкие границы, крупные зоны касания на телефоне. */
:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #111827; --ink2: #374151; --muted: #636a76; --line: #e6e8ec; --line2: #d5d9e0;
  --accent: #2557d6; --accent-h: #1d47b3; --accent-weak: #edf2ff; --accent-ink: #1e40af;
  --ok: #15803d; --okbg: #ecfdf3; --err: #b91c1c; --errbg: #fef2f2; --warn: #a15c07; --warnbg: #fff7e6;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --font: Inter, "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, "Roboto Mono", monospace;
  --side-w: 236px;
}
* { box-sizing: border-box; }
/* атрибут hidden скрывает всегда (правила .btn/button с display иначе перебивают его) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sub { color: var(--muted); margin: -12px 0 18px; }
h2 { font-size: 15px; font-weight: 650; margin: 26px 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
.pagehead { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin: 0; }
.pagehead .sub { margin: 2px 0 0; }

/* ---------- боковое меню (компьютер) / верхняя панель (телефон) */
.topbar { display: none; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; z-index: 40; }
.brand { color: var(--ink); font-size: 18px; font-weight: 700; padding: 18px 20px 12px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 22px; height: 22px; border-radius: 7px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8M8 4v8' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.brand b { color: var(--accent); font-weight: 700; }
.brand:hover { text-decoration: none; }
.gsearch { padding: 0 14px 10px; display: flex; gap: 6px; }
.gsearch input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); }
.side nav { flex: 1; padding: 0 10px 12px; }
.side nav a { display: block; color: var(--ink2); padding: 7px 12px; border-radius: var(--r-sm); margin: 1px 0; font-weight: 500; }
.side nav a:hover { background: #f1f3f6; text-decoration: none; color: var(--ink); }
.side nav a.on { background: var(--accent-weak); color: var(--accent-ink); font-weight: 600; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 16px 12px 4px; font-weight: 600; }
.me { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; font-size: 13px; }
.me .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.me .who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { color: var(--muted); font-size: 12px; }
.me > a { flex: none; }
main.withside { margin-left: var(--side-w); padding: 26px 32px 64px; max-width: calc(1440px + var(--side-w)); }
main.bare { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.navshade { display: none; }

/* ---------- сообщения / результат скана */
.flash { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 10px; font-weight: 500; overflow-wrap: anywhere; border: 1px solid transparent; }
.flash.ok { background: var(--okbg); color: var(--ok); border-color: #c6ecd4; }
.flash.err { background: var(--errbg); color: var(--err); border-color: #f6caca; }
.flash.warn { background: var(--warnbg); color: var(--warn); border-color: #f5ddb0; }
.scanpage .flash.result { font-size: 20px; font-weight: 650; line-height: 1.35; padding: 18px 20px 18px 62px; position: relative; border-radius: var(--r); box-shadow: 0 6px 18px rgba(16, 24, 40, .12); max-width: 760px; margin: 0 auto 14px; }
.scanpage .flash.result::before { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .25); display: flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; }
.scanpage .flash.result.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.scanpage .flash.result.ok::before { content: "✔"; }
.scanpage .flash.result.err { background: #c81e1e; color: #fff; border-color: #c81e1e; animation: shake .35s; }
.scanpage .flash.result.err::before { content: "✖"; }
.scanpage .flash.result.warn { background: #f59e0b; color: #1f1300; border-color: #f59e0b; }
.scanpage .flash.result.warn::before { content: "!"; font-weight: 800; background: rgba(0, 0, 0, .12); }
.scanpage .flash.result a { color: inherit; text-decoration: underline; }
/* баннер печати: на компьютере — подсказка (PDF печатается автоматически), на телефоне — кнопка */
.flash.job { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; }
.flash.job .jobbtn { display: none; }
@media (pointer: coarse), (max-width: 800px) {
  .flash.job .jobhint { display: none; }
  .flash.job .jobbtn { display: inline-flex; background: var(--ok); border-color: var(--ok); color: #fff; }
  .flash.job .jobbtn:hover { background: #116632; border-color: #116632; }
}
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- блоки */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side-main { grid-template-columns: minmax(0, 1fr) minmax(0, 420px); }
/* сетка полей формы: между строками — только отступ .field (14px), поля строки выровнены по низу
   (длинная подпись в две строки не сдвигает поле ввода) */
.grid:has(> .field) { row-gap: 0; }
.grid.g2 > .field, .grid.g3 > .field { display: flex; flex-direction: column; justify-content: flex-end; }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .side-main { grid-template-columns: minmax(0, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--line2); }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- таблицы */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; border-bottom: 1px solid var(--line); }
tr:hover > td { background: #f8f9fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; margin-bottom: 16px; background: var(--panel); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.tbl table { border: 0; }
@media (min-width: 801px) {
  .tbl { max-height: 78vh; }
  .tbl th { position: sticky; top: 0; z-index: 1; }
}
.list { list-style: none; margin: 0 0 16px; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.list > li { padding: 10px 14px; border-bottom: 1px solid #eef0f3; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .empty { color: var(--muted); }
/* длинный путь / команда моноширинным: переносится в любом месте, без горизонтальной прокрутки на телефоне */
.mono.path { overflow-wrap: anywhere; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; min-width: 160px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f1f3f6; color: #374151; white-space: nowrap; line-height: 1.5; }
.b-new, .b-planned, .b-open, .b-draft { background: #f1f3f6; color: #374151; }
.b-in_work, .b-production, .b-closed { background: #e8efff; color: #1e40af; }
.b-ready, .b-verified, .b-done { background: #e3f6ea; color: #166534; }
.b-packed, .b-in_kit { background: #f1ebff; color: #5b21b6; }
.b-shipped, .b-partial_shipped { background: #e0f4f6; color: #0f5f6e; }
.b-rework { background: #fff1d6; color: #8a4b05; }
.b-scrapped, .b-cancelled, .b-void { background: #fde8e8; color: #9b1c1c; }

/* ---------- формы и кнопки */
form.inline { display: inline; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 0 0 auto; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
/* флажок с подписью: длинный текст переносится рядом с флажком, а не под него */
label.chk { display: flex; align-items: flex-start; gap: 8px; width: fit-content; max-width: 100%; color: var(--ink); font-size: 14px; font-weight: 400; cursor: pointer; }
label.chk > input { flex: none; margin: 2px 0 0; }
label.chk.inl { display: inline-flex; margin: 0 14px 6px 0; }
td > label.chk, label.chk.nowrap { white-space: nowrap; margin: 0; }
::placeholder { color: var(--muted); opacity: 1; }
.field { margin-bottom: 14px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
input, select, textarea { font: inherit; padding: 8px 11px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: #fff; color: var(--ink); max-width: 100%; min-height: 38px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 87, 214, .18); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; vertical-align: middle; accent-color: var(--accent); }
input[type=color] { padding: 2px; width: 60px; }
.w100 { width: 100%; }
textarea { width: 100%; min-height: 76px; }
.btn, button { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 16px; border-radius: var(--r-sm); border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap; text-align: center; line-height: 1.3; transition: background .12s, border-color .12s; }
.btn:hover, button:hover { background: var(--accent-h); border-color: var(--accent-h); text-decoration: none; }
.btn:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid rgba(37, 87, 214, .35); outline-offset: 1px; }
.btn.sec, button.sec { background: #fff; color: var(--ink2); border-color: var(--line2); }
.btn.sec:hover, button.sec:hover { background: #f5f7fa; border-color: #c4c9d2; }
.btn.danger, button.danger { background: #fff; color: var(--err); border-color: #f0b4b4; }
.btn.danger:hover, button.danger:hover { background: var(--errbg); border-color: #e59a9a; }
.btn.ok, button.ok { background: var(--ok); border-color: var(--ok); }
.btn.ok:hover, button.ok:hover { background: #116632; border-color: #116632; }
.btn.sm, button.sm { min-height: 30px; padding: 3px 11px; font-size: 13px; font-weight: 500; }
.btn.big, button.big { min-height: 48px; padding: 10px 24px; font-size: 16px; }
/* тихая кнопка опасного действия в строке таблицы (рамка появляется при наведении/фокусе) */
.btn.ghost, button.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover, button.ghost:hover, .btn.ghost:focus-visible, button.ghost:focus-visible { border-color: #e59a9a; background: var(--errbg); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.right { margin-left: auto; }
.sending { opacity: .6; pointer-events: none; }

/* ---------- «Ещё» */
details.more { margin: 0 0 16px; }
details.more > summary { display: inline-flex; align-items: center; min-height: 38px; padding: 7px 16px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: #fff; color: var(--ink2); font-weight: 600; list-style: none; user-select: none; }
details.more > summary:hover { background: #f5f7fa; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 7px; height: 7px; margin-left: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-2px) rotate(45deg); }
details.more[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
details.more > .body { margin-top: 10px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
details.more > .body .actions { margin: 0; }
details.more > .body h3 { margin: 0 0 6px; }
/* основное действие страницы, раскрывающее форму (например, «+ Новый комплект») */
details.more.primary > summary { background: var(--accent); border-color: var(--accent); color: #fff; }
details.more.primary > summary:hover { background: var(--accent-h); border-color: var(--accent-h); }
details.more.primary > summary::after { border-color: #fff; }
details summary { cursor: pointer; color: var(--accent); }
details.plain > summary { color: var(--accent); font-weight: 500; margin: 6px 0; }
/* роли: карточка-раскрывашка */
details.card > summary { list-style: none; font-weight: 600; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--muted); }
details.card[open] > summary::before { content: "▾"; }
details.card > summary .muted { font-weight: 400; }
details.card[open] > summary { margin-bottom: 12px; }
details.card { padding-top: 14px; padding-bottom: 14px; margin-bottom: 10px; }
/* строка редактирования в таблице: открывается ссылкой (app.js) или по #якорю */
tr.editrow:not(.open):not(:target) { display: none; }
tr.editrow > td { background: #fafbfc; }
/* постраничная навигация */
.pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.pager .gap { color: var(--muted); padding: 0 2px; }

/* ---------- рабочее место (скан) */
.ws { max-width: 760px; margin: 0 auto; }
.ws > h1 { justify-content: center; text-align: center; }
.ws > .sub { text-align: center; }
.scanbox { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; box-shadow: 0 4px 16px rgba(16, 24, 40, .06); }
.scanbox.check { border: 2px solid #f0b54a; background: #fffdf7; }
.scanbox .ttl { font-weight: 650; font-size: 15px; margin-bottom: 10px; }
.scanbox.check .ttl { color: var(--warn); }
.scanrow { display: flex; gap: 10px; align-items: stretch; }
.scanrow > input { flex: 1; min-width: 0; }
.scanbox input.scan { font-size: 22px; padding: 12px 16px; min-height: 60px; width: 100%; font-family: var(--mono); border-radius: 12px; border: 2px solid var(--line2); text-overflow: ellipsis; }
/* подсказка в поле — обычным шрифтом (моноширинная кириллица широкая и обрезается на телефоне) */
.scanbox input.scan::placeholder { font-family: var(--font); font-size: 17px; font-weight: 400; }
.scanbox input.scan:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 87, 214, .15); }
.scanbox .hint { color: var(--muted); margin-top: 8px; font-size: 13px; }
.scanbox .opts { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.cambtn { flex: 0 0 auto; min-width: 60px; padding: 0 16px; border-radius: 12px; }
.cambtn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gsearch .cambtn { min-width: 38px; min-height: 38px; padding: 0 8px; border-radius: var(--r-sm); background: #fff; color: var(--ink2); border-color: var(--line2); }
.gsearch .cambtn svg { width: 20px; height: 20px; }
.counter { font-size: 34px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counter small { font-size: 16px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.bar .grow { flex: 1; }
.seg { display: inline-flex; background: #f1f3f6; border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { margin: 0; display: flex; align-items: center; gap: 6px; padding: 8px 16px; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--ink2); border-radius: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label.on { background: var(--ok); color: #fff; box-shadow: var(--shadow); }
.seg label.fail.on { background: #c81e1e; color: #fff; }
/* нейтральный выбор (не «Годен / Не прошёл»): выбранный пункт — акцентным цветом, зелёный только для ОТК */
.seg.accent label.on { background: var(--accent); color: #fff; }
.seg.accent label.fail.on { background: #c81e1e; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.chipnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ws .chipnav { justify-content: center; }
.chipnav a { padding: 7px 14px; border: 1px solid var(--line2); border-radius: 999px; background: #fff; color: var(--ink2); font-weight: 500; display: inline-flex; align-items: center; }
.chipnav a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chipnav a:hover { text-decoration: none; border-color: #c4c9d2; }
.chipnav a.on:hover { border-color: var(--accent); }
/* фильтр списка по статусу — светлее вкладок раздела и основных кнопок */
.chipnav.filter a { padding: 5px 13px; font-size: 13.5px; }
.chipnav.filter a.on { background: var(--accent-weak); color: var(--accent-ink); border-color: #c3d2fb; font-weight: 600; }
.lastcard { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.lastcard .sn { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.big-result { font-size: 20px; padding: 14px 16px; }
.progress { height: 6px; background: #eceef2; border-radius: 3px; overflow: hidden; min-width: 80px; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.labelprev { border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; max-width: 100%; }
.warnlist { color: var(--warn); margin: 6px 0; padding-left: 18px; }
.chips a, .chips span { margin-right: 6px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; margin-bottom: -1px; }
.tabs a.on { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .cnt { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 9px; background: #f59e0b; color: #1f1300; font-size: 11px; text-align: center; font-weight: 700; }
/* лента с прокруткой: затенённый край показывает, что дальше есть пункты (классы ставит app.js) */
.tabs.can-r, .chipnav.can-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.tabs.can-l, .chipnav.can-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px); mask-image: linear-gradient(90deg, transparent, #000 32px); }
.tabs.can-l.can-r, .chipnav.can-l.can-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
/* столбец действий в справочниках всегда виден (длинные таблицы прокручиваются вбок) */
@media (min-width: 801px) {
  table.sticky-act th.act, table.sticky-act td.act { position: sticky; right: 0; background: var(--panel); box-shadow: -1px 0 0 var(--line); white-space: nowrap; }
  table.sticky-act th.act { background: #fafbfc; z-index: 2; }
  table.sticky-act tr:hover > td.act { background: #f8f9fb; }
}
.stage-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.pill-ok { color: var(--ok); font-weight: 600; }
.pill-err { color: var(--err); font-weight: 600; }

/* ---------- окно камеры */
.camov { position: fixed; inset: 0; background: rgba(17, 24, 39, .94); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; color: #fff; }
.camov video { width: 100%; max-width: 640px; max-height: 68vh; border-radius: 14px; background: #000; object-fit: cover; display: block; }
.camov .frame { position: relative; width: 100%; max-width: 640px; }
.camov .frame::after { content: ""; position: absolute; left: 8%; right: 8%; top: 28%; bottom: 28%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; pointer-events: none; }
.camov .msg { margin: 16px 0; font-size: 17px; text-align: center; max-width: 520px; }
.camov .choices { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 480px; max-height: 60vh; overflow: auto; }
.camov .choices button { font-size: 18px; min-height: 50px; font-family: var(--mono); background: #fff; color: var(--ink); border-color: #fff; flex: none; }
.camov .choices button.all { background: var(--accent); color: #fff; border-color: var(--accent); }
.camov .choices button.grp { font-family: var(--font); font-weight: 650; }
.camov .choices button small { font-family: var(--font); font-size: 14px; font-weight: 500; opacity: .85; }
.camov .btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.camov .btns button { min-height: 48px; min-width: 140px; font-size: 16px; }
.camov .spin { width: 44px; height: 44px; border: 4px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- телефон */
@media (max-width: 800px) {
  body { font-size: 15px; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 4px; height: 56px; padding: 0 6px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
  .topbar .brand { padding: 0 6px; font-size: 17px; }
  .topbar .brand::before { width: 20px; height: 20px; }
  .topbar button { background: transparent; border: 0; color: var(--ink); min-width: 44px; min-height: 44px; padding: 0; font-size: 22px; border-radius: 10px; }
  .topbar button:hover { background: #f1f3f6; }
  .topbar .ttl { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: right; padding-right: 8px; }
  .side { width: 290px; max-width: 86vw; transform: translateX(-100%); transition: transform .2s ease, box-shadow .2s; border-right: 0; visibility: hidden; }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(16, 24, 40, .18); }
  body.nav-open .navshade { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 35; }
  .side nav a { padding: 11px 12px; font-size: 15px; }
  main.withside { margin-left: 0; padding: 14px 14px 64px; }
  h1 { font-size: 20px; }
  .sub { margin-bottom: 14px; }
  .g2, .g3, .g4, .side-main { grid-template-columns: minmax(0, 1fr); }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .v { font-size: 22px; }
  .card { padding: 14px 16px; }
  .kv { grid-template-columns: 112px minmax(0, 1fr); }
  input, select, textarea { font-size: 16px; }
  input:not([type=checkbox]):not([type=radio]):not([type=color]), select { min-height: 44px; }
  .btn, button { min-height: 44px; padding: 10px 16px; }
  .btn.sm, button.sm { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .actions > .btn, .actions > button, .actions > form { flex: 1 1 auto; }
  .actions > form > button { width: 100%; }
  /* зоны касания не меньше 44px */
  details.plain > summary { padding: 11px 0; margin: 0; }
  details.card > summary { min-height: 44px; align-items: center; margin: -10px 0; }
  details.card[open] > summary { margin-bottom: 4px; }
  .gsearch .cambtn { min-width: 44px; min-height: 44px; }
  .me { padding-top: 4px; padding-bottom: 4px; }
  .me > a, .me .who { min-height: 44px; justify-content: center; }
  .me > a { display: inline-flex; align-items: center; padding: 0 4px; }
  .side .me .who { align-items: stretch; }
  label.chk { min-height: 44px; align-items: center; margin-bottom: 0; }
  label.chk > input[type=checkbox], label.chk > input[type=radio] { width: 22px; height: 22px; margin: 0; }
  label.chk.inl { margin-bottom: 4px; }
  .btn.big, button.big { width: 100%; min-height: 54px; }
  details.more > summary { min-height: 44px; padding: 10px 16px; }
  details.more > .body { padding: 14px; }
  details.more > .body .btn, details.more > .body button:not(.sm) { width: 100%; }
  details.more > .body form.inline { display: block; }
  .row > * { flex: 1 1 140px; min-width: 0; }
  .row > div > select, .row > div > input:not([type=checkbox]):not([type=radio]) { width: 100% !important; }
  .row > button, .row > .btn { flex: 0 0 auto; }
  .scanbox { padding: 12px; border-radius: 14px; }
  .scanbox input.scan { font-size: 20px; padding: 10px 12px; min-height: 60px; }
  .scanbox input.scan::placeholder { font-size: 16px; }
  .cambtn { min-width: 64px; }
  .scanpage .flash.result { font-size: 18px; padding: 16px 16px 16px 58px; }
  .tabs a { padding: 12px 12px; }
  .chipnav, .ws .chipnav { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; margin: 0 -14px 12px; padding: 0 14px 4px; scrollbar-width: none; }
  .chipnav::-webkit-scrollbar { display: none; }
  .chipnav a { padding: 10px 16px; white-space: nowrap; flex: 0 0 auto; }
  .chipnav.filter a { padding: 10px 14px; font-size: 14px; min-height: 44px; }
  /* выбор этапа (этап ещё не выбран): все этапы видны — по одному крупному пункту в строке */
  .chipnav.pick, .ws .chipnav.pick { flex-direction: column; flex-wrap: nowrap; overflow: visible; margin: 0 0 14px; padding: 0; }
  .chipnav.pick a { justify-content: flex-start; padding: 14px 16px; font-size: 16px; white-space: normal; border-radius: 12px; }
  .list > li { row-gap: 4px; }
  .list .grow { flex: 1 1 100%; }
  .seg { display: flex; width: 100%; }
  .seg label { flex: 1; justify-content: center; padding: 12px; font-size: 16px; }
  .counter { font-size: 30px; }
  /* таблицы рабочих мест -> карточки */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr.hd { display: none; }
  table.cards tr { border-bottom: 1px solid #eef0f3; padding: 10px 14px; }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 1px 0; text-align: left !important; overflow-wrap: anywhere; }
  table.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 13px; }
  table.cards td:empty { display: none; }
  table.cards td.num[data-l] { display: inline-block; width: auto; margin-right: 16px; vertical-align: top; }
  table.cards td.num[data-l] .progress { width: 90px; }
  table.cards td.num[data-l]:empty { display: none; }
  .grid > .preview { order: -1; }
  h1 a.muted { font-weight: 500; }
  table.cards td:first-child { font-size: 16px; font-weight: 600; }
  table.cards td.act { margin-top: 6px; }
  /* флажок выбора строки — слева от заголовка карточки */
  table.cards td.sel { float: left; width: auto; margin: 0 12px 0 0; padding: 2px 0 0; }
  table.cards td.sel input { width: 22px; height: 22px; }
  table.cards td.sel + td { font-size: 16px; font-weight: 600; }
  /* справочник на телефоне: название + 2 поля + действия */
  table.cards.compact td:nth-child(n+4):not(.act) { display: none; }
  /* позиции заказа: поля во всю ширину, подписи над полями */
  #items input:not([type=checkbox]):not([type=radio]), #items select { width: 100% !important; }
  #items td[data-l]::before { display: block; margin-bottom: 2px; }
  #items td { padding: 3px 0; }
  table.cards tr:hover > td { background: none; }
}
@media (max-width: 800px) and (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}
@media (hover: none) { tr:hover > td { background: none; } }
@media print { .side, .topbar, .wsbar, .tabbar, .viewas, .actions, .flash, form, details.more { display: none !important; } main.withside, main.wsonly { margin: 0; } }
.scanrow > textarea { flex: 1; min-width: 0; }
.scanrow:has(> textarea) { align-items: flex-start; }
.scanrow > textarea + .cambtn { min-height: 52px; }
@media (min-width: 801px) { .grid > .preview { position: sticky; top: 16px; align-self: start; } }

/* ======================================================================= рабочие места ролей
   Классы — только на header/main/блоках (не на body: app.js сбрасывает body.className при подмене страницы). */
:root { --amber: #8a4b05; --amberbg: #fff6dd; --amberline: #f3d08a; --amberdot: #f59e0b; }

/* ---------- минимальный режим: верхняя полоса вместо бокового меню */
.wsbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 4px 14px; min-height: 56px; padding: 4px 20px; background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.wsbar .brand { padding: 0; font-size: 17px; flex: none; }
.wsbar .wsttl { flex: 1; min-width: 0; font-weight: 650; font-size: 16px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 14px; border-left: 1px solid var(--line); line-height: 28px; }
.wsbar .who, .topbar .who { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; justify-content: center; color: var(--ink2); font-weight: 500; max-width: 240px; flex: none; }
.wsbar .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsbar .who svg, .topbar .who svg, .topbar .ico svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wsbar .who:hover, .wsbar .out:hover { text-decoration: none; color: var(--ink); }
.wsbar .out, .topbar .out { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; font-weight: 500; flex: none; }
main.wsonly { max-width: 920px; margin: 0 auto; padding: 20px 24px 64px; }
/* выход, профиль и поиск в верхней полосе телефона — только в режиме нижней панели вкладок */
.topbar .out, .topbar .ico, .topbar .who { display: none; }

/* ---------- нижняя панель вкладок (2–4 пункта меню) — только на телефоне */
.tabbar { display: none; }

/* ---------- «Смотреть как роль»: закреплённая янтарная полоса */
.viewas { position: sticky; top: 0; z-index: 29; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; margin: -26px -32px 18px; background: var(--amberbg); border-bottom: 1px solid var(--amberline); color: var(--amber); box-shadow: 0 2px 8px rgba(138, 75, 5, .08); }
.viewas .va-t { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; flex: 1 1 260px; flex-wrap: wrap; }
.viewas .va-t svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viewas .va-t small { font-weight: 500; opacity: .85; font-size: 12.5px; }
.viewas form { display: flex; gap: 6px; align-items: center; margin: 0; }
.viewas select { min-height: 34px; padding: 4px 8px; border-color: var(--amberline); background: #fff; max-width: 220px; }
.viewas button { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.viewas button.sec { border-color: var(--amberline); color: var(--amber); }
.viewas button.exit { background: var(--amber); border-color: var(--amber); color: #fff; }
.viewas button.exit:hover { background: #6d3b04; border-color: #6d3b04; }
.viewas .va-m, .viewas .va-short { display: none; }
main.wsonly > .viewas { margin: -20px -24px 16px; top: 56px; }
/* селектор «Смотреть как» в боковом меню администратора */
.vaform { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.vaform label { margin-bottom: 4px; }
.vaform .row { flex-wrap: nowrap; gap: 6px; }
.vaform select { flex: 1; min-width: 0; min-height: 36px; padding: 6px 8px; }
.vaform button { flex: none; min-height: 36px; padding: 4px 12px; background: #fff; color: var(--ink2); border-color: var(--line2); text-transform: none; letter-spacing: 0; font-size: 13px; }
.vaform button:hover { background: #f5f7fa; border-color: #c4c9d2; }

/* ---------- станция /ws */
.station { max-width: 880px; margin: 0 auto; }
.station > h1 { margin-bottom: 8px; }
.st-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; background: #eef0f4; color: var(--ink2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.today { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; color: var(--muted); font-size: 13.5px; }
.today .lbl { font-weight: 600; color: var(--ink2); }
.today b { color: var(--ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 2px; }
.qtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.qtile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-height: 92px; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); transition: border-color .12s, background .12s; }
.qtile:hover { text-decoration: none; border-color: #c4c9d2; }
.qtile .t { font-weight: 600; color: var(--ink2); font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; }
.qtile .v { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.qtile .v small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.qtile .s { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.qtile.on { border-color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1px var(--accent); }
.qtile.on .t { color: var(--accent-ink); }
.badge-warn { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #fde7b8; color: var(--amber); font-weight: 600; font-size: 12px; white-space: nowrap; }
.rw-txt { color: var(--amber); font-weight: 500; }
.alertbar, .hintbar { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--r-sm); font-weight: 500; overflow-wrap: anywhere; }
.alertbar { background: var(--amberbg); border: 1px solid var(--amberline); color: var(--amber); }
.alertbar::before { content: "!"; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--amberdot); color: #1f1300; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.alertbar .txt, .hintbar .txt { flex: 1 1 220px; min-width: 0; }
.alertbar .mono { font-weight: 650; color: #5c3203; }
.alertbar.err { background: var(--errbg); border-color: #f6caca; color: var(--err); }
.alertbar.err::before { background: #f3a1a1; color: #4c0808; }
.alertbar.err .mono { color: var(--err); }
.hintbar { background: var(--accent-weak); border: 1px solid #c3d2fb; color: var(--accent-ink); }
.hintbar .btn { flex: none; }
.qhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.qhead .t { font-size: 16px; font-weight: 650; }
.qhead .n { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.qhead .s { color: var(--muted); font-size: 13px; }
.station h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.station h2 .n { color: var(--muted); font-weight: 600; }
.qc-note { flex: 1 1 220px; min-width: 0; }
.qc-note input { width: 100%; }
.lastcard { padding: 12px 16px; gap: 4px 12px; }
.lastcard .meta { flex: 1 1 100%; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.lastcard .lbl { flex: 1 1 100%; font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.list > li.queue { gap: 8px 14px; }
.queue .qi { flex: 1 1 260px; min-width: 0; }
.queue .qt { font-weight: 600; overflow-wrap: anywhere; }
.queue .qs { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.queue .qs b { color: var(--ink2); }
.queue .qa { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
.queue .qa form { margin: 0; }
.list > li.more-row { color: var(--muted); font-size: 13px; }
.note-qc { color: var(--amber); background: var(--amberbg); border-radius: 6px; padding: 1px 8px; font-size: 13px; overflow-wrap: anywhere; }
details.rework > summary { border-color: var(--amberline); color: var(--amber); background: var(--amberbg); }
details.more > .list { margin: 10px 0 0; }
.box { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.box .bi { flex: 1 1 220px; min-width: 0; }
.box .bc { font-family: var(--mono); font-weight: 650; font-size: 16px; }
.box .progress { height: 8px; max-width: 260px; }
.box .ba { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.box .ba form { margin: 0; }
.stiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stiles .stat { padding: 12px 14px; }
.stiles .stat .v { font-size: 24px; }
.stiles .stat.zero .v { color: #a3a9b3; }
.stiles .stat.hot { border-color: var(--amberline); background: #fffcf3; }
.otherq { margin-top: 22px; }
.otherq > h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.otherq details.more > summary .n { margin-left: 8px; color: var(--muted); font-weight: 600; }

/* ---------- цепочка «Сборка → Прошивка → ОТК → Упаковка → Склад → Отгружено» */
.pipe { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 6px; margin-bottom: 16px; }
.pipe .step { position: relative; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px 9px; color: inherit; box-shadow: var(--shadow); }
a.step:hover { text-decoration: none; border-color: #c4c9d2; }
.pipe .step .t { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe .step .t .stage-dot { margin-right: 0; flex: none; }
.pipe .step .v { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.pipe .step.zero .v { color: #a3a9b3; }
.pipe .step.rw { background: var(--amberbg); border-color: var(--amberline); }
.pipe .step.rw .t { color: var(--amber); }
.pipe .step.done .v { color: var(--ok); }
.pipe .step .x { display: block; font-size: 11.5px; color: var(--err); font-weight: 600; }

/* ---------- «Поток» начальника, цепочка заказа, матрица покрытия */
.flowtbl th, .flowtbl td { text-align: center; white-space: nowrap; }
.flowtbl th:first-child, .flowtbl td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; box-shadow: 1px 0 0 var(--line); }
.flowtbl th:first-child { background: #fafbfc; z-index: 3; }
.flowtbl th { white-space: normal; min-width: 76px; vertical-align: bottom; }
.flowtbl td .n { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.flowtbl td .n.zero { color: #b0b5be; font-weight: 500; }
.flowtbl td .x { display: block; font-size: 11.5px; color: var(--err); font-weight: 600; }
.flowtbl td .who { display: block; font-size: 11px; color: var(--muted); white-space: normal; overflow-wrap: anywhere; max-width: 130px; margin: 2px auto 0; line-height: 1.3; }
.flowtbl td.na { color: #c4c9d2; }
.flowtbl tr.tot td { background: #fafbfc; font-weight: 700; }
.flowtbl th.grp, .flowtbl td.grp { border-left: 1px solid var(--line); }
.covtbl td { min-width: 120px; font-size: 13px; }
.covtbl td.cov-ok { background: #f2fbf5; }
.covtbl td.cov-warn { background: #fff8e6; }
.covtbl td.cov-none { background: #fdf0f0; color: var(--err); font-weight: 600; }
.covtbl td.cov-na { color: #b0b5be; text-align: center; }
.covtbl .rl { display: inline-block; margin: 1px 4px 1px 0; padding: 1px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink2); white-space: nowrap; }
.covtbl a.rl:hover { text-decoration: none; border-color: var(--accent); }
.covtbl .rl.idle { color: var(--muted); border-style: dashed; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; border: 1px solid var(--line2); }
.legend .l-ok { background: #e3f6ea; } .legend .l-warn { background: #fde7b8; } .legend .l-none { background: #fbd5d5; }

/* ---------- карточка роли: группы флажков */
.fset { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px 6px; margin: 0; min-width: 0; }
.fset > legend { font-size: 12.5px; font-weight: 650; color: var(--ink2); padding: 0 6px; margin-left: -6px; }
.chkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 14px; transition: opacity .12s; }
.chkgrid.off { opacity: .45; }
.chkgrid label.chk { margin-bottom: 6px; }
label.chk.dis { color: var(--muted); cursor: not-allowed; }
label.chk .why { display: block; font-size: 11.5px; color: var(--muted); }
label.chk.all { font-weight: 600; margin-bottom: 8px; }
.permgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px; margin: 6px 0 12px; }
.permgrid .grp { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 4px 0 6px; }
.rolemeta { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.rolefoot { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rolefoot form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.rolefoot select { max-width: 300px; }
.wsgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wsgrid .wide { grid-column: 1 / -1; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.suggest form { margin: 0; }

/* ---------- /bulk: блок группы очереди и одна операция */
.bulk .grpbox { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 14px; border-radius: var(--r-sm); background: var(--accent-weak); border: 1px solid #c3d2fb; color: var(--accent-ink); font-weight: 600; margin-bottom: 14px; }
.bulk .opone { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-weight: 650; margin-bottom: 14px; }
.backlink { display: inline-flex; align-items: center; min-height: 32px; margin: -6px 0 10px; font-weight: 500; }

/* ---------- телефон: рабочие места */
@media (max-width: 800px) {
  .wsbar { padding: 4px 6px 4px 12px; gap: 6px; }
  .wsbar .wsttl { padding-left: 10px; font-size: 15px; }
  main.wsonly { padding: 12px 16px 64px; }
  main.wsonly > .viewas { margin: -12px -16px 12px; }
  /* телефон: одна строка «👁 Просмотр: [роль ▾] [Выйти]» — полоса закреплена и не съедает экран */
  .viewas { margin: -14px -14px 12px; top: 56px; padding: 6px 10px; flex-wrap: nowrap; gap: 6px; }
  .viewas .va-t { flex: none; gap: 6px; font-size: 13px; }
  .viewas .va-t small, .viewas .va-l, .viewas .va-long, .viewas .vasel button { display: none; }
  .viewas .va-m, .viewas .va-short { display: inline; }
  .viewas form.vasel { flex: 1 1 auto; min-width: 0; }
  .viewas select { flex: 1; min-width: 0; max-width: none; min-height: 44px; font-size: 15px; }
  .viewas button { min-height: 44px; }
  .viewas form.vaexit { flex: 0 0 auto; }
  .topbar.tb [data-navtoggle] { display: none; }
  .topbar.tb { padding-left: 10px; }
  .topbar.tb .out, .topbar.tb .ico, .topbar.tb .who { display: inline-flex; }
  .topbar .ico { align-items: center; justify-content: center; min-width: 44px; min-height: 44px; color: var(--ink2); border-radius: 10px; }
  .topbar .who { max-width: none; border-radius: 10px; }
  .topbar .who span { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .98); border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); backdrop-filter: blur(8px); }
  .tabbar a { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 2px; border-radius: 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
  .tabbar a::before { content: ""; width: 26px; height: 4px; border-radius: 2px; background: transparent; margin-bottom: 6px; }
  .tabbar a.on { color: var(--accent-ink); background: var(--accent-weak); }
  .tabbar a.on::before { background: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  main.withtabbar { padding-bottom: 88px; }
  .qtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .qtile { min-height: 96px; padding: 10px 12px; }
  .qtile .v { font-size: 28px; }
  .stiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .queue .qa { flex: 1 1 100%; }
  .queue .qa > a, .queue .qa > form { flex: 1 1 auto; }
  .queue .qa button, .queue .qa .btn { width: 100%; white-space: normal; }
  .box .ba { flex: 1 1 100%; }
  .box .ba > form, .box .ba > a.btn { flex: 1 1 auto; }
  .box .ba button { width: 100%; white-space: normal; }
  .alertbar .btn, .hintbar .btn { width: 100%; }
  .pipe { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipe .step { padding: 7px 10px; }
  .pipe .step .v { font-size: 19px; }
  .rolefoot form, .rolefoot select { width: 100%; max-width: none; }
  .rolefoot form button { flex: 1 1 auto; }
  .chkgrid, .permgrid, .wsgrid { grid-template-columns: minmax(0, 1fr); }
  .fset { padding: 8px 12px 4px; }
  .lastcard .sn { font-size: 18px; }
  /* «Поток» и цепочка заказа на телефоне: узкий закреплённый столбец категории, без подписей ролей */
  .flowtbl th:first-child, .flowtbl td:first-child { white-space: normal; min-width: 96px; max-width: 120px; font-size: 13px; }
  .flowtbl td .who { display: none; }
  details.card > summary { flex-wrap: wrap; row-gap: 2px; }
  details.card > summary .rolemeta { flex: 1 1 100%; padding-left: 16px; }
  .flowtbl th, .flowtbl td { padding: 8px 8px; }
}
@media (max-width: 480px) {
  .wsbar .brand span { display: none; }
  .wsbar .wsttl { border-left: 0; padding-left: 2px; }
  .wsbar .who span { display: none; }
}

/* ======================================================================= v3: облёт, ремонт, массовые действия на /ws, склады */
:root { --rep: #9a3412; --repbg: #fff1e7; --repline: #f6c9a8; }
.b-repair, .b-received, .b-in_repair { background: var(--repbg); color: var(--rep); }
.b-checking { background: #e8efff; color: #1e40af; }
.b-in_transit { background: #e0f4f6; color: #0f5f6e; }
.b-accepted { background: #e3f6ea; color: #166534; }
.b-rejected { background: #fde8e8; color: #9b1c1c; }
/* кнопка камеры у полей сканирования внутри раскрывашек не растягивается на всю ширину (телефон) */
details.more > .body .scanrow > .cambtn, .mass .scanrow > .cambtn { width: auto; flex: 0 0 auto; }

/* ---------- группы очереди станции: ремонт — янтарная полоса слева */
.list > li.queue.grp-rep { box-shadow: inset 3px 0 0 #f59e0b; }
.queue .qt .badge { vertical-align: 1px; }
.queue .qs .rep-n { color: var(--rep); }

/* ---------- панель массового действия (/ws, mass): заголовок-полоса + тело с итогом, формами и подтверждением */
details.mass { margin: 0 0 18px; scroll-margin-top: 124px; }
details.mass > summary { display: flex; width: 100%; min-height: 46px; padding: 10px 16px; border-radius: var(--r) var(--r) 0 0; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
details.mass > summary:hover { background: var(--accent-h); }
details.mass > summary::after { border-color: #fff; margin-left: auto; flex: none; }
details.mass:not([open]) > summary { border-radius: var(--r); }
.mass-t { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; padding-right: 10px; }
.mass-k { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 999px; background: rgba(255, 255, 255, .2); font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
details.mass > .body { margin-top: 0; border-top: 0; border-color: #c3d2fb; border-radius: 0 0 var(--r) var(--r); box-shadow: 0 6px 18px rgba(37, 87, 214, .08); gap: 14px; }
.mass-sum { display: flex; flex-wrap: wrap; gap: 8px; }
.mass-sum .ms { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 14px; border-radius: 999px; background: #f1f3f6; color: var(--ink2); font-weight: 600; font-size: 14px; }
.mass-sum .ms b { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mass-sum .ms.ok { background: var(--okbg); color: var(--ok); }
.mass-sum .ms.fail { background: var(--errbg); color: var(--err); }
.mass-sum .ms.skip { background: #f1f3f6; color: var(--muted); }
.mass-note { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.mass-skip > summary, .mass-list > summary { margin: 0; }
.mass-reasons { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.mass-reasons li { display: flex; gap: 12px; justify-content: space-between; padding: 7px 12px; border-bottom: 1px solid #eef0f3; font-size: 13.5px; }
.mass-reasons li:last-child { border-bottom: 0; }
.mass-reasons li b { font-variant-numeric: tabular-nums; }
.mass-rows { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; }
.mass-reasons + .mass-rows { margin-top: 8px; }
.mass-rows li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding: 6px 12px; border-bottom: 1px solid #eef0f3; }
.mass-rows li:last-child { border-bottom: 0; }
.mass-rows li .mono { font-weight: 600; }
.mass-rows li .msg { margin-left: auto; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.mass-rows li.r-fail { background: var(--errbg); }
.mass-rows li.r-fail .msg { color: var(--err); font-weight: 600; }
.mass-rows li.more-row { color: var(--muted); }
/* «Есть не прошедшие» */
.mass-fail { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid #f6caca; border-radius: var(--r-sm); background: #fffafa; }
.mass-fail label { margin: 0; }
.mass-ft { font-weight: 650; color: var(--err); }
.mass-ft .muted { font-weight: 400; }
.mass input.scan { font-size: 18px; min-height: 52px; font-family: var(--mono); border: 2px solid var(--line2); border-radius: 10px; padding: 8px 12px; width: 100%; }
.mass input.scan::placeholder { font-family: var(--font); font-size: 15px; }
.mass input.scan:focus { border-color: var(--accent); }
.mass .scanrow > .cambtn { min-height: 52px; border-radius: 10px; }
.mass-failrows { display: flex; flex-direction: column; gap: 6px; }
.mass-failrows .fr { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; padding: 6px 8px 6px 12px; background: var(--errbg); border-radius: var(--r-sm); }
.mass-failrows .fr .mono { font-weight: 650; color: var(--err); flex: 0 0 auto; }
.mass-failrows .fr input { flex: 1 1 200px; min-width: 0; }
.mass .g2f { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; align-items: start; }
.mass .g2f input { width: 100%; }
.mass .g2f details.plain > summary { margin: 22px 0 4px; }
.mass-fail > button, .mass-work > button { align-self: flex-start; }
.mass-work { display: flex; flex-direction: column; gap: 6px; }
.mass-work label, .mass-wh label { margin: 0 0 4px; }
.mass-range { display: flex; flex-direction: column; gap: 10px; }
.mass-step { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-weight: 600; }
.mass-from { padding: 2px 10px; border-radius: 999px; background: var(--accent-weak); color: var(--accent-ink); font-weight: 500; }
.mass-confirm { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mass-confirm > button.ok { flex: 1 1 260px; white-space: normal; }
.mass-confirm > label.chk { flex: 1 1 100%; }
.mass-block { margin: 0; }
/* строка вместо основной формы скана при открытой панели */
.massbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 14px; margin-bottom: 14px; border: 1px dashed #c3d2fb; border-radius: var(--r-sm); background: #fafcff; color: var(--accent-ink); font-weight: 500; }
.massbar .txt { flex: 1 1 220px; min-width: 0; }
/* диапазон SN под очередью */
details.range .row { flex-wrap: nowrap; }
details.range .row > div { flex: 1 1 180px; min-width: 0; }
details.range .row input { width: 100%; }
details.range .dash { align-self: center; color: var(--muted); padding-top: 18px; flex: none; }
details.range .help { font-size: 12.5px; color: var(--muted); margin: 0; }

/* ---------- «В ремонте» на станции */
.replist > li { align-items: flex-start; }
.replist .rk { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.replist .rk .mono { font-weight: 650; }
.replist .rd { font-size: 13px; color: var(--ink2); margin-top: 2px; overflow-wrap: anywhere; }
.replist .rd b { color: var(--muted); font-weight: 600; }
.replist .ra { display: flex; flex-wrap: wrap; gap: 6px; }
.replist .ra form { margin: 0; }
.days { display: inline-block; padding: 0 8px; border-radius: 999px; background: #f1f3f6; color: var(--ink2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.days.stale { background: var(--errbg); color: var(--err); }

/* ---------- приём в ремонт */
.rin .opts { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; width: 100%; align-items: end; }
.rin .opts > div { min-width: 0; }
.rin .opts input, .rin .opts select { width: 100%; }
.rin .opts label { margin-bottom: 3px; }
.intake { border-left: 3px solid var(--accent); }
.intake.err { border-left-color: var(--err); }
.intake .ih { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin-bottom: 10px; }
.intake .ih .sn { font-family: var(--mono); font-size: 18px; font-weight: 650; }
.needs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.needs li { padding: 8px 12px; border-radius: var(--r-sm); background: var(--amberbg); color: var(--amber); font-size: 13.5px; }

/* ---------- режим «Склад»: плитки складов */
.whtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 16px; }
.whtile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); color: inherit; }
a.whtile:hover { text-decoration: none; border-color: #c4c9d2; }
.whtile .t { font-weight: 650; color: var(--ink2); display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.whtile .t .code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-weight: 500; }
.whtile .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.whtile .v small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.whtile .s { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.whtile .s .chip { font-size: 12px; padding: 1px 9px; }
.chip.warn { background: var(--amberbg); color: var(--amber); }
.chip.info { background: #e0f4f6; color: #0f5f6e; }
.chip.ok { background: var(--okbg); color: var(--ok); }
.chip.rep { background: var(--repbg); color: var(--rep); }
.whcells { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; }
.whcell { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px 10px; border-radius: 999px; background: #f1f3f6; font-size: 12.5px; color: var(--ink2); white-space: nowrap; }
.whcell b { font-variant-numeric: tabular-nums; }
.whcell.zero { color: #9aa1ab; background: #f6f7f9; }
.pickrow { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 6px; font-size: 13px; }
.pickrow .wn { font-weight: 600; min-width: 130px; }
.pickrow .cnt { font-variant-numeric: tabular-nums; }
.pickrow a { white-space: nowrap; }
.progress.inl { display: inline-block; width: 80px; vertical-align: middle; margin: 0; }

/* ---------- склад: сводка, ячейки, «в пути» */
.whsum { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13.5px; margin: -4px 0 14px; }
.whsum b { color: var(--ink); font-variant-numeric: tabular-nums; }
.loc { font-family: var(--mono); font-size: 12.5px; color: var(--ink2); background: #f1f3f6; border-radius: 6px; padding: 0 6px; white-space: nowrap; }
.tag-transit, .tag-rep { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-transit { background: #e0f4f6; color: #0f5f6e; }
.tag-rep { background: var(--repbg); color: var(--rep); }

/* ---------- документ «Перемещение»: путь, шаги, приёмка */
.route-wh { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-weight: 600; font-size: 15px; margin: -8px 0 12px; }
.route-wh .arr { color: var(--muted); font-weight: 400; }
.route-wh .muted { font-weight: 400; font-size: 13.5px; }
.steps { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 16px; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line2); background: #fff; flex: none; }
.steps li + li::after { order: -1; content: ""; width: 22px; height: 2px; background: var(--line2); margin: 0 4px 0 8px; }
.steps li.done { color: var(--ok); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.cur { color: var(--ink); font-weight: 650; }
.steps li.cur::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 3px rgba(37, 87, 214, .18); }
.steps li.bad { color: var(--err); }
.steps li.bad::before { border-color: var(--err); background: var(--err); }
tr.got > td { background: #f6fcf8; }
tr.gone > td { opacity: .6; }
.recv { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; }
.recv .counter { font-size: 30px; }

/* ---------- карточка ремонта */
.rhead { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: -8px 0 14px; color: var(--muted); }
.rhead .sn { font-family: var(--mono); font-size: 17px; font-weight: 650; }
.rstatus { display: flex; gap: 2px; list-style: none; margin: 0 0 16px; padding: 0; }
.rstatus li { flex: 1 1 0; min-width: 0; padding: 7px 8px; background: #f1f3f6; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rstatus li:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.rstatus li:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.rstatus li.done { background: #e3f6ea; color: #166534; }
.rstatus li.cur { background: var(--accent); color: #fff; }
.rstatus li.cur.bad { background: #c81e1e; }
.rroute { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rroute .badge.next { background: var(--accent); color: #fff; }
.rroute .arr { color: #b0b5be; font-size: 12px; }
/* этап маршрута, который изделие не проходило (добавлен позже / пропущен) */
.badge.skip { background: transparent; border: 1px dashed var(--line2); color: var(--muted); padding: 1px 9px; }
.cardh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.cardh h3 { margin: 0; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 6px; }
.danger-zone form { margin-top: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 2px 12px; padding: 7px 0; border-bottom: 1px solid #eef0f3; font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .ts { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline .who { color: var(--muted); }
.timeline .ev { overflow-wrap: anywhere; }
.timeline b { font-weight: 600; }

/* ---------- реестр ремонтов */
.fltbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; margin-bottom: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.fltbar > div { flex: 0 1 auto; min-width: 0; }
.fltbar > div.q { flex: 1 1 220px; }
.fltbar > div.q input { width: 100%; }
.fltbar .chks { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: center; flex: 1 1 100%; }
.fltbar .chks label.chk { margin: 0; font-size: 13.5px; }
.fltbar .chks .right { display: flex; gap: 8px; }
.chipnav .cnt { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 9px; background: #e6e9ee; color: var(--ink2); font-size: 11px; text-align: center; font-weight: 700; }
.chipnav a.on .cnt { background: #fff; color: var(--accent-ink); }
tr.stale > td:first-child { box-shadow: inset 3px 0 0 var(--err); }
.selbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: -6px 0 16px; }

/* ---------- отгрузка: места по складам, возвраты из ремонта */
.whgrp { margin-bottom: 14px; }
.whgrp .gh { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 10px 14px; background: #fafbfc; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; }
.whgrp .gh b { font-size: 14.5px; }
.whgrp .tbl { border-radius: 0 0 var(--r) var(--r); margin-bottom: 0; }
tr.rep > td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }

/* ---------- маршруты этапов в настройках, матрица покрытия */
.routes { list-style: none; margin: 0 0 6px; padding: 0; }
.routes li { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 4px 14px; padding: 9px 0; border-bottom: 1px solid #eef0f3; align-items: baseline; }
.routes li:last-child { border-bottom: 0; }
.routes .cat { font-weight: 650; }
.routes .fls { display: flex; flex-direction: column; gap: 4px; }
.routes .fl { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
.routes .fl .lbl { color: var(--muted); font-size: 12px; min-width: 96px; }
.routes .fl .arr { color: #b0b5be; }
.covtbl th .fl { display: block; font-size: 11px; font-weight: 600; color: var(--rep); }
.covtbl tr.whrow td { background: #fafbfc; }
.covtbl tr.whrow td.cov-ok { background: #f2fbf5; }
.covtbl tr.whrow td.cov-warn { background: #fff8e6; }
.covtbl tr.whrow td.cov-none { background: #fdf0f0; }

@media (max-width: 800px) {
  details.mass > summary { padding: 10px 14px; }
  details.mass > .body { padding: 14px 12px; }
  .mass .g2f { grid-template-columns: minmax(0, 1fr); }
  .mass .g2f details.plain > summary { margin: 0; }
  .mass-confirm { flex-direction: column; align-items: stretch; }
  .mass-confirm > button.ok, .mass-confirm > .btn, .mass-confirm > button { flex: none; width: 100%; white-space: normal; }
  .mass-fail > button, .mass-work > button { align-self: stretch; }
  .mass-rows li .msg { margin-left: 0; text-align: left; flex: 1 1 100%; }
  .mass-sum .ms { padding: 5px 12px; }
  .mass-sum .ms b { font-size: 18px; }
  .massbar .btn { width: 100%; }
  details.range .row { flex-wrap: wrap; }
  details.range .dash { display: none; }
  .rin .opts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rin .opts > div:first-child { grid-column: 1 / -1; }
  .whtiles { grid-template-columns: minmax(0, 1fr); }
  .replist .ra { flex: 1 1 100%; }
  .replist .ra form { flex: 1 1 auto; }
  .replist .ra button { width: 100%; }
  .rstatus li { padding: 7px 2px; font-size: 11px; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .routes li { grid-template-columns: minmax(0, 1fr); }
  .fltbar > div { flex: 1 1 140px; }
  .fltbar > div select, .fltbar > div input { width: 100%; }
  .whgrp .gh .btn { width: 100%; }
  .pickrow .wn { min-width: 0; flex: 1 1 100%; }
  .recv .counter { font-size: 26px; }
}
.pipe .step.rep { background: var(--repbg); border-color: var(--repline); }
.pipe .step.rep .t { color: var(--rep); }

.flowtbl td .whs { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; font-size: 11.5px; margin-top: 2px; }
.flowtbl td .whs a { color: var(--ink2); white-space: nowrap; }
.flowtbl td .whs a:hover { color: var(--accent); }
.recv > div.grow { flex: 1 1 220px; min-width: 0; }
.recv select { width: 100%; }
@media (max-width: 480px) {
  .steps li .muted { display: none; }
  .steps li + li::after { width: 14px; margin: 0 2px 0 6px; }
}

/* ======================================================================= v4: вкладки станции и выбор строк (гл. 1)
   Вкладка = режим: панель вкладок с числом; очередь — список с выбором касанием (static/sel.js); липкая панель
   «Выбрано: N» над нижней панелью разделов и экранной клавиатурой (--kb ставит sel.js по visualViewport). */
.wstabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 14px; }
.wstab { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t c" "s c"; align-items: center; gap: 0 10px; min-height: 56px; padding: 8px 12px; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); transition: border-color .12s, background .12s; }
.wstab:hover { text-decoration: none; border-color: #c4c9d2; }
.wstab .t { grid-area: t; font-weight: 650; color: var(--ink2); font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.wstab .s { grid-area: s; font-size: 12px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.wstab .cnt { grid-area: c; font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.wstab.on { border-color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1px var(--accent); }
.wstab.on .t, .wstab.on .cnt { color: var(--accent-ink); }
.hintbar.nolabel .chip { background: #fff; }

.sel { margin: 0 0 18px; }
.sel [hidden] { display: none !important; }
.sel-head h2 { margin: 18px 0 6px; }
.sel-hint { margin: -2px 0 10px; }
.sel-tools { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; border-bottom: 0; }
.sel-search { flex: 1 1 180px; min-width: 0; }
.sel-search input { width: 100%; font-family: var(--mono); }
.sel-search input::placeholder { font-family: var(--font); }
.sel-filters { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.sel-filters select { min-height: 34px; padding: 4px 8px; max-width: 220px; min-width: 0; }
.sel-bulk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sel-first { display: inline-flex; gap: 4px; align-items: center; }
.sel-first input { width: 70px; min-height: 30px; padding: 3px 8px; }
.sel-bulk button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.sel-live { margin: 0; color: var(--muted); background: var(--panel); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.sel-live:empty { display: none; }
.sel-live:not(:empty) { padding: 6px 12px; }
.sel-live.ok { color: var(--ok); }
.sel-live.warn { color: var(--amber); }
.sel-live.err { color: var(--err); }
.sel-body, .sel-found { background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); box-shadow: var(--shadow); overflow: hidden; }
.sel-found { border-radius: 0; border-bottom: 0; box-shadow: none; }
.sel-head + .sel-found + .sel-body { border-radius: var(--r); }
.sel-empty { margin: 0; padding: 14px; color: var(--muted); }
.sel-grp { border-top: 1px solid var(--line); }
.sel-grp:first-child { border-top: 0; }
.sel-grp.nohit { display: none; }
.sel-grp > details > summary.sel-gh, .sel-gh.static { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 8px 12px; background: #fafbfc; list-style: none; cursor: pointer; color: var(--ink); min-height: 48px; }
.sel-grp > details > summary.sel-gh::-webkit-details-marker { display: none; }
.sel-grp > details > summary.sel-gh::after { content: ""; width: 7px; height: 7px; margin-left: auto; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); flex: none; order: 9; }
.sel-grp > details[open] > summary.sel-gh::after { transform: rotate(-135deg); }
.sel-grp.explicit > details > summary.sel-gh { background: var(--amberbg); }
.sel-gall { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; margin: -6px 0 -6px -6px; }
.sel-gall input, .sel-row input[type=checkbox] { width: 22px; height: 22px; margin: 0; cursor: pointer; }
.sel-gt { font-weight: 650; overflow-wrap: anywhere; }
.sel-gt .n { color: var(--muted); font-weight: 600; margin-left: 4px; }
.sel-gmeta { flex: 1 1 100%; padding-left: 38px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.sel-gh.static .sel-gmeta { padding-left: 0; }
.sel-rows { list-style: none; margin: 0; padding: 0; }
.sel-row { display: flex; align-items: stretch; border-top: 1px solid #eef0f3; }
.sel-row[hidden] { display: none; }
.sel-row > label { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 22px minmax(0, auto) minmax(0, 1fr); grid-template-areas: "c sn t" "c s s"; align-items: center; gap: 0 12px; min-height: 48px; padding: 6px 12px; margin: 0; color: var(--ink); font-size: 14px; font-weight: 400; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sel-row > label > input { grid-area: c; }
.sel-row .sn { grid-area: sn; font-family: var(--mono); font-size: 14.5px; color: var(--ink2); overflow-wrap: anywhere; }
.sel-row .sn b { color: var(--ink); font-weight: 750; }
.sel-row .t { grid-area: t; color: var(--ink2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-row .s { grid-area: s; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.sel-row .s:empty { display: none; }
.sel-row .s .badge { font-size: 11px; padding: 0 7px; }
.sel-row .s .why { color: var(--amber); }
.sel-row:hover > label { background: #f8f9fb; }
.sel-row.on > label { background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }
.sel-row.off > label { cursor: not-allowed; opacity: .7; }
.sel-row > label:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.sel-open { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; color: var(--muted); font-size: 22px; border-left: 1px solid #f1f3f6; }
.sel-open:hover { text-decoration: none; background: #f5f7fa; color: var(--accent); }
.sel-more { display: block; width: 100%; border: 0; border-top: 1px solid #eef0f3; border-radius: 0; background: #fafbfc; color: var(--accent); font-weight: 600; min-height: 44px; }
.sel-more:hover { background: var(--accent-weak); border-color: #eef0f3; }
.sel-none { padding: 12px; color: var(--muted); }
.sel-search-res > .sel-gh { background: var(--accent-weak); color: var(--accent-ink); cursor: default; }
/* липкая панель «Выбрано: N» */
.sel .selbar { position: sticky; z-index: 20; bottom: calc(env(safe-area-inset-bottom) + var(--kb, 0px) + 10px); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 760px; margin: 12px auto 0; padding: 10px 12px; background: rgba(255, 255, 255, .98); border: 1px solid #c3d2fb; border-radius: 14px; box-shadow: 0 8px 28px rgba(16, 24, 40, .16); backdrop-filter: blur(8px); }
.sel .selbar[hidden] { display: none; }
.selcount { font-weight: 650; color: var(--accent-ink); white-space: nowrap; }
.selcount b { font-size: 20px; font-variant-numeric: tabular-nums; }
.selacts { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; justify-content: flex-end; }
.selacts button { min-height: 44px; }
.selro { flex: 1 1 100%; color: var(--amber); }
body.sel-scan form.scanbox { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 87, 214, .18); }
body.sel-scan form.scanbox::before { content: "Скан → в выбор: код добавится в выбор"; display: block; margin: -4px 0 8px; font-size: 12.5px; font-weight: 650; color: var(--accent-ink); }
.lastact { flex: 1 1 100%; }
.lastact form { margin: 0; }
.reqlist .ra { display: flex; gap: 6px; flex-wrap: wrap; }
.reqlist .ra form { margin: 0; }
.mass-print .row { margin-bottom: 10px; }
.mass-print .row .grow { flex: 1 1 260px; }
.ordlabels { padding-top: 14px; }
.ordlabels-h { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.ordlabels-h .ms { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #f1f3f6; font-weight: 600; font-size: 13.5px; }
.ordlabels-h .ms.ok { background: var(--okbg); color: var(--ok); }
.ordlabels-h .ms.fail { background: var(--amberbg); color: var(--amber); }
.ordlabels-h .ms b { font-size: 17px; font-variant-numeric: tabular-nums; }
.ordlabels .sel { margin-bottom: 0; }

@media (max-width: 800px) {
  .wstabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; margin: 0 -14px 12px; padding: 0 14px 4px; scrollbar-width: none; }
  main.wsonly .wstabs { margin: 0 -16px 12px; padding: 0 16px 4px; }
  .wstabs::-webkit-scrollbar { display: none; }
  .wstabs.can-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
  .wstabs.can-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px); mask-image: linear-gradient(90deg, transparent, #000 32px); }
  .wstabs.can-l.can-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
  .wstab { flex: 0 0 auto; min-width: 132px; max-width: 200px; min-height: 60px; }
  .sel-tools { padding: 10px; }
  .sel-filters { flex: 1 1 100%; min-width: 0; }
  .sel-filters select { flex: 1 1 140px; min-width: 0; width: 100%; max-width: 100%; min-height: 44px; }
  .sel-bulk { flex: 1 1 100%; }
  .sel-bulk > button { flex: 1 1 130px; }
  .sel-first { flex: 1 1 100%; order: 3; }
  .sel-first input { flex: 0 0 84px; min-height: 44px; }
  .sel-first button { flex: 1 1 auto; }
  .sel-row > label { grid-template-columns: 22px minmax(0, 1fr); grid-template-areas: "c sn" "c t" "c s"; padding: 8px 10px; min-height: 56px; }
  .sel-row .t { white-space: normal; }
  .sel .selbar { bottom: calc(env(safe-area-inset-bottom) + var(--kb, 0px) + 8px); margin: 10px 0 0; padding: 8px 10px; }
  main.withtabbar .sel .selbar { bottom: calc(env(safe-area-inset-bottom) + var(--kb, 0px) + 76px); }
  .selcount { flex: 1 1 auto; }
  .selacts { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-start; }
  .selacts button { flex: 1 1 auto; min-height: 48px; white-space: normal; }
  .selacts button[data-sel-clear] { flex: 0 0 auto; }
  .lastact form, .lastact button { width: 100%; }
  .reqlist .ra { flex: 1 1 100%; }
  .reqlist .ra form { flex: 1 1 auto; }
  .reqlist .ra button { width: 100%; }
}

/* ---------- v4 (A): план производства и сроки — риск, загрузка, план/факт, мощности, календарь */
.b-none { background: #eef0f4; color: #4b5563; }
.riskt .stat .v { font-variant-numeric: tabular-nums; }
.riskt .stat.r-overdue:not(.zero) { border-color: #f6caca; background: #fff7f7; }
.riskt .stat.r-overdue:not(.zero) .v { color: var(--err); }
.riskt .stat.r-at_risk:not(.zero) { border-color: var(--amberline); background: #fffcf3; }
.riskt .stat.r-at_risk:not(.zero) .v { color: var(--amber); }
.riskt .stat.r-on_time:not(.zero) .v { color: var(--ok); }
a.stat:hover { text-decoration: none; border-color: var(--line2); }
tr.hot > td { background: #fff7f7; }
.plancard .cardh h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.planform select, .planform input[type=date] { min-width: 0; }
.inlplan { flex-wrap: nowrap; gap: 6px; align-items: center; }
.inlplan select { min-width: 104px; }
.inlplan input[type=number] { width: 84px; }
.plantbl td { vertical-align: middle; }
.pfcard { overflow: hidden; }
.pflegend .lg.fact { margin-left: 8px; }
.pfchart { display: block; width: 100%; max-width: 760px; height: auto; }
.pfchart .pf-axis { stroke: var(--line2); stroke-width: 1; }
.pfchart .pf-plan { fill: var(--accent-weak); stroke: var(--accent); stroke-width: 1.4; }
.pfchart .pf-plan.prelim { stroke-dasharray: 3 2; }
.pfchart .pf-fact { fill: var(--accent); }
.pfchart text { font: 10px var(--font); fill: var(--muted); text-anchor: middle; }
.pfchart .pf-fv { fill: var(--accent-ink); font-weight: 700; }
.pfchart .pf-na { fill: #b0b5be; }
.pfchart .pf-d { font-size: 10.5px; fill: var(--ink2); }
.pflegend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 6px; }
.pflegend .lg { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.pflegend .lg.plan { background: var(--accent-weak); border: 1.4px solid var(--accent); }
.pflegend .lg.fact { background: var(--accent); }
.captbl th, .captbl td { white-space: nowrap; vertical-align: middle; }
.captbl input[type=number] { width: 86px; min-height: 36px; }
.calnav { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.calnav b { font-size: 16px; min-width: 150px; text-align: center; }
.caltbl { table-layout: fixed; }
.caltbl th { text-align: center; }
.caltbl td { padding: 4px; height: 64px; vertical-align: top; }
.caltbl form { margin: 0; height: 100%; }
.calday { width: 100%; height: 100%; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; padding: 6px 8px; background: var(--okbg); border: 1px solid #c6ecd4; color: var(--ink); border-radius: var(--r-sm); font-weight: 600; text-align: left; }
.calday:hover { border-color: var(--ok); background: #e2f8ea; }
.calday.off { background: #f1f3f6; border-color: var(--line); color: var(--muted); }
.calday.off:hover { border-color: var(--line2); }
.calday.ovr { box-shadow: inset 0 0 0 2px var(--amberdot); }
.calday.now { outline: 2px solid var(--accent); outline-offset: 1px; }
.calday .dn { font-size: 14px; }
.calday .dnote { font-size: 11px; font-weight: 500; color: var(--amber); line-height: 1.25; overflow-wrap: anywhere; }
.calform { align-items: flex-end; }
.chip.plancnt { background: var(--accent-weak); color: var(--accent-ink); font-size: 13.5px; padding: 4px 12px; }
.chip.plancnt b { font-size: 15px; font-variant-numeric: tabular-nums; }
.chip.plancnt.ok { background: var(--okbg); color: var(--ok); }
/* v4 (B): версия прошивки на станции и в массовом действии */
.scanbox .fwopt { margin-bottom: 10px; }
.qc-note.fw { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; }
.qc-note.fw .fwl { margin: 0; white-space: nowrap; font-weight: 600; color: var(--ink2); }
.fwbox { display: flex; gap: 6px; flex: 1 1 auto; min-width: 0; }
.fwbox input { flex: 1 1 auto; min-width: 0; }
.fwbox .fwx { flex: 0 0 auto; min-width: 40px; }
.fwbox .fwx[hidden] { display: none !important; }
.mass-fw { margin: 8px 0; }
.mass-fw input { width: 100%; max-width: 260px; }
.fwhist { margin: 8px 0 0; padding-left: 18px; }
@media (max-width: 800px) {
  .rin .opts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .inlplan { flex-wrap: wrap; }
  .pfcard { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pfchart { min-width: 600px; }
  .caltbl td { height: 52px; padding: 2px; }
  .calday { min-height: 46px; padding: 4px 5px; }
  .calday .dnote { display: none; }
  .captbl input[type=number] { width: 72px; }
  .qc-note.fw { flex-wrap: wrap; }
  .qc-note.fw .fwl { width: 100%; }
}
/* v4 (C): документы отгрузки — карточки видов, ссылки на карточке отгрузки, предпросмотр шаблона */
.doccard .docnum { font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.docgrid { margin-bottom: 8px; }
.doclinks { list-style: none; margin: 0; padding: 0; }
.doclinks li { display: flex; gap: 6px 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid #eef0f3; }
.doclinks li:last-child { border-bottom: 0; }
.doclinks .dl { white-space: nowrap; }
.phlist { display: flex; flex-wrap: wrap; gap: 6px; }
.phlist .badge { font-family: var(--mono); white-space: normal; overflow-wrap: anywhere; }
.docprevbox { overflow-x: auto; }
.docprevbox p { margin: 0 0 6px; overflow-wrap: anywhere; }
.docprevbox table.docprev { border: 1px solid var(--line2); margin: 6px 0 10px; }
.docprevbox table.docprev td { border: 1px solid var(--line); padding: 4px 6px; font-size: 12.5px; }
.ph-ok { background: var(--okbg); color: var(--ok); border-radius: 4px; padding: 0 2px; font-family: var(--mono); }
.ph-bad { background: var(--errbg); color: var(--err); border-radius: 4px; padding: 0 2px; font-family: var(--mono); }

/* ---------- v5 (R): вкладка «Ремонт» — сегмент очередей, карточки ремонта в списке выбора, нижняя панель ---------- */
.repseg { margin-bottom: 12px; }
.repseg a .cnt { margin-left: 6px; font-variant-numeric: tabular-nums; }
.sel-row > label { grid-template-areas: "c sn t" "c s s" "c ri ri"; }
.sel-row .ri { grid-area: ri; display: flex; flex-direction: column; gap: 1px; margin-top: 3px; font-size: 12.5px; color: var(--ink2); min-width: 0; }
.sel-row .ri-l { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sel-row .ri-l b { color: var(--muted); font-weight: 600; }
.badge.b-stage { background: #eef2ff; color: var(--accent-ink); }
.repcard .meta b { color: var(--ink); }
dialog.sheet { border: 0; padding: 0; border-radius: var(--r); background: var(--panel); color: var(--ink); width: min(640px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; box-shadow: 0 18px 50px rgba(16, 24, 40, .22); }
dialog.sheet::backdrop { background: rgba(17, 24, 39, .42); }
.sheet-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sheet-body { padding: 14px 16px 18px; }
.repinfo h2 { margin: 0; font-size: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.repinfo h3 { margin: 18px 0 8px; font-size: 15px; }
.repinfo .ri-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.repinfo .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.repinfo .ri-route { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.repinfo .ri-route li { display: inline-flex; align-items: center; gap: 4px; opacity: .65; }
.repinfo .ri-route li.done, .repinfo .ri-route li.next { opacity: 1; }
.repinfo .ri-route li.next .badge { box-shadow: 0 0 0 2px var(--accent); }
.repinfo .ok-txt { color: var(--ok); }
.repinfo .ri-list li { align-items: flex-start; }
@media (max-width: 800px) {
  .sel-row > label { grid-template-areas: "c sn" "c t" "c s" "c ri"; }
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r) var(--r) 0 0; max-height: 85vh; }
  /* два сегмента вкладки «Ремонт» — всегда целиком на экране телефона, без горизонтальной прокрутки */
  .chipnav.repseg, .ws .chipnav.repseg { overflow: visible; margin: 0 0 12px; padding: 0; }
  .chipnav.repseg a { flex: 1 1 0; min-width: 0; justify-content: center; white-space: normal; text-align: center; line-height: 1.2; padding: 9px 10px; }
}

/* ---------- v5 (S): нумерация SN строки заказа ---------- */
#items tbody.itemrow + tbody.itemrow > tr:first-child > td { border-top: 1px solid var(--line); }
#items tr.snrow > td { padding-top: 0; border-top: 0; }
details.snplan { margin: 0 0 6px; border: 1px dashed var(--line2); border-radius: var(--r-sm); padding: 6px 10px; background: #fafbfc; }
details.snplan[open] { background: #fff; border-style: solid; }
details.snplan > summary { cursor: pointer; font-size: 13px; color: var(--ink2); overflow-wrap: anywhere; }
details.snplan.own > summary { color: var(--accent-ink); font-weight: 600; }
.snp-body { margin-top: 8px; }
/* сетка помещается в ширину блока при любой ширине окна (без горизонтальной прокрутки таблицы позиций) */
.snp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 10px; align-items: end; }
details.snplan { min-width: 0; max-width: 100%; }
details.snplan [data-sn-suggest] { white-space: normal; max-width: 100%; height: auto; min-height: 36px; text-align: left; overflow-wrap: anywhere; }
@media (min-width: 801px) {
  .snp-grid .snp-mask { grid-column: span 2; }
  #items tr.snrow > td { max-width: 0; }  /* строка нумерации не расширяет таблицу позиций */
}
.snp-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); margin: 0; min-width: 0; }
.snp-grid input, .snp-grid select { width: 100%; min-width: 0; }
details.snplan:not(.own) .snp-mask, details.snplan:not(.own) .snp-n, details.snplan:not(.own) .snp-date, details.snplan:not(.own) .snp-help { opacity: .45; }
.snp-help { margin: 6px 0 4px; }
output.snprev { display: block; font-size: 13px; margin: 4px 0; overflow-wrap: anywhere; }
output.snprev .snp-range { font-weight: 600; }
output.snprev .snp-err { color: var(--err); background: var(--errbg); border-radius: 6px; padding: 4px 8px; margin: 4px 0; }
output.snprev .snp-warn { color: var(--amber); background: var(--amberbg); border-radius: 6px; padding: 4px 8px; margin: 4px 0; }
output.snprev .snp-ok { color: var(--ok); margin-top: 2px; }
output.snprev .snp-list { margin: 4px 0 0 18px; padding: 0; }
.snplan-manual { padding: 2px 0 6px; }
.snplans .ra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.snplans .ra form { margin: 0; }
@media (max-width: 800px) {
  .snp-grid { grid-template-columns: 1fr 1fr; }
  .snp-grid .snp-mode, .snp-grid .snp-mask, .snp-grid .snp-date { grid-column: 1 / -1; }
  #items tr.snrow > td { display: block; width: 100%; }
  .snplans .ra { flex: 1 1 100%; }
}

/* ---------------- v5.1: архив справочников, отмена действий, «Входящие», «Сообщить об ошибке» */
.help.lock { color: var(--warn); }
/* заблокированное поле используемой записи (🔒) и прочие disabled — видно, что не редактируется */
input:disabled:not([type=checkbox]):not([type=radio]), select:disabled, textarea:disabled { background: #f1f3f6; color: var(--muted); cursor: not-allowed; }
.lockbox { background: var(--warnbg); border-color: #f3dcae; margin: 6px 0 12px; }
.undo-page { max-width: 900px; }
.undo-list { margin: 0 0 14px; padding-left: 20px; }
.undo-list li { margin: 4px 0; }
.undo-bad li { color: var(--err); }
.undo-form textarea { width: 100%; }
.undo-form .chk { margin: 8px 0; }
.undo-card .undo-ops li { gap: 8px; flex-wrap: wrap; }
.undo-card .actions form { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; min-width: 0; }
.undo-card .actions select { max-width: 100%; min-width: 0; }
.undo-line { margin: 10px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
tr.undone td, li.undone .grow { opacity: .6; }
tr.undone td:first-child, li.undone .grow a { text-decoration: line-through; }
.inboxbadge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--errbg); color: var(--err); font-weight: 650; font-size: 13px; white-space: nowrap; border: 1px solid #f6caca; text-decoration: none; }
.inboxbadge:hover { background: #fde4e4; text-decoration: none; }
.side-inbox { display: flex; margin: 0 0 10px; padding: 7px 12px; border-radius: var(--r-sm); }
.topbar .inboxbadge, .wsbar .inboxbadge { margin-left: auto; }
.rep-err { min-height: 30px; padding: 3px 9px; font-size: 12.5px; font-weight: 600; color: var(--err); border-color: #f1c4c4; background: #fff; }
.rep-code { margin-top: 14px; }
.inbox-act td { background: #fafbfc; }
.inbox-act form.row { gap: 6px; flex-wrap: wrap; }
.inbox-act input { min-width: 0; flex: 1 1 200px; }
@media (max-width: 800px) {
  .undo-page .actions .btn, .undo-page .actions button { width: 100%; }
  .undo-line .btn { width: 100%; }
  .undo-card .undo-ops .btn { width: 100%; }
  .inbox-act .actions .btn, .inbox-act button { width: 100%; }
  .inbox-act input { flex-basis: 100%; width: 100%; }
  .side-inbox { margin: 0 0 8px; }
}

/* ---------------- v6.1: живая панель станций прошивки (вкладка «Прошивка» рабочего места, страница «Прошивка»;
   docs/features_v61_ws_flasher_link_spec.md, гл. 7, К10.1). Части обновляет static/flive.js. */
.flive { margin: 4px 0 12px; }
.flive-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 8px; }
.flive-sum { margin: 0; flex: 1 1 320px; min-width: 0; font-size: 13.5px; color: var(--ink2); overflow-wrap: anywhere; }
.flive-upd { white-space: nowrap; }
.flive > .flive-upd { float: right; margin: 1px 0 0 12px; line-height: 1.4; }   /* вне частей: замена частей его не трогает */
.flive-set { white-space: nowrap; }
/* ряд карточек — место под «в работе» (шаг, ход, «идёт М:СС»): простой ↔ прошивка не сдвигают поле скана; карточка с
   ошибкой не растягивает соседей (align-items: start) */
.flive-st { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); grid-auto-rows: minmax(13rem, auto);
  gap: 10px; align-items: start; }
.flive-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line2); border-radius: var(--r-sm);
  padding: 8px 12px 10px; min-width: 0; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.flive-card.busy { border-left-color: #7c3aed; }
.flive-card.err { border-left-color: var(--err); }
.flive-card.stop { border-left-color: var(--err); background: #fffafa; }
.flive-card.off { border-left-color: #cbd5e1; background: #fafbfc; }
.flive-card.off .flive-cb, .flive-card.dis .flive-cb { opacity: .8; }
.flive-card.stale .flive-now, .flive-card.stale .flive-step { opacity: .6; }
.flive-card.stale .flive-sline { color: var(--muted); }
.flive-sst { color: var(--warn); }
.flive-card > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-height: 28px;
  position: relative; padding-right: 16px; }
.flive-card > summary::-webkit-details-marker { display: none; }
/* маркер — в углу, не отдельный элемент строки (не переносится на свою строку) */
.flive-card > summary::after { content: "▾"; position: absolute; right: 0; top: 6px; color: var(--muted); font-size: 12px; }
.flive-card:not([open]) > summary::after { content: "▸"; }
.flive-name { font-weight: 650; }
.fl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex: none; }
.fl-dot.on { background: #16a34a; }
.flive-sline { display: none; color: var(--ink2); font-size: 13px; min-width: 0; }
.flive-cb { display: grid; gap: 4px; margin-top: 4px; font-size: 13.5px; }
.flive-conn { color: var(--muted); }
.flive-now .lbl, .flive-exp .lbl, .flive-errday .lbl { color: var(--muted); }
.flive-step b { font-variant-numeric: tabular-nums; }
.flive-bar { height: 8px; max-width: none; }
.flive-bar > i { background: #7c3aed; transition: width .6s ease; }
.flive-alert { background: var(--amberbg); border: 1px solid var(--amberline); color: var(--amber); border-radius: 6px; padding: 4px 8px; font-weight: 500; }
.flive-alert.err { background: var(--errbg); border-color: #f6caca; color: var(--err); }
.flive-err { background: var(--errbg); border: 1px solid #f6caca; border-radius: 6px; padding: 6px 8px; color: #7f1d1d;
  max-height: 20em; overflow: auto; }
/* «Что делать» в карточке — две строки (полностью — по «Что случилось · полностью» и в «Отказы сегодня»): карточка с
   ошибкой не вырастает на пол-экрана и не сдвигает поле скана */
.flive-act { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flive-err:has(.flive-why[open]) .flive-act { display: block; -webkit-line-clamp: unset; line-clamp: none; }
.flive-why > summary { color: var(--muted); margin-top: 2px; }
.flive-err.stop { border-width: 2px; }
.flive-exp { margin-top: 2px; color: var(--ink2); }
.flive-stale { color: var(--warn); }
.flive-old { color: var(--warn); font-weight: 600; }
.flive-q { margin: 2px 0 0; padding-left: 18px; }
.flive-q li { margin: 1px 0; }
.flive-q li.warn { color: var(--warn); }
.flive-q li.err { color: var(--err); font-weight: 600; }
.flive-errday .flive-ed { white-space: normal; }
.flive-warn { color: var(--warn); font-weight: 600; }
.flive-ok { color: var(--ok); }
.flive-today, .flive-fails { margin: 10px 0; }
.flive-today > summary, .flive-fails > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.flive-tt td { vertical-align: top; }
.flive-fl { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.flive-fl > li { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--r-sm); padding: 6px 10px; overflow-wrap: anywhere; }
.flive-fl > li.stop { border-left-color: var(--err); }
.flive-fl > li.res { opacity: .6; border-left-color: var(--ok); }
.flive-fl > li.org { border-left-color: var(--line2); }
.flive-none { margin: 6px 0; }
.sel-row.fm-done { opacity: .55; }
.badge[data-fm][hidden] { display: none; }
@media (max-width: 800px) {
  .flive-st { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: 6px; }
  .flive-card { padding: 6px 10px; }
  /* свёрнутая карточка — одна строка: «● Станция 1 SN · 42 % · шаг» с многоточием (К10.1, 7.3). Длинное название
     станции — не больше 40 % строки, «в работе» — фиолетовой полосой слева (метка скрыта): SN и ход видны всегда;
     «ошибка» / «СТОП» остаются */
  .flive-card:not([open]) > summary { flex-wrap: nowrap; min-height: 24px; }
  .flive-card:not([open]) .flive-name { flex: 0 1 auto; min-width: 0; max-width: 40%; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .flive-card:not([open]) > summary > .small { display: none; }
  .flive-card:not([open]) > summary > .badge { flex: none; }
  .flive-card:not([open]) > summary > .badge.b-rework { display: none; }
  .flive-card:not([open]) .flive-sline { display: flex; flex: 1 1 0; min-width: 0; white-space: nowrap; }
  .flive-slm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .flive-sst { flex: none; }   /* «данные N назад» не обрезается многоточием */
  .flive-card:not([open]) > summary::after { top: 4px; }
  .flive-card[open] > summary { padding-bottom: 2px; }
  .flive-sum { flex-basis: 100%; }
  .flive-tt td { overflow-wrap: anywhere; }
}
