/* Сапат CRM — light + dark theme, same tokens as lib/core/theme.dart.
   Brand book «Сапат Максимум» 2026: brand colour #213CA5 (white text on it 9.3:1),
   tints of it (--a03…--a15) for light backgrounds and selections. */
/* Montserrat (brand font, SIL OFL — fonts/OFL.txt), local woff2 only: screen titles,
   big numbers on Главная, the name on the start screen. Body text stays the system font. */
@font-face {
	font-family: 'Montserrat';
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url('../fonts/montserrat-cyrillic-600.woff2') format('woff2');
	unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
	font-family: 'Montserrat';
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url('../fonts/montserrat-latin-600.woff2') format('woff2');
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: 'Montserrat';
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url('../fonts/montserrat-cyrillic-700.woff2') format('woff2');
	unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
	font-family: 'Montserrat';
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url('../fonts/montserrat-latin-700.woff2') format('woff2');
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
	--accent: #213ca5;
	--brand-font: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	/* only for «оплачено» / success */
	--green: #1f6f50;
	/* second factory */
	--violet: #7a4fcf;
	--red: #c62828;
	--amber: #e09f00;
	--blue: #2f6db5;
	--bg: #f6f7f6;
	--border: #e3e6e4;
	--muted: #7a827e;
	--text: #1a1f1c;
	--outline: #c5ccc8;
	--a03: rgba(33, 60, 165, 0.03);
	--a06: rgba(33, 60, 165, 0.06);
	--a10: rgba(33, 60, 165, 0.1);
	--a12: rgba(33, 60, 165, 0.12);
	--a15: rgba(33, 60, 165, 0.15);
	--nav-h: 64px;
	--sat: env(safe-area-inset-top, 0px);
	--sab: env(safe-area-inset-bottom, 0px);
	--bottom-ui: var(--sab);
	--w: min(100vw, 600px);
	color-scheme: light;
}
/* light-only tokens (dark values below) */
:root {
	--surface: #fff;
	--surface-2: #f1f3f2;
	--surface-fade: rgba(255, 255, 255, 0.55);
	--frame: #e9ecea;
	--switch-off: #e1e4e2;
	--seg-on: #0f3d2b;
	--ebar: rgba(227, 230, 228, 0.6);
	--toast-bg: #1a1f1c;
	--toast-text: #fff;
	--toast-action: #8fd3b4;
	--bone: #e8ebe9;
	--bone-shine: #f7f9f8;
}
/* Dark theme: follows the phone unless «Профиль → Тема» picks one
   (html[data-theme="light" | "dark"]). Same colours as lib/core/theme.dart. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		--green: #4cb386;
		--violet: #9f7fe6;
		--red: #ef5350;
		--blue: #5b9be6;
		--bg: #111413;
		--border: #2f3532;
		--muted: #9aa39e;
		--text: #e6eae8;
		--outline: #4a524e;
		--surface: #1c201e;
		--surface-2: #252a27;
		--surface-fade: rgba(28, 32, 30, 0.55);
		--frame: #0b0d0c;
		--switch-off: #2a2f2c;
		--seg-on: #ccd3f0;
		--ebar: rgba(47, 53, 50, 0.6);
		--toast-bg: #e6eae8;
		--toast-text: #1a1f1c;
		--toast-action: #213ca5;
		--bone: #2a2f2c;
		--bone-shine: #363c39;
		--a12: rgba(33, 60, 165, 0.28);
		color-scheme: dark;
	}
}
:root[data-theme='dark'] {
	--green: #4cb386;
	--violet: #9f7fe6;
	--red: #ef5350;
	--blue: #5b9be6;
	--bg: #111413;
	--border: #2f3532;
	--muted: #9aa39e;
	--text: #e6eae8;
	--outline: #4a524e;
	--surface: #1c201e;
	--surface-2: #252a27;
	--surface-fade: rgba(28, 32, 30, 0.55);
	--frame: #0b0d0c;
	--switch-off: #2a2f2c;
	--seg-on: #ccd3f0;
	--ebar: rgba(47, 53, 50, 0.6);
	--toast-bg: #e6eae8;
	--toast-text: #1a1f1c;
	--toast-action: #213ca5;
	--bone: #2a2f2c;
	--bone-shine: #363c39;
	--a12: rgba(33, 60, 165, 0.28);
	color-scheme: dark;
}
*,
*::before,
*::after {
	box-sizing: border-box;
}
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	background: var(--bg);
}
body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--bg);
	color: var(--text);
	font: 400 14px/1.43 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
	font-variant-numeric: tabular-nums;
	-webkit-tap-highlight-color: transparent;
	overflow-x: hidden;
}
body.has-nav {
	--bottom-ui: calc(var(--nav-h) + var(--sab));
}
button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}
button {
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
}
h1, h2, h3, p {
	margin: 0;
}
b {
	font-weight: 600;
}
a {
	color: var(--accent);
}
[hidden] {
	display: none !important;
}

/* ---- icons ---- */
.i {
	width: 24px;
	height: 24px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	vertical-align: middle;
}

