/* BLAGO — склад зеркал. Мобильная вёрстка, крупный шрифт, работа одной рукой.
 * Строгий стиль: без градиентов и теней, ровные углы. Светлая и тёмная темы на переменных:
 * тёмная включается по настройке телефона или кнопкой в шапке (html[data-theme]). */
/* Палитра — та же, что в BLAGO OTGRUZKI: тёмно-синий «slate» и фирменный золотой.
 * Светлая тема строгая: графитовые кнопки, золото только в логотипе.
 * Контраст основного и серого текста к фону — не ниже 4.5:1. */
:root {
	color-scheme: light;
	--bg: #f1f5f9;
	--card: #ffffff;
	--card-alt: #f8fafc;
	--text: #0f172a;
	--muted: #475569;
	--line: #e2e8f0;
	--line-strong: #cbd5e1;
	--accent: #1e293b;
	--accent-dark: #0f172a;
	--accent-soft: #e2e8f0;
	--on-accent: #ffffff;
	--focus: #f2b53b;
	--brand: #b7791f;
	--top-bg: #0b1120;
	--top-text: #f1f5f9;
	--th-bg: #f1f5f9;
	--group-bg: #e2e8f0;
	--ok: #15803d;
	--ok-bg: #dcfce7;
	--err: #b91c1c;
	--err-bg: #fee2e2;
	--warn: #9a5b00;
	--warn-bg: #fef3c7;
	--zero: #fecdd3;
	--neg: #dc2626;
	--ship-before: #fde7c8;
	--ship-ch: #fdf0e3;
	--ship-ch-cell: #fff8e8;
	--ship-after: #d1fae5;
	--radius: 6px;
}

/* Тёмная тема: по настройке системы, если пользователь не выбрал светлую */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--bg: #0f172a;
		--card: #151f33;
		--card-alt: #1a2540;
		--text: #f1f5f9;
		--muted: #94a3b8;
		--line: #24314a;
		--line-strong: #334155;
		--accent: #f2b53b;
		--accent-dark: #ffc85c;
		--accent-soft: #2a2416;
		--on-accent: #1a1405;
		--focus: #f2b53b;
		--brand: #f2b53b;
		--top-bg: #0b1120;
		--top-text: #f1f5f9;
		--th-bg: #1a2540;
		--group-bg: #1e2a44;
		--ok: #22c55e;
		--ok-bg: #0f2a1a;
		--err: #f87171;
		--err-bg: #3a1518;
		--warn: #fb923c;
		--warn-bg: #3a2412;
		--zero: #4a1f24;
		--neg: #b91c1c;
		--ship-before: #3a2c18;
		--ship-ch: #2f2618;
		--ship-ch-cell: #241f16;
		--ship-after: #12301f;
	}
}
:root[data-theme="dark"] {
	color-scheme: dark;
	--bg: #0f172a;
	--card: #151f33;
	--card-alt: #1a2540;
	--text: #f1f5f9;
	--muted: #94a3b8;
	--line: #24314a;
	--line-strong: #334155;
	--accent: #f2b53b;
	--accent-dark: #ffc85c;
	--accent-soft: #2a2416;
	--on-accent: #1a1405;
	--focus: #f2b53b;
	--brand: #f2b53b;
	--top-bg: #0b1120;
	--top-text: #f1f5f9;
	--th-bg: #1a2540;
	--group-bg: #1e2a44;
	--ok: #22c55e;
	--ok-bg: #0f2a1a;
	--err: #f87171;
	--err-bg: #3a1518;
	--warn: #fb923c;
	--warn-bg: #3a2412;
	--zero: #4a1f24;
	--neg: #b91c1c;
	--ship-before: #3a2c18;
	--ship-ch: #2f2618;
	--ship-ch-cell: #241f16;
	--ship-after: #12301f;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 18px;
	line-height: 1.4;
	-webkit-tap-highlight-color: transparent;
	/* Ничто не должно растягивать страницу вбок на телефоне */
	overflow-x: clip;
}

a { color: var(--accent); }

