:root {
  --primary: #036ce5;         /* синий МойСклад */
  --primary-dark: #0257bd;
  --primary-light: #e7f1fd;
  --success: #16a34a;
  --success-light: #dcfce7;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2733;
  --muted: #6b7684;
  --border: #e4e8ee;
  --border-strong: #cfd6df;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --shadow: 0 1px 2px rgba(16,30,54,.06), 0 1px 3px rgba(16,30,54,.04);
  --radius: 7px;
  --nav-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #eef4fc 0%, #f2f4f7 100%); }
.login-card { background: var(--card); width: 100%; max-width: 380px; padding: 32px; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(16,30,54,.12); }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin: 0; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.logo-badge { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: #fff; font-weight: 800; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Верхняя навигация — светлая, иконки над подписями (как в МойСклад) */
.topnav { background: #fff; color: var(--text); display: flex; align-items: stretch; height: var(--nav-h);
  padding: 0 10px; gap: 2px; position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(16,30,54,.05); }
.brand { display: flex; align-items: center; gap: 7px; color: var(--text); font-size: 16px; margin-right: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-drop { display: flex; align-items: center; }
.brand-name { letter-spacing: .3px; font-weight: 600; }
.brand-name b { color: var(--primary); font-weight: 800; }
.topnav-items { display: flex; align-items: stretch; gap: 0; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav-items::-webkit-scrollbar { display: none; }
.topnav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 0 13px; color: #55606d; font-size: 11.5px; border-bottom: 3px solid transparent; white-space: nowrap; }
.topnav-item:hover { color: var(--text); background: #f2f6fb; text-decoration: none; }
.topnav-item.active { color: var(--primary); border-bottom-color: var(--primary); background: #eef5fd; }
.tn-ic { display: flex; align-items: center; justify-content: center; height: 24px; }
.tn-lbl { line-height: 1; }

/* ---------- Линейные иконки ---------- */
.ic { display: block; flex-shrink: 0; }
.ic-wrap { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn .ic, .btn .ic-wrap { color: currentColor; }
.dd-lbl { display: inline-flex; align-items: center; gap: 6px; }
.dd-chev { display: inline-flex; align-items: center; opacity: .65; margin-left: 1px; }
.btn-icon { padding: 7px; }
.btn-icon .ic { width: 17px; height: 17px; }
.topnav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; padding-left: 10px; }
.tn-user-info { text-align: right; line-height: 1.15; }
.tn-user-name { font-size: 13px; color: var(--text); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-user-role { font-size: 11px; color: var(--muted); }
.logout-btn { color: var(--muted) !important; font-size: 15px; border-color: var(--border-strong) !important; background: transparent !important; }
.logout-btn:hover { background: #f2f6fb !important; color: var(--text) !important; }
.nav-toggle { display: none; color: var(--text); background: transparent; border-color: var(--border-strong); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* Глобальный поиск */
.gsearch { position: relative; margin: 0 8px; align-self: center; }
.gsearch input { width: 200px; height: 34px; padding: 6px 12px; border-radius: 18px; background: #f2f4f7; border-color: transparent; font-size: 13px; }
.gsearch input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.gsearch-results { display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 340px; max-height: 70vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px rgba(16,30,54,.18); z-index: 60; padding: 6px 0; }
.gsearch-results.open { display: block; }
.gs-group { padding: 8px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.gs-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 14px; color: var(--text); font-size: 13.5px; }
.gs-item:hover { background: #f2f6fb; text-decoration: none; }
.gs-item .gs-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gs-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .gsearch input { width: 130px; } .gsearch-results { width: 280px; } }

/* Под-навигация: синие вкладки */
.subnav { background: var(--card); border-bottom: 1px solid var(--border); min-height: 42px; display: flex; align-items: center;
  padding: 0 24px; position: sticky; top: var(--nav-h); z-index: 30; overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav-tabs { display: flex; gap: 2px; height: 42px; }
.subnav-tab { display: flex; align-items: center; padding: 0 14px; height: 42px; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav-tab:hover { color: var(--primary); text-decoration: none; }
.subnav-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.subnav-title { font-size: 15px; font-weight: 600; }

.content { padding: 18px 24px; flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13.5px; font-family: inherit; transition: .12s; white-space: nowrap; }
.btn:hover { background: #f6f8fa; border-color: #b9c2ce; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f5; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 7px; box-shadow: 0 8px 24px rgba(16,30,54,.16); min-width: 200px; z-index: 60; padding: 4px 0; }
.dropdown-menu.open { display: block; }
.dropdown-menu button { display: block; width: 100%; text-align: left; padding: 8px 14px; border: none; background: none;
  cursor: pointer; font-size: 13.5px; color: var(--text); font-family: inherit; }
.dropdown-menu button:hover { background: #f2f6fb; }
.dropdown-menu button.danger { color: var(--danger); }
.dd-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- Cards / KPI ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.kpi .value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; }
.kpi .value.green { color: var(--success); }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }

/* ---------- Заголовок страницы ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar .search { flex: 1; max-width: 420px; }
.toolbar .search input { width: 100%; }
.search { position: relative; display: inline-flex; align-items: center; }
.search input { padding-left: 36px; }
.search input:only-child { padding-left: 10px; }
.search .search-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .search-ic .ic { width: 17px; height: 17px; }

/* ---------- Страница с деревом слева ---------- */
.page-grid { display: grid; grid-template-columns: 244px 1fr; gap: 16px; align-items: start; }
.side-tree { position: sticky; top: calc(var(--nav-h) + 56px); }
.tree-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; }
.tree-list { padding: 6px 0; max-height: 62vh; overflow-y: auto; }
.tree-head { padding: 12px 16px 8px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.tree-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 16px; cursor: pointer;
  font-size: 13.5px; color: var(--text); border-left: 3px solid transparent; }
.tree-item:hover { background: #f2f6fb; }
.tree-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; border-left-color: var(--primary); }
.tree-item .cnt { color: var(--muted); font-size: 12.5px; flex-shrink: 0; }
.tree-item.active .cnt { color: var(--primary); }
.tree-item .ti-twist { width: 16px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; border-radius: 4px; }
.tree-item .ti-twist:hover { background: rgba(0,0,0,.06); }
.tree-item .ti-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-item.tree-root .sn-ic { color: var(--muted); display: inline-flex; }
.tree-item.dragging { opacity: .45; }
.tree-item.drop-into { background: var(--primary-light); box-shadow: inset 0 0 0 2px var(--primary); border-radius: 6px; }

/* Контекстное меню (ПКМ по группе) */
.ctx-menu { position: fixed; z-index: 200; background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 32px rgba(16,30,54,.20); padding: 4px 0; min-width: 200px; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 14px;
  border: none; background: none; cursor: pointer; font-size: 13.5px; color: var(--text); font-family: inherit; }
.ctx-menu button:hover { background: #f2f6fb; }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button .sn-ic { display: inline-flex; color: var(--muted); }
.ctx-menu button.danger .sn-ic { color: var(--danger); }
.ctx-menu button:hover .sn-ic { color: inherit; }
[data-theme="dark"] .ctx-menu button:hover { background: #232b36; }
[data-theme="dark"] .tree-item .ti-twist:hover { background: rgba(255,255,255,.08); }
.tree-foot { padding: 12px; border-top: 1px solid var(--border); }
.tree-new { width: 100%; justify-content: center; gap: 8px; border: 1px dashed var(--border-strong); background: transparent;
  color: var(--primary); font-weight: 500; padding: 9px 12px; }
.tree-new:hover { background: var(--primary-light); border-color: var(--primary); }
.tree-new .ic { width: 16px; height: 16px; }

/* ---------- Массовые операции ---------- */
.bulkbar { display: flex; align-items: center; gap: 10px; background: #eef5fd; border: 1px solid #c8ddf7; border-radius: 7px;
  padding: 7px 12px; margin-bottom: 10px; flex-wrap: wrap; }
.bulkbar b { color: var(--primary); font-size: 15px; }

/* ---------- Forms ---------- */
input, select, textarea { font-family: inherit; font-size: 13.5px; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
/* Правило выше перебивает стилизацию :disabled браузером — без этого заблокированное
   поле выглядит активным и молча проглатывает клик. */
input:disabled, select:disabled, textarea:disabled { background: #f6f8fa; color: var(--muted);
  border-color: var(--border); cursor: not-allowed; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- Table ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13.5px; }
th { background: #fafbfc; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #f5f9ff; }
tbody tr.selected { background: #fff9df; }
tbody tr.selected:hover { background: #fff3c4; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
.row-click { cursor: pointer; }
th.chk, td.chk { width: 34px; padding-right: 4px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th .sort-arrow { margin-left: 3px; font-size: 9px; color: var(--primary); }

/* ---------- Пагинация ---------- */
.paginator { display: flex; align-items: center; gap: 12px; padding: 10px 4px; justify-content: flex-start; font-size: 13px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--success-light); color: var(--success); }
.badge.gray { background: #eef0f3; color: var(--muted); }
.badge.red { background: var(--danger-light); color: var(--danger); }
.badge.warn { background: var(--warn-light); color: var(--warn); }
.badge.blue { background: var(--primary-light); color: var(--primary); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,30,48,.5); display: flex; align-items: flex-start; justify-content: center;
  padding: 44px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(16,30,54,.3); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0; width: auto; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #1f2733; color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 13.5px; max-width: 360px; animation: slidein .2s ease; }
.toast.ok { background: var(--primary); }
.toast.err { background: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px; }
.item-rows td { padding: 6px 8px; }
.item-rows input, .item-rows select { padding: 6px 8px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: inherit; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; background: var(--primary-light); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; transition: .2s; }
.bars .bar:hover { background: var(--primary); }
.bars .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pill-tabs { display: inline-flex; background: #eef1f5; border-radius: 8px; padding: 3px; gap: 2px; }
.pill-tabs button { border: none; background: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--muted); font-family: inherit; }
.pill-tabs button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .topnav-items { position: fixed; top: var(--nav-h); left: 0; right: 0; background: #fff; flex-direction: column; align-items: stretch;
    height: auto; max-height: 0; overflow: hidden; transition: max-height .2s; z-index: 39; border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(16,30,54,.12); }
  .topnav-items.open { max-height: 80vh; overflow-y: auto; }
  .topnav-item { flex-direction: row; justify-content: flex-start; gap: 10px; height: 44px; padding: 0 16px; font-size: 13.5px;
    border-bottom: 1px solid var(--border); border-left: 3px solid transparent; }
  .topnav-item.active { border-bottom-color: var(--border); border-left-color: var(--primary); }
  .nav-toggle { display: inline-flex; }
  .tn-user-info { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-grid { grid-template-columns: 1fr; }
  .side-tree { position: static; max-height: none; }
}

/* ---------- Миниатюры и двухстрочные ячейки ---------- */
.prod-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f2f4f7; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; color: #aeb6c2; font-size: 17px; flex-shrink: 0; overflow: hidden; }
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-thumb.ph { background: #f4f6f9; color: #a7b1bf; }
.prod-thumb.ph .ic { width: 22px; height: 22px; }
.prod-thumb.sm { width: 34px; height: 34px; border-radius: 7px; }
.prod-thumb.sm.ph .ic { width: 18px; height: 18px; }
.prod-thumb.lg { width: 72px; height: 72px; border-radius: 10px; }
.prod-thumb.lg.ph .ic { width: 30px; height: 30px; }
.cell-prod { display: flex; align-items: center; gap: 12px; }
.cell-2 { display: flex; flex-direction: column; line-height: 1.3; }
.cell-2 .cell-sub { color: var(--muted); font-size: 12px; }

/* ---------- Мягкие бейджи остатка ---------- */
.stock-pill { display: inline-block; padding: 3px 10px; border-radius: 14px; font-size: 12.5px; font-weight: 600; }
.stock-pill.ok { background: #e7f6ec; color: #1a8f45; }
.stock-pill.mid { background: #fff4e0; color: #c47d18; }
.stock-pill.low { background: #fdeae2; color: #d1622a; }
.stock-pill.zero { background: var(--danger-light); color: var(--danger); }
.stock-pill.none { color: var(--muted); background: transparent; font-weight: 400; }

/* ---------- Меню строки (⋯) ---------- */
.row-menu { width: 30px; height: 30px; border-radius: 6px; border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.row-menu .ic { width: 18px; height: 18px; }
.row-menu:hover { background: #eef1f5; color: var(--text); }

/* ---------- Пагинация: размер страницы + номера ---------- */
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 6px 4px; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager .pg { min-width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }
.pager .pg:hover:not(:disabled) { background: #f6f8fa; }
.pager .pg:disabled { opacity: .45; cursor: not-allowed; }
.pager .pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .pg-info { color: var(--muted); font-size: 13px; margin-left: 8px; }
.page-size { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.page-size select { width: auto; padding: 5px 8px; }

/* ---------- KPI-плитки (низ страницы) ---------- */
.kpi-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; }
.kpi-tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px; }
.kpi-ico { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.kpi-ico .ic { width: 24px; height: 24px; }
.kpi-ico.blue { background: #e7f1fd; color: #2b7de0; } .kpi-ico.green { background: #e7f6ec; color: #1a8f45; }
.kpi-ico.violet { background: #efeafd; color: #7c5cf0; } .kpi-ico.amber { background: #fef6e0; color: #d99a12; }
.kpi-tile .k-label { color: var(--muted); font-size: 13px; }
.kpi-tile .k-value { font-size: 22px; font-weight: 700; letter-spacing: -.5px; margin: 2px 0; }
.kpi-tile .k-delta { font-size: 12.5px; font-weight: 600; }
.k-delta.up { color: var(--success); } .k-delta.down { color: var(--danger); } .k-delta.flat { color: var(--muted); }

/* ---------- Колокол и user-dropdown в шапке ---------- */
.bell { position: relative; width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; cursor: pointer;
  font-size: 18px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.bell .ic { width: 21px; height: 21px; }
.bell:hover { background: #f2f4f7; color: var(--text); }
.bell-badge { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.user-menu { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.user-menu:hover { background: #f2f4f7; }
.user-chevron { color: var(--muted); display: inline-flex; align-items: center; }
.user-chevron .ic { width: 16px; height: 16px; }
.bell-wrap { position: relative; }
.bell-drop { display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 300px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(16,30,54,.18); z-index: 60; padding: 6px 0; max-height: 60vh; overflow-y: auto; }
.bell-drop.open { display: block; }
.bell-item { padding: 9px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.bell-item:hover { background: #f6f8fa; }
.bell-item .bi-ico { font-size: 15px; }

/* ---------- Полноэкранная карточка сущности ---------- */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { color: var(--border-strong); }
.entity-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.entity-title { display: flex; align-items: center; gap: 12px; }
.entity-title h1 { font-size: 22px; margin: 0; }
.status-badge { padding: 3px 11px; border-radius: 14px; font-size: 12.5px; font-weight: 600; }
.status-badge.active { background: #e7f6ec; color: #1a8f45; }
.status-badge.archived { background: #eef0f3; color: var(--muted); }
.entity-actions { display: flex; align-items: center; gap: 10px; }
.card-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.card-tab { padding: 9px 16px; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.card-tab:hover { color: var(--primary); }
.card-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.entity-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.entity-grid > * { min-width: 0; }
.entity-main { min-width: 0; }
.info-sidebar { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow); position: sticky; top: calc(var(--nav-h) + 16px); }
.info-sidebar h3 { margin: 0 0 14px; font-size: 15px; }
.info-row { padding: 10px 0; border-top: 1px solid var(--border); }
.info-row:first-of-type { border-top: none; padding-top: 0; }
.info-row .ir-label { color: var(--muted); font-size: 12.5px; margin-bottom: 3px; }
.info-row .ir-value { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.info-row .ir-value.pos { color: var(--success); } .info-row .ir-value.neg { color: var(--danger); }
.info-dates { display: flex; gap: 24px; }
.section-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.section-card h3 { margin: 0 0 14px; font-size: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h3 { margin: 0; }
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.tile .t-label { color: var(--muted); font-size: 12px; }
.tile .t-value { font-size: 16px; font-weight: 600; margin: 3px 0 2px; }
.tile .t-hint { color: var(--muted); font-size: 11px; }
.tile input, .tile select { border: none; padding: 0; font-size: 16px; font-weight: 600; height: auto; background: transparent; }
.tile input:focus, .tile select:focus { box-shadow: none; }
.tile.readonly { background: #f7f9fc; }
.tile.readonly input { color: var(--muted); }
[data-theme="dark"] .tile.readonly { background: rgba(255,255,255,.03); }

/* Иконка типа в инфо-сайдбаре */
.ir-type-ic { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.ir-type-ic .ic { width: 16px; height: 16px; }
.ir-type-ic.product { background: #e7f1fd; color: #2b7de0; }
.ir-type-ic.service { background: #e7f6ec; color: #1a8f45; }
.ir-type-ic.bundle { background: #efeafd; color: #7c5cf0; }

/* Таблица состава комплекта */
.comp-table .col-sku { color: var(--muted); white-space: nowrap; }
.comp-table td, .comp-table th { vertical-align: middle; }

/* Степпер количества */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.stepper button { border: none; background: #f6f8fa; width: 28px; height: 30px; cursor: pointer; font-size: 15px; color: var(--muted); }
.stepper button:hover { background: #eef1f5; color: var(--text); }
.stepper input { border: none; width: 52px; text-align: center; border-radius: 0; padding: 6px 2px; }
.stepper input:focus { box-shadow: none; }
.char-counter { text-align: right; color: var(--muted); font-size: 11px; margin-top: 4px; }
.img-upload { display: flex; align-items: center; gap: 14px; }
.img-upload .prod-thumb { width: 72px; height: 72px; font-size: 26px; }

@media (max-width: 900px) {
  .entity-grid { grid-template-columns: 1fr; }
  .info-sidebar { position: static; }
}

/* ---------- Левый сайдбар секции/карточки ---------- */
.app-body { display: flex; flex: 1; align-items: stretch; min-height: 0; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-sidebar { width: 232px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border);
  padding: 14px 10px 10px; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h));
  overflow-y: auto; display: flex; flex-direction: column; z-index: 20; }
.sn-title { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted);
  padding: 2px 12px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sn-body { flex: 1; }
.sn-group { font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
  padding: 16px 12px 6px; }
.sn-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px;
  color: var(--text); font-size: 13.5px; border: none; background: none; cursor: pointer; text-align: left;
  font-family: inherit; margin-bottom: 1px; }
.sn-item:hover { background: #f2f6fb; text-decoration: none; }
.sn-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sn-item .sn-ic { display: inline-flex; color: inherit; opacity: .75; flex-shrink: 0; }
.sn-item.active .sn-ic { opacity: 1; }
.sn-lbl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sn-cnt { color: var(--muted); font-size: 12.5px; }
.sn-item.active .sn-cnt { color: var(--primary); }
.sn-foot { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.sn-collapse { color: var(--muted); }
.app-sidebar.collapsed { width: 62px; padding-left: 8px; padding-right: 8px; }
.app-sidebar.collapsed .sn-lbl, .app-sidebar.collapsed .sn-cnt,
.app-sidebar.collapsed .sn-title, .app-sidebar.collapsed .sn-group { display: none; }
.app-sidebar.collapsed .sn-item { justify-content: center; padding: 9px 0; }
@media (max-width: 900px) { .app-sidebar { display: none !important; } }

/* ---------- Чипы статусов (список документов) ---------- */
.chip-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 13.5px;
  cursor: pointer; font-family: inherit; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { color: var(--primary); border-color: var(--primary); font-weight: 600; box-shadow: 0 0 0 3px var(--primary-light); }
.chip .c-cnt { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 1px 7px; }
.chip.active .c-cnt { color: var(--primary); background: var(--primary-light); }

/* ---------- Список + правая панель документа ---------- */
.docs-grid { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
.docs-grid.panel-open { grid-template-columns: minmax(0, 1fr) minmax(380px, 460px); }
.doc-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 20px; position: sticky; top: calc(var(--nav-h) + 16px); max-height: calc(100vh - var(--nav-h) - 32px); overflow-y: auto; }
.doc-panel .dp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.doc-panel .dp-head h2 { font-size: 17px; margin: 0; flex: 1; }
.dp-close { border: none; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; }
.dp-close:hover { background: #eef1f5; color: var(--text); }
.dp-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; margin-bottom: 16px; }
.dp-f .l { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.dp-f .v { font-size: 13.5px; font-weight: 600; }
.dp-total td { border-top: 1px solid var(--border); font-size: 14px; }
.dp-actions-title { font-size: 14.5px; font-weight: 700; margin: 18px 0 10px; }
.dp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 1100px) {
  .docs-grid.panel-open { grid-template-columns: 1fr; }
  .doc-panel { position: static; max-height: none; }
}
.td-2line { line-height: 1.25; }
.td-2line .sub { color: var(--muted); font-size: 12px; }
tr.row-active { background: var(--primary-light); }
tr.row-active td { border-color: transparent; }

/* ---------- Combobox (поиск с выпадающим списком) ---------- */
.combobox { position: relative; }
.cb-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 80;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(16,30,54,.18);
  max-height: 300px; overflow-y: auto; padding: 4px 0; }
.cb-menu.open { display: block; }
.cb-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; cursor: pointer; font-size: 13.5px; }
.cb-opt:hover, .cb-opt.active { background: #f2f6fb; }
.cb-opt .cb-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cb-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; text-align: center; }
.cb-create { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: 13.5px;
  color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); }
.cb-create:hover { background: var(--primary-light); }
.cb-create .cb-plus { display: inline-flex; }
[data-theme="dark"] .cb-opt:hover, [data-theme="dark"] .cb-opt.active { background: #232b36; }

/* Поле с кнопкой «+» справа (быстрое создание) */
.field-plus { display: flex; gap: 8px; align-items: stretch; }
.field-plus > :first-child { flex: 1; min-width: 0; }
.btn-plus { flex-shrink: 0; width: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* Поле добавления позиции (как в МойСклад) */
.pos-add { position: relative; margin-bottom: 10px; }
.pos-add .combobox .cb-input { padding-left: 34px; }
.pos-add .pa-ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); z-index: 1; pointer-events: none; display: inline-flex; }

/* ---------- Карточка контрагента ---------- */
.input-ic { position: relative; }
.input-ic input { padding-right: 34px; }
.input-ic .ii { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: inline-flex; }
.star-btn { border: none; background: none; cursor: pointer; color: #c3ccd8; padding: 4px; display: inline-flex; border-radius: 6px; }
.star-btn:hover { background: #eef1f5; }
.star-btn.on { color: #f5b301; }
.star-btn.on svg { fill: #f5b301; }

.stat-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-chip { border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; border: 1px solid transparent; }
.stat-chip .sc-ic { display: inline-flex; flex-shrink: 0; }
.stat-chip .sc-l { font-size: 12px; opacity: .8; }
.stat-chip .sc-v { font-size: 15px; font-weight: 700; }
.stat-chip.green { background: #e7f6ec; color: #14713a; }
.stat-chip.blue { background: #e7f1fd; color: #1d5fae; }
.stat-chip.violet { background: #efeafd; color: #6742d1; }
.stat-chip.orange { background: #fdeee2; color: #b35a1c; }
.stat-chip.sand { background: #fdf6e3; color: #8f6b13; }

.contact-avatar { width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.contact-avatar.lg { width: 42px; height: 42px; font-size: 15px; }
.doc-total { text-align: right; margin: 12px 0 0; font-size: 15px; }

/* ---------- Вкладки внутри формы ---------- */
.tab-pane.hidden { display: none; }
.card-tab .tab-err-dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-left: 6px; }
.card-tab.has-error .tab-err-dot { display: inline-block; }
.card-tab.has-error { color: var(--danger); }

/* ---------- Доставка (вкладка заказа) ---------- */
.dlv-method { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.dlv-method-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--card); cursor: pointer; font-family: inherit; font-size: 13.5px; color: var(--text); }
.dlv-method-btn:hover:not(:disabled) { border-color: var(--primary); }
.dlv-method-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.dlv-method-btn:disabled { opacity: .6; cursor: not-allowed; }
.dlv-method-ic { display: flex; }
.dlv-hint { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.dlv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 1000px) { .dlv-grid { grid-template-columns: 1fr; } }
.dlv-col { min-width: 0; }
.dlv-col-head { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.dlv-switch { display: inline-flex; gap: 2px; background: #eef1f5; border-radius: 7px; padding: 3px; margin-bottom: 12px; }
.dlv-switch-btn { border: none; background: none; padding: 5px 12px; border-radius: 5px; cursor: pointer;
  font-size: 12.5px; font-family: inherit; color: var(--muted); }
.dlv-switch-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.dlv-time-range { display: flex; align-items: center; gap: 8px; }
.dlv-stale { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 8px;
  background: #fef6e0; color: #8a5a00; font-size: 12.5px; margin-bottom: 12px; }
.dlv-stale.hidden, .dlv-grid .hidden, .field.hidden, .dlv-switch.hidden { display: none; }
.field label.req::after { content: ' *'; color: var(--danger); }
[data-theme="dark"] .dlv-switch { background: #232b36; }
[data-theme="dark"] .dlv-switch-btn.active { background: var(--card); }
[data-theme="dark"] .dlv-stale { background: rgba(251,191,36,.14); color: #f0cf7c; }

/* ---------- Карточка контакта ---------- */
/* min-width:0 снимает неявный min-width:auto у флекс/грид-элементов — без него
   длинный email выламывает карточку за её границы. */
.cc-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px; min-width: 0; }
.cc-row > .muted:first-child { min-width: 108px; font-size: 12.5px; flex-shrink: 0; }
.cc-row > :last-child { min-width: 0; overflow-wrap: anywhere; }
.cc-company { display: flex; align-items: flex-start; gap: 14px; }
.cc-company-name { font-size: 16px; font-weight: 700; }
.cc-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.cc-block-title { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.role-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.role-badge.b0 { background: #e7f1fd; color: #1d5fae; }
.role-badge.b1 { background: #e0f4fa; color: #0d7490; }
.role-badge.b2 { background: #f0eafd; color: #6742d1; }
.role-badge.b3 { background: #e7f6ec; color: #14713a; }
.icon-act { border: none; background: none; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 6px; display: inline-flex; }
.icon-act:hover { background: #eef1f5; color: var(--text); }
.icon-act.danger:hover { color: var(--danger); background: var(--danger-light); }

.bank-card .b-row { padding: 8px 0; border-top: 1px solid var(--border); }
.bank-card .b-row:first-of-type { border-top: none; padding-top: 0; }
.bank-card .b-l { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.bank-card .b-v { font-size: 13.5px; font-weight: 600; word-break: break-all; }
.link-more { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-size: 13px; font-weight: 600;
  background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; margin-top: 10px; }
.link-more:hover { text-decoration: underline; }

.notes-list { display: flex; flex-direction: column; gap: 4px; }
.note-item { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; align-items: flex-start; }
.note-item:hover { background: #f6f8fa; }
.note-item .n-ic { display: inline-flex; margin-top: 2px; flex-shrink: 0; color: var(--primary); }
.note-item .n-text { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.note-item .n-text.done { text-decoration: line-through; color: var(--muted); }
.note-item .n-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.note-item .n-badge { margin-left: auto; flex-shrink: 0; }
.note-add { display: flex; gap: 8px; margin-top: 12px; }
.note-add input { flex: 1; }
.note-add select { width: auto; }

.ir-ic { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary); flex-shrink: 0; }
.info-row.with-ic { display: flex; gap: 12px; align-items: flex-start; }
.info-row.with-ic > div:last-child { min-width: 0; }

/* ---------- Тёмная тема ---------- */
:root[data-theme="dark"] {
  --primary: #4a9eff; --primary-dark: #3a86e0; --primary-light: rgba(74,158,255,.16);
  --success: #34d17a; --success-light: rgba(52,209,122,.16);
  --bg: #0f141b; --card: #1a212b; --text: #e5e9f0; --muted: #93a0b0;
  --border: #2a323d; --border-strong: #3a4552;
  --danger: #f87171; --danger-light: rgba(248,113,113,.16);
  --warn: #fbbf24; --warn-light: rgba(251,191,36,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.3);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .login-wrap { background: linear-gradient(135deg, #131a24 0%, #0f141b 100%); }
[data-theme="dark"] .topnav { background: var(--card); border-bottom-color: var(--border); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
[data-theme="dark"] .topnav-item { color: #aeb8c4; }
[data-theme="dark"] .topnav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
[data-theme="dark"] .topnav-item.active { background: rgba(74,158,255,.14); }
[data-theme="dark"] .brand, [data-theme="dark"] .brand-name { color: var(--text); }
[data-theme="dark"] .gsearch input, [data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #0f141b; color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .gsearch input { border-color: transparent; }
[data-theme="dark"] input:disabled, [data-theme="dark"] select:disabled, [data-theme="dark"] textarea:disabled {
  background: #232b36; color: var(--muted); border-color: var(--border); }
[data-theme="dark"] .btn { background: var(--card); color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .btn:hover { background: #232b36; border-color: #46525f; }
[data-theme="dark"] .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-dark); }
[data-theme="dark"] .btn-ghost { background: transparent; }
[data-theme="dark"] .btn-ghost:hover, [data-theme="dark"] .row-menu:hover, [data-theme="dark"] .bell:hover, [data-theme="dark"] .user-menu:hover { background: #232b36; }
[data-theme="dark"] th { background: #151b23; }
[data-theme="dark"] tbody tr:hover { background: #222b37; }
[data-theme="dark"] tbody tr.selected { background: #33301c; }
[data-theme="dark"] tbody tr.selected:hover { background: #3d3922; }
[data-theme="dark"] .pill-tabs { background: #232b36; }
[data-theme="dark"] .pill-tabs button.active { background: var(--card); }
[data-theme="dark"] .board-col, [data-theme="dark"] .stepper button, [data-theme="dark"] .board-col-head .cnt { background: #232b36; }
[data-theme="dark"] .board-col.dragover { background: rgba(74,158,255,.14); }
[data-theme="dark"] .dropdown-menu button:hover, [data-theme="dark"] .bell-item:hover, [data-theme="dark"] .gs-item:hover, [data-theme="dark"] .tree-item:hover { background: #232b36; }
[data-theme="dark"] .prod-thumb { background: #232b36; }
[data-theme="dark"] .kpi-ico.blue { background: rgba(74,158,255,.18); }
[data-theme="dark"] .kpi-ico.green { background: rgba(52,209,122,.18); }
[data-theme="dark"] .kpi-ico.violet { background: rgba(150,120,240,.20); }
[data-theme="dark"] .kpi-ico.amber { background: rgba(251,191,36,.18); }
[data-theme="dark"] .search::before { opacity: .7; }
[data-theme="dark"] .status-badge.active { background: rgba(52,209,122,.18); color: var(--success); }
[data-theme="dark"] .status-badge.archived, [data-theme="dark"] .badge.gray { background: #2a323d; color: var(--muted); }
[data-theme="dark"] .bulkbar { background: rgba(74,158,255,.12); border-color: rgba(74,158,255,.3); }
[data-theme="dark"] code { background: #0f141b !important; }
[data-theme="dark"] .toast { background: #2a323d; }

/* ---------- Доска заказов (kanban) ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { flex: 0 0 258px; background: #f2f4f7; border-radius: 10px; padding: 10px; min-height: 120px; }
.board-col.dragover { background: #e7f1fd; outline: 2px dashed var(--primary); outline-offset: -2px; }
.board-col-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; padding: 2px 6px 10px; }
.board-col-head .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.board-col-head .cnt { margin-left: auto; background: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
.board-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.board-card:hover { border-color: var(--primary); }
.board-card:active { cursor: grabbing; }
.board-card.dragging { opacity: .45; }
.board-card .bc-num { font-weight: 600; font-size: 13.5px; }
.board-card .bc-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.board-card .bc-total { font-weight: 600; margin-top: 6px; }
.board-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 16px 0; }

/* ---------- Печать ---------- */
#print-root { display: none; }
@media print {
  .topnav, .subnav, #modal-root, #toast-root { display: none !important; }
  #app { display: none !important; }
  #print-root { display: block !important; }
  @page { margin: 14mm; size: A4; }
  body { background: #fff; }
}
.print-doc { color: #000; font-size: 13px; max-width: 190mm; margin: 0 auto; }
.print-doc h1 { font-size: 18px; margin: 0 0 4px; }
.print-doc .pd-sub { color: #333; margin-bottom: 16px; }
.print-doc .pd-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.print-doc .pd-party b { display: block; margin-bottom: 3px; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.print-doc th, .print-doc td { border: 1px solid #000; padding: 5px 8px; font-size: 12px; }
.print-doc th { background: #eee; }
.print-doc td.num, .print-doc th.num { text-align: right; }
.print-doc .pd-total { text-align: right; font-size: 14px; margin-top: 8px; }
.print-doc .pd-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.print-doc .pd-sign .line { border-top: 1px solid #000; padding-top: 4px; color: #333; }
.labels-sheet { display: flex; flex-wrap: wrap; gap: 8px; }
.label-box { border: 1px dashed #999; padding: 8px 10px; text-align: center; page-break-inside: avoid; }
.label-box .lb-name { font-size: 12px; color: #000; margin-bottom: 4px; max-width: 200px; overflow: hidden; }
.label-box .lb-price { font-size: 13px; font-weight: 700; margin-top: 2px; }
@media print { .label-box { border-color: transparent; } }

/* ---------- Тёмная тема: сайдбар, чипы, панель, карточка контрагента ---------- */
[data-theme="dark"] .app-sidebar { background: var(--card); border-right-color: var(--border); }
[data-theme="dark"] .sn-item:hover { background: #232b36; }
[data-theme="dark"] .chip { background: var(--card); }
[data-theme="dark"] .chip .c-cnt { background: #232b36; }
[data-theme="dark"] .dp-close:hover, [data-theme="dark"] .icon-act:hover, [data-theme="dark"] .star-btn:hover { background: #232b36; }
[data-theme="dark"] .note-item:hover { background: #232b36; }
[data-theme="dark"] .stat-chip.green { background: rgba(52,209,122,.14); color: #6fdea4; }
[data-theme="dark"] .stat-chip.blue { background: rgba(74,158,255,.14); color: #8cc0ff; }
[data-theme="dark"] .stat-chip.violet { background: rgba(150,120,240,.16); color: #b9a3f7; }
[data-theme="dark"] .stat-chip.orange { background: rgba(251,146,60,.14); color: #ffb37a; }
[data-theme="dark"] .stat-chip.sand { background: rgba(251,191,36,.12); color: #f0cf7c; }
[data-theme="dark"] .role-badge.b0 { background: rgba(74,158,255,.16); color: #8cc0ff; }
[data-theme="dark"] .role-badge.b1 { background: rgba(34,211,238,.14); color: #7ee2f2; }
[data-theme="dark"] .role-badge.b2 { background: rgba(150,120,240,.18); color: #b9a3f7; }
[data-theme="dark"] .role-badge.b3 { background: rgba(52,209,122,.14); color: #6fdea4; }

/* ---------- CRM: Сделки (воронка), Счета, Интеграции ---------- */
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); border-color: var(--success); }
.stage-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.board-col-sum { font-size: 13px; font-weight: 700; color: var(--text); margin: -4px 0 8px; }
.deal-card .dc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.deal-card .dc-prob { font-size: 12px; color: var(--muted); font-weight: 600; }
.deal-card .dc-next { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--warn); }
.deal-card .dc-next span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-list { display: flex; flex-direction: column; gap: 4px; }
.linked-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); }
.linked-item:hover { background: #f2f6fb; text-decoration: none; }
.linked-item .li-sum { margin-left: auto; font-weight: 600; }

/* Редактор счёта */
.readonly-box { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: #f7f9fc; font-weight: 600; font-size: 13.5px; }
.inv-items input, .inv-items select { padding: 5px 7px; font-size: 13px; }
.inv-items .ii-qty { width: 76px; } .inv-items .ii-price { width: 96px; } .inv-items .ii-disc { width: 66px; } .inv-items .ii-vat { width: 68px; }
.pay-rows { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.pay-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.pay-row span { color: var(--muted); }
.pay-block { padding-top: 14px; }
.pay-label { color: var(--muted); font-size: 13px; }
.pay-total { font-size: 30px; font-weight: 800; letter-spacing: -.5px; color: var(--success); margin: 2px 0 6px; }
.pay-margin { font-size: 13px; color: var(--muted); }
.pay-margin .margin-val { font-weight: 700; }
.pay-margin .margin-val.pos { color: var(--success); } .pay-margin .margin-val.neg { color: var(--danger); }

/* Интеграции */
.integ-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.integ-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.integ-head { display: flex; align-items: flex-start; gap: 12px; }
.integ-ic { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.integ-name { font-size: 16px; font-weight: 700; }
.integ-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.integ-info { display: flex; flex-direction: column; gap: 6px; font-size: 13px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.integ-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.payload-pre { max-height: 50vh; overflow: auto; background: #0f141b; color: #cfe3ff; padding: 14px; border-radius: 8px; font-size: 12px; line-height: 1.5; }
[data-theme="dark"] .readonly-box { background: rgba(255,255,255,.03); }
[data-theme="dark"] .linked-item:hover { background: #232b36; }