/* ---- shell ---- */
#app {
	width: var(--w);
	margin: 0 auto;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--bg);
}
@media (min-width: 701px) {
	html,
	body {
		background: var(--frame);
	}
	#app {
		border-left: 1px solid var(--border);
		border-right: 1px solid var(--border);
	}
}
.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 4px;
	min-height: calc(56px + var(--sat));
	padding: var(--sat) 4px 0 16px;
	background: var(--bg);
}
.topbar.back {
	padding-left: 4px;
}
.topbar h1 {
	font-family: var(--brand-font);
	flex: 1;
	min-width: 0;
	font-size: 20px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.topbar .acts {
	display: flex;
	align-items: center;
	gap: 2px;
}
main {
	padding: 4px 16px calc(var(--bottom-ui) + 24px);
}
body.has-fab main {
	padding-bottom: calc(var(--bottom-ui) + 96px);
}
.loadbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 100;
	overflow: hidden;
	opacity: 0;
	transition: opacity 0.2s;
	pointer-events: none;
}
body.loading .loadbar {
	opacity: 1;
}
.loadbar::before {
	content: '';
	position: absolute;
	top: 0;
	height: 100%;
	width: 40%;
	background: var(--accent);
	animation: lb 1.1s ease-in-out infinite;
}
@keyframes lb {
	from { left: -40%; }
	to { left: 100%; }
}

/* bottom navigation */
.nav {
	position: fixed;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: var(--w);
	z-index: 30;
	display: flex;
	height: calc(var(--nav-h) + var(--sab));
	padding-bottom: var(--sab);
	background: var(--surface);
	border-top: 1px solid var(--border);
}
.nav a {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	color: var(--text);
	text-decoration: none;
	font-size: 11px;
	font-weight: 500;
	min-width: 0;
}
.nav a span:first-child {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 30px;
	border-radius: 15px;
	transition: background 0.2s;
}
.nav a.on span:first-child {
	background: var(--a12);
}
.nav a.on {
	font-weight: 600;
}

/* floating action button */
.fab {
	position: fixed;
	z-index: 25;
	right: max(16px, calc((100vw - 600px) / 2 + 16px));
	bottom: calc(var(--bottom-ui) + 16px);
	display: flex;
	align-items: center;
	gap: 8px;
	height: 56px;
	padding: 0 20px 0 16px;
	border: 0;
	border-radius: 16px;
	background: var(--accent);
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}
.fab:active {
	filter: brightness(0.92);
}

/* sticky bottom action bar of forms */
.footbar {
	position: fixed;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: var(--w);
	z-index: 30;
	padding: 8px 16px calc(12px + var(--sab));
	background: var(--bg);
	border-top: 1px solid var(--border);
}
.footbar .tot {
	display: flex;
	align-items: baseline;
	margin-bottom: 8px;
}
.footbar .tot b {
	margin-left: auto;
	font-size: 20px;
	font-weight: 700;
}