header.top {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 16px;
	background: var(--top-bg);
	color: var(--top-text);
	border-bottom: 1px solid #000;
}
header.top a { color: var(--top-text); text-decoration: none; }
header.top .brand { display: flex; align-items: baseline; gap: 8px; }
header.top .brand b { font-size: 22px; font-weight: 800; letter-spacing: .18em; color: var(--brand); }
header.top .brand span { font-size: 13px; opacity: .6; letter-spacing: .04em; }
header.top .who {
	margin-left: auto; min-width: 0; text-align: right; font-size: 15px; line-height: 1.2;
	overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
header.top .who small { display: block; opacity: .6; overflow: hidden; text-overflow: ellipsis; }
header.top .brand, header.top form, header.top button.theme { flex-shrink: 0; }
header.top form { margin: 0; }
header.top button.exit, header.top button.theme {
	min-height: 38px; padding: 6px 12px; font-size: 15px; font-weight: 600;
	background: transparent; color: var(--top-text); border: 1px solid rgba(255, 255, 255, .3);
}
header.top button.exit:hover, header.top button.theme:hover { background: rgba(255, 255, 255, .1); }
header.top button.theme { min-width: 38px; padding: 6px 8px; font-size: 17px; }

nav.menu {
	display: flex; flex-wrap: wrap; gap: 6px;
	padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
nav.menu a {
	flex: 0 0 auto; display: inline-flex; align-items: center; padding: 8px 14px; min-height: 42px;
	border-radius: var(--radius); color: var(--text); text-decoration: none;
	border: 1px solid var(--line); font-size: 16px; font-weight: 600; white-space: nowrap;
}
nav.menu a:hover { background: var(--accent-soft); }
nav.menu a.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

main { padding: 14px; max-width: 1200px; margin: 0 auto; }

h1 { font-size: 24px; margin: 4px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 18px 0 10px; }
.card > h2:first-child, .card > .line:first-child h2 { margin-top: 0; }

.card {
	background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
	padding: 16px; margin-bottom: 12px;
	/* Широкая таблица прокручивается внутри карточки, а не растягивает страницу */
	overflow-x: auto;
}

label { display: block; margin: 10px 0 4px; font-weight: 600; }

input[type=text], input[type=number], input[type=password], input[type=search],
input[type=date], input[type=time], select, textarea {
	width: 100%; min-height: 48px; padding: 10px 12px; font-size: 18px;
	border: 1px solid var(--line-strong); border-radius: var(--radius);
	background: var(--card); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); border-color: var(--accent); }

button, .btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 10px 18px; font-size: 18px; font-weight: 600;
	border: 1px solid var(--accent); border-radius: var(--radius);
	background: var(--accent); color: var(--on-accent);
	cursor: pointer; text-decoration: none; transition: background .15s;
}
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary { background: var(--card); color: var(--text); border-color: var(--line-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--accent-soft); }
button.danger, .btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.big, .btn.big { width: 100%; min-height: 68px; font-size: 21px; }
button.big.secondary, .btn.big.secondary { background: var(--card); }
button:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > * { flex: 1 1 200px; }
.row.tight > * { flex: 0 0 auto; }

.muted { color: var(--muted); font-size: 15px; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 14px; }

.msg { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; font-weight: 600; border-left: 4px solid currentColor; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--th-bg); font-size: 14px; font-weight: 700; position: sticky; top: 0; z-index: 2; }
tr.header-row td { font-weight: 700; background: var(--group-bg); text-transform: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.zero { background: var(--zero); }
/* Строки с цветом подгруппы из TOP — цвета светлые, текст на них всегда тёмный */
/* В строке с цветом подгруппы ячейки всегда в светлых цветах, как в гугл-таблице, и в тёмной теме тоже */
tr[style*="background"], td[style*="background"] {
	color: #14171f;
	--zero: #f6cfd2; --ship-ch-cell: #fff8e8; --neg: #d92d20; --accent: #1f3a8a;
}

.badge {
	display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 4px;
	font-size: 14px; font-weight: 600; background: var(--group-bg); color: var(--text);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* Экран сканирования */
.scan-result { padding: 20px 18px 20px 62px; border-radius: var(--radius); font-size: 22px; font-weight: 700; margin-bottom: 12px; position: relative; }
.scan-result:empty { display: none; }
.scan-result.ok { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
.scan-result.err { background: var(--err-bg); color: var(--err); border: 2px solid var(--err); }
.scan-result.warn { background: var(--warn-bg); color: var(--warn); border: 2px solid var(--warn); }
.scan-result.warn::before { content: "!"; background: var(--warn); }
.scan-result.ok::before, .scan-result.err::before, .scan-result.warn::before {
	position: absolute; left: 16px; top: 18px; width: 32px; height: 32px; border-radius: 4px;
	display: flex; align-items: center; justify-content: center; color: var(--card); font-size: 20px;
}
.scan-result.ok::before { content: "✓"; background: var(--ok); }
.scan-result.err::before { content: "✕"; background: var(--err); }
.scan-result .sub { font-size: 17px; font-weight: 500; margin-top: 6px; }
.scan-input { font-size: 22px; min-height: 56px; }
.scan-history { list-style: none; padding: 0; margin: 0; }
.scan-history li { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 16px; }
.scan-history li.ok { border-left: 4px solid var(--ok); }
.scan-history li.err { border-left: 4px solid var(--err); }
.scan-history li.warn { border-left: 4px solid var(--warn); }
#batch-table tr.done td { color: var(--muted); }
#batch-table tr.short td:first-child { color: var(--err); font-weight: 600; }

/* Прогресс задач */
.progress { height: 10px; background: var(--group-bg); border-radius: 2px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); }

.task { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--card-alt); }
.task.done { background: var(--ok-bg); border-color: var(--ok); }
.task .line, .line { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.task .name { font-weight: 700; font-size: 19px; }

/* Камера */
#camera-box { width: 100%; max-width: 420px; margin: 0 auto; }
#camera-box .camera-frame { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
#camera-box video { display: block; width: 100%; }
/* Прицел совпадает с полосой кадра, которая уходит в распознавание (15% сверху и снизу отрезаются) */
#camera-box .camera-aim {
	position: absolute; left: 4%; right: 4%; top: 15%; bottom: 15%;
	border: 3px solid rgba(255, 255, 255, .9); border-radius: 4px;
	box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none;
}
#camera-box .camera-aim::after {
	content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: #e53935;
}

