:root {
  --ink: #1B1F1D; --ink-2: #3E4642; --muted: #5A635E; --line: #DDE0DC; --line-2: #ECEEEB;
  --bg: #F3F4F2; --card: #FFFFFF; --side: #1B1F1D; --side-act: #2C332F; --side-text: #B8BFBA;
  --accent: #E8A33D; --ok: #17643A; --ok-bg: #E3F3E9; --bad: #B42318; --bad-bg: #FDECEA;
  --warn: #8A4A06; --warn-bg: #FDF0DC; --blue: #1E40AF; --blue-bg: #E3EAFB;
  --mono: Consolas, 'IBM Plex Mono', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, 'Segoe UI', system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
input, select, button, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr { position: absolute; left: -9999px; }

/* Каркас */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 232px; max-width: 100%; background: var(--side); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 28px; }
.brand b { font-size: 15px; display: block; }
.brand span { font-size: 12px; color: #9AA39D; }
.nav { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-size: 14px; }
.nav:hover { color: #fff; }
.nav.act { background: var(--side-act); color: #fff; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--side-act); font-size: 13px; color: #9AA39D; display: flex; flex-direction: column; gap: 8px; }
.side-foot button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; text-align: left; text-decoration: underline; }
.side-foot button:hover { color: #fff; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 800px) {
  .side { flex-basis: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { padding: 0 8px 0 4px; width: 100%; }
  .side-foot { margin-top: 0; width: 100%; border-top: 0; flex-direction: row; justify-content: space-between; }
  .main { padding: 20px 16px; }
}

.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.head h1 { margin: 0; font-size: 26px; font-weight: 700; }
.head p { margin: 4px 0 0; color: var(--muted); }
.head .acts { display: flex; gap: 10px; flex-wrap: wrap; }
.row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card h2 { margin: 0; font-size: 16px; }
.grow { flex: 999 1 560px; }
.side-card { flex: 1 1 340px; }

/* Формы */
.f { display: flex; flex-direction: column; gap: 6px; flex: 1 1 180px; min-width: 0; }
.f > label, .f > .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); }
.fields { display: flex; flex-wrap: wrap; gap: 14px; }
.in { height: 44px; border: 1px solid #C9CDC8; border-radius: 8px; padding: 0 12px; background: #fff; font-size: 15px; width: 100%; min-width: 0; }
textarea.in { height: 80px; padding: 10px 12px; resize: vertical; }
.in:focus, .btn:focus-visible, .nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { height: 44px; padding: 0 16px; border: 1px solid #C9CDC8; border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: #000; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.big { height: 52px; font-size: 16px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.qty { display: flex; align-items: center; border: 1px solid #C9CDC8; border-radius: 8px; overflow: hidden; width: max-content; }
.qty button { width: 44px; height: 44px; border: 0; background: var(--bg); cursor: pointer; font-size: 18px; }
.qty input { width: 72px; height: 44px; border: 0; text-align: center; font-weight: 600; font-size: 15px; }
.err { color: var(--bad); font-weight: 600; font-size: 13px; }

/* Таблицы */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 10px 8px; white-space: nowrap; }
.tbl td { padding: 11px 8px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.off td { color: var(--muted); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 24px 8px; color: var(--muted); text-align: center; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-off { background: var(--line-2); color: #4A524D; }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-bad { background: var(--bad-bg); color: var(--bad); }

.kpis { display: flex; flex-wrap: wrap; gap: 16px; }
.kpi { flex: 1 1 200px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 28px; }

/* Предпросмотр этикетки */
.stage { background: repeating-linear-gradient(45deg, #ECEEEB 0 8px, #E4E7E3 8px 16px); border-radius: 10px; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; overflow: hidden; }
.stage .scaler { transform-origin: top left; }
.stage .label { box-shadow: 0 1px 3px rgba(0,0,0,.2); border-radius: 1mm; }
.dims { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

/* Этикетка (одинаково для экрана и печати) */
.label { position: relative; background: #fff; overflow: hidden; color: #000; font-family: Arial, 'Segoe UI', sans-serif; }
.label .lb-in { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; }
.label svg { display: block; shape-rendering: crispEdges; }
.label .lb-digits { font-family: Consolas, 'Courier New', monospace; line-height: 1.1; white-space: nowrap; }
.label .lb-name { font-weight: 700; line-height: 1.12; text-align: center; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; word-break: break-word; }

/* Вход */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: 100%; max-width: 380px; }

/* Модальное окно */
.modal-bg { position: fixed; inset: 0; background: rgba(27,31,29,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; }

#toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 380px; }
#toast div.bad { background: var(--bad); }
.fields.stack { flex-direction: column; }
.fields.stack > .f { flex: none; }
.card > .f { flex: none; }
.tbl th, .tbl td { white-space: nowrap; }