/* banners (offline, update, install) */
#banners {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0 16px;
}
#banners:not(:empty) {
	padding-bottom: 8px;
}
.banner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 12px;
	font-size: 13px;
	background: var(--a06);
	border: 1px solid var(--a12);
}
.banner .i {
	width: 20px;
	height: 20px;
	color: var(--accent);
}
.banner.off {
	background: rgba(198, 40, 40, 0.06);
	border-color: rgba(198, 40, 40, 0.18);
	color: var(--red);
}
.banner.off .i {
	color: var(--red);
}
.banner > span {
	flex: 1;
	min-width: 0;
}
.banner .btn.text {
	height: 36px;
	padding: 0 10px;
}

/* ---- buttons ---- */
.btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 48px;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
}
.btn .i {
	width: 20px;
	height: 20px;
}
.btn:active {
	filter: brightness(0.93);
}
.btn:disabled {
	opacity: 0.5;
	cursor: default;
}
.btn.outline {
	background: transparent;
	color: var(--accent);
	border: 1px solid var(--border);
}
.btn.outline.danger {
	color: var(--red);
}
.btn.tonal {
	width: auto;
	min-height: 44px;
	padding: 0 20px;
	background: var(--a10);
	color: var(--accent);
}
.btn.text {
	width: auto;
	min-height: 44px;
	padding: 0 12px;
	background: transparent;
	color: var(--accent);
}
.btn.text.danger {
	color: var(--red);
}
.btn.small {
	min-height: 40px;
	font-size: 14px;
}
.btn.busy {
	color: transparent !important;
}
.btn.busy::after {
	content: '';
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid var(--on-accent, #fff);
	border-right-color: transparent;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}
.btn.outline.busy::after,
.btn.text.busy::after,
.btn.tonal.busy::after {
	border-color: var(--accent);
	border-right-color: transparent;
}
@keyframes spin {
	to { transform: rotate(360deg); }
}
.ibtn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--text);
}
.ibtn:active {
	background: rgba(127, 127, 127, 0.16);
}
.ibtn:disabled {
	opacity: 0.32;
}
.ibtn.sm .i {
	width: 20px;
	height: 20px;
}
body.offline .needs-net,
body.cached .needs-net {
	opacity: 0.5;
}

/* factory switcher chip */
.fsw {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 36px;
	margin: 0 8px 0 2px;
	padding: 0 4px 0 10px;
	border: 1px solid var(--border);
	border-radius: 18px;
	background: var(--surface);
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
}
.fsw .i {
	width: 16px;
	height: 16px;
}
.fsw .i:last-child {
	width: 20px;
	height: 20px;
}
.fsw.c0 { color: var(--accent); border-color: rgba(33, 60, 165, 0.5); }
.fsw.c1 { color: var(--violet); border-color: rgba(122, 79, 207, 0.5); }
.fsw.c2 { color: var(--amber); border-color: rgba(224, 159, 0, 0.5); }

