:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1c2128;
  --muted: #6b7280;
  --accent: #d97a3a;
  --accent-soft: #fdf0e6;
  --green: #2e9e5b; --green-soft: #e6f6ec;
  --blue: #2f6fe4; --blue-soft: #e8effc;
  --yellow: #d49a0b; --yellow-soft: #fdf5dc;
  --red: #d2473c; --red-soft: #fbe8e6;
  --gray-soft: #eef0f3;
  --purple: #7b4fd6; --purple-soft: #efe9fb;
  --sidebar: #1e2430;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  display: flex; align-items: stretch; min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: #c7ccd6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #2b3240; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 18px; }
.brand b { color: #fff; font-size: 15px; display: block; }
.brand small { font-size: 11px; color: #8a92a3; }
.nav { padding: 10px 10px; overflow-y: auto; flex: 1; }
.nav .group { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #6f7786; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #c7ccd6; font-size: 13.5px; cursor: pointer;
}
.nav a:hover { background: #2a3140; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a .cnt { margin-left: auto; background: #353d4d; color: #c7ccd6; font-size: 11px; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.nav a .cnt:empty, .nav a .cnt.zero { display: none; }
.nav a.active .cnt { background: rgba(255,255,255,.25); }
.user { padding: 14px 20px; border-top: 1px solid #2b3240; display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.user .ava { width: 30px; height: 30px; border-radius: 50%; background: #3b82f6; display: grid; place-items: center; color: #fff; font-weight: 600; }
.user small { display: block; color: #8a92a3; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; max-width: 420px; position: relative; }
.search input[type=text] {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 13px;
}
.search::before { content: "⌕"; position: absolute; left: 12px; top: 6px; color: var(--muted); font-size: 16px; }
.topbar .spacer { flex: 1; }
.iconbtn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; cursor: pointer; position: relative; }
.iconbtn .dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }

.screen { display: none; padding: 22px 24px 40px; }
.screen.active { display: block; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--blue); }
select, input[type=text], input[type=date], textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; font-family: inherit;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chip { padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; cursor: pointer; }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card.flush { padding: 0; overflow: hidden; overflow-x: auto; }
.nw { white-space: nowrap; }
.c-prod { white-space: nowrap; }
.card .card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card .card-head h2 { flex: 1; }
.card.flush .card-head { padding: 14px 18px 0; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 600; margin: 4px 0 2px; }
.kpi .delta { font-size: 12px; }
.up { color: var(--green); } .down { color: var(--red); }
.mt { margin-top: 14px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.bold { font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.b-new { background: var(--blue-soft); color: var(--blue); }
.b-ok, .b-green { background: var(--green-soft); color: var(--green); }
.b-warn, .b-yellow { background: var(--yellow-soft); color: var(--yellow); }
.b-bad, .b-red { background: var(--red-soft); color: var(--red); }
.b-gray { background: var(--gray-soft); color: var(--muted); }
.b-prod, .b-purple { background: var(--purple-soft); color: var(--purple); }
.b-accent { background: var(--accent-soft); color: var(--accent); }
.src { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.src i { font-style: normal; width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; font-size: 10px; color: #fff; }
.src .ig { background: #d6336c; } .src .tg { background: #2aabee; } .src .web { background: #555; } .src .ph { background: #2e9e5b; }

/* ---------- Progress / bars ---------- */
.bar { height: 6px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bar.green span { background: var(--green); } .bar.red span { background: var(--red); } .bar.yellow span { background: var(--yellow); }
.stock-row { display: flex; align-items: center; gap: 10px; }
.stock-row .bar { flex: 1; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .col b { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; }
.chart .col b.alt { background: #c9ced6; }
.chart .col span { font-size: 10.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.hbar { display: grid; grid-template-columns: 170px 1fr 60px; align-items: center; gap: 10px; font-size: 13px; padding: 6px 0; }
.hbar .bar { height: 10px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow small { display: block; color: var(--muted); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
.kcol { background: #eceef2; border-radius: var(--radius); padding: 10px; }
.kcol h3 { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.kcol h3 .cnt { margin-left: auto; background: #fff; border-radius: 10px; padding: 0 8px; font-size: 11px; color: var(--text); }
.kcard { background: #fff; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); cursor: grab; }
.kcard .t { font-weight: 600; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.kcard .t .id { color: var(--muted); font-weight: 400; font-size: 12px; }
.kcard .d { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.kcard .f { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.kcard .f .ava { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 10px; margin-left: auto; }
.kcard.urgent { border-left: 3px solid var(--red); }
.ops { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.ops span { font-size: 10.5px; padding: 2px 6px; border-radius: 4px; background: var(--gray-soft); color: var(--muted); }
.ops span.done { background: var(--green-soft); color: var(--green); }
.ops span.cur { background: var(--yellow-soft); color: var(--yellow); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-size: 13.5px; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 500; }
.tab-pane { display: none; } .tab-pane.on { display: block; }

/* ---------- Order detail ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 16px; font-size: 12.5px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--border); }
.timeline li.done::before { background: var(--green); border-color: var(--green); }
.timeline li.cur::before { background: var(--accent); border-color: var(--accent); }
.timeline li small { display: block; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.steps { display: flex; gap: 0; margin-bottom: 18px; }
.steps div { flex: 1; text-align: center; padding: 8px 4px; font-size: 12px; background: #fff; border: 1px solid var(--border); color: var(--muted); position: relative; }
.steps div:first-child { border-radius: 8px 0 0 8px; } .steps div:last-child { border-radius: 0 8px 8px 0; }
.steps div.done { background: var(--green-soft); color: var(--green); border-color: #bfe6cd; }
.steps div.cur { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------- Module tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.tile .pic { height: 110px; border-radius: 8px; background: #f6f3ee; display: grid; place-items: center; margin-bottom: 8px; overflow: hidden; }
.tile .pic img { max-height: 100px; max-width: 90%; object-fit: contain; mix-blend-mode: multiply; }
.tile .nm { font-weight: 500; font-size: 12px; color: var(--text); line-height: 1.3; }
.tile .pr { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12.5px; }
.tile .pr s { color: var(--muted); }

.cfg { border: 1px dashed var(--border); border-radius: 8px; padding: 12px; background: #fafbfc; }
.cfg .row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12.5px; }
.cfg .row .qty { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cfg .row .qty b { padding: 2px 10px; font-weight: 500; }
.cfg .row .qty i { padding: 2px 8px; font-style: normal; background: #fff; cursor: pointer; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 8px; position: relative; }
.alert .close { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: inherit; opacity: .5; font-size: 14px; line-height: 1; padding: 0 2px; }
.alert .close:hover { opacity: 1; }
.alert.gone { display: none; }
.alert.red { background: var(--red-soft); color: #8a2a22; }
.alert.yellow { background: var(--yellow-soft); color: #7a5a06; }
.alert.blue { background: var(--blue-soft); color: #214ea8; }

.toggle { width: 34px; height: 20px; border-radius: 10px; background: #cfd4dc; position: relative; display: inline-block; vertical-align: middle; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.toggle.on { background: var(--green); } .toggle.on::after { left: 16px; }

.footer-note { margin-top: 30px; color: var(--muted); font-size: 12px; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .kanban { grid-template-columns: repeat(3, 1fr); } .tiles { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Режим настройки страницы ---------- */
.stack > .widget + .widget, .stack > :not(.widget) + .widget { margin-top: 14px; }
.edit-bar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 16px;
  padding: 10px 14px; border-radius: 10px; background: #fff7ef; border: 1px dashed var(--accent); font-size: 13px;
}
.edit-bar b { color: var(--accent); }
.edit-bar .ebhint { color: var(--muted); flex: 1; min-width: 240px; font-size: 12.5px; }
.screen.editing .edit-bar { display: flex; }
.screen.editing .btn-edit { background: var(--accent); color: #fff; border-color: var(--accent); }

.widget { position: relative; }
.screen.editing .widget { outline: 1.5px dashed #e9b48c; outline-offset: 3px; cursor: grab; transition: outline-color .15s; }
.screen.editing .widget:hover { outline-color: var(--accent); }
.screen.editing .widget.drag-over { outline: 2px solid var(--accent); }
.widget.dragging { opacity: .4; }
.wctl {
  display: none; position: absolute; top: -12px; right: 8px; z-index: 3; gap: 2px;
  background: var(--text); border-radius: 6px; padding: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.screen.editing .widget > .wctl { display: inline-flex; }
.wctl button { border: 0; background: transparent; color: #fff; width: 22px; height: 20px; border-radius: 4px; cursor: pointer; font-size: 12px; line-height: 1; padding: 0; }
.wctl button:hover { background: rgba(255,255,255,.2); }
.wctl .grip { cursor: grab; opacity: .7; }
.widget.hidden-w { display: none !important; }
.screen.editing.show-hidden .widget.hidden-w { display: block !important; opacity: .45; outline-color: var(--red); }
.screen.editing.show-hidden .kcol.widget.hidden-w { display: block !important; }
.hidden-count { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 1px 8px; font-size: 12px; }

.screen.editing [contenteditable="true"] { outline: 1px dashed #bbb; outline-offset: 2px; border-radius: 3px; cursor: text; min-width: 20px; }
.screen.editing [contenteditable="true"]:focus { outline-color: var(--blue); background: #fff; }

/* колонки таблиц */
th { position: relative; }
.thctl { display: none; margin-left: 6px; white-space: nowrap; }
.screen.editing .thctl { display: inline-flex; gap: 1px; }
.thctl button { border: 1px solid var(--border); background: #fff; border-radius: 4px; width: 18px; height: 18px; font-size: 10px; cursor: pointer; padding: 0; color: var(--muted); line-height: 1; }
.thctl button:hover { color: var(--text); border-color: var(--muted); }
.col-hidden { display: none; }
.tbl-hidden { display: none; padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); background: #fffaf5; flex-wrap: wrap; gap: 6px; align-items: center; }
.screen.editing .tbl-hidden:not(:empty) { display: flex; }
.tbl-hidden .chip { padding: 2px 9px; font-size: 11.5px; }

/* фильтры */
.chip .rm { display: none; margin-left: 6px; color: var(--red); font-weight: 600; }
.screen.editing .chip .rm { display: inline; }
.chip-add { display: none; }
.screen.editing .chip-add { display: inline-block; border-style: dashed; color: var(--muted); }

/* канбан */
.kcol-add { display: none; border: 2px dashed var(--border); border-radius: var(--radius); min-height: 80px; place-items: center; color: var(--muted); cursor: pointer; font-size: 13px; }
.screen.editing .kcol-add { display: grid; }
.kcard.drag-over { outline: 2px solid var(--accent); }
.kcol.drag-over-col { background: #e3e6ec; }
.screen.editing .kanban { grid-template-columns: repeat(6, 1fr); }

/* ---------- Подсказки «?» ---------- */
.hint {
  display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 5px; vertical-align: 1px;
  border-radius: 50%; background: #d4d8de; color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
  cursor: help; user-select: none; flex-shrink: 0;
}
.hint::before { content: "?"; }
.hint:hover, .hint.on { background: var(--accent); }
.badge[data-tip] { cursor: help; }
.kpi .label .hint, h2 .hint { vertical-align: 0; }
th .hint { vertical-align: 0; }
#tip {
  position: fixed; z-index: 1000; max-width: 300px; padding: 9px 12px; border-radius: 8px;
  background: #1e2430; color: #e8ebf0; font-size: 12.5px; line-height: 1.45; font-weight: 400; text-transform: none; letter-spacing: 0;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); pointer-events: none; opacity: 0; transition: opacity .12s;
}
#tip.show { opacity: 1; }
#tip b { color: #fff; display: block; margin-bottom: 3px; font-size: 12px; }
#tip::after { content: ""; position: absolute; top: -5px; left: var(--ax, 16px); width: 10px; height: 10px; background: #1e2430; transform: rotate(45deg); }
#tip.above::after { top: auto; bottom: -5px; }

/* ---------- Очередь производства ---------- */
.prog { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; color: var(--text); }
.prog .bar { width: 60px; }
.units { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.units .u {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #cfd4dc; background: #fff; display: inline-grid; place-items: center;
  font-style: normal; font-size: 12px; color: #fff; cursor: pointer; transition: all .1s;
}
.units .u:hover { border-color: var(--accent); }
.units .u.done { background: var(--green); border-color: var(--green); }
.prow { display: grid; grid-template-columns: 40px 1fr 28px auto 44px; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.prow.ok .pname { color: var(--muted); }
.prow.work { background: var(--accent-soft); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.pname { font-size: 12.5px; }
.pname small { display: block; color: var(--muted); font-size: 11px; }
.pcnt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.pbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; font-size: 13px; }
.pbar .bar { flex: 1; height: 8px; }
.pfoot { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pfoot .ghost { margin-left: auto; }
.pord.late { border-left: 3px solid var(--red); }
.pgroup .card-head { margin-bottom: 4px; }
.pitem { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; margin-top: 8px; }
.pitem .porders { display: none; border-top: 1px solid var(--border); margin-top: 6px; }
.pitem.open .porders { display: block; }
.pitem .prow:first-child { border-top: 0; }
.btn.chev { color: var(--muted); white-space: nowrap; }
.btn.chev.on, .pihead:hover .btn.chev { color: var(--text); border-color: #c9ced6; }
.pord .pbody { display: none; }
.pord.open .pbody { display: block; }
.pord:not(.open) .pfoot { border-top: 0; padding-top: 4px; }
.pitem.work { border-color: var(--accent); background: #fffaf5; }
.pitem.ok { opacity: .7; }
.pitem .prow.work { background: transparent; margin: 0; padding-left: 0; padding-right: 0; }
.pihead { display: grid; grid-template-columns: 48px 1fr 200px auto auto; cursor: pointer; border-radius: 6px; align-items: center; gap: 14px; padding-bottom: 6px; }
.pisum { font-size: 12.5px; }
.pisum .bar { height: 8px; margin-bottom: 4px; }
.pisum small { display: block; color: var(--muted); }
.pitem .prow { padding-left: 12px; }
.pitem .prow .pname { font-size: 12.5px; }
#prod-summary .kpi .bar { margin-top: 8px; }
.stack .alert + * { margin-top: 0; }

/* ---------- Картинки деталей ---------- */
.thumb { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: #f6f3ee; flex-shrink: 0; vertical-align: middle; mix-blend-mode: multiply; }
.thumb.lg { width: 48px; height: 48px; }
.thumb.xs { width: 24px; height: 24px; border-radius: 4px; }
.pics { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.pics .pic { position: relative; display: inline-block; cursor: help; }
.pics .pic b { position: absolute; right: -4px; bottom: -4px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; line-height: 15px; text-align: center; font-weight: 600; }
.pics-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 18px 12px; }
.chipimg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--bg); border-radius: 6px; padding: 3px 8px 3px 3px; }
.card-head .thumb { margin-right: 4px; }

/* подсказки про заготовки в производстве */
.take { width: 26px; height: 26px; border-radius: 6px; border: 1px solid #bfe6cd; background: var(--green-soft); cursor: pointer; font-size: 13px; padding: 0; line-height: 1; }
.take:hover { background: #d4f0de; }
.btn.take-all { background: var(--green-soft); border-color: #bfe6cd; color: var(--green); padding: 2px 8px; font-size: 11.5px; }
.cutnote { font-size: 11px; color: var(--yellow); background: var(--yellow-soft); padding: 1px 6px; border-radius: 5px; vertical-align: middle; cursor: help; }
.stockline { display: inline-flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; font-size: 12px; }
.lnk { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: inherit; padding: 0 0 0 4px; font-family: inherit; }
.lnk:hover { text-decoration: underline; }

/* раздел «Заготовки» */
.slist .srow { display: grid; grid-template-columns: 56px 1fr 120px 160px 130px 1fr; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
.slist .srow:last-child { border-bottom: 0; }
.qty.big { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; align-items: center; }
.qty.big b { padding: 4px 12px; min-width: 40px; text-align: center; font-size: 15px; }
.qty.big i { padding: 4px 10px; font-style: normal; background: #fff; cursor: pointer; color: var(--muted); border-left: 1px solid var(--border); border-right: 1px solid var(--border); user-select: none; }
.qty.big i:first-child { border-left: 0; } .qty.big i:last-child { border-right: 0; }
.qty.big i:hover { background: var(--bg); color: var(--text); }

/* ---------- UX-доводка ---------- */
.page-head .actions .btn-edit { color: var(--muted); }
.footer-tools { margin-top: 24px; display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.footer-tools button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: inherit; font-family: inherit; text-decoration: underline dotted; }
tr.clickable:hover td { background: #fbf7f2; }
.c-prod .btn.primary { padding: 5px 10px; }
.filters .chip .cnt-s { color: inherit; opacity: .6; margin-left: 2px; }
.pord .card-head h2 { font-size: 14px; }

/* компактная таблица заказов */
.c-items { min-width: 210px; }
.c-items .itxt { font-weight: 500; }
.c-items .itxt { font-size: 12.5px; line-height: 1.3; }
#orders-rows td { padding: 9px 12px; }
#orders-rows .src i { width: 16px; height: 16px; font-size: 9px; vertical-align: -3px; margin-right: 2px; }

@media (max-width: 1100px) { .pihead { grid-template-columns: 48px 1fr auto; row-gap: 6px; } .pihead .pisum { grid-column: 2; } .pihead .btn.chev { grid-column: 3; justify-self: end; } }

/* ---------- Номенклатура: карточки со составом ---------- */
.tiles.mods { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .tiles.mods { grid-template-columns: repeat(2, 1fr); } }
.tile.mod { cursor: pointer; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.tile.mod:hover { border-color: var(--accent); }
.tile.mod .thead { display: flex; gap: 12px; align-items: flex-start; }
.tile.mod .thead .thumb.lg { width: 64px; height: 64px; }
.tile.mod .nm { font-size: 13.5px; font-weight: 600; }
.tile.mod .pr { display: block; margin-top: 4px; font-size: 12.5px; }
.tile.mod .pr s { margin: 0 6px 0 2px; }
.tile.mod .pr .muted { display: block; margin-top: 2px; }
.tsec { border-top: 1px solid var(--border); padding-top: 8px; }
.tsec .tl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; margin-bottom: 5px; }
.mats { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.mats li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dashed #eef0f3; }
.mats li:last-child { border-bottom: 0; }
.mats li b { font-weight: 500; white-space: nowrap; color: var(--text); }
.mats li { color: var(--muted); }
.stages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11.5px; }
.stages span { display: inline-flex; align-items: center; gap: 5px; background: var(--bg); border-radius: 6px; padding: 3px 8px; }
.stages span i { font-style: normal; }
.stages span b { color: var(--accent); font-weight: 600; }
.stages em { color: #c9ced6; font-style: normal; }
/* спецификация */
#bom-list .bg { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px 4px; }
#bom-list .bitem { display: flex; align-items: center; gap: 8px; padding: 6px 14px; color: var(--text); font-size: 13px; }
#bom-list .bitem:hover { background: #fafbfc; }
#bom-list .bitem.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
#bom-detail .card-head { padding: 14px 18px 8px; margin: 0; }
#bom-detail tr.total td { background: #fafbfc; }

/* ---------- Редактор (модальное окно) ---------- */
#modal { position: fixed; inset: 0; background: rgba(20,24,32,.45); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 500; overflow-y: auto; }
#modal.show { display: flex; }
.mbox { background: #fff; border-radius: 12px; width: 760px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.mhead { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.mhead h2 { flex: 1; font-size: 16px; }
.mclose { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.mbody { padding: 16px 20px; }
.mbody h3 { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.mfoot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 12px 12px; }
.frow { display: flex; gap: 12px; margin-bottom: 12px; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.f.grow { flex: 1; }
.f input, .f select { font-size: 13px; color: var(--text); }
.f input[type=number] { width: 110px; }
.imgpick { display: flex; gap: 8px; align-items: center; }
.etable { width: 100%; }
.etable th, .etable td { padding: 6px 8px; }
.etable input[type=text] { width: 100%; }
.etable input[type=number] { width: 90px; text-align: right; }
.etable select { max-width: 260px; }
.lnk.red { color: var(--red); }
.lnk:disabled { color: #ccc; cursor: default; text-decoration: none; }
.btn.ghost.red { color: var(--red); }
.esum { display: flex; gap: 24px; margin-top: 16px; padding: 12px 14px; background: var(--bg); border-radius: 8px; font-size: 13px; }
.esum b { font-size: 15px; margin-left: 4px; }
.tile.mod { position: relative; }
.tedit { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--muted); opacity: 0; transition: opacity .15s; }
.tile.mod:hover .tedit { opacity: 1; }
.tedit:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- правка по двойному клику ---------- */
.ed { cursor: text; border-bottom: 1px dotted transparent; border-radius: 3px; padding: 0 2px; }
.ed:hover { border-bottom-color: var(--accent); background: var(--accent-soft); }
.edin { width: 72px; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 5px; font: inherit; text-align: right; background: #fff; }
.edin.txt { width: 160px; text-align: left; }
h2 .edin.txt { width: 260px; }
#pendbar { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all .15s;
  display: flex; align-items: center; gap: 10px; background: var(--text); color: #fff; padding: 10px 14px 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 13px; z-index: 400; }
#pendbar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#pendbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
#pendbar .btn.primary { background: var(--accent); border-color: var(--accent); }

#savetoast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 12.5px; opacity: 0; transform: translateY(8px); transition: all .15s; pointer-events: none; z-index: 600; }
#savetoast.show { opacity: 1; transform: none; }

/* ---------- формы на страницах (новый заказ) ---------- */
.card .f { margin-bottom: 10px; }
.card .f input, .card .f select, .card .f textarea { width: 100%; }
.no-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 4px; }
.no-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #eef0f3; font-size: 13px; }
.no-row .nm small { display: block; color: var(--muted); font-size: 12px; }
.no-row .nm small b { color: var(--accent); }
.no-row.has { background: var(--accent-soft); margin: 0 -14px; padding-left: 14px; padding-right: 14px; border-radius: 8px; border-bottom-color: transparent; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.stepper button { width: 34px; border: 0; background: #fff; font-size: 18px; color: var(--text); cursor: pointer; line-height: 1; }
.stepper button:hover { background: var(--bg); }
.stepper button:disabled { color: #c9ced6; cursor: default; }
.stepper input { width: 48px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0; text-align: center; font-size: 14px; font-weight: 600; padding: 6px 2px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--accent-soft); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.steps div.cancel { background: var(--gray-soft); color: var(--muted); }

.stepper.locked { opacity: .55; }

textarea { overflow: hidden; min-height: 64px; line-height: 1.45; }

/* ---------- выпадающие списки: единый вид ---------- */
select {
  -webkit-appearance: none; appearance: none;
  padding: 7px 30px 7px 10px; min-height: 34px; line-height: 1.3; color: var(--text);
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round'/></svg>") no-repeat right 10px center;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; max-width: 100%;
}
select:hover { border-color: #c9ced6; }
select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
select:disabled { opacity: .6; cursor: default; }
.page-head .actions select, .filters select, .card-head select { width: auto; }
.card-head select { max-width: 320px; }
input[type=text], input[type=number], input[type=date], textarea { min-height: 34px; line-height: 1.3; }
input[type=date] { -webkit-appearance: none; appearance: none; }
.f select, .f input, .f textarea { width: 100%; }

.prog-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; }
.prog-pill .bar { width: 90px; height: 6px; }
.prog-pill b { font-variant-numeric: tabular-nums; }
.prog-pill span { color: var(--muted); }
.prog-pill:hover { border-color: var(--accent); }

/* прокручиваемые блоки дашборда: все записи, высота ограничена */
.scrollbox { max-height: 360px; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
.scrollbox::-webkit-scrollbar { width: 6px; } .scrollbox::-webkit-scrollbar-thumb { background: #d4d8de; border-radius: 3px; }

/* =====================================================================
   Мобильная вёрстка
   ===================================================================== */
.menu-btn { display: none; font-size: 18px; }
.topbar .btn .short { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(20,24,32,.45); z-index: 40; }

@media (max-width: 900px) {
  body { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: 268px; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.35);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar.open { transform: none; }
  body.menu-open .sidebar-overlay { display: block; }
  body.menu-open { overflow: hidden; }
  .nav a { padding: 12px 12px; font-size: 15px; }
  .main { min-height: 100dvh; }

  .topbar { height: 54px; padding: 0 12px; gap: 8px; padding-top: env(safe-area-inset-top, 0px); height: calc(54px + env(safe-area-inset-top, 0px)); }
  .menu-btn { display: grid; }
  .search { max-width: none; }
  .search input[type=text] { font-size: 16px; }   /* iOS не зумит поле при 16px */
  .topbar .btn .full { display: none; } .topbar .btn .short { display: inline; }
  .topbar .btn.primary { padding: 8px 14px; font-size: 18px; line-height: 1; }
  .topbar .iconbtn[title="Уведомления"], #logout { display: none; }

  .screen { padding: 14px 12px 90px; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { font-size: 19px; }
  .page-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 6px; }
  .page-head .actions .btn { flex: 1 1 auto; justify-content: center; }
  .page-head .actions .btn-edit { display: none; }
  .edit-bar { display: none !important; }

  .grid, .grid.g4, .grid.g3, .grid.g2, .grid.g-2-1, .grid.g-1-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid.g4 { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px; }
  .kpi .value { font-size: 22px; }
  .tiles, .tiles.mods { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-size: 12px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters .chip, .filters select, .filters input { flex-shrink: 0; }
  .filters > span[style*="flex:1"] { display: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; } .tabs a { white-space: nowrap; }
  .steps { overflow-x: auto; } .steps div { min-width: 86px; font-size: 11px; }

  /* таблицы: прокрутка по горизонтали, компактные ячейки */
  table { font-size: 12.5px; }
  th { padding: 8px 10px; } td { padding: 9px 10px; }
  #orders-rows td { padding: 9px 8px; }
  .c-items { min-width: 150px; }
  .card.flush { border-radius: 10px; }

  /* производство: строка в два яруса */
  .prow { grid-template-columns: 40px 1fr auto; grid-template-areas: "thumb name take" "units units units"; row-gap: 6px; padding: 10px 0; }
  .prow > .thumb, .prow > span:first-child:not(.pname) { grid-area: thumb; }
  .prow > .pname { grid-area: name; }
  .prow > .take, .prow > span:empty { grid-area: take; }
  .prow > .units { grid-area: units; justify-self: start; }
  .prow > .pcnt { grid-area: units; justify-self: end; align-self: center; }
  .prow.work { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .units .u { width: 30px; height: 30px; border-radius: 8px; }
  .pihead { grid-template-columns: 48px 1fr; grid-template-areas: "thumb name" "sum sum" "act act"; row-gap: 8px; }
  .pihead > .thumb { grid-area: thumb; } .pihead > .pname { grid-area: name; } .pihead > .pisum { grid-area: sum; }
  .pihead > .btn, .pihead > .badge { grid-area: act; justify-self: start; }
  .pihead > .btn.chev { justify-self: end; }
  .pitem .prow { padding-left: 0; }
  .pfoot .ghost { margin-left: 0; }

  /* заготовки и склад */
  .slist .srow { grid-template-columns: 48px 1fr auto; grid-template-areas: "thumb name qty" "info info info"; padding: 10px 12px; row-gap: 6px; }
  .slist .srow > .thumb { grid-area: thumb; } .slist .srow > .pname { grid-area: name; } .slist .srow > .qty { grid-area: qty; }
  .slist .srow > .small, .slist .srow > .badge { grid-area: info; justify-self: start; }
  .slist .srow > .badge { justify-self: end; }
  .slist .srow > .small.muted:last-child { display: none; }

  /* форма заказа */
  .no-row { grid-template-columns: 36px 1fr auto; gap: 8px; }
  .no-row.has { margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
  .stepper button { width: 38px; height: 38px; } .stepper input { width: 44px; font-size: 15px; }
  .card-head { flex-wrap: wrap; } .card-head select { max-width: 100%; width: 100%; }

  /* модальные окна и плашки */
  #modal { padding: 0; align-items: stretch; }
  .mbox { width: 100%; border-radius: 0; min-height: 100dvh; display: flex; flex-direction: column; }
  .mbody { flex: 1; overflow-y: auto; }
  .mfoot { position: sticky; bottom: 0; flex-wrap: wrap; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .frow { flex-direction: column; gap: 8px; }
  .f input[type=number] { width: 100%; }
  .etable select { max-width: 160px; }
  #pendbar { left: 12px; right: 12px; transform: none; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; justify-content: flex-end; }
  #pendbar.show { transform: none; }
  #pendbar span { flex: 1 1 100%; }
  #savetoast { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .prog-pill .bar { width: 60px; }
  .footer-note, .footer-tools { font-size: 11.5px; }
  input, select, textarea { font-size: 16px; }   /* против автозума iOS */
  .btn { min-height: 36px; }
}
@media (max-width: 520px) {
  .grid.g4 { grid-template-columns: 1fr; }
  .steps div { min-width: 72px; padding: 6px 2px; font-size: 10.5px; }
}

/* карточки заказов на телефоне */
.ocards { display: none; }
@media (max-width: 900px) {
  .orders-table { display: none; }
  .ocards { display: flex; flex-direction: column; gap: 10px; }
  .ocard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
  .oc-top { display: flex; align-items: center; gap: 8px; }
  .oc-top b { font-size: 15px; }
  .oc-sum { margin-left: auto; font-weight: 600; font-size: 15px; }
  .oc-client { font-size: 14px; }
  .oc-items .pics { margin-top: 4px; }
  .oc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px dashed var(--border); }
  .oc-act { margin-left: auto; }
  .oc-act .prog { min-width: 0; }
  .footer-note { display: none; }
}

.sb-foot { display: none; padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #2b3240; }
.sb-foot a { color: #c7ccd6; font-size: 14px; }
@media (max-width: 900px) { .sb-foot { display: block; } }

.pord .card-head h2 { line-height: 1.3; }
.pord-sub { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pord-note { color: var(--text); }
