/* UI-kit. Все страницы берут цвета, отступы и компоненты только отсюда. */
:root {
  --blue: #2347e6; --blue-dark: #1a37b8; --blue-soft: #ecf0ff;
  --ink: #14161c; --ink-2: #4a5060; --muted: #666c7c;
  --line: #e6e8ee; --bg: #f7f8fa; --card: #fff;
  --green: #128a4a; --green-soft: #e3f6ec; --red: #d1293d; --red-soft: #fdebed;
  --amber: #b86e00; --amber-soft: #fff3dc;
  --r: 8px; --r-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; }
.right { text-align: right; }
.center { text-align: center; }
@media (max-width: 800px) { .ellipsis.stock-name { max-width: 150px; } }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Кнопки: синяя — основное действие (всегда справа), белая — вторичное */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r); background: #fff; color: var(--ink); font: inherit;
  font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); }
.btn.sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn.lg { height: 48px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .link:focus-visible, .nav a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--blue); font: inherit; cursor: pointer; padding: 0; }

/* Переключатель вида: выбор из двух, а не действие, поэтому без синей заливки */
.segmented { display: inline-flex; align-self: flex-start; gap: 4px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.segmented button { height: 28px; padding: 0 12px; border: 0; border-radius: 4px; background: none; font: inherit; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.segmented button:focus-visible, summary.fold:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* Раскрывающийся блок: значок из общего набора вместо системного треугольника */
summary.fold { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; }
summary.fold::-webkit-details-marker { display: none; }
summary.fold .icon { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
details[open] > summary.fold .icon { transform: rotate(90deg); }

/* Поля */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--r); background: #fff; font: inherit; color: var(--ink); }
textarea.input { height: auto; min-height: 76px; padding: 8px 12px; resize: vertical; }
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.input:disabled { background: var(--bg); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 28px; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border: 1px solid var(--line);
  border-radius: var(--r); background: #fff; cursor: pointer; font-size: 13px; user-select: none; }
.chip input { accent-color: var(--blue); }
.chip:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Сетка */
.grid { display: grid; gap: 12px; }
.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)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
/* Заголовок страницы: длинное пояснение переносится само, а кнопки остаются справа в одну строку */
@media (min-width: 801px) {
  .page .row.between:has(> div:first-child > h1) { flex-wrap: nowrap; align-items: flex-start; }
  .page .row.between > div:first-child:has(> h1) { flex: 1 1 auto; min-width: 0; }
  .page .row.between:has(> div:first-child > h1) > .row { flex: none; flex-wrap: nowrap; }
}
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; min-width: 0; }
.card > h2, .card > .row:first-child { margin-bottom: 12px; }
.card.kpi { display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; gap: 8px; padding: 12px 16px; }
.kpi .label { font-size: 11px; line-height: 1.35; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 22px; line-height: 1.25; font-weight: 700; }
.kpi.bad .value { color: var(--red); }
.kpi.warn .value { color: var(--amber); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--bg); color: var(--ink-2); border: 1px solid var(--line);
  /* в значке бывает название от пользователя: на узком экране оно переносится, а не выталкивает страницу вбок */
  max-width: 100%; overflow-wrap: anywhere; }
td .badge { white-space: nowrap; }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