/* ---- cards, rows ---- */
.card {
	display: block;
	width: 100%;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 14px;
	text-align: left;
	color: inherit;
}
.card.flush {
	padding: 0;
	overflow: hidden;
}
.tap {
	cursor: pointer;
}
.tap:active,
.tile.tap:active {
	background: var(--surface-2);
}
.stack {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}
.row.top {
	align-items: flex-start;
}
.g4 { gap: 4px; }
.g6 { gap: 6px; }
.g8 { gap: 8px; }
.g10 { gap: 10px; }
.wrap {
	flex-wrap: wrap;
	row-gap: 3px;
}
.grow {
	flex: 1;
	min-width: 0;
}
.ell {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.ell2 {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.tile {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 52px;
	padding: 10px 14px;
	border: 0;
	background: transparent;
	text-align: left;
	color: inherit;
}
.tile + .tile,
.divided > * + * {
	border-top: 1px solid var(--border);
}
.tile .t {
	flex: 1;
	min-width: 0;
}
.tile .t > b {
	display: block;
	font-weight: 500;
}
.tile .t > small,
.tile .t > .row {
	margin-top: 2px;
}
.tile .end {
	text-align: right;
	flex: none;
}
.tile .end small {
	display: block;
}
.title {
	font-weight: 600;
}
.big {
	font-size: 22px;
	font-weight: 700;
}
.val {
	font-size: 16px;
	font-weight: 700;
	white-space: nowrap;
}
small,
.small {
	font-size: 12px;
}
.xs {
	font-size: 11px;
}
.muted { color: var(--muted); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.accent { color: var(--accent); }
.green { color: var(--green); }
.bold { font-weight: 700; }
.strike { text-decoration: line-through; }
.mt4 { margin-top: 4px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; }
.hr {
	height: 1px;
	background: var(--border);
	margin: 11px 0;
}
.voided {
	opacity: 0.55;
}
.voided .val,
.voided .title {
	text-decoration: line-through;
}

/* section header */
.sh {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 20px 2px 8px;
	min-height: 52px;
}
.sh h2 {
	flex: 1;
	min-width: 0;
	font-size: 16px;
	font-weight: 600;
}
.sh .btn.text {
	margin-right: -10px;
}

/* key-value / labeled value */
.kv {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 3px 0;
}
.kv > span {
	flex: 1;
	color: var(--muted);
}
.kv > b {
	max-width: 62%;
	text-align: right;
	font-weight: 500;
	overflow-wrap: anywhere;
}
.kv > b.bold {
	font-weight: 700;
}
.lv {
	min-width: 0;
}
.lv small {
	display: block;
	color: var(--muted);
}
.lv b {
	display: block;
	margin-top: 2px;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
}
.lv b.big {
	font-size: 22px;
	font-weight: 700;
}
.cols {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	gap: 10px;
}

/* badges and chips */
.fb {
	display: inline-block;
	padding: 1px 6px;
	border: 1px solid;
	border-radius: 6px;
	font-size: 11px;
	line-height: 1.3;
	font-weight: 600;
	white-space: nowrap;
}
.fb.c0 { color: var(--accent); background: rgba(33, 60, 165, 0.1); border-color: rgba(33, 60, 165, 0.35); }
.fb.c1 { color: var(--violet); background: rgba(122, 79, 207, 0.1); border-color: rgba(122, 79, 207, 0.35); }
.fb.c2 { color: var(--amber); background: rgba(224, 159, 0, 0.1); border-color: rgba(224, 159, 0, 0.35); }
.chip {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.35;
	white-space: nowrap;
}
.chip.accent { color: var(--accent); background: rgba(33, 60, 165, 0.1); }
.chip.green { color: var(--green); background: rgba(31, 111, 80, 0.1); }
.chip.amber { color: var(--amber); background: rgba(224, 159, 0, 0.1); }
.chip.red { color: var(--red); background: rgba(198, 40, 40, 0.1); }
.chip.blue { color: var(--blue); background: rgba(47, 109, 181, 0.1); }
.chip.muted { color: var(--muted); background: rgba(122, 130, 126, 0.1); }
.chip.void { color: #fff; background: var(--muted); }
.due {
	font-size: 12px;
	font-weight: 500;
}
.due.red { color: var(--red); }
.due.amber { color: var(--amber); }
.due.muted { color: var(--muted); }

/* KPI tiles */
.kpis {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}
.kpi small {
	display: block;
	color: var(--muted);
}
.kpi b {
	font-family: var(--brand-font);
	font-variant-numeric: tabular-nums;
	display: block;
	margin: 6px 0 4px;
	font-size: 22px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
}
.kpi .d {
	display: flex;
	align-items: center;
	gap: 2px;
	font-size: 12px;
	font-weight: 600;
	min-height: 18px;
	white-space: nowrap;
}
.kpi .d .i {
	width: 13px;
	height: 13px;
	stroke-width: 2.5;
}
.kpi .d em {
	margin-left: 4px;
	font-style: normal;
	font-weight: 400;
	font-size: 11px;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
}
.d.up { color: var(--accent); }
.d.down { color: var(--red); }

/* month selector */
.monthsel {
	display: flex;
	align-items: center;
	padding: 2px 4px;
}
.monthsel b {
	flex: 1;
	text-align: center;
	font-size: 16px;
}

/* ---- fields ---- */
.field {
	position: relative;
	display: block;
	padding: 6px 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
}
.field > span {
	display: block;
	font-size: 12px;
	line-height: 16px;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.field input,
.field select,
.field textarea {
	display: block;
	width: 100%;
	border: 0;
	outline: 0;
	padding: 2px 0 3px;
	background: transparent;
	font-size: 16px;
	line-height: 22px;
	min-height: 27px;
	border-radius: 0;
	-webkit-appearance: none;
	appearance: none;
}
.field textarea {
	resize: vertical;
}
.field input[type='date'] {
	min-height: 27px;
}
.field:has(em) input {
	padding-right: 52px;
}
.field em {
	position: absolute;
	right: 12px;
	bottom: 9px;
	font-style: normal;
	color: var(--muted);
	pointer-events: none;
}
.field:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent);
}
.field.err {
	border-color: var(--red);
}
.field.sel .i {
	position: absolute;
	right: 10px;
	bottom: 10px;
	width: 20px;
	height: 20px;
	color: var(--muted);
	pointer-events: none;
}
.field.search {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
	min-height: 48px;
}
.field.search .i {
	color: var(--muted);
}
.field.search input {
	padding: 12px 0;
}
.ferr {
	margin: 4px 4px 0;
	font-size: 12px;
	color: var(--red);
}
.form {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.two {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	align-items: start;
}
.fsel small {
	display: block;
	margin-bottom: 6px;
	color: var(--muted);
}
.hint {
	font-size: 12px;
	color: var(--muted);
}
.switch {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 48px;
}
.switch span {
	flex: 1;
}
.switch input {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	width: 52px;
	height: 32px;
	border-radius: 16px;
	background: var(--switch-off);
	border: 2px solid var(--muted);
	transition: background 0.15s;
	flex: none;
}
.switch input::after {
	content: '';
	position: absolute;
	top: 6px;
	left: 6px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--muted);
	transition: all 0.15s;
}
.switch input:checked {
	background: var(--accent);
	border-color: var(--accent);
}
.switch input:checked::after {
	left: 22px;
	top: 2px;
	width: 24px;
	height: 24px;
	background: #fff;
}

/* segmented control */
.seg {
	display: flex;
	border: 1px solid var(--outline);
	border-radius: 22px;
	overflow: hidden;
	background: transparent;
}
.seg button {
	flex: 1;
	min-height: 42px;
	padding: 0 8px;
	border: 0;
	background: transparent;
	font-size: 14px;
	font-weight: 500;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.seg button + button {
	border-left: 1px solid var(--outline);
}
.seg button.on {
	background: var(--a12);
	color: var(--seg-on);
	font-weight: 600;
}
/* small «кг | г» switch under an ingredient amount */
.seg.sm {
	display: inline-flex;
}
.seg.sm button {
	flex: none;
	min-height: 28px;
	padding: 0 12px;
	font-size: 12px;
}

/* month picker next to search */
.msel {
	position: relative;
	display: flex;
	align-items: center;
	gap: 6px;
	flex: none;
	max-width: 48%;
	min-height: 48px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
}
.msel .i {
	width: 18px;
	height: 18px;
	color: var(--muted);
}
.msel select {
	min-width: 0;
	max-width: 100%;
	border: 0;
	outline: 0;
	background: transparent;
	font-size: 15px;
	-webkit-appearance: none;
	appearance: none;
	text-overflow: ellipsis;
}
.msel:focus-within {
	border-color: var(--accent);
}
.i.xs-i {
	width: 14px;
	height: 14px;
}
@media (max-width: 400px) {
	.topbar h1 {
		font-size: 18px;
	}
	.fsw {
		margin-right: 4px;
	}
}

/* choice chips */
.choices {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scrollbar-width: none;
	margin: 0 -16px;
	padding: 4px 16px;
}
.choices::-webkit-scrollbar {
	display: none;
}
.choices.wrapped {
	flex-wrap: wrap;
	overflow: visible;
	margin: 0;
	padding: 0;
}
.choice {
	position: relative;
	flex: none;
	height: 36px;
	padding: 0 14px;
	border: 1px solid var(--outline);
	border-radius: 8px;
	background: var(--surface);
	font-size: 14px;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.choice::after {
	content: '';
	position: absolute;
	inset: -4px 0;
}
.choice.on {
	background: var(--a15);
	border-color: transparent;
	font-weight: 600;
}
.choice .i {
	width: 16px;
	height: 16px;
}

/* ---- empty states ---- */
.empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	max-width: 300px;
	margin: 0 auto;
	padding: 10vh 0 24px;
}
.empty h3 {
	margin-top: 20px;
	font-size: 17px;
	font-weight: 600;
}
.empty p {
	margin-top: 6px;
	font-size: 13px;
	line-height: 1.4;
	color: var(--muted);
}
.empty .btn {
	margin-top: 20px;
}
.sheet .empty {
	padding-top: 24px;
}
.ib {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--s);
	height: var(--s);
	border-radius: 50%;
	background: var(--a06);
	color: var(--accent);
}
.ib > span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 70%;
	height: 70%;
	border-radius: 50%;
	background: var(--a12);
}
.ib .i {
	width: calc(var(--s) * 0.34);
	height: calc(var(--s) * 0.34);
}
.ib.muted {
	color: var(--muted);
	background: rgba(122, 130, 126, 0.06);
}
.ib.muted > span {
	background: rgba(122, 130, 126, 0.12);
}
.ie {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 4px 0;
}
.ie b {
	display: block;
	font-weight: 500;
}
.ie small {
	display: block;
	color: var(--muted);
	margin-top: 2px;
}
.ie-i {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	flex: none;
	background: rgba(122, 130, 126, 0.1);
	color: var(--muted);
}
.ie-i.accent {
	background: var(--a10);
	color: var(--accent);
}
.ie-i .i {
	width: 20px;
	height: 20px;
}
.addph {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	padding: 22px 16px;
	border: 1.2px dashed rgba(33, 60, 165, 0.45);
	border-radius: 12px;
	background: var(--a03);
	color: var(--accent);
	text-align: center;
}
.addph > span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--a12);
	margin-bottom: 10px;
}
.addph small {
	margin-top: 3px;
	color: var(--muted);
}
.warn {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 12px;
	border-radius: 12px;
	background: rgba(224, 159, 0, 0.1);
	border: 1px solid rgba(224, 159, 0, 0.4);
	font-size: 13px;
}
.warn b {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	margin-bottom: 4px;
}
.warn b .i {
	width: 18px;
	height: 18px;
	color: var(--amber);
}
.warn small {
	color: var(--muted);
	margin-top: 4px;
}
.note-amber {
	font-size: 11px;
	color: var(--amber);
}

