:root {
  --bg: #f4f6f5; --panel: #ffffff; --line: #dfe4e2; --line-soft: #edf0ef;
  --text: #1c2523; --muted: #66736f; --accent: #0f7a5c; --accent-dark: #0b5f47; --accent-soft: #e3f3ee;
  --warn: #b7791f; --warn-soft: #fdf3dc; --bad: #b42318; --bad-soft: #fde8e6; --ok: #0f7a5c;
  --side: #17302a; --side-text: #cfdcd8; --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.4 "Segoe UI", Tahoma, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 18px 0 8px; font-weight: 600; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* каркас */
.layout { display: flex; min-height: 100vh; }
.side { width: 216px; flex: none; background: var(--side); color: var(--side-text); padding: 0 0 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: block; padding: 14px 16px; color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .2px; border-bottom: 1px solid #24443c; }
.side .brand span { color: #7fd1b7; }
.side h3 { margin: 14px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #85a199; font-weight: 600; }
.side a { display: block; padding: 5px 16px; color: var(--side-text); }
.side a:hover { background: #21433a; text-decoration: none; color: #fff; }
.side a.on { background: var(--accent); color: #fff; }
.main { flex: 1; min-width: 0; padding: 0 22px 40px; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.top .grow { flex: 1; }
.top form.search input { width: 320px; }
.user { color: var(--muted); }

/* элементы */
.btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); cursor: pointer; font: inherit; line-height: 1.3; }
.btn:hover { background: #f0f3f2; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--bad); border-color: #efc4bf; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.bar .grow { flex: 1; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; padding: 5px 8px; border: 1px solid #c9d1ce; border-radius: 4px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd8c6; outline-offset: 0; border-color: var(--accent); }
textarea { width: 100%; min-height: 54px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.msg { padding: 8px 12px; border-radius: var(--radius); margin: 0 0 10px; border: 1px solid var(--line); background: var(--panel); }
.msg.success { background: var(--accent-soft); border-color: #b9e0d3; }
.msg.error { background: var(--bad-soft); border-color: #f3c3be; color: #7a1a12; }
.msg.warning { background: var(--warn-soft); border-color: #f0dba9; }
ul.errorlist { margin: 2px 0; padding: 0; list-style: none; color: var(--bad); font-size: 12px; }

/* таблицы */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); background: #f8faf9; position: sticky; top: 0; z-index: 1; }
table.grid td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.grid tr:hover td { background: #f7faf9; }
table.grid tr.group td { font-weight: 600; background: #f3f6f5; }
table.grid tr.total td { font-weight: 600; background: #f3f6f5; border-top: 1px solid var(--line); }
table.grid td.act { white-space: nowrap; text-align: right; }
tr.deleted td { color: #9aa5a1; text-decoration: line-through; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: #eef1f0; color: var(--muted); white-space: nowrap; }
.tag.posted { background: var(--accent-soft); color: var(--accent-dark); }
.tag.draft { background: var(--warn-soft); color: var(--warn); }
.tag.deleted { background: var(--bad-soft); color: var(--bad); }
.neg { color: var(--bad); }
.pager { display: flex; gap: 6px; align-items: center; margin: 10px 0; color: var(--muted); }

/* формы */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 18px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.field input[type=text], .field input[type=number], .field select, .field input[type=datetime-local], .field input[type=date] { width: 100%; }
.field.check label { display: inline; font-size: 14px; color: var(--text); margin-left: 4px; }
.field.wide { grid-column: 1 / -1; }
.field .help { font-size: 12px; color: var(--muted); }
.lookup { position: relative; display: block; }
.lookup input[type=text] { width: 100%; }
.lookup-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #b9c4c0; border-radius: 4px; box-shadow: 0 6px 18px rgba(0,0,0,.14); max-height: 320px; overflow-y: auto; min-width: 360px; }
.lookup-list div { padding: 5px 8px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.lookup-list div:hover, .lookup-list div.on { background: var(--accent-soft); }
.lookup-list div small { display: block; }
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.lines td { padding: 3px 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.lines input[type=text], table.lines input[type=number], table.lines select { width: 100%; }
table.lines td.n { width: 34px; color: var(--muted); padding-top: 9px; }
table.lines td.w-s { width: 110px; } table.lines td.w-m { width: 160px; }
table.lines .info { font-size: 12px; color: var(--muted); }
table.lines tr.removed { display: none; }
.totals { text-align: right; margin-top: 8px; font-size: 15px; }
.totals b { font-variant-numeric: tabular-nums; }

/* плитки рабочего стола */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 12px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

/* вход */
.center { max-width: 380px; margin: 9vh auto; }
.center .panel { padding: 22px; }
.center h1 { margin-bottom: 14px; }
.center .field { margin-bottom: 10px; }
.center input { width: 100%; }

/* печать */
@media print {
  .side, .top, .bar, .noprint { display: none !important; }
  .main { padding: 0; } body { background: #fff; }
  table.grid th { position: static; }
}
.print-doc { max-width: 900px; background: #fff; padding: 18px; }
.print-doc h1 { font-size: 18px; margin: 10px 0; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.print-doc th, .print-doc td { border: 1px solid #444; padding: 3px 6px; font-size: 12px; }
.print-doc .sign { display: flex; justify-content: space-between; margin-top: 30px; }

/* ТСД */
body.tsd { background: #fff; font-size: 17px; }
.tsd-wrap { max-width: 560px; margin: 0 auto; padding: 8px 10px 30px; }
.tsd-head { display: flex; align-items: center; gap: 8px; padding: 6px 0 10px; border-bottom: 2px solid var(--accent); margin-bottom: 10px; }
.tsd-head b { flex: 1; font-size: 18px; }
.tsd-btn { display: block; width: 100%; padding: 14px; margin: 8px 0; font: inherit; font-weight: 600; text-align: center; border-radius: 8px; border: 1px solid var(--line); background: #f3f6f5; color: var(--text); cursor: pointer; }
.tsd-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.tsd-btn.warn { background: var(--warn-soft); border-color: #e7c98a; }
.tsd-btn.small { padding: 8px; font-weight: 400; }
a.tsd-btn:hover { text-decoration: none; }
.tsd-scan input { width: 100%; font-size: 20px; padding: 12px; border: 2px solid var(--accent); border-radius: 8px; }
.tsd-list { list-style: none; margin: 0; padding: 0; }
.tsd-list li { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.tsd-list li.done { background: var(--accent-soft); border-color: #b9e0d3; }
.tsd-list li .grow { flex: 1; min-width: 0; }
.tsd-list li b { display: block; }
.tsd-list li small { display: block; }
.tsd-list li .q { font-size: 20px; font-weight: 600; white-space: nowrap; }
.tsd-row { display: flex; gap: 8px; }
.tsd-row > * { flex: 1; }
.beep-bad { animation: flash-bad .5s; }
@keyframes flash-bad { from { background: #f9b3ac; } to { background: #fff; } }

/* этикетки */
.labels { display: flex; flex-wrap: wrap; gap: 2mm; }
.label { border: 1px dashed #bbb; padding: 2mm; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; page-break-inside: avoid; }
.label .art { font-weight: 700; font-size: 13pt; line-height: 1.1; }
.label .name { font-size: 8pt; line-height: 1.15; max-height: 3.5em; overflow: hidden; }
.label .cell { font-size: 9pt; font-weight: 600; }
.label svg { width: 100%; height: 12mm; }
@media print { .label { border: none; } }