.table-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table { min-width: 560px; }
.table-wrap td.sticky, .table-wrap th.sticky {
	position: sticky; left: 0; background: var(--card); z-index: 3; box-shadow: 1px 0 0 var(--line);
}
.table-wrap th.sticky { z-index: 4; background: var(--th-bg); }
.dense td, .dense th { padding: 1px 8px; font-size: 13px; line-height: 1.3; }
.dense tr.header-row td { padding: 3px 8px; }
.table-wrap .mini { min-height: 26px; padding: 2px 8px; font-size: 13px; font-weight: 600; }
.table-wrap thead th { padding: 4px 8px; font-size: 13px; }
.stock-controls .card { padding: 10px; }

.hint { font-size: 15px; color: var(--muted); margin-top: 4px; }

/* Компактная форма закрытия смены прямо в табло */
.inline-form input, .inline-form select { min-height: 34px; font-size: 14px; padding: 4px 8px; }
.inline-form button { min-height: 34px; font-size: 14px; padding: 4px 10px; }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.card:hover { border-color: var(--accent); }
a.card h2 { color: var(--text); margin-top: 0; }
a.card.tile { border-left: 4px solid var(--accent); }

/* Погрузка: плитки каналов и выбор машины */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.channel-grid form { margin: 0; }
.channel-btn { width: 100%; min-height: 92px; font-size: 24px; font-weight: 800; letter-spacing: .03em; }
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
	display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 14px 18px; min-height: 56px;
	border: 2px solid var(--line); border-radius: var(--radius); font-size: 20px; cursor: pointer; background: var(--card);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 22px; height: 22px; }
.counter { font-size: 20px; }
.counter b { font-size: 30px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 10px auto; }
.pinpad button { min-height: 60px; font-size: 24px; background: var(--card); color: var(--text); border: 1px solid var(--line-strong); }
.pinpad button:hover { background: var(--accent-soft); }
.pin-dots { font-size: 32px; letter-spacing: 8px; text-align: center; min-height: 44px; }
@media (max-width: 600px) {
	main { padding: 10px; }
	/* На телефоне меню — одна строка с прокруткой пальцем */
	nav.menu { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 8px 12px; }
	nav.menu::-webkit-scrollbar { display: none; }
	nav.menu a { padding: 9px 14px; min-height: 44px; font-size: 16px; }
	/* Шапка в одну строку: длинное имя обрезается многоточием, а не растягивает страницу вбок */
	header.top { gap: 8px; padding: 8px 10px; }
	header.top .brand b { font-size: 19px; letter-spacing: .12em; }
	header.top .brand span { display: none; }
	header.top .who { font-size: 14px; }
	header.top button.exit { padding: 6px 10px; }
}


/* Экран входа */
.login-hero {
	max-width: 460px; margin: 6px auto 12px; padding: 22px 20px; border-radius: var(--radius);
	text-align: center; color: #fff; background: var(--top-bg);
}
.login-logo { font-size: 40px; font-weight: 800; letter-spacing: .22em; padding-left: .22em; color: var(--brand); }
.login-hero p { margin: 4px 0 0; opacity: .7; }
.login-card { max-width: 460px; margin: 0 auto; }
.login-theme { max-width: 460px; margin: 10px auto 0; text-align: center; }