/* charts */
.chart {
	display: block;
	overflow: visible;
}
.chart text {
	font-size: 10px;
	fill: var(--muted);
}
.chart .gl {
	stroke: var(--border);
	stroke-width: 1;
}
.echart {
	position: relative;
}
.ebars {
	position: absolute;
	inset: 12px 8px 4px;
	display: flex;
	align-items: flex-end;
	gap: 8px;
}
.ebars i {
	flex: 1;
	background: var(--ebar);
	border-radius: 4px 4px 0 0;
}
.echart::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(var(--surface), var(--surface-fade));
}
.elabel {
	position: absolute;
	z-index: 1;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--border);
	border-radius: 20px;
	background: var(--surface);
	color: var(--muted);
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
}
.elabel .i {
	width: 18px;
	height: 18px;
}
.legend {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 16px;
	margin-top: 10px;
	font-size: 12px;
	color: var(--muted);
}
.legend span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.legend i {
	width: 10px;
	height: 10px;
	border-radius: 2px;
}
.hbars .hb {
	padding: 6px 0;
}
.hb > i {
	display: block;
	height: 8px;
	margin-top: 4px;
	border-radius: 4px;
	background: var(--bg);
	overflow: hidden;
}
.hb > i > i {
	display: block;
	height: 100%;
	border-radius: 4px;
}
.progress {
	height: 6px;
	border-radius: 4px;
	background: var(--surface);
	overflow: hidden;
}
.progress i {
	display: block;
	height: 100%;
	background: var(--accent);
}

