:root {
  --brand: #8a2d4b; --brand-2: #b24a6b; --bg: #f6f3ef; --card: #fff; --text: #2a2326; --muted: #7a6f73;
  --line: #e4dcd6; --ok: #2e7d32; --warn: #c65911; --warn-bg: #fff4d6; --err: #c62828; --input: #fff8e1;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.4 "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.topbar { display: flex; align-items: center; gap: 4px; background: var(--brand); color: #fff; padding: 0 14px; height: 50px;
  position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 4px rgba(0,0,0,.15); flex-wrap: nowrap; overflow-x: auto; }
.topbar .logo { font-weight: 700; font-size: 16px; margin-right: 14px; white-space: nowrap; }
.topbar a.nav { color: #fff; text-decoration: none; padding: 7px 11px; border-radius: 6px; white-space: nowrap; opacity: .9; }
.topbar a.nav:hover { background: rgba(255,255,255,.12); opacity: 1; }
.topbar a.nav.active { background: rgba(255,255,255,.22); opacity: 1; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { white-space: nowrap; font-size: 13px; opacity: .95; margin-left: 10px; }
.topbar .pill { background: rgba(255,255,255,.2); border-radius: 12px; padding: 2px 9px; font-size: 12px; white-space: nowrap; cursor: default; }
.topbar button.link { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; margin-left: 8px; }
.banner { background: var(--warn-bg); border-bottom: 2px solid #f0c040; padding: 8px 16px; font-weight: 600; display: none; }
.banner.show { display: block; }
.banner.offline { background: #fde2e2; border-color: #e57373; }
main { padding: 16px; max-width: 1800px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .l { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .grow { flex: 1; }
button, .btn { font: inherit; background: var(--brand); color: #fff; border: 0; border-radius: 7px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: var(--brand-2); }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
button.secondary:hover, .btn.secondary:hover { background: #fbeff3; }
button.danger { background: var(--err); }
button.small { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #cfc4bd; border-radius: 6px; background: #fff; }
label { display: inline-flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
table.simple { border-collapse: collapse; width: 100%; background: #fff; }
table.simple th, table.simple td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
table.simple th { background: #faf7f4; font-weight: 600; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #eee; font-size: 12px; }
.tag.admin { background: #f3d9e2; } .tag.staff { background: #dcebf7; } .tag.partner { background: #e6f2dc; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
.dirty { color: var(--warn); font-weight: 600; }
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: #333; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.25); max-width: 420px; }
#toast div.err { background: var(--err); } #toast div.ok { background: var(--ok); }
.center-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.narrow { max-width: 420px; width: 100%; text-align: center; }
.narrow form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.narrow input { width: 100%; padding: 9px; }
.big-emoji { font-size: 46px; }
.err-text { color: var(--err); min-height: 20px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 10px; padding: 18px; max-width: 760px; width: 100%; max-height: 85vh; overflow: auto; }
.modal h3 { margin: 0 0 10px; }
.status-saved { color: var(--ok); font-size: 13px; } .status-pending { color: var(--warn); font-size: 13px; font-weight: 600; }
/* таблицы Tabulator */
.tabulator { font-size: 13px; border: 1px solid var(--line); background: #fff; border-radius: 6px; }
.tabulator .tabulator-header .tabulator-col { background: #f4eee9; }
.tabulator .tabulator-header .tabulator-col.grp-orders { background: #fbeec2; }
.tabulator .tabulator-header .tabulator-col.grp-total { background: #e2efda; }
.tabulator .tabulator-header .tabulator-col.grp-boxes { background: #ddebf7; }
.tabulator .tabulator-header .tabulator-col.cust .tabulator-col-title { cursor: pointer; text-decoration: underline dotted; }
.tabulator-row .tabulator-cell.edit { background: var(--input); }
.tabulator-row.tabulator-row-even .tabulator-cell.edit { background: #fff3cf; }
.tabulator-row .tabulator-cell.partial { background: #f8cbad !important; }
.tabulator-row .tabulator-cell.flash { animation: flash 1.6s; }
@keyframes flash { 0% { background: #a5d6a7; } 100% { } }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row { background: #e2efda !important; font-weight: 700; }
.note-warn { color: var(--warn); font-weight: 600; }
@media (max-width: 700px) { .topbar .who { display: none; } main { padding: 10px; } }
.tabulator .tabulator-footer .tabulator-page { color: #333; background: #fff; border: 1px solid #ccc; padding: 2px 8px; }
.tabulator .tabulator-footer .tabulator-page.active { color: #fff; background: var(--brand); }
.tabulator-menu .tabulator-menu-item { padding: 6px 12px; }
/* общий поиск в шапке */
.gsearch { position: relative; margin-left: 8px; }
.gsearch input { width: 240px; padding: 5px 9px; border-radius: 16px; border: 0; }
.gsearch input:focus { width: 340px; outline: 2px solid #f0c040; }
#gresults { display: none; position: absolute; right: 0; top: 36px; width: 460px; max-height: 70vh; overflow: auto; background: #fff;
  color: var(--text); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 300; }
#gresults.show { display: block; }
#gresults a { display: block; padding: 7px 10px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
#gresults a.sel, #gresults a:hover { background: #fbeff3; }
kbd { background: #f4eee9; border: 1px solid #cfc4bd; border-radius: 4px; padding: 0 5px; font-size: 12px; }
/* статусы документов — крупно и по цвету, чтобы не путать */
.st { display: inline-block; padding: 2px 10px; border-radius: 12px; font-weight: 700; font-size: 12px; }
.st.draft { background: #fff1c2; color: #8a6100; border: 1px dashed #d4a300; }
.st.posted { background: #dcefd9; color: #1f6b25; }
.doc-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.doc-head label select, .doc-head label input { width: 100%; }
.big-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.big-actions a, .big-actions button { padding: 10px 16px; font-size: 15px; }
.attn { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.attn .card { margin: 0; }
.attn h3 { margin: 0 0 8px; font-size: 15px; }
.attn ul { margin: 0; padding-left: 18px; }
.attn li { margin: 2px 0; }
.empty-ok { color: var(--ok); }
/* товары */
input.search { min-width: 360px; flex: 0 1 460px; padding: 8px 10px; font-size: 15px; }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.warn-badge { background: #fde2c4; color: var(--warn); border-radius: 10px; padding: 1px 7px; font-weight: 700; font-size: 12px; cursor: help; }
img.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; vertical-align: middle; }
.tabulator-row.row-archived .tabulator-cell { color: #9b9094; text-decoration: line-through; }
.tabulator-row.row-low .tabulator-cell[tabulator-field="stock"] { background: #fde2e2 !important; color: var(--err); font-weight: 700; }
.tabulator .tabulator-row.tabulator-group { background: #efe6df; font-weight: 600; }
.modal.wide { max-width: 1100px; }
.card-grid { display: grid; grid-template-columns: 220px 1fr 1fr; gap: 16px; align-items: start; }
.card-grid h4 { margin: 10px 0 4px; }
.card-photo img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.no-photo { height: 180px; border: 2px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
table.kv th { width: 45%; font-weight: 500; color: var(--muted); background: none; }
table.kv td, table.kv th { padding: 3px 6px; }
.issues { background: var(--warn-bg); border: 1px solid #f0c040; border-radius: 8px; padding: 6px 10px; }
.issues ul { margin: 4px 0 0 18px; padding: 0; }
.ok-text { color: var(--ok); font-weight: 600; }
.cols-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } input.search { min-width: 0; flex: 1 1 100%; } }