/* Таблицы на телефоне: компактнее, текст ячеек не ломается по буквам */
@media (max-width: 600px) {
	th, td { padding: 6px 8px; font-size: 15px; }
	th { white-space: nowrap; }
}

/* Табло: закрытие забытой смены спрятано, чтобы строки оставались короткими */
details.close-shift summary {
	cursor: pointer; color: var(--accent); font-weight: 600; font-size: 15px; white-space: nowrap;
	list-style: none;
}
details.close-shift summary::-webkit-details-marker { display: none; }
details.close-shift .inline-form { display: grid; gap: 6px; margin-top: 6px; min-width: 200px; }
#board-table td { white-space: nowrap; }

/* Кабинет администратора: действия по ролям */
.admin-section { margin-bottom: 22px; }
.admin-section h1, .admin-section h2 { display: flex; align-items: center; gap: 10px; }
.admin-section h1::before, .admin-section h2::before { content: ""; width: 4px; height: 24px; background: var(--accent); }
.admin-section.keeper h1::before, .admin-section.keeper h2::before { background: #c27a00; }
.admin-section.assembler h1::before, .admin-section.assembler h2::before { background: #0f8a7c; }
.admin-section.loader h1::before, .admin-section.loader h2::before { background: #2b6cd9; }
.admin-section.returns h1::before, .admin-section.returns h2::before { background: #c2255c; }
.admin-section.admin h1::before, .admin-section.admin h2::before { background: var(--muted); }
.admin-section.later h1::before, .admin-section.later h2::before { background: var(--line-strong); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.grid3 .card { margin: 0; padding: 12px 14px; }
.grid3 h3 { margin: 0 0 4px; font-size: 17px; color: var(--text); }
.grid3 p { margin: 0; }

/* Отгрузка: группы столбцов как в гугл-таблице */
.shipments th.group { text-align: center; font-size: 13px; }
.shipments th.group.before { background: var(--ship-before); }
.shipments th.group.ch { background: var(--ship-ch); }
.shipments th.group.after { background: var(--ship-after); }
.shipments td.ch { background: var(--ship-ch-cell); }
.shipments td.neg { background: var(--neg); color: #fff; font-weight: 700; }
.shipments tr.totals th { background: var(--th-bg); font-size: 13px; }
/* Шапка из трёх строк закреплена целиком: при прокрутке видно, что за столбец */
.shipments thead { position: sticky; top: 0; z-index: 5; }
.shipments thead th { position: static; }
.shipments thead th.sticky { position: sticky; left: 0; z-index: 6; }
/* В закреплённой шапке рамки рисуем тенью: у border-collapse они при прокрутке пропадают */
.shipments thead tr:last-child th { box-shadow: inset 0 -2px 0 var(--line-strong); }

/* Вкладки раздела «Склад» */
.subtabs { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a {
	flex: 0 0 auto; padding: 8px 14px; text-decoration: none; white-space: nowrap;
	color: var(--muted); font-weight: 600; font-size: 15px;
	border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.subtabs a:hover { color: var(--text); }
.subtabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* Отгрузка: сетка по клеточкам, как в гугл-таблице */
.shipments { border-collapse: collapse; }
.shipments th, .shipments td { border: 1px solid var(--line-strong); }
.shipments td.num, .shipments th.num { min-width: 46px; }
.shipments tr.header-row td { border-left: 1px solid var(--line-strong); }

/* Маленькая кнопка «Закончить смену» — чтобы не нажать случайно */
button.small-btn { min-height: 36px; padding: 6px 12px; font-size: 14px; font-weight: 600; }

/* Выбор артикула: поиск + выпадающий список */
.article-picker { position: relative; flex: 1 1 260px; min-width: 220px; }
.article-picker .ap-input { padding-right: 36px; }
.article-picker.chosen .ap-input { border-color: var(--ok); background: var(--ok-bg); font-weight: 600; }
.article-picker.chosen::after {
	content: "✓"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
	color: var(--ok); font-weight: 800; pointer-events: none;
}
.article-picker.error .ap-input { border-color: var(--err); outline: 3px solid var(--err-bg); }
.ap-list {
	position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px);
	max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
	background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius);
	box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
}
.ap-list li { padding: 10px 12px; border-radius: 4px; cursor: pointer; font-size: 17px; }
.ap-list li.active, .ap-list li:hover { background: var(--accent-soft); color: var(--text); }
.ap-list li.ap-empty { color: var(--muted); cursor: default; background: none; }
/* Форма новой задачи */
.task-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-top: 10px; }
.task-add .qty { width: 110px; flex: 0 0 110px; }
.task-add button { flex: 0 0 auto; }
.card:has(.article-picker) { overflow: visible; }

/* Задачи в «Отгрузке»: при наведении (или нажатии на телефоне) — кто делает */
.shipments td.who { position: relative; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
/* Подсказка: мышью — при наведении, на телефоне — по нажатию, убирается нажатием в любое место */
@media (hover: hover) {
	.shipments td.who:hover::after { content: attr(data-who); }
}
.shipments td.who.show::after { content: attr(data-who); }
.shipments td.who:hover::after, .shipments td.who.show::after {
	position: absolute; z-index: 40; right: 0; top: 100%; margin-top: 4px;
	white-space: nowrap; padding: 6px 10px; border-radius: 4px; font-size: 13px; font-weight: 600;
	background: var(--top-bg); color: #fff; border: 1px solid var(--line-strong);
}

.channel-btn.site-btn { font-size: 20px; padding: 10px 8px; overflow-wrap: anywhere; }
.row.tight > * { max-width: 100%; }
.row.tight > button, .row.tight > form > button { white-space: normal; text-align: center; }

/* Переключатель «Сканер / Камера» над полем скана */
.scan-mode { display: inline-flex; gap: 0; margin: 0 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.scan-mode button {
	min-height: 38px; padding: 6px 16px; font-size: 15px; border-radius: 0; border: 0;
	background: var(--card); color: var(--text);
}
.scan-mode button.active { background: var(--accent); color: var(--on-accent); }
.scan-mode button:hover { background: var(--accent-soft); }
.scan-mode button.active:hover { background: var(--accent); }

/* Название группы в широкой таблице остаётся слева при прокрутке вбок */
tr.header-row .group-name { position: sticky; left: 8px; }
.shipments thead { background: var(--th-bg); }
/* Отгрузка: рамки без border-collapse, чтобы под закреплённой шапкой не просвечивали строки */
table.shipments { border-collapse: separate; border-spacing: 0; }
.shipments th, .shipments td { border: 0; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.shipments tr.header-row td { border-left: 0; }
.shipments thead tr:last-child th { box-shadow: none; border-bottom: 2px solid var(--line-strong); }

/* Погрузка: открытый канал площадки выделен, под названием — сколько уже загружено */
.channel-btn { flex-direction: column; gap: 2px; }
.channel-btn small { font-size: 14px; font-weight: 600; letter-spacing: 0; }
.channel-btn.secondary { color: var(--text); }

/* Выбор артикула: весь список площадки с заголовками подгрупп */
.ap-list { max-height: min(60vh, 460px); }
.ap-list li.ap-group {
	position: sticky; top: -4px; z-index: 1; margin: 4px -4px 0; padding: 6px 12px;
	font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
	color: var(--muted); background: var(--th-bg); cursor: default; border-radius: 0;
}
.ap-list li.ap-group:hover { background: var(--th-bg); color: var(--muted); }

/* Отгрузка: отсканировано в открытый канал — серым, в итог не входит до закрытия */
.shipments .pending { color: var(--muted); font-weight: 600; font-size: 12px; }
tr[style*="background"] .pending { color: #6b7280; }

/* Отгрузка: «!» у открытого канала — подсказка, кто и когда открыл */
.shipments .open-mark {
	position: relative; display: inline-flex; align-items: center; justify-content: center;
	width: 16px; height: 16px; margin-left: 2px; border-radius: 50%; vertical-align: 1px;
	background: var(--warn); color: #fff; font-size: 11px; font-weight: 800; cursor: help;
}
@media (hover: hover) {
	.shipments .open-mark:hover::after { content: attr(data-tip); }
}
.shipments .open-mark.show::after { content: attr(data-tip); }
.shipments .open-mark:hover::after, .shipments .open-mark.show::after {
	position: absolute; z-index: 40; right: -6px; top: 100%; margin-top: 6px;
	white-space: pre; text-align: left; padding: 6px 10px; border-radius: 4px;
	font-size: 13px; font-weight: 600; line-height: 1.4;
	background: var(--top-bg); color: #fff; border: 1px solid var(--line-strong);
}

/* Отгрузка: «20 (сделано 20)» в одну строку — иначе строки таблицы разъезжаются */
.shipments td.num { white-space: nowrap; }
.shipments td.num .muted { font-size: 11px; }

/* Партии BLAGO OTGRUZKI и вопросы по нехватке */
.ship-alert { display: block; padding: 10px 16px; background: var(--err-bg); color: var(--err); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--err); }
tr.ship-moved td { background: var(--warn-bg); }
tr.ship-removed td { color: var(--muted); }
tr.ship-loaded td { color: var(--muted); }
tr.overdue td { color: var(--err); font-weight: 600; }
.urgent-list { list-style: none; margin: 0; padding: 0; }
.urgent-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.urgent-list li:last-child { border-bottom: 0; }
.urgent-list .line { display: flex; justify-content: space-between; gap: 12px; }
.urgent-list li.overdue, .urgent-list li.overdue .muted { color: var(--err); }
.urgent-list li.done { color: var(--muted); }
.urgent-task { margin: 0 0 12px; padding: 12px 14px; border: 2px solid var(--err); border-radius: 10px; background: var(--err-bg); color: var(--err); font-size: 17px; }
.urgent-task .sub { font-size: 14px; margin-top: 4px; }
.urgent-task.overdue { animation: urgent-blink 1.2s ease-in-out infinite alternate; }
@keyframes urgent-blink { from { box-shadow: 0 0 0 0 var(--err); } to { box-shadow: 0 0 0 4px transparent; } }
@media (prefers-reduced-motion: reduce) { .urgent-task.overdue { animation: none; } }
.batch-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 14px; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.moved-list li { background: var(--warn-bg); color: var(--warn); padding: 6px 10px; border-left: 4px solid var(--warn); margin-bottom: 4px; }

/* Фильтры и формы «в строку» на компьютере: дата, площадка и кнопка — рядом, а не столбиком */
@media (min-width: 700px) {
	.row.tight > input, .row.tight > select { width: auto; min-width: 190px; }
	.row.tight > input[type=date] { min-width: 170px; }
}
.badge.muted-badge { background: var(--card-alt); color: var(--muted); border: 1px solid var(--line); }
.worker-free { border-bottom: 1px solid var(--line); padding: 8px 0; }
.worker-free summary { cursor: pointer; font-weight: 600; }
.worker-free .task-add { margin-top: 8px; }

/* План отгрузки (2026-10-30): цвет строки — решение склада */
.plan tr.plan-go td { background: var(--ok-bg); }
.plan tr.plan-no td { background: var(--err-bg); }
.plan tr.plan-ask td, .plan tr.plan-work td { background: var(--warn-bg); }
.plan tr.plan-done td { background: var(--ok-bg); }
.plan tr.plan-no td.state { color: var(--err); font-weight: 600; }
.plan tr.plan-ask td.state, .plan tr.plan-work td.state { color: var(--warn); font-weight: 600; }
.plan tr.plan-done td.state { color: var(--ok); }
.plan td.ch.full { color: var(--ok); font-weight: 700; }
.plan td.state { white-space: nowrap; }
.plan td.state .muted { white-space: normal; font-weight: 400; font-size: 12px; max-width: 260px; }
.plan-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; }
.plan-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.plan-chip.go { background: var(--ok-bg); color: var(--ok); }
.plan-chip.work, .plan-chip.ask { background: var(--warn-bg); color: var(--warn); }
.plan-chip.no { background: var(--err-bg); color: var(--err); }
label.check { display: flex; align-items: center; gap: 6px; align-self: end; min-height: 44px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.check-list label.check { min-height: 40px; align-self: auto; }

/* Заголовки каналов не переносятся: «Озон 1» в одну строку, иначе «1» выглядит как цифра в таблице */
.shipments thead th.ch { white-space: nowrap; }

/* Сколько из остатка — старые без нашей этикетки (2026-11-04) */
.old-count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 12px;
	font-weight: 700; line-height: 18px; background: #f59e0b; color: #1f1300; vertical-align: 1px; }

/* ---------- Современный вид таблиц (2026-11-05) ----------
   Формат прежний: те же столбцы, заливка цветами из TOP, заголовки подгрупп, кнопки «копировать».
   Меняется только отделка: скругления, лёгкая тень, тонкие линии, подсветка строки под курсором. */
:root {
	--tbl-radius: 12px;
	--tbl-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
	--tbl-line: #e9edf2;
	--tbl-hover: rgba(15, 23, 42, .045);
	--tbl-head: #f8fafc;
	--tbl-head-text: #64748b;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--tbl-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
		--tbl-line: #222d42;
		--tbl-hover: rgba(255, 255, 255, .05);
		--tbl-head: #18233b;
		--tbl-head-text: #94a3b8;
	}
}
:root[data-theme="dark"] {
	--tbl-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
	--tbl-line: #222d42;
	--tbl-hover: rgba(255, 255, 255, .05);
	--tbl-head: #18233b;
	--tbl-head-text: #94a3b8;
}
table { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--tbl-line); }
th {
	background: var(--tbl-head); color: var(--tbl-head-text); font-size: 12px; font-weight: 600;
	text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line-strong);
}
tbody tr:last-child td { border-bottom: 0; }
/* Подсветка строки под курсором поверх любой заливки, цвет из TOP остаётся виден */
/* Подсветка — фоновой картинкой поверх заливки: дешевле огромной внутренней тени, скролл не тормозит */
tbody tr:hover > td { background-image: linear-gradient(var(--tbl-hover), var(--tbl-hover)); }
/* В цветных строках линии чуть темнее, чтобы строки не сливались */
tr[style*="background"] > td { border-bottom-color: #d9dde3; }
tr.header-row td {
	background: var(--group-bg); font-size: 12px; font-weight: 700; letter-spacing: .06em;
	text-transform: uppercase; box-shadow: inset 3px 0 0 var(--brand); border-bottom: 1px solid var(--line-strong);
}
tbody tr.header-row:hover > td { background-image: none; }
td.zero { color: rgba(20, 23, 31, .45); }

/* Таблица внутри карточки и в прокрутке — скруглённый блок с тенью */
.table-wrap, .card:has(> table), .card:has(> .scroll > table) {
	border: 1px solid var(--line); border-radius: var(--tbl-radius); box-shadow: var(--tbl-shadow);
	contain: paint;
}
.card:has(> table) { padding: 0; overflow: hidden; }
.card:has(> table) > :not(table) { margin-left: 14px; margin-right: 14px; }
.table-wrap { background: var(--card); }
.table-wrap thead th { padding: 8px 10px; font-size: 12px; }
.dense td { padding: 3px 10px; font-size: 13.5px; }
.dense tr.header-row td { padding: 7px 10px; }
.table-wrap td.sticky, .table-wrap th.sticky { box-shadow: 1px 0 0 var(--tbl-line); }
.table-wrap th.sticky { background: var(--tbl-head); }

/* Кнопки «копировать» в шапке — аккуратные, не спорят с цифрами */
.table-wrap .mini {
	min-height: 24px; padding: 1px 10px; font-size: 12px; font-weight: 600; border-radius: 999px;
	text-transform: none; letter-spacing: 0; color: var(--muted); background: var(--card); border-color: var(--line);
}
.table-wrap .mini:hover { color: var(--text); border-color: var(--line-strong); background: var(--card-alt); }

/* Таблица отгрузок с сеткой как в Excel: линии тоньше */
.shipments th, .shipments td { border-right-color: var(--tbl-line); border-bottom-color: var(--tbl-line); }
.shipments thead tr:last-child th { border-bottom: 1px solid var(--line-strong); }
.old-count { border-radius: 999px; }
.table-wrap thead tr + tr th { text-transform: none; letter-spacing: 0; }
.table-wrap .mini { color: var(--text); }

/* ---------- Большие таблицы: ровные строки, широкий и полноэкранный режим (2026-11-06) ---------- */
/* Все строки одной высоты: текст не переносится, ячейка не растёт от «(сделано 20)» или «+1» */
.table-wrap td, .table-wrap th { white-space: nowrap; }
.table-wrap tbody td { height: 26px; line-height: 20px; padding-top: 2px; padding-bottom: 2px; vertical-align: middle; }
.table-wrap tbody td * { line-height: inherit; }
.shipments td.num, .shipments th.num { min-width: 56px; }
/* Закреплённый столбец — рамкой, а не тенью: тень на сотнях ячеек перерисовывается на каждом кадре */
.table-wrap td.sticky, .table-wrap th.sticky { box-shadow: none; border-right: 1px solid var(--line-strong); }
.table-wrap { overscroll-behavior: contain; }

/* Страница с большой таблицей — на всю ширину окна */
body.wide main { max-width: none; }

/* Кнопка над таблицей */
.tbl-tools { display: flex; justify-content: flex-end; margin: 0 0 6px; }
.tbl-tools button, .tbl-exit {
	min-height: 32px; padding: 4px 12px; font-size: 13px; font-weight: 600; border-radius: 999px;
	background: var(--card); color: var(--text); border: 1px solid var(--line-strong);
}
.tbl-tools button:hover, .tbl-exit:hover { background: var(--card-alt); border-color: var(--line-strong); }

/* Полноэкранный режим: таблица поверх страницы, на всё окно */
body.tbl-full-open { overflow: hidden; }
.tbl-full {
	position: fixed !important; inset: 0; z-index: 200; margin: 0 !important; max-height: none !important;
	border-radius: 0 !important; border: 0 !important; overflow: auto !important; background: var(--card);
	padding: 0 !important;
}
.card.tbl-full { padding: 12px !important; }
.tbl-exit {
	display: none; position: fixed; z-index: 210;
	bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: calc(20px + env(safe-area-inset-right, 0px));
	min-height: 40px; padding: 6px 16px; font-size: 14px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
body.tbl-full-open .tbl-exit { display: inline-flex; align-items: center; }

/* Цветные строки (заливка из TOP) всегда светлые — линии в них тёмные в любой теме,
   иначе в тёмной теме белёсые линии столбцов на светлой заливке не видны */
/* Линии только сплошным цветом: полупрозрачные на тысячах ячеек «Отгрузки» тормозят прокрутку */
tr[style*="background"] > td { border-bottom-color: #d0d4db; border-right-color: #d0d4db; }
.shipments th, .shipments td { border-right-color: var(--line-strong); border-bottom-color: var(--line-strong); }
.shipments tr[style*="background"] > td { border-right-color: #c6cbd3; border-bottom-color: #d0d4db; }

/* Пока таблицу крутят, строки не реагируют на мышь: иначе подсветка «бежит» по строкам
   и широкая «Отгрузка» перерисовывается на каждом кадре. Остановились — подсветка снова есть */
.table-wrap.is-scrolling table { pointer-events: none; }
.table-wrap.is-scrolling tbody tr:hover > td { background-image: none; }

/* ---------- Таблицы на телефоне: видно и артикул, и цифры (2026-11-06) ---------- */
@media (max-width: 600px) {
	.table-wrap { max-height: calc(100vh - 150px); }
	.table-wrap table { min-width: 0; }
	.table-wrap th, .table-wrap td { font-size: 12px; padding: 2px 6px; }
	/* Артикул — треть экрана, длинное название в две строки; все строки одной высоты */
	.table-wrap td.sticky, .table-wrap th.sticky {
		width: 36vw; min-width: 36vw; max-width: 36vw; white-space: normal; overflow-wrap: anywhere;
	}
	.table-wrap tbody td { height: 32px; line-height: 14px; }
	.table-wrap tbody td.sticky {
		display: table-cell; overflow: hidden;
	}
	.table-wrap tbody td.sticky > .name-clip {
		display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	}
	/* Шапка переносится по словам — столбцы с цифрами остаются узкими */
	.table-wrap thead th { white-space: normal; font-size: 11px; line-height: 13px; letter-spacing: 0; text-transform: none; }
	.table-wrap td.num, .table-wrap th.num, .shipments td.num, .shipments th.num { min-width: 38px; }
	.table-wrap .mini { padding: 1px 6px; font-size: 11px; min-height: 22px; }
	.table-wrap .old-count { font-size: 10px; padding: 0 4px; margin-left: 3px; }
	tr.header-row .group-name { font-size: 11px; }
	/* Копирование столбцов — с компьютера; на телефоне эта строка только раздувает столбцы */
	.table-wrap tr.copy-row { display: none; }
}

/* План: покрашено «не едет» в отчёте BLAGO — серым, отдельно от «не хватит» */
.plan-chip.cut { background: var(--card-alt); color: var(--muted); border: 1px solid var(--line-strong); }
.plan tr.plan-cut td { color: var(--muted); }
.plan .cut-note { font-size: 11px; font-weight: 600; color: var(--warn); white-space: nowrap; text-transform: none; letter-spacing: 0; }
.plan .cut-mark { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700;
	line-height: 16px; background: #f59e0b; color: #1f1300; }
.plan-chip.cut b { color: var(--warn); }
.plan-chip .chip-split { font-weight: 500; opacity: .85; margin-left: 4px; }
.plan-chip.neutral { background: var(--card-alt); color: var(--text); border: 1px solid var(--line-strong); font-weight: 500; }
/* Плавающая подсказка [data-tip] */
.float-tip {
	position: fixed; z-index: 300; max-width: 280px; padding: 6px 10px; border-radius: 6px;
	white-space: pre-line; font-size: 13px; font-weight: 600; line-height: 1.4;
	background: var(--top-bg); color: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); pointer-events: none;
}
[data-tip]:not(.open-mark) { cursor: help; }