/* getting started */
.gs-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 14px;
	background: linear-gradient(90deg, rgba(33, 60, 165, 0.12), rgba(33, 60, 165, 0.03));
}
.gs-step .dot {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--a10);
	color: var(--accent);
	flex: none;
}
.gs-step .dot .i {
	width: 17px;
	height: 17px;
}
.gs-wrap {
	display: grid;
	grid-template-rows: 1fr;
	transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}
.gs-wrap > div {
	overflow: hidden;
	min-height: 0;
}
.gs-wrap.closing {
	grid-template-rows: 0fr;
	opacity: 0;
}
.gs-head .gs-x {
	align-self: flex-start;
	margin: -6px -6px 0 0;
	color: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
	.gs-wrap {
		transition: none;
	}
}
.gs-step.done .dot {
	background: var(--green);
	color: #fff;
}
.gs-step.done b {
	color: var(--muted);
	text-decoration: line-through;
}

/* ---- layers: sheets, dialogs ---- */
.layer {
	position: fixed;
	inset: 0;
	z-index: 60;
}
.scrim {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.32);
	opacity: 0;
	transition: opacity 0.18s;
}
.layer.in .scrim {
	opacity: 1;
}
.sheet {
	position: absolute;
	left: 50%;
	bottom: 0;
	width: var(--w);
	max-height: 92vh;
	max-height: 92dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
	transform: translate(-50%, 100%);
	transition: transform 0.2s ease-out;
	background: var(--surface);
	border-radius: 28px 28px 0 0;
	padding: 0 16px calc(20px + var(--sab));
}
.sheet.tall {
	height: 80vh;
	height: 80dvh;
}
.layer.in .sheet {
	transform: translate(-50%, 0);
}
.handle {
	width: 32px;
	height: 4px;
	margin: 12px auto;
	border-radius: 2px;
	background: var(--outline);
}
.sh-t {
	font-size: 18px;
	font-weight: 600;
	margin-bottom: 16px;
}
.row.sh-t {
	margin-bottom: 8px;
}
.row.sh-t h3 {
	font-size: 18px;
	font-weight: 600;
}
.sh-body .form + .btn,
.sh-body .btn + .btn {
	margin-top: 8px;
}
.plist {
	margin: 8px -16px 0;
}
.pitem {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 56px;
	padding: 8px 16px;
	border: 0;
	border-top: 1px solid var(--border);
	background: transparent;
	text-align: left;
}
.pitem:first-child {
	border-top: 0;
}
.pitem:active {
	background: var(--surface-2);
}
.pitem .t {
	flex: 1;
	min-width: 0;
}
.pitem b {
	display: block;
	font-weight: 400;
	font-size: 16px;
}
.pitem small {
	color: var(--muted);
}
.pitem .i {
	color: var(--amber);
	width: 20px;
	height: 20px;
}
/* multi-choice pick: tick box + sticky «Добавить (N)» */
.pbox {
	flex: none;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border: 2px solid var(--outline);
	border-radius: 6px;
}
.pbox.on {
	border-color: var(--accent);
	background: var(--accent);
}
.pbox .i {
	width: 16px;
	height: 16px;
	color: #fff;
	stroke-width: 3;
}
.pdone {
	position: sticky;
	bottom: 0;
	margin: 0 -16px;
	padding: 8px 16px 4px;
	background: var(--surface);
	border-top: 1px solid var(--border);
}
.pdone .btn {
	width: 100%;
}
.dialog {
	position: absolute;
	left: 50%;
	top: 50%;
	width: min(calc(100vw - 48px), 380px);
	transform: translate(-50%, -46%);
	opacity: 0;
	transition: all 0.18s;
	padding: 24px 24px 12px;
	border-radius: 14px;
	background: var(--surface);
}
.layer.in .dialog {
	transform: translate(-50%, -50%);
	opacity: 1;
}
.dialog h3 {
	font-size: 20px;
	font-weight: 600;
	margin-bottom: 12px;
}
.dialog p {
	color: var(--muted);
}
.dlg-a {
	display: flex;
	justify-content: flex-end;
	gap: 4px;
	margin-top: 16px;
}