.note { padding: 12px 12px; border-radius: var(--r); background: var(--blue-soft); }
.note.warn { background: var(--amber-soft); color: #6d4200; }
.note.bad { background: var(--red-soft); color: #8d1626; }
.note.good { background: var(--green-soft); color: #0c5c31; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Таблицы: на телефоне прокручиваются внутри контейнера */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th[data-sort] { cursor: pointer; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child > td { border-bottom: 0; }
/* По просьбе владельца числа, статусы и коды стоят по центру колонки; текст — слева, действия — справа */
td.right, th.right, td.center, th.center { text-align: center; }
td.center { white-space: nowrap; }
/* Узкие колонки: суммы и действия не растягиваются на пол-экрана */
th.fit, td.fit { width: 1%; white-space: nowrap; padding-left: 16px; padding-right: 16px; }
td.row-actions, th.row-actions { width: 1%; white-space: nowrap; text-align: right; }
/* Между соседними кнопками не меньше 8 px: 4 px даёт пробел в разметке и ещё 4 px — отступ */
td.row-actions .btn + .btn { margin-left: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: flex-end; gap: 8px; align-items: center; margin-top: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* Прайс: цифровые колонки одной ширины во всех блоках — читаются сверху вниз */
.price-table th.right, .price-table td.right { width: 132px; white-space: nowrap; }
.price-table.boxes th:nth-child(2), .price-table.boxes td:nth-child(2) { width: 396px; }
.summary { max-width: 760px; }

/* Фото товаров всегда 3:4. Снимок виден целиком (не обрезается), щелчок открывает его крупно */
.thumb { width: 60px; height: 80px; padding: 0; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
  flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.zoom { background: #fff; cursor: zoom-in; }
.thumb.zoom:hover { border-color: var(--blue); }
/* Маленький снимок тоже растягивается на всю область, без искажения */
.photo-large { display: block; width: 100%; height: 68vh; object-fit: contain; }
.item-head .thumb { width: 48px; height: 64px; }
.packer .thumb { width: 72px; height: 96px; }
/* Нет фото: знак компании целиком, приглушённо, чтобы не путать со снимком товара */
.thumb.no-photo img { width: 76%; height: auto; object-fit: contain; opacity: .55; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; }

/* Каркас */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { scrollbar-width: thin; background: #fff; border-right: 1px solid var(--line); padding: 12px 12px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 12px; }
.brand img { width: 34px; height: 34px; }
.brand > div { min-width: 0; overflow-wrap: anywhere; }
.brand b { display: block; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.nav-title { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 12px 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 4px 12px; border-radius: var(--r); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.nav-count { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.nav-count[data-count="defects"] { color: var(--red); }
.nav svg { width: 17px; height: 17px; flex: none; }
/* Иконки: один набор (Lucide), размеры — 18 px в тексте и кнопках */
.icon { width: 18px; height: 18px; flex: none; }
.btn .icon, .item-head .name .icon { width: 16px; height: 16px; }
.x .icon { width: 22px; height: 22px; display: block; }
.fab .icon { width: 24px; height: 24px; display: block; margin: 0 auto; }
.userbox .btn { width: 32px; padding: 0; }
.item-head .name .icon { vertical-align: -3px; margin-right: 8px; color: var(--muted); }
.step { display: inline-flex; align-items: center; gap: 8px; }
.step .icon { color: var(--muted); }
.step.ready .icon { color: var(--green); }
.userbox { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.main { padding: 24px 24px 128px; min-width: 0; }
.page { display: flex; flex-direction: column; gap: 16px; max-width: 1500px; }
.topbar { display: none; }

/* Рабочий стол: поиск сверху, показатели одной полосой, дела на сегодня */
.deskbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; max-width: 1500px; margin-bottom: 16px; }
body[data-page="calculator"] [data-new-calc] { display: none; }
.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search > .icon { position: absolute; left: 12px; top: 9px; color: var(--muted); pointer-events: none; }
.search .input { padding: 0 64px 0 40px; text-overflow: ellipsis; }
.search > kbd { position: absolute; right: 10px; top: 9px; pointer-events: none; }
.search:focus-within > kbd { visibility: hidden; }
.search-pop { position: absolute; z-index: 28; top: calc(100% + 4px); left: 0; right: 0; max-height: min(60vh, 520px); overflow-y: auto;
  overscroll-behavior: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 30px #10131c26; padding: 4px; }
.search-pop a { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 6px; color: var(--ink); overflow-wrap: anywhere; }
.search-pop a:hover, .search-pop a.on { background: var(--blue-soft); text-decoration: none; }
.search-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.search-note { padding: 16px 12px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.stats > div { display: flex; flex-direction: column; justify-content: flex-start; align-items: center; text-align: center; gap: 2px; padding: 12px 16px; min-width: 0; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats span { font-size: 12px; color: var(--muted); }
.stats b { font-size: 20px; }
.stats .bad b { color: var(--red); }
.stats .warn b { color: var(--amber); }
.todo-card ul { list-style: none; margin-top: 8px; }
.todo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.todo > span { min-width: 0; overflow-wrap: anywhere; }
.todo > span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--line); }
.todo.bad > span::before { background: var(--red); }
.todo.warn > span::before { background: var(--amber); }
.todo .btn { flex: none; }
.todo-buttons { display: flex; gap: 8px; flex: none; }
.stats small { font-size: 12px; color: var(--muted); }
.stats small.good { color: #0e6b39; }
.stats small.bad { color: var(--red); }
.todo-card .link { margin-top: 8px; }
@media (max-width: 800px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stats b { font-size: 17px; }
  /* На телефоне кнопки дела — под его текстом, во всю ширину */
  .todo { flex-wrap: wrap; }
  .todo > span { flex: 1 1 100%; }
  .todo-buttons { width: 100%; }
  .todo-buttons [data-todo-do] { flex: 1 1 auto; }
  .search > kbd { display: none; }
  .search .input { padding-right: 12px; }
}

/* Модальные окна: боковая панель, на телефоне — на весь экран */
.overlay { position: fixed; inset: 0; background: #10131c66; z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto; }
.dialog { background: #fff; border-radius: var(--r-lg); width: min(560px, 100%); }
.dialog.wide { width: min(920px, 100%); }
.overlay.side-panel { padding: 0; justify-content: flex-end; overflow: hidden; }
.card-layout .calc-layout { grid-template-columns: minmax(0, 1fr) 252px; gap: 12px; }
.card-layout .calc-total .big { font-size: 24px; }
.calc-total .kv { align-items: baseline; font-size: 13px; padding: 4px 0; }
.calc-total .kv > span:last-child { white-space: nowrap; }
.card-layout .item-head { gap: 8px; }
.card-layout .item-head .qty { width: 68px; }
.card-layout .item-head .sum { width: 82px; }
.card-layout .item-head .name { white-space: normal; line-height: 1.3; }
.item-head .sum { margin-left: auto; }
.overlay.side-panel .dialog { width: min(1260px, 96vw); height: 100vh; border-radius: 0; display: flex; flex-direction: column; }
.overlay.side-panel .dialog-body { overflow-y: auto; flex: 1; background: var(--bg); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.x { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r); max-width: 420px; box-shadow: 0 6px 20px #0003; }
.toast.bad { background: var(--red); }

/* Фильтры доски: на компьютере в строку, на телефоне поиск во всю ширину и два списка рядом */
.filters .input { max-width: 200px; }
.filters input.input { max-width: 280px; }
@media (max-width: 800px) {
  .filters .input, .filters input.input { max-width: none; flex: 1 1 calc(50% - 8px); width: auto; min-width: 0; }
  .filters input.input { flex-basis: 100%; }
}

/* Канбан */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { flex: 0 0 250px; background: #eef0f5; border-radius: var(--r-lg); padding: 8px; border-top: 3px solid var(--c); }
.column.over { outline: 2px dashed var(--blue); }
.column h3 { display: flex; justify-content: space-between; padding: 4px 8px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--c); }
.column .list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; max-height: 68vh; overflow-y: auto; }
.kcard { background: #fff; border-radius: var(--r); border-left: 3px solid var(--c); padding: 12px; cursor: pointer; box-shadow: 0 1px 2px #0000000f; }
.kcard[draggable="true"] { cursor: grab; }
/* Нерешённый брак: карточку видно среди сотен других */
.kcard.has-defect { border-left-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.column .list:has(.has-defect) { padding: 2px; }
.kcard .title { font-weight: 600; margin: 4px 0; overflow-wrap: anywhere; }
.progress { height: 5px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue); }

/* Карточка поставки */
.card-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; overflow-wrap: anywhere; }
.details { max-width: 760px; }
/* приёмка сканером: узкая колонка, крупный счёт */
.overlay.side-panel.scan-panel .dialog { width: min(480px, 100vw); }
.scan-form { flex-wrap: nowrap; }
.scan-form .input { height: 48px; font-size: 16px; }
.scan-form .btn { height: 48px; }
.scan-message { display: flex; flex-direction: column; gap: 8px; overflow-wrap: anywhere; }
.scan-message .btn { height: auto; min-height: 32px; max-width: 100%; white-space: normal; text-align: left; }
.scan-card .btn.lg { height: auto; min-height: 48px; padding: 8px 12px; font-size: 14px; white-space: normal; justify-content: center; text-align: center; }
.scan-count { font-size: 20px; text-align: center; }
.scan-count b { font-size: 40px; line-height: 1.1; }
.scan-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.scan-bar i { display: block; height: 100%; background: var(--blue); }
.scan-row { flex-wrap: nowrap; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.scan-row:last-child { border-bottom: 0; }
.scan-row .link { text-align: left; min-height: 36px; }
/* первая колонка с длинным пояснением не сжимается в столбик: таблица прокручивается */
table.wide-first :is(th, td):first-child { min-width: 220px; }
.path { overflow-wrap: anywhere; font-size: 12px; }
.details .kv { justify-content: flex-start; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.details .kv:last-child { border-bottom: 0; }
.details .kv > span:first-child { flex: 0 0 220px; }
.details .kv > span:last-child { text-align: left; min-width: 0; }
.details + .row.end, .row.end.narrow { max-width: 760px; width: 100%; }
@media (max-width: 560px) { .details .kv { flex-direction: column; gap: 2px; } .details .kv > span:first-child { flex: none; font-size: 12px; } }
.timeline > div { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline > div::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.gallery img { width: 100%; aspect-ratio: 3/4; object-fit: contain; background: #fff; border-radius: var(--r); border: 1px solid var(--line); }

/* Калькулятор */
.item { border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; }
.item-head .name { flex: 1 1 96px; min-width: 0; text-align: left; background: none; border: 0; font: inherit; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .qty { width: 90px; flex: none; }
.item-head .sum { width: 110px; text-align: right; flex: none; }
.item-body { border-top: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.calc-total { position: sticky; top: 16px; }
.big { font-size: 28px; font-weight: 700; }

/* График */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.bars div { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bars i { display: block; width: 100%; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars div:hover i { background: var(--blue-dark); }
.bars-axis { display: flex; justify-content: space-between; margin-top: 8px; }
.funnel { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 8px; }
.funnel a span { display: block; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; }
/* 13 колонок — только когда самое длинное название этапа входит в колонку целиком */
@media (max-width: 1750px) { .funnel { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
@media (max-width: 800px) { .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.funnel a { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 8px; color: var(--ink); min-width: 0; text-align: center; }
.funnel b { display: block; font-size: 22px; }

/* Быстрые действия */
.fabs { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; z-index: 30; }
.fab { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; font-size: 28px; cursor: pointer; box-shadow: 0 8px 22px #2347e655; }
.fab.help { width: 40px; height: 40px; font-size: 18px; font-weight: 700; background: #fff; color: var(--blue); border: 1px solid var(--line); box-shadow: 0 4px 12px #0000001f; }
.packer ~ .fabs { bottom: 74px; }
@media (min-width: 801px) {
  .fabs { flex-direction: row; right: 20px; bottom: 16px; }
  .fabs .fab { width: 44px; height: 44px; font-size: 24px; }
  .fabs .fab.help { width: 36px; height: 36px; font-size: 16px; }
}
.overlay.side-panel.help-panel .dialog { width: min(620px, 100vw); }
.article summary { cursor: pointer; }
.article[open] summary { margin-bottom: 12px; }
.md { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4 { margin-top: 8px; }
.md ul, .md ol { padding-left: 24px; }
.md li { margin: 4px 0; }
.md img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); }
.md code { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.article-text.input { min-height: 220px; }
.actions { display: grid; gap: 8px; }
.actions button { justify-content: space-between; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; color: var(--muted); }

/* Обучение: карточка поверх страницы (ниже окон) и обводка того, о чём идёт речь */
.tour { position: fixed; right: 20px; bottom: 76px; z-index: 32; width: min(360px, calc(100vw - 24px)); background: #fff; border: 1px solid var(--blue);
  border-radius: var(--r-lg); box-shadow: 0 12px 32px #10131c40; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.tour.top { top: 16px; bottom: auto; }
.tour-target { outline: 3px solid var(--blue); outline-offset: 4px; border-radius: var(--r); scroll-margin-top: 80px; }
/* Запас снизу, чтобы нижний блок страницы можно было прокрутить выше карточки */
body.touring .main, body.touring .packer { padding-bottom: 360px; }
@media (max-width: 800px) {
  .tour { right: 12px; left: 12px; width: auto; bottom: 12px; }
  .tour.top { top: 64px; bottom: auto; }
  /* У упаковщика внизу меню разделов — карточка стоит над ним */
  body:has(.bottom-nav) .tour { bottom: 72px; }
}
@media print { .tour { display: none; } }

/* Вход и публичные страницы */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.public { max-width: 780px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 16px; }
.hero { background: var(--blue-soft); border-radius: var(--r-lg); padding: 20px; }
.scanner video { width: 100%; max-height: 300px; border-radius: var(--r); background: #000; }
.label-preview { background: #fff; border: 1px dashed var(--muted); width: 330px; max-width: 100%; margin: 0 auto; padding: 12px; text-align: center; color: #000; }
.label-preview svg { width: 100%; height: 70px; }
.label-preview + .label-preview { margin-top: 8px; }
.label-name { font-size: 20px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.place-line { font-size: 16px; overflow-wrap: anywhere; }
.place-name { font-size: 16px; overflow-wrap: anywhere; }
.block-line { display: block; }

/* Кабинет упаковщика: крупно, под телефон */
.packer { max-width: 560px; margin: 0 auto; padding: 16px 16px 192px; display: flex; flex-direction: column; gap: 12px; }
.packer .kpi { padding: 12px; }
.packer .kpi .value { font-size: 16px; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); z-index: 20; }
.bottom-nav a { padding: 12px 4px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.bottom-nav a svg { width: 20px; height: 20px; display: block; margin: 0 auto 2px; }
.bottom-nav a.on { color: var(--blue); }

/* Логотип и страница UI-kit */
.login-logo { display: block; margin: 0 auto 12px; max-width: 100%; height: auto; }
.kit-logos { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.kit-logo { border: 1px solid var(--line); border-radius: var(--r); padding: 20px 16px 12px; text-align: center; }
.kit-logo img { width: 100%; max-width: 250px; height: 60px; object-fit: contain; }
.kit-logo.mark img { width: 60px; }
.kit-logo.tall img { height: 96px; }
.kit-logo figcaption { font-size: 12px; margin-top: 12px; color: var(--muted); }
.kit-logo.dark { background: var(--blue); border-color: var(--blue); }
.kit-logo.dark figcaption, .kit-logo.dark a { color: #fff; }
.kit-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.kit-color { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 8px; font: inherit; color: var(--ink); cursor: pointer; }
.kit-color i { height: 44px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 4px; }
.kit-icon { display: inline-flex; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--r); align-items: center; justify-content: center; }
.kit-icon svg { width: 18px; height: 18px; }

/* Печать счёта и акта */
.doc { background: #fff; color: #000; font-size: 13px; }
.doc .void { border: 2px solid var(--red); color: var(--red); padding: 8px 12px; text-align: center; }
.payment-row { padding: 4px 0; border-top: 1px solid var(--line); }
/* На телефоне широкая таблица счёта прокручивается внутри документа; печати это не касается */
@media screen and (max-width: 800px) { .doc { overflow-x: auto; } }
.doc table td, .doc table th { border: 1px solid #999; color: #000; }
.doc table td.right, .doc table th.right { text-align: right; }
.doc .sign { display: flex; justify-content: space-between; gap: 32px; margin-top: 36px; }
@media print {
  body { background: #fff; }
  body.printing #app { display: none; }
  body.printing .overlay { position: static; background: none; padding: 0; display: block; overflow: visible; }
  .deskbar, .fabs, body.printing .overlay:not(:last-of-type), body.printing .dialog-head, body.printing .no-print, #toasts { display: none !important; }
  body.printing .dialog { width: 100%; }
  .label-preview { border: 0; break-inside: avoid; }
  .label-preview + .label-preview { break-before: page; margin-top: 0; }
}

@media (max-width: 1100px) {
  .calc-layout, .card-layout, .card-layout .calc-layout { grid-template-columns: minmax(0, 1fr); }
  .calc-total { position: static; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 35; left: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 0 100vw #0006; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 25; }
  .main { padding: 16px 12px 128px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .item-head .name { flex-basis: calc(100% - 72px); }
  .overlay.side-panel .dialog { width: 100vw; }
}

/* Телефон: цели нажатия крупнее, а шрифт полей 16 px, чтобы экран не увеличивался при вводе. Блок стоит последним */
@media (max-width: 800px) {
  .btn { height: 40px; }
  .btn.sm { height: 36px; }
  .btn.lg { height: 48px; }
  .input, select.input { height: 40px; font-size: 16px; }
  textarea.input { height: auto; font-size: 16px; }
  .search > .icon { top: 11px; }
  .segmented button { height: 36px; }
  .check, .chip, .item-head .name, summary.fold, .card .link { min-height: 36px; }
}