/* toasts */
.toasts {
	position: fixed;
	z-index: 80;
	left: 50%;
	transform: translateX(-50%);
	bottom: calc(var(--bottom-ui) + 12px);
	width: min(calc(100vw - 24px), 576px);
	pointer-events: none;
}
.toast {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 48px;
	padding: 8px 8px 8px 16px;
	border-radius: 8px;
	background: var(--toast-bg);
	color: var(--toast-text);
	font-size: 14px;
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
	pointer-events: auto;
	animation: tin 0.18s ease-out;
}
.toast {
	touch-action: pan-y;
	transition: transform 0.15s ease, opacity 0.15s ease;
	user-select: none;
}
.toast > span {
	flex: 1;
	padding: 6px 0;
}
.toast.err {
	background: var(--red);
}
.toast button {
	min-height: 40px;
	padding: 0 10px;
	border: 0;
	background: transparent;
	color: var(--toast-action);
	font-weight: 700;
	white-space: nowrap;
}
.toast.err button {
	color: #fff;
}
@keyframes tin {
	from { transform: translateY(12px); opacity: 0; }
}

/* login / setup */
.center-page {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 100vh;
	min-height: 100dvh;
	padding: calc(32px + var(--sat)) 24px calc(32px + var(--sab));
}
/* full logo (mark + «САПАТ МАКСИМУМ»), white in the dark theme */
.logo-img {
	display: block;
	width: 160px;
	height: auto;
	margin: 0 auto 12px;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) .logo-img {
		filter: brightness(0) invert(1);
	}
}
:root[data-theme='dark'] .logo-img {
	filter: brightness(0) invert(1);
}
.center-page .app-name {
	text-align: center;
	color: var(--muted);
	font-size: 13px;
	margin: 0 0 24px;
}
.center-page h1 {
	font-family: var(--brand-font);
	text-align: center;
	font-size: 24px;
	font-weight: 700;
}
.center-page .sub {
	text-align: center;
	color: var(--muted);
	margin: 4px 0 28px;
}
.pass-field {
	position: relative;
}
.pass-field .ibtn {
	position: absolute;
	right: 4px;
	bottom: 4px;
	color: var(--muted);
}
.pass-field input {
	padding-right: 44px;
}
.secret {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	letter-spacing: 0.5px;
}
.code {
	padding: 2px 6px;
	border-radius: 6px;
	background: var(--bg);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
}

/* skeleton while the first load runs */
.bone {
	display: block;
	border-radius: 6px;
	background: linear-gradient(90deg, var(--bone) 30%, var(--bone-shine) 50%, var(--bone) 70%) 0 0 / 300% 100%;
	animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
	from { background-position: 100% 0; }
	to { background-position: 0 0; }
}

.fade {
	animation: fade 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes fade {
	from { opacity: 0; transform: translateY(12px); }
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
	.loadbar::before {
		left: 0;
		width: 100%;
		opacity: 0.6;
	}
}

/* ---- Главная: quick actions, section cards, folded charts ---- */
.qa {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 8px;
}
.qa .card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 12px 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--accent);
	text-align: center;
}
.qa .card span {
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
@media (max-width: 379px) {
	.qa {
		grid-template-columns: 1fr 1fr;
	}
	.qa .card {
		flex-direction: row;
		justify-content: center;
		padding: 12px 8px;
	}
}
.all-kpis {
	display: block;
	margin: 4px 0 4px auto;
}
.hcards {
	display: grid;
	gap: 12px;
	margin-top: 8px;
}
@media (min-width: 701px) {
	.hcards {
		grid-template-columns: 1fr 1fr;
		align-items: start;
	}
}
.hc-head {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px 4px 0 14px;
}
.hc-title {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 16px;
	text-align: left;
}
.hc-title b {
	font-weight: 600;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.hc-total {
	padding: 0 14px 10px;
	font-size: 14px;
	overflow-wrap: anywhere;
}
.hc .divided {
	border-top: 1px solid var(--border);
}
.hc .tile .end {
	white-space: nowrap;
}
.hc-empty {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 12px;
	padding: 10px 14px 14px;
	border-top: 1px solid var(--border);
}
.hc-empty small {
	flex: 1 1 140px;
}
.charts-toggle {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	font-size: 16px;
}

/* raw-material form: «Минимальный остаток» group */
.minstock > b {
	display: block;
	margin-bottom: 8px;
	font-weight: 600;
}
.minstock .hint {
	margin-top: 6px;
}
