/* =========================================================================
   ERP — базовая система стилей. Без зависимостей и сборки.
   ========================================================================= */

:root {
  --bg:            #f4f6f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-3:     #f1f3f6;
  --border:        #e3e7ec;
  --border-strong: #cfd6de;
  --text:          #10151c;
  --text-2:        #47525f;
  /* Контраст доведён до нормы 4,5:1 (v3.24, UX-033).
     Было #7a8694 — 3,71:1 на белом и 3,33:1 на сером фоне таблиц: на
     хорошем мониторе незаметно, на ноутбуке у окна подписи читались с
     трудом. Стало 5,10:1 на белом и 4,59:1 на самом светлом сером —
     то есть норма выполняется на всех фонах системы, а не только на белом.
     Разница на глаз небольшая: текст остался второстепенным. */
  --muted:         #656f7c;
  --accent:        #2563eb;
  --accent-dark:   #1d4ed8;
  --accent-soft:   #eaf1ff;

  --green:  #12855a;  --green-soft:  #e6f6ee;
  --amber:  #b06a00;  --amber-soft:  #fdf2df;
  --red:    #c02626;  --red-soft:    #fdeceb;
  --violet: #6d3ae0;  --violet-soft: #f1ecfe;
  --cyan:   #0e7490;  --cyan-soft:   #e2f5fa;
  --grey:   #64748b;  --grey-soft:   #eef1f5;
  /* Доставлен и Оплачен раньше были одного цвета и сливались (v2.2) */
  --teal:   #0f766e;  --teal-soft:   #dcf5f1;
  --pink:   #b83280;  --pink-soft:   #fce8f3;
  /* Палитра статусов заказа задана заказчиком (v2.4) */
  --yellow: #a16207;  --yellow-soft: #fef7c3;
  --orange: #c2410c;  --orange-soft: #ffece0;
  --green-bright: #15803d; --green-bright-soft: #d9f7e4;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-1:  0 1px 2px rgba(16, 21, 28, .05), 0 1px 3px rgba(16, 21, 28, .04);
  --shadow-2:  0 4px 14px rgba(16, 21, 28, .08);
  --shadow-3:  0 12px 40px rgba(16, 21, 28, .16);

  --sidebar-w:   244px;
  --sidebar-w-c: 62px;
  --topbar-h:    56px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }

.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.ic-lg { width: 22px; height: 22px; }
.ic-sm { width: 15px; height: 15px; }

.muted     { color: var(--muted); }
.text-2    { color: var(--text-2); }
.small     { font-size: 12.5px; }
.xs        { font-size: 11.5px; }
.mono      { font-family: var(--mono); font-size: 12.5px; }
.bold      { font-weight: 600; }
.right     { text-align: right; }
.center    { text-align: center; }
.nowrap    { white-space: nowrap; }
/* Ссылка, которая не выглядит ссылкой (v3.18): имя клиента в списках —
   это в первую очередь имя, а синий цвет на каждой строке рябит.
   Подчёркивание и указатель появляются при наведении, так что понять,
   что это кликабельно, по-прежнему можно. */
.lnk-plain { color: var(--text); font-weight: 600; text-decoration: none; }
.lnk-plain:hover, .lnk-plain:focus-visible { text-decoration: underline; }
.pos       { color: var(--green); }
.neg       { color: var(--red); }
.hidden    { display: none !important; }
.w-100     { width: 100%; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px } .mb-3 { margin-bottom: 24px }
.gap-1 { gap: 8px } .gap-2 { gap: 16px }
.flex  { display: flex; align-items: center; min-width: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.grow { flex-grow: 1; }
.stack { display: flex; flex-direction: column; }

/* =========================== Каркас =========================== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .16s ease, flex-basis .16s ease;
  z-index: 40;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-c); flex-basis: var(--sidebar-w-c); }
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-sub { display: none; }
body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }

.brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  /* Логотип — ссылка на главную, но выглядеть должен как раньше: тот же
     цвет текста, без подчёркивания. Только курсор показывает, что нажимается (v3.16) */
  color: var(--text); text-decoration: none; cursor: pointer;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #4f7cf7);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -.02em;
  flex: 0 0 auto;
}
.brand-text { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; }

.nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 8px 20px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: #dfe4ea; border-radius: 8px; }

.nav-group { margin-bottom: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
/* Заголовок раздела теперь кнопка (v3.20, UX-032) — чтобы до него можно
   было добраться с клавиатуры. Выглядеть он должен ровно как раньше,
   поэтому снимаем всё, что браузер рисует кнопке по умолчанию. */
button.nav-item {
  width: 100%; margin: 0; text-align: left;
  background: none; border: 0; font-family: inherit; line-height: inherit;
}
button.nav-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.nav-item:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.nav-item .ic { color: currentColor; opacity: .85; }
.nav-item .chev { margin-left: auto; width: 14px; height: 14px; transition: transform .15s; opacity: .5; }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-sub { padding: 2px 0 6px 34px; display: none; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a {
  display: block; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px;
}
.nav-sub a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav-sub a.active { color: var(--accent-dark); background: var(--accent-soft); font-weight: 600; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 30;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: grid; place-items: center; cursor: pointer;
  color: var(--text-2); background: transparent; border: 0;
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.global-search { position: relative; flex: 1 1 auto; min-width: 0; max-width: 520px; }
.global-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.global-search input[type=search],
.global-search input[type=text] {
  width: 100%; min-width: 0; height: 36px; min-height: 36px; padding: 0 12px 0 38px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); font-size: 13.5px; font-family: inherit; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.global-search input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }

.search-results {
  position: absolute; top: 42px; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3);
  max-height: 70vh; overflow-y: auto; z-index: 60; padding: 6px;
}
.search-results .sr-group { padding: 6px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.search-results a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); }
.search-results a:hover, .search-results a.hl { background: var(--accent-soft); text-decoration: none; }
.search-results .sr-meta { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; display: flex; flex-direction: column; gap: 1px; }
/* Картинка товара в поиске и в строках заказа (v3.4.1) */
.search-results .sr-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sr-thumb {
  width: 30px; height: 30px; flex: none; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-3); border: 1px solid var(--border);
}
.sr-thumb-ph { display: block; }
.row-thumb {
  width: 30px; height: 30px; flex: none; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-3); border: 1px solid var(--border);
}
.cell-product { display: flex; align-items: center; gap: 9px; min-width: 0; }




/* Панель сборки: действия столбиком, чтобы таблица не уезжала вправо (v3.5.3).
   Селектор с `table.data`, иначе `table.data .col-actions { white-space: nowrap }`
   перебивает по специфичности и кнопки снова встают в одну строку. */
/* Итоговый столбец таблицы (v3.12.1).
   Ради общей суммы в отчёт и заходят: она стоит последней справа, набрана
   жирным и подложена лёгкой заливкой — глаз находит её, не читая строку. */
table.data th.col-total, table.data td.col-total {
  background: var(--accent-soft);
  font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 1px 0 0 #c7d9fb;
}
table.data thead th.col-total { color: var(--accent-dark); background: #dbe7ff; }
table.data tfoot td.col-total { font-weight: 750; }
table.data tbody tr:hover td.col-total { background: #dbe7ff; }

/* Долги по клиентам: имя не должно ломаться на три строки (v3.13).
   Таблица помещается в экран, поэтому имени можно отдать место, а
   денежные столбцы сжать — цифры узкие. */
table.data th.debt-name, table.data td.debt-name { min-width: 190px; }
table.data td.debt-name { line-height: 1.25; }

/* Колонка действий в сборке (v3.12).
   Была во всю ширину: кнопка растягивалась на 170 пикселей и выглядела
   плашкой. Теперь колонка сжата по содержимому, кнопки одной ширины и
   прижаты вправо — колонка читается как ровный столбик действий. */
table.data td.pick-actions {
  width: 1%; white-space: nowrap; text-align: right; vertical-align: middle;
}
table.data td.pick-actions .pick-stack {
  display: inline-flex; flex-direction: column; align-items: stretch; gap: 5px;
  min-width: 128px;
}
table.data td.pick-actions .pick-stack > * { width: 100%; }
table.data td.pick-actions .btn { justify-content: center; }
table.data td.pick-actions .badge { text-align: center; }
table.data td.pick-actions form { display: block; }

/* Статус пользователя меняется прямо из строки (v3.5.4).
   Селектор с двумя классами: `table.data .col-actions { width: 1% }`
   иначе выигрывает по специфичности и сжимает колонку в столбик. */
table.data td.col-actions.user-actions {
  width: 1%; white-space: nowrap; text-align: right;
}
table.data td.col-actions.user-actions .row-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px; flex-wrap: nowrap;
}
table.data td.col-actions.user-actions form { display: inline-flex; }
table.data td.col-actions.user-actions .btn-sm { padding: 0 7px; gap: 5px; }

/* Ссылка-кнопка внутри подписи плитки (v3.4.7) */
.link-btn {
  border: 0; background: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); border-bottom: 1px solid transparent;
}
.link-btn:hover { color: var(--accent-dark); border-bottom-color: var(--accent); }

/* Атрибут hidden должен прятать даже flex-элементы: кнопки и строки таблиц
   мы скрываем именно им (v3.4.6) */
[hidden] { display: none !important; }

/* График ожидаемых поступлений: столбец на день, клик — счета этого дня (v3.4.6) */
.pay-chart {
  display: flex; align-items: flex-end; gap: 4px;
  overflow-x: auto; padding: 6px 2px 0; min-height: 200px;
}
.pay-col {
  flex: 1 0 44px; min-width: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; gap: 4px;
  height: 190px; padding: 0 0 4px; border: 0; background: none; cursor: pointer;
  border-radius: var(--radius-sm); transition: background .12s;
}
.pay-col:hover { background: var(--surface-3); }
/* Сумма над столбцом: постоянно висящие подписи соседних дней наезжали
   друг на друга, поэтому показываем их только при наведении и у выбранного
   дня, а в остальное время держим место (v3.4.9) */
.pay-sum {
  /* Сумма и число накладных читаются как цифры дня — жирным (v3.5.3) */
  font-size: 11.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
  white-space: nowrap; opacity: 0; transition: opacity .12s;
  background: var(--surface); padding: 0 3px; border-radius: 4px; position: relative; z-index: 2;
}
.pay-col:hover .pay-sum, .pay-col.is-picked .pay-sum { opacity: 1; }
.pay-bar {
  width: 60%; min-height: 3px; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent) 0%, #6f9bf5 100%);
  transition: background .12s, transform .12s; transform-origin: bottom;
}
.pay-col.is-empty .pay-bar { background: var(--border); }
.pay-col.is-today .pay-bar { background: linear-gradient(180deg, var(--green) 0%, #34b27b 100%); }
.pay-col.is-picked { background: var(--accent-soft); }
.pay-col.is-picked .pay-bar { transform: scaleX(1.15); }
.pay-day { font-size: 11px; color: var(--muted); white-space: nowrap; }
.pay-col.is-today .pay-day { color: var(--green); font-weight: 650; }
.pay-cnt {
  font-size: 11.5px; font-weight: 700; color: var(--text-2); min-height: 14px;
  font-variant-numeric: tabular-nums;
}
.pay-col:hover .pay-cnt, .pay-col.is-picked .pay-cnt { color: var(--accent-dark); }

/* Вкладки складов в остатках: цифра рядом с названием (v3.4.5) */
.wh-tabs a { display: inline-flex; align-items: center; gap: 8px; }
.wh-tab-qty {
  font-size: 11.8px; font-weight: 600; color: var(--text-2);
  background: var(--surface-3); border-radius: 20px; padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.wh-tabs a.active .wh-tab-qty { background: var(--accent-soft); color: var(--accent-dark); }

/* Раскладка остатка по складам в списке остатков (v3.4.4) */
.wh-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.wh-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 2px 8px; border-radius: 20px; font-size: 12.2px;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border); text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.wh-chip:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }
.wh-chip b { color: var(--text); }
.wh-chip:hover b { color: var(--accent-dark); }

/* Цель по товарам: строка «сколько достичь — товар либо категория» (v3.4.1) */
.mu-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.mu-row {
  display: grid; grid-template-columns: 130px 150px minmax(0, 1fr) 32px;
  gap: 8px; align-items: start;
}
.mu-row .mu-target { text-align: right; }
.mu-row .mu-del { align-self: center; }
@media (max-width: 720px) {
  .mu-row { grid-template-columns: 1fr 1fr; }
  .mu-row .mu-pick, .mu-row .combo { grid-column: 1 / -1; }
}
.search-results .sr-price { color: var(--text-2); font-weight: 600; }

.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 20px; cursor: pointer; }
.user-chip:hover { background: var(--surface-3); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: 0 0 auto;
}
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3);
  min-width: 210px; padding: 6px; z-index: 70; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; background: none; border: 0;
  font-family: inherit; text-align: left; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
/* Лента сообщений системы (v3.19) */
.dropdown-title { padding: 8px 10px 6px; font-size: 11.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); }
.msg-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red); }
.msg-row { display: block; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; }
.msg-row + .msg-row { border-top: 1px solid var(--border); border-radius: 0; }
.msg-row .msg-when { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.msg-row.error { border-left: 3px solid var(--red); }
/* Ошибка висит, пока её не закроют (v3.19) — но глаз к ней должен
   возвращаться, поэтому оставляем заметную рамку */
.flash.sticky { border-left-width: 4px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 5px 2px; }

.content { flex: 1 1 auto; padding: 18px 20px 64px; max-width: 1720px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .titles { flex: 1 1 auto; min-width: 200px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
/* Кнопки страницы всегда прижаты к правому краю — даже когда подзаголовок
   длинный и блок переносится на свою строку (v2.2.2) */
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }

.breadcrumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }

/* =========================== Кнопки =========================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 550; font-family: inherit;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.94); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn .ic { width: 16px; height: 16px; }

/* Тональные кнопки для строк таблицы (v3.12).
   Сплошная заливка в каждой строке превращает колонку действий в стену
   цвета: глаз перестаёт различать, где что. Тональная кнопка говорит то же
   самое — «это главное действие строки», — но не кричит. */
.btn-tonal {
  background: var(--accent-soft); border-color: #c7d9fb; color: var(--accent-dark); font-weight: 600;
}
.btn-tonal:hover { background: #dbe7ff; border-color: var(--accent); color: var(--accent-dark); }
.btn-tonal.good { background: var(--green-soft); border-color: #b9e3cd; color: var(--green); }
.btn-tonal.good:hover { background: #d6f0e3; border-color: var(--green); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* =========================== Карточки =========================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { flex: 1 1 auto; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-1 { grid-template-columns: minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* Цветные подложки иконок разделов — используются иконками статусов
   и плитками (блок «Разделы» с главной убран в v2.7) */
.tone-blue   { background: #e8f0ff; color: #1d4ed8; }
.tone-violet { background: #f0ebfe; color: #6d3ae0; }
.tone-amber  { background: #fdf1dc; color: #b06a00; }
.tone-teal   { background: #ddf5f0; color: #0f766e; }
.tone-green  { background: #e3f6ec; color: #12855a; }
.tone-cyan   { background: #e0f4fb; color: #0e7490; }
.tone-orange { background: #fdecdf; color: #c2410c; }
.tone-slate  { background: #eaeef3; color: #475569; }
.tone-indigo { background: #eaeafd; color: #4338ca; }
.tone-pink   { background: #fce9f2; color: #be1e63; }
.tone-red    { background: #fdeaea; color: #c02626; }
.tone-lime   { background: #eef7dc; color: #5a7d11; }
.tone-grey   { background: #eef1f5; color: #64748b; }

/* =========================== KPI =========================== */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.kpi .kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .035em; color: var(--muted); font-weight: 600; }
/* Точные суммы длиннее сокращённых: цифра ужимается, но не обрезается —
   обрезанная сумма хуже, чем мелкая (v3.0.2) */
.kpi .kpi-value {
  font-size: clamp(17px, 1.35vw, 21px); font-weight: 640; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.accent .kpi-value { color: var(--accent-dark); }
.kpi.good   .kpi-value { color: var(--green); }
.kpi.bad    .kpi-value { color: var(--red); }
.kpi.warn   .kpi-value { color: var(--amber); }
.kpi a { color: inherit; }
/* Ссылкой в плитке служит только цифра: слова остаются словами, а курсор-рука
   появляется ровно там, куда можно нажать (v3.10.1) */
.kpi .kpi-value a.kpi-link { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.kpi .kpi-value a.kpi-link:hover { border-bottom-color: currentColor; }
.kpi .kpi-value a.kpi-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ============== Показатели главной страницы (v2.7) ==============
   Плитки KPI были одного размера и одного веса — глаз не понимал,
   что здесь главное. Теперь два ряда с подписями: «За период» —
   итоги, которые меняются со временем и сравниваются с прошлым;
   «На сегодня» — снимок состояния, сравнивать который не с чем. */

.metrics { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }

.metrics-head {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  margin-top: 6px;
}
.metrics-head:first-child { margin-top: 0; }

.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  border-left: 3px solid var(--border-strong);
}
.metric.accent { border-left-color: var(--accent); }
.metric.good   { border-left-color: var(--green); }
.metric.bad    { border-left-color: var(--red); }

.metric-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .035em;
  color: var(--muted); font-weight: 600;
}
.metric-value {
  font-size: 25px; font-weight: 660; letter-spacing: -.022em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.metric.accent .metric-value { color: var(--accent-dark); }
.metric.bad    .metric-value { color: var(--red); }
.metric.good   .metric-value { color: var(--green); }
.metric a { color: inherit; }
.metric-sub { font-size: 12px; color: var(--muted); }
.metric-delta { font-size: 12.5px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }

.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up   { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); font-weight: 500; }
.delta-base { color: var(--muted); font-size: 12px; }
.warn-note { color: var(--amber); }

/* Выбор периода прямо в строке быстрых кнопок */
.period-form { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.period-form input[type=date] {
  padding: 5px 8px; font-size: 12.5px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}

/* ================= Состояние заказов (v2.7) =================
   Полоса — это путь заказа слева направо, ширина сегмента равна
   доле статуса. Цвета те же, что у бейджей в списках, иначе
   пришлось бы держать в голове две легенды. */

.state-bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--surface-2); margin-bottom: 14px; gap: 2px;
}
.state-seg { display: block; min-width: 6px; transition: .14s; }
.state-seg:hover { filter: brightness(1.12); }
.state-seg.tone-blue         { background: var(--accent); }
.state-seg.tone-red          { background: var(--red); }
.state-seg.tone-yellow       { background: var(--yellow); }
.state-seg.tone-orange       { background: var(--orange); }
.state-seg.tone-violet       { background: var(--violet); }
.state-seg.tone-green-bright { background: var(--green-bright); }
.state-seg.tone-grey         { background: var(--grey); }

.state-list { display: flex; flex-direction: column; }
.state-row {
  display: grid;
  grid-template-columns: 10px 1fr auto 52px auto;
  align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.4px;
  border-bottom: 1px solid var(--border);
}
.state-row:last-child { border-bottom: 0; }
.state-row:hover { background: var(--surface-2); text-decoration: none; }

.state-dot { width: 10px; height: 10px; border-radius: 3px; }
.state-dot.tone-blue         { background: var(--accent); }
.state-dot.tone-red          { background: var(--red); }
.state-dot.tone-yellow       { background: var(--yellow); }
.state-dot.tone-orange       { background: var(--orange); }
.state-dot.tone-violet       { background: var(--violet); }
.state-dot.tone-green-bright { background: var(--green-bright); }
.state-dot.tone-grey         { background: var(--grey); }

.state-name  { font-weight: 500; }
.state-share { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.state-cnt   { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.state-amount{ color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ================= Ожидаемые платежи (v2.7) ================= */

/* Три плитки в ряд: блок стоит во всю ширину, и колонкой он пустовал (v2.8) */
.expect { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.expect-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "title" "amount" "meta";
  gap: 4px; align-items: baseline;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); transition: .14s;
}
.expect-row:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface); }
.expect-row.accent { border-color: rgba(37,99,235,.35); background: var(--accent-soft); }
.expect-row.empty-row { opacity: .62; }

.expect-title  { grid-area: title;  font-weight: 640; font-size: 14px; }
.expect-meta   { grid-area: meta;   font-size: 12.2px; color: var(--muted); }
.expect-amount {
  grid-area: amount;
  font-size: 22px; font-weight: 660; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.expect-row.accent .expect-amount { color: var(--accent-dark); }

/* Полоска доли в таблице менеджеров */
.mini-bar {
  height: 8px; border-radius: 4px; background: var(--surface-2);
  overflow: hidden; min-width: 60px;
}
.mini-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

@media (max-width: 860px) {
  .metric-row, .metric-row.two { grid-template-columns: 1fr; }
  .expect { grid-template-columns: 1fr; }
  .state-row { grid-template-columns: 10px 1fr auto auto; }
  .state-row .state-amount { grid-column: 2 / -1; text-align: left; }
}

/* ================= Цели (KPI) на главной, v2.8 =================
   Полоса выполнения плюс засечка темпа: где мы должны быть, если идти
   ровно. Без засечки процент ни о чём не говорит — 40 % в середине
   месяца это норма, а в последний день провал. */

/* auto-fill, а не auto-fit: одна карточка не должна растягиваться
   на всю ширину экрана — она читается как таблица, а не как плитка */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.goal {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid var(--grey);
}
.goal-ok     { border-left-color: var(--accent); }
.goal-done   { border-left-color: var(--green); }
.goal-behind { border-left-color: var(--amber); }

.goal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.goal-name { font-weight: 650; font-size: 14px; }
.goal-owner { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.goal-nums { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.goal-fact { font-size: 20px; font-weight: 660; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.goal-target { font-size: 12.5px; color: var(--muted); }

.goal-bar {
  position: relative; height: 9px; border-radius: 5px;
  background: var(--surface-3); overflow: visible;
}
.goal-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.goal-done   .goal-fill { background: var(--green); }
.goal-behind .goal-fill { background: var(--amber); }
/* Засечка темпа */
.goal-pace {
  position: absolute; top: -3px; width: 2px; height: 15px;
  background: var(--text); opacity: .45; border-radius: 1px;
}

.goal-foot { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal-pct { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.goal-done   .goal-pct { color: var(--green); }
.goal-behind .goal-pct { color: var(--amber); }
.goal-note { font-size: 11.8px; color: var(--muted); }

/* --- Цель как блок: шапка + карточка на каждого исполнителя (v3.1) ---
   Одна цель может держать несколько показателей и несколько менеджеров.
   Карточка — это человек, строки в ней — показатели. */

.goal-set { margin-bottom: 18px; }
.goal-set + .goal-set { padding-top: 16px; border-top: 1px dashed var(--border); }
.goal-set-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.goal-set-name { font-weight: 680; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-set-sub { font-size: 11.8px; color: var(--muted); margin-top: 2px; }

.goal-total { border-left-color: var(--violet); background: var(--surface-3); }

.gm { display: flex; flex-direction: column; gap: 5px; }
.gm + .gm { margin-top: 4px; padding-top: 9px; border-top: 1px dashed var(--border); }
/* Подпись показателя бывает длинной («штук по выбранным товарам · Картридж
   Aria 1.2 Ом») и переносится на две строки. Процент при этом ломался на
   «17» и «%» — поэтому подпись сжимаемая, а процент не переносится (v3.4.8) */
.gm-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.gm-label {
  font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  min-width: 0; flex: 1 1 auto; line-height: 1.3;
}
.gm-pct {
  font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--accent);
  flex: 0 0 auto; white-space: nowrap; line-height: 1.3;
}
/* Объект цели — товар или категория — читается как обычный текст, а не капсом */
.gm-obj {
  display: block; margin-top: 2px; text-transform: none; letter-spacing: 0;
  font-size: 12.6px; font-weight: 620; color: var(--text);
}
.gm-pct.done   { color: var(--green); }
.gm-pct.behind { color: var(--amber); }
.gm-nums { font-size: 13px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.gm-nums b { font-size: 16px; font-weight: 660; letter-spacing: -.01em; }
.gm-edit { color: var(--muted); display: inline-flex; align-items: center; }
.gm-edit:hover { color: var(--accent); }
.goal-fill.done   { background: var(--green); }
.goal-fill.behind { background: var(--amber); }

/* ================= Продажи по менеджерам, v2.8 ================= */

.mgr-split { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.mgr-donut { flex: 0 0 auto; display: grid; place-items: center; padding-top: 4px; }
.mgr-table { flex: 1 1 420px; min-width: 0; }

.donut-top { font-size: 15px; font-weight: 700; fill: var(--text); }
.donut-sub { font-size: 8.5px; fill: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.mgr-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 7px; vertical-align: baseline;
}

.share-line { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.share-line .mini-bar { flex: 1 1 auto; min-width: 40px; }
.share-val { font-size: 11.8px; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.share-tag { font-size: 10.5px; color: var(--muted); min-width: 40px; }

/* Полный показатель прошлого месяца отдельной строкой (v2.8) */
.metric-full {
  font-size: 11.8px; color: var(--muted);
  border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 2px;
}
.metric-full b { color: var(--text-2); font-weight: 650; }

@media (max-width: 720px) {
  .mgr-split { gap: 14px; }
  .mgr-donut { width: 100%; }
}

/* ============ Подтверждение доставки (v2.9) ============ */

.deliver-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.deliver-move { display: flex; gap: 6px; align-items: center; }
.deliver-move input[type=date] {
  padding: 5px 8px; font-size: 12.5px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}

/* =========================== Таблицы =========================== */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.2px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data thead th {
  background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; position: sticky; top: 0; z-index: 5;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
/* Товар, который прямо сейчас держит другой заказ (v3.19) */
table.data tbody tr.row-busy { background: var(--amber-soft); }
.busy-note { margin-top: 3px; color: var(--amber); line-height: 1.35; }
.busy-note.busy-tight { color: var(--red); }
/* Фокус на строке виден (v3.19): по таблице теперь ходят с клавиатуры,
   и человек должен видеть, где он стоит */
table.data tbody tr.clickable:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface-2);
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { padding: 10px 12px; font-weight: 650; background: var(--surface-3); border-top: 2px solid var(--border-strong); font-variant-numeric: tabular-nums; }
table.data .th-sort { color: inherit; }
table.data .th-sort:hover { color: var(--accent); text-decoration: none; }
table.data tr.row-total td { font-weight: 650; background: var(--surface-3); }
table.data.compact th, table.data.compact td { padding: 6px 7px; font-size: 12.4px; }
/* Длинные названия переносятся, чтобы широкие таблицы влезали без горизонтальной прокрутки */
/* Первая колонка переносится по словам, но не тогда, когда её явно просили
   не переносить: номера вида «ЗК-00048/26» рвались на три строки (v2.2.1) */
table.data.compact td:first-child:not(.nowrap) { white-space: normal; word-break: break-word; }

/* ------------------------------------------------------------------
   Таблица не должна ехать вбок (v3.19)
   ------------------------------------------------------------------
   Правило «без горизонтальной прокрутки» нарушалось давно и молча: на
   экране 1024 px дебиторка вылезала за край на 184 px, отчёт по клиентам —
   на 672 px. Аудит это записал (UX/PERF), но чинить было нечем: колонок в
   этих таблицах действительно много, и все нужны.

   Лечим тем, что дёшево и ничего не прячет:
   1. на узком экране колонки ужимаются в отступах и кегле, а не режутся;
   2. денежные колонки перестают быть шире, чем нужно цифрам;
   3. текстовые колонки получают потолок ширины и переносятся по словам.

   Скрывать колонки классом .col-optional можно там, где колонка правда
   вторична — но по умолчанию не скрывается ничего: пропавшая цифра хуже
   прокрутки. */
@media (max-width: 1280px) {
  table.data th, table.data td { padding: 8px 8px; }
  table.data.compact th, table.data.compact td { padding: 5px 5px; font-size: 12px; }
}
@media (max-width: 1100px) {
  table.data { font-size: 12.6px; }
  table.data th, table.data td { padding: 7px 6px; }
  table.data.compact th, table.data.compact td { padding: 4px 4px; font-size: 11.6px; }
  table.data thead th { letter-spacing: 0; }
  /* Заголовок в две строки вместо одной длинной: «Ожидаемая оплата»
     держал колонку шире, чем сама дата */
  table.data thead th { white-space: normal; }
  table.data td.col-optional, table.data th.col-optional { display: none; }
}
/* Колонка действий, приклеенная к правому краю (v3.24, UX-041).

   В дебиторке одиннадцать колонок, и на ноутбуке таблица шире окна — она
   прокручивается внутри себя, как и положено по правилу «полоса на таблице,
   а не на странице». Но кнопки работы с долгом при этом уезжали за край, и
   до главного действия приходилось сначала прокрутить.

   Колонка держится у правого края и не уезжает. Фон обязателен: без него
   сквозь неё просвечивают проезжающие цифры. */
table.data th.col-sticky, table.data td.col-sticky {
  position: sticky; right: 0; z-index: 2;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
table.data thead th.col-sticky { background: var(--surface-3); }
table.data tbody tr:nth-child(even) td.col-sticky { background: var(--surface-2); }
table.data tbody tr:hover td.col-sticky { background: var(--accent-soft); }
table.data tfoot td.col-sticky { background: var(--surface-3); }

/* Денежная колонка ровно под цифры: моноширинные цифры дают одинаковую
   ширину знака, поэтому колонку можно не расширять «на всякий случай» */
table.data td.num, table.data th.num { font-variant-numeric: tabular-nums; }
/* Длинному тексту — потолок и перенос, иначе одно название товара
   растягивает всю таблицу */
table.data td.wrap-max { max-width: 260px; white-space: normal; word-break: break-word; }
table.data .col-actions { width: 1%; white-space: nowrap; text-align: right; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }

.pagination { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.pagination .pages a, .pagination .pages span {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm);
  display: inline-grid; place-items: center; font-size: 13px;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface);
}
.pagination .pages a:hover { background: var(--surface-3); text-decoration: none; }
.pagination .pages .cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination .pages .gap { border: 0; background: none; }

/* =========================== Бейджи =========================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11.8px; font-weight: 600; white-space: nowrap; line-height: 1.7;
}
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-blue   { background: var(--accent-soft); color: var(--accent-dark); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-cyan   { background: var(--cyan-soft);   color: var(--cyan); }
.badge-grey   { background: var(--grey-soft);   color: var(--grey); }
.badge-teal   { background: var(--teal-soft);   color: var(--teal); }
.badge-pink   { background: var(--pink-soft);   color: var(--pink); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-green-bright { background: var(--green-bright-soft); color: var(--green-bright); font-weight: 650; }

/* Дерево групп клиентов (v2.2) */
.tree-pad { display: inline-block; }

/* Строка списания, где просят больше, чем лежит на складе (v2.2) */
tr.row-bad > td { background: var(--red-soft); }
tr.row-bad input { border-color: var(--red); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 7px; background: var(--surface-3);
  font-size: 12.2px; color: var(--text-2);
}
.chip a { color: var(--muted); display: grid; place-items: center; }
/* Чип-ссылка: выглядит как обычный чип, но кликается (v2.5) */
a.chip { color: var(--text-2); text-decoration: none; }
a.chip:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }

/* Строка фильтра чипами: «Важность: все / Важно / Обычный …» (v3.16).
   Тот же чип, что и везде, только выбранный залит акцентом */
.chip-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: -4px 0 14px; }
.chip-filters .chip-label { color: var(--muted); font-size: 12.5px; }
a.chip.on, a.chip.on:hover { background: var(--accent); color: #fff; }
a.chip .count { font-size: 11.5px; opacity: .72; }

/* =========================== Формы =========================== */

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-full { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 570; color: var(--text-2); }
label .req { color: var(--red); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=file],
select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); }
input[readonly] { background: var(--surface-3); }
textarea { min-height: 76px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8694' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 15px; padding-right: 28px; }
input.num, td input.num { text-align: right; font-variant-numeric: tabular-nums; }
.field .hint { font-size: 11.5px; color: var(--muted); }
/* Подсказка отдельной строкой: под полем она распирает соседей по сетке (v2.6) */
.field.hint-row { margin-top: -6px; }
.field .err  { font-size: 11.8px; color: var(--red); }
.field.has-error input, .field.has-error select { border-color: var(--red); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text); }
.check input[type=checkbox], .check input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.input-group { display: flex; }
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.suffix-pct { position: relative; }
.suffix-pct::after { content: '%'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12.5px; }
.suffix-pct input { padding-right: 24px; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
legend { font-size: 12.5px; font-weight: 650; color: var(--text-2); padding: 0 6px; }

/* =========================== Фильтры =========================== */

.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px; box-shadow: var(--shadow-1);
}
/* Поля выравниваются по верху: у части полей снизу подсказка, и при
   выравнивании по низу соседний список уезжал вниз (v3.4.5) */
.filters form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
/* Кнопки без подписи — поднимаем на высоту подписи, чтобы стояли в линию с полями */
.filters .actions { margin-top: 23px; }
.filters .field { flex: 0 1 168px; }
.filters .field.wide { flex: 1 1 240px; }
/* Поле на всю ширину отдельной строкой: поиск в заказах (v2.5) */
.filters .field.full { flex: 1 0 100%; }
/* Диапазон дат одним блоком: «с» и «по» никогда не разъезжаются (v2.5) */
.filters .field.range { flex: 0 1 250px; }
.filters .field.range .range-row { display: flex; align-items: center; gap: 6px; }
.filters .field.range input { min-width: 0; flex: 1 1 auto; }
.filters .field.range .range-sep { color: var(--muted); flex: 0 0 auto; }
.filters .actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.quick-periods { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-periods a {
  padding: 4px 10px; border-radius: 20px; font-size: 12.3px;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface);
}
.quick-periods a:hover { background: var(--surface-3); text-decoration: none; }
.quick-periods a.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* =========================== Вкладки =========================== */

/* Вкладки переносятся на вторую строку, а не уезжают в горизонтальную прокрутку */
.tabs { display: flex; flex-wrap: wrap; gap: 2px 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a {
  padding: 9px 13px; font-size: 13.5px; font-weight: 550; color: var(--text-2);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
@media (max-width: 560px) {
  .tabs a { padding: 8px 10px; font-size: 13px; }
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; color: var(--muted); margin-left: 4px; }

/* =========================== Уведомления =========================== */

.flash-area { position: fixed; top: 66px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.flash {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-2); font-size: 13.3px;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.flash.success { border-left: 3px solid var(--green); }
.flash.error   { border-left: 3px solid var(--red); }
.flash.warning { border-left: 3px solid var(--amber); }
.flash.info    { border-left: 3px solid var(--accent); }
.flash .close { margin-left: auto; cursor: pointer; color: var(--muted); background: none; border: 0; }

.alert { padding: 11px 13px; border-radius: var(--radius); font-size: 13.3px; margin-bottom: 14px;
         display: flex; gap: 9px; align-items: flex-start; flex-wrap: wrap; min-width: 0; }
/* Полоски-подсказки переносятся по словам (v3.21, AUD4-006).
   Без flex-wrap строка «Задолженность: … · лимит: … · доступно к отгрузке: …»
   вытягивала страницу на телефоне до 507 точек при экране 390: вбок ездила
   вся страница, а не таблица внутри неё. */
.alert > * { min-width: 0; }
.alert-info { background: var(--accent-soft); color: #1e40af; }
.alert-warn { background: var(--amber-soft); color: #92400e; }
.alert-error{ background: var(--red-soft);  color: #991b1b; }
.alert-good { background: var(--green-soft); color: #065f46; }

/* =========================== Модальные окна =========================== */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 21, 28, .42);
  display: none; align-items: center; justify-content: center; z-index: 150; padding: 12px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); width: 100%; max-width: 560px;
  /* Окно занимает почти всю высоту экрана: чем оно выше, тем реже внутри
     появляется собственная прокрутка (v3.5.6) */
  max-height: calc(100vh - 24px); display: flex; flex-direction: column; animation: pop .16s ease;
}
.modal.wide { max-width: 900px; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

/* Почти во всех окнах между `.modal` и его частями стоит <form>. Без этих
   трёх строк форма не подчиняется колоночному flex окна: `max-height: 90vh`
   ни на что не влияет, тело не прокручивается, и кнопки «Отмена/Сохранить»
   уезжают за нижний край экрана — прокручивается страница позади (v3.5.6) */
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.modal-head, .modal-foot { flex: 0 0 auto; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Пока окно открыто, страница под ним не прокручивается: иначе колесо
   листает фон, а не содержимое окна */
html.modal-open, body.modal-open { overflow: hidden; }
/* Место под полосу прокрутки резервируем всегда — иначе при открытии окна
   страница дёргается на ширину полосы */
html { scrollbar-gutter: stable; }

/* ===== Полоска состояния банка на финансовых страницах (v3.2.3) ===== */

.bank-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 13px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); font-size: 12.8px; color: var(--text-2);
}
.bank-strip.bad { border-color: var(--red); background: var(--red-soft, #fff1f0); }
.bs-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.bank-strip.bad .bs-dot { background: var(--red); }
.bs-main { min-width: 0; }
.bs-next { font-size: 12px; }
.bs-link { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ============ Три линии на одной картинке (v3.1) ============
   Деньги, штуки и клиенты — разные единицы и разные порядки величин.
   Каждая линия масштабируется на свой максимум: сравнивается форма —
   где растём, где просели, где деньги вверх, а клиентов всё меньше. */

.tl { display: flex; flex-direction: column; gap: 10px; }
.tl-legend { display: flex; gap: 18px; flex-wrap: wrap; }
.tl-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.6px; }
.tl-item i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tl-item b { font-weight: 600; }
.tl-plot { position: relative; }
.tl-plot svg { display: block; width: 100%; height: 240px; overflow: visible; }
.tl-grid { stroke: var(--border); stroke-width: 1; opacity: .6; vector-effect: non-scaling-stroke; }
.tl-guide { stroke: var(--text); stroke-width: 1; opacity: .28; vector-effect: non-scaling-stroke; }
.tl-dot { opacity: 0; transition: opacity .1s; }
.tl-dot.on { opacity: 1; }
.tl-hit { cursor: crosshair; }
.tl-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.tl-axis span { flex: 1 1 0; text-align: center; min-width: 0; }
.tl-axis span:first-child { text-align: left; }
.tl-axis span:last-child { text-align: right; }

/* Плитка-кнопка: открывает окно с детализацией, а выглядит как плитка */
button.kpi { text-align: left; cursor: pointer; font: inherit; }
button.kpi:hover { border-color: var(--border-strong); }

/* =========================== Графики =========================== */

.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.chart-bars .bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart-bars .bar {
  width: 100%; max-width: 46px; background: linear-gradient(180deg, #4f83f1, var(--accent));
  border-radius: 5px 5px 0 0; min-height: 2px; position: relative; transition: opacity .12s;
}
.chart-bars .bar:hover { opacity: .82; }
.chart-bars .bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chart-bars .bar-value { font-size: 11px; color: var(--text-2); font-weight: 600; }
.chart-bars .bar-qty { font-size: 10px; white-space: nowrap; }

.hbar { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.hbar .hbar-name { width: 190px; flex: 0 0 auto; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hbar-track { flex: 1 1 auto; height: 20px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbar .hbar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.hbar .hbar-val { width: 110px; flex: 0 0 auto; text-align: right; font-size: 12.6px; font-variant-numeric: tabular-nums; font-weight: 600; }

.progress { height: 7px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.progress > div, .progress > span { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.progress.good > div { background: var(--green); }
.progress.warn > div { background: var(--amber); }
.progress.bad  > div { background: var(--red); }

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 30px; }
.sparkline i { flex: 1; background: var(--accent-soft); border-radius: 2px 2px 0 0; min-height: 2px; }

/* =========================== Прочее =========================== */

.def-list { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: 13.3px; align-items: baseline; }
.def-list dt { color: var(--muted); }
.def-list dd { margin: 0; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline .tl-item { position: relative; padding-bottom: 14px; }
.timeline .tl-item::before { content: ''; position: absolute; left: -19px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline .tl-time { font-size: 11.8px; color: var(--muted); }

.thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); }
.thumb-ph { display: grid; place-items: center; color: var(--muted); }
.thumb-lg { width: 120px; height: 120px; }
.thumb-zoom { display: inline-block; cursor: zoom-in; position: relative; }
.thumb-zoom:hover img { border-color: var(--accent); }

/* Просмотр изображения в полном размере */
.lightbox {
  position: fixed; inset: 0; z-index: 300; display: none;
  background: rgba(15, 20, 28, .82); padding: 32px;
  align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 18px 48px rgba(0,0,0,.5); background: #fff; }
.lightbox .lb-close {
  position: absolute; top: 16px; right: 20px; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 22px; cursor: pointer;
}
.lightbox .lb-close:hover { background: rgba(255,255,255,.3); }

.stat-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13.3px; }
.stat-line:last-child { border-bottom: 0; }
/* Значение записи журнала целиком (v3.18): длинный текст переносится,
   но остаётся выделяемым — его копируют, чтобы восстановить удалённое */
.audit-val { margin: 4px 0 0; padding: 8px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; }
.stat-line .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1 1 auto; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.link-muted { color: var(--muted); }
.link-muted:hover { color: var(--accent); }

.mobile-only { display: none; }
.desktop-only { display: initial; }

/* Нижнее меню на мобильных (§127) */
.mobile-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 58px;
  background: var(--surface); border-top: 1px solid var(--border);
  display: none; z-index: 90; padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bar a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 10.5px; font-weight: 550;
}
.mobile-bar a.active { color: var(--accent); }
.mobile-bar a:hover { text-decoration: none; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(16,21,28,.4); z-index: 100; display: none; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; z-index: 110;
  transform: translateY(100%); transition: transform .2s ease; padding-bottom: 20px;
}
.sheet.open { transform: none; }
.sheet-handle { width: 38px; height: 4px; border-radius: 3px; background: var(--border-strong); margin: 9px auto; }

/* Мобильная сборка заказа (§56) */
.pick-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.pick-card.done { background: var(--green-soft); border-color: #bfe6d3; }
.pick-card .pc-head { display: flex; gap: 10px; align-items: flex-start; }
.pick-card .pc-qty { font-size: 19px; font-weight: 650; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Табличные блоки не должны растягивать сетку шире экрана */
.grid > * { min-width: 0; }
.card { min-width: 0; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-3); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(16,21,28,.4); z-index: 35; }
  .content { padding: 14px 12px 84px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .card, .kpi, .table-wrap { min-width: 0; }
  /* На телефоне ряды кнопок и подсказок переносятся, а не растягивают страницу
     (v3.21, AUD4-006). Проверено на шести экранах, где полоса появлялась:
     правка заказа, копия заказа, приход, аналитика по единицам, настройки,
     создание набора. */
  .flex, .flex-between, .card-foot, .card-head, .filters, .btn-group { flex-wrap: wrap; }
  .btn, .btn-sm { max-width: 100%; }
  .card-body > table, .card-body > form > table { display: block; overflow-x: auto; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .mobile-bar { display: flex; }
  .mobile-only { display: initial; }
  .desktop-only { display: none !important; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .kpi-value { font-size: 18px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .user-chip { padding: 4px; }
  .page-head h1 { font-size: 18px; }
  .flash-area { left: 12px; right: 12px; max-width: none; top: 62px; }
  .hbar .hbar-name { width: 110px; }
  .hbar .hbar-val { width: 84px; font-size: 11.5px; }
  table.data th, table.data td { padding: 8px 9px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* =========================== Печать =========================== */

@media print {
  .sidebar, .topbar, .mobile-bar, .page-actions, .filters, .pagination, .flash-area, .no-print { display: none !important; }
  body, html { background: #fff; font-size: 11pt; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; margin: 0; }
  .card-body { padding: 0; }
  a { color: #000; text-decoration: none; }
  table.data th, table.data td { border: 1px solid #999; padding: 4px 6px; }
  table.data thead th { background: #eee !important; -webkit-print-color-adjust: exact; }
  /* Бланк печатается строго на портретный A4: без явного size браузер
     берёт последнюю настройку принтера, и накладная уезжала «поперёк» (v2.2.1) */
  @page { size: A4 portrait; margin: 12mm 10mm; }
  .print-doc {
    max-width: none; width: auto;
    padding: 0; margin: 0; box-shadow: none; border-radius: 0;
  }
  .doc-form { width: 100%; }
}

/* Печатная форма документа */
/* Ширина листа — как у полосы набора A4 (210 мм минус поля), чтобы
   на экране было видно ровно то, что уйдёт на бумагу (v2.2.1) */
.print-doc {
  background: #fff; padding: 12mm 10mm; width: 190mm; max-width: 100%;
  margin: 0 auto; font-size: 13px; box-shadow: var(--shadow-1); border-radius: 2px;
}
.print-doc h1 { font-size: 17px; text-align: center; margin-bottom: 4px; }
.print-doc .doc-sub { text-align: center; color: var(--text-2); margin-bottom: 18px; }
.print-doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 16px; }
.print-doc .party-title { font-size: 11.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; margin-bottom: 4px; }
.print-doc table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-doc table th, .print-doc table td { border: 1px solid #b8c0ca; padding: 5px 7px; }
.print-doc table th { background: #f1f3f6; font-weight: 600; text-align: center; }
.print-doc .sign-row { display: flex; justify-content: space-between; margin-top: 34px; gap: 30px; }
.print-doc .sign-box { flex: 1; }
.print-doc .sign-line { border-bottom: 1px solid #333; height: 26px; margin-bottom: 4px; }

/* Бланк по украинскому образцу: шапка «Постачальник / Одержувач / …» */
/* ==================================================================
   Печатные формы: счёт-фактура и расходная накладная.
   Свёрстано по образцам заказчика (см. docs/): шапка БЕЗ рамок,
   товарная таблица С рамками, шрифт с засечками.
   Меняя тут что-либо, сверяйтесь с образцами — эти документы
   уходят клиентам и в бухгалтерию.
   ================================================================== */
.doc-form { font-family: "Times New Roman", Times, serif; color: #000; font-size: 12.5px; line-height: 1.28; }
.doc-form table { width: 100%; border-collapse: collapse; }

/* --- Шапка: ни одной рамки, подписи слева жирные с подчёркиванием --- */
.doc-form .hdr { margin-bottom: 8px; border: none; }
.doc-form .hdr td { border: none; padding: 0 0 1px; vertical-align: top; }
.doc-form .hdr td.lbl { width: 148px; font-weight: 700; text-decoration: underline; white-space: nowrap; padding-right: 12px; }
.doc-form .hdr tr.spacer td { height: 11px; padding: 0; }
.doc-form .hdr .supplier { font-weight: 700; }
.doc-form .hdr.loose td { padding-bottom: 6px; }

/* --- Заголовок документа --- */
.doc-form .doc-title { text-align: center; font-weight: 700; font-size: 15px; margin: 10px 0 7px; }
.doc-form .doc-title.sm { font-size: 12.5px; margin: 18px 0 2px; }
.doc-form .doc-date { text-align: center; font-weight: 700; font-size: 12.5px; margin: 0 0 10px; }

/* --- Таблица товаров: рамки как в образце --- */
.doc-form .goods { border: none; }   /* рамку рисуют сами ячейки — как в образце */
.doc-form .goods th, .doc-form .goods td { border: 1px solid #000; padding: 2px 5px; font-size: 12px; }
.doc-form .goods th { font-weight: 700; text-align: center; background: none; }
.doc-form .goods td.n { text-align: right; }
.doc-form .goods td.c { text-align: center; }
.doc-form .goods tr.sum td { border: none; padding-top: 2px; }
.doc-form .goods tr.sum td.k { text-align: right; font-weight: 700; padding-right: 9px; }
.doc-form .goods tr.sum td.v { border: 1px solid #000; text-align: right; font-weight: 700; }

/* --- Итоги прописью --- */
.doc-form .after { margin-top: 7px; line-height: 1.35; }
.doc-form .after b { font-weight: 700; }

/* --- Подписи --- */
.doc-form .place { margin: 22px 0 0 88px; }
.doc-form .signs, .doc-form .signs tr, .doc-form .signs td { border: none !important; }
.doc-form .signs { margin-top: 26px; }
.doc-form .signs td { padding: 0; vertical-align: top; font-size: 12.5px; }
.doc-form .sig-line { display: inline-block; min-width: 168px; border-bottom: 1px solid #000; height: 13px; }
.doc-form .sig-left { padding-left: 88px; }
.doc-form .sig-name { text-align: center; margin-top: 16px; padding-left: 118px; padding-right: 34px; white-space: nowrap; }
.doc-form .sig-sub { margin-top: 5px; padding-left: 108px; }
.doc-form .star { vertical-align: super; font-size: 9px; }
.doc-form .sign-invoice { margin-top: 66px; text-align: right; padding-right: 96px; font-size: 12.5px; }
.doc-form .note { font-size: 10px; margin-top: 20px; }
@media print { .doc-form { font-size: 12px; } .doc-form .goods th, .doc-form .goods td { font-size: 11.5px; } }

/* Наценка в прайс-листе — выделенная колонка, её смотрят чаще остальных (v1.8) */
table.data th.markup-col,
table.data td.markup-col {
  font-weight: 700;
  background: var(--surface-3);
  border-left: 2px solid var(--border-strong);
}
table.data td.markup-col.pos { color: var(--green, #1a7f37); }
table.data td.markup-col.neg { color: var(--red, #c0392b); }

/* Карточка товара: основные поля слева, фото справа (v1.9) */
.form-split { display: flex; gap: 22px; align-items: flex-start; }
.form-split-main { flex: 1 1 auto; min-width: 0; }
.form-split-aside { flex: 0 0 220px; }
.form-split-aside > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.photo-box {
  width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.photo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-ph { text-align: center; color: var(--muted); }
@media (max-width: 900px) {
  .form-split { flex-direction: column; }
  .form-split-aside { flex: 1 1 auto; width: 100%; }
  .photo-box { width: 100%; max-width: 260px; }
}
.warn-text { color: var(--amber, #b26a00); }

/* Полоска настроек раздела (справочники товара) — v1.9 */
.subnav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: -6px 0 16px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.subnav-label { font-size: 12.5px; color: var(--muted); margin-right: 4px; }
.subnav a {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px; font-size: 13px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
}
.subnav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Выпадающий список с поиском (v1.9) */
.combo { position: relative; }
.combo .combo-native { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.combo-input { width: 100%; }
.combo-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: 100%; margin-top: 3px;
  max-height: 280px; overflow-y: auto;
  /* Поле фильтра узкое, а названия клиентов длинные: разрешаем списку быть
     шире поля, иначе каждый пункт переносится на две строки (v2.6) */
  min-width: 260px; width: max-content; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; box-shadow: 0 10px 26px rgba(0,0,0,.14);
}
.combo-item { padding: 7px 11px; font-size: 13.2px; cursor: pointer; }
.combo-item:hover, .combo-item.on { background: var(--surface-2); }
.combo-item.sel { font-weight: 650; }
.combo-empty { padding: 11px; font-size: 13px; color: var(--muted); }

/* Мультивыбор с галочками (v2.5) */
.combo-check { display: flex; align-items: center; gap: 9px; margin: 0; }
.combo-check input { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; }
.combo-check span { flex: 1 1 auto; min-width: 0; }
.combo-clear {
  border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px;
}
.combo-clear:hover { color: var(--red); }

/* Промежуточный итог внутри отчёта: жирнее строк, но не как ИТОГО (v3.16) */
table.data tr.sub-total td { font-weight: 650; border-top: 1px solid var(--border-strong); }

/* Разделитель-подзаголовок внутри таблицы: «Покупали / Не покупали» (v3.16) */
table.data tr.row-group td {
  background: var(--surface-3); color: var(--text-2);
  font-size: 11.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  padding: 5px 9px;
}
table.data tr.row-group:hover td { background: var(--surface-3); }

/* Заголовок раздела в мультивыборе: нажатие отмечает весь раздел (v3.16) */
.combo-group {
  position: sticky; top: 0; z-index: 1;
  padding: 6px 11px 5px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 11.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  cursor: pointer; user-select: none;
}
.combo-group:hover { background: var(--accent-soft); color: var(--accent-dark); }

/* Многолинейный SVG-график аналитики (v1.9) */
.chart-multi { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; font-size: 12.8px; }
.cl-item { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.cl-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cl-item small { font-size: 11px; }
.cg-line { stroke: var(--border); stroke-width: 1; }
.cg-axis { stroke: var(--border-strong); stroke-width: 1.2; }
.cg-tick { font-size: 11px; fill: var(--muted); }
.cg-xlab { font-size: 11px; fill: var(--muted); }

/* Вкладки настроек (v3.24, UX-035).
   Прячем только когда скрипт пометил форму: без него все разделы видны
   сразу, и страница остаётся такой, какой была. */
form.paned .settings-pane { display: none; }
form.paned .settings-pane.on { display: block; }

/* Подсказка на графиках аналитики (v3.23) */
.chart-multi, .chart-pie { position: relative; }
.cg-hair { stroke: var(--text); stroke-width: 1; opacity: .28; vector-effect: non-scaling-stroke; }
.cg-hit { cursor: crosshair; }
.cg-tip {
  position: absolute; z-index: 30; pointer-events: none;
  min-width: 180px; max-width: 320px; padding: 9px 11px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .16);
  font-size: 12.5px; line-height: 1.5;
  opacity: 0; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease;
}
.cg-tip.on { opacity: 1; transform: none; }
.cg-tip .mt-name {
  display: flex; align-items: center; gap: 7px;
  color: var(--text); font-weight: 650; margin-bottom: 5px;
}
.cg-tip .mt-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.cg-tip .mt-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.cg-tip .mt-row span { display: inline-flex; align-items: center; gap: 7px; }
.cg-tip .mt-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Круговая диаграмма долей */
.chart-pie { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.chart-pie svg { width: 230px; height: 230px; flex: none; }
.pie-slice { cursor: pointer; transition: opacity .12s ease; transform-origin: 50% 50%; }
.chart-pie:hover .pie-slice { opacity: .45; }
.chart-pie .pie-slice.on { opacity: 1; }
.pie-legend { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 240px; max-width: 420px; font-size: 13px; }
.pie-legend .pl-item { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pie-legend .pl-item i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.pie-legend .pl-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-legend .pl-val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) { .chart-pie svg { width: 190px; height: 190px; } }
@media (prefers-reduced-motion: reduce) { .cg-tip, .pie-slice { transition: none; } }

/* Мини-график в строке таблицы */
.spark { display: block; width: 110px; height: 26px; }
.spark path { fill: none; stroke-width: 1.8; }

.is-invalid { border-color: var(--red) !important; background: rgba(200,0,0,.05); }

/* Водопад «из чего сложилась прибыль» (v1.9) */
.waterfall { display: flex; flex-direction: column; gap: 7px; }
.wf-row { display: grid; grid-template-columns: 190px 1fr 130px 68px; gap: 12px; align-items: center; }
.wf-name { font-size: 13px; color: var(--text); }
.wf-bar { height: 20px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.wf-fill { height: 100%; border-radius: 4px; }
.wf-blue { background: #2563eb; } .wf-red { background: #dc2626; }
.wf-green { background: #16a34a; } .wf-amber { background: #f59e0b; }
.wf-violet { background: #7c3aed; }
.wf-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px; }
.wf-pct { text-align: right; font-size: 12px; }
@media (max-width: 760px) {
  .wf-row { grid-template-columns: 120px 1fr 96px; }
  .wf-pct { display: none; }
}
.reserved-link { font-weight: 650; color: var(--amber, #b26a00); border-bottom: 1px dashed currentColor; }
.reserved-link:hover { text-decoration: none; opacity: .8; }

/* Подпись второй строкой в заголовке столбца (v2.1) */
table.data th .th-sub {
  display: block; font-weight: 500; text-transform: none;
  letter-spacing: 0; opacity: .65; font-size: 10.5px;
}

/* ================= Блок «Обрати внимание» на главной (v2.1) ================= */
/* flex:0 — иначе заголовок распирает шапку и счётчик прижимается вплотную
   к подписи «обновлено», превращаясь в одну кашу (v2.6) */
.attention .card-head h2 { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
/* Подпись «обновлено N минут назад» + ручной пересчёт (v2.6) */
.att-fresh { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.att-fresh .att-refresh {
  display: grid; place-items: center; width: 22px; height: 22px;
  padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--muted); transition: .14s;
}
.att-fresh .att-refresh:hover { background: var(--surface-2); color: var(--text); }
.att-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.att {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); transition: .14s;
}
.att:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); }
.att-ic { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.att-body { flex: 1; min-width: 0; }
.att-title { font-weight: 650; font-size: 13.4px; margin-bottom: 3px; }
.att-text { font-size: 12.4px; color: var(--text-2); line-height: 1.45; }
.att-go { flex: none; color: var(--muted); opacity: .5; margin-top: 4px; }
.att:hover .att-go { opacity: 1; }
.att-bad  { border-color: rgba(200,60,50,.32); background: rgba(200,60,50,.06); }
.att-bad .att-ic  { background: rgba(200,60,50,.14); color: var(--red); }
.att-warn { border-color: rgba(200,150,20,.34); background: rgba(200,150,20,.07); }
.att-warn .att-ic { background: rgba(200,150,20,.16); color: #a8760a; }
.att-info .att-ic { background: var(--surface-3); color: var(--text-2); }
@media (max-width: 900px) { .att-grid { grid-template-columns: 1fr; } }

/* Постановка целей: показатель раскрывается только когда отмечен (v2.9.1) */
/* Выбор в строку: две-четыре короткие опции, которым не нужен целый ряд (v3.2) */
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-row .check {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); cursor: pointer;
}
.choice-row .check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.choice-list { display: grid; gap: 9px; }
.choice-list .check { align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.choice-list .check input { margin-top: 2px; }
.metric-box {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 10px; background: var(--surface-2); transition: .14s;
}
.metric-box:last-child { margin-bottom: 0; }
.metric-box > .check { align-items: flex-start; }
.metric-box > .check input { margin-top: 2px; }
.metric-box.on { border-color: var(--accent); background: var(--accent-soft); }
.metric-body { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.metric-box.on .metric-body { background: var(--surface); padding: 12px 12px 4px; border-radius: 8px; border-top: 0; }

/* Подсказка на кольце «Продажи по менеджерам» (v3.0.1) */
.mgr-seg { transition: opacity .12s, stroke-width .12s; pointer-events: none; }
.mgr-hit { cursor: pointer; }
.mgr-donut:has(.mgr-hit:hover) .mgr-seg { opacity: .5; }
.mgr-seg.hot, .mgr-donut:has(.mgr-hit:hover) .mgr-seg.hot { opacity: 1; stroke-width: 21; }
.mgr-row.hot > td { background: var(--surface-3); }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none;
  min-width: 216px; max-width: 280px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(16,22,29,.16);
  font-size: 12.8px; color: var(--text-2);
  opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
}
.chart-tip.on { opacity: 1; transform: none; }
.chart-tip .mt-name {
  display: flex; align-items: center; gap: 7px;
  font-weight: 650; font-size: 13.4px; color: var(--text);
  padding-bottom: 7px; margin-bottom: 7px; border-bottom: 1px solid var(--border);
}
.chart-tip .mt-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chart-tip .mt-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.chart-tip .mt-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .chart-tip, .mgr-seg { transition: none; }
}

/* Контактные лица клиента: строка-визитка в общем стиле карточек (v3.0.4) */
.person-list { display: flex; flex-direction: column; }
.person {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.person:first-child { padding-top: 3px; }
.person:last-child { border-bottom: 0; padding-bottom: 3px; }
.person > .avatar { margin-top: 1px; }
.person-body { flex: 1; min-width: 0; }
.person-name {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  font-weight: 640; font-size: 14.2px; line-height: 1.3;
}
.person-role { font-size: 12.4px; color: var(--muted); margin-top: 2px; }
.person-lines { display: flex; flex-direction: column; gap: 1px; margin-top: 5px; font-size: 13.2px; }
.person-lines a { word-break: break-word; }
.person-actions { display: flex; gap: 1px; flex: none; opacity: 0; transition: opacity .12s; }
.person:hover .person-actions, .person:focus-within .person-actions { opacity: 1; }
.person-actions form { display: inline-flex; }
@media (hover: none) { .person-actions { opacity: 1; } }

/* Динамика продаж по месяцам: две дорожки с общей осью месяцев (v3.0.1) */
.ms-chart { display: flex; flex-direction: column; gap: 14px; --ms-gap: 4px; }
.ms-facet { display: flex; flex-direction: column; gap: 7px; }
.ms-facet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ms-title { display: inline-flex; align-items: center; gap: 7px; font-size: 12.8px; font-weight: 600; color: var(--text-2); }
.ms-key { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.ms-key.money { background: var(--accent); }
.ms-key.qty { background: var(--green); }
.ms-key.profit { background: var(--violet, #6d3ae0); }
.ms-max { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ms-plot { position: relative; height: 190px; }
.ms-plot.short { height: 84px; }
.ms-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.ms-grid i { display: block; height: 1px; background: var(--border); opacity: .55; }
.ms-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: var(--ms-gap); }
.ms-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; }
.ms-bar {
  /* Ширину ограничиваем: за три месяца столбец в четверть экрана перестаёт
     читаться как график и выглядит заливкой (v3.0.1) */
  width: 100%; max-width: 54px; border-radius: 4px 4px 0 0;
  transition: opacity .12s, filter .12s;
}
.ms-bar.money { background: var(--accent); }
.ms-bar.qty { background: var(--green); }
.ms-bar.profit { background: var(--violet, #6d3ae0); }
.ms-chart:hover .ms-bar { opacity: .5; }
.ms-col.hot .ms-bar, .ms-chart:hover .ms-col.hot .ms-bar { opacity: 1; }

.ms-axis { display: flex; gap: var(--ms-gap); }
.ms-tick {
  flex: 1 1 0; min-width: 0; text-align: center; cursor: pointer;
  font-size: 11px; color: var(--muted); padding: 3px 0; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-tick.hot { background: var(--surface-3); color: var(--text); font-weight: 600; }
@media (max-width: 720px) {
  .ms-plot { height: 132px; }
  .ms-tick { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .ms-bar { transition: none; } }

/* Значение, которое нельзя менять: номер документа выдаёт система (v3.0.3) */
.static-value {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 14px;
}

/* Контакты: иконка перед номером и почтой, чтобы строки читались с одного
   взгляда, а не сливались в две одинаковые синие ссылки (v3.1) */
/* Контакты человека: иконка — часть строки, а не ссылки; телефон просто
   текст, кликается только почта. Синий цвет ссылок в карточке смотрелся
   дёшево и спорил с остальным текстом (v3.4) */
.person-lines { gap: 4px; }
.pl-row {
  display: grid; grid-template-columns: 16px 1fr; align-items: center;
  gap: 9px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.pl-row svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.pl-val { min-width: 0; word-break: break-word; }
.pl-mail {
  color: var(--text-2); text-decoration: none; min-width: 0; word-break: break-word;
  /* Подчёркивание по тексту, а не по всей ячейке — иначе линия тянется в пустоту */
  justify-self: start; border-bottom: 1px solid var(--border-strong);
}
.pl-mail:hover { color: var(--accent-dark); border-bottom-color: var(--accent); }

/* Контактные лица: список слева, карточка выбранного справа (v3.4.1).
   Сплошной колонкой пять человек занимали пол-экрана и читались тяжело. */
/* Карточке контактов нужно больше места, чем соседним спискам «подпись —
   значение»: внутри неё две колонки (v3.4.1) */
.ov-top { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .ov-top { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .ov-top { grid-template-columns: minmax(0, 1fr); } }

/* Карточка контактов растягивается на всю высоту ряда, а серая колонка —
   на всю высоту карточки: раньше она обрывалась по своему содержимому
   и была сдвинута от края (v3.4.2) */
.card-pp { display: flex; flex-direction: column; }
.card-pp > .card-body { flex: 1; display: flex; padding: 0; }
.pp {
  display: grid; grid-template-columns: minmax(0, 186px) minmax(0, 1fr);
  min-height: 214px; width: 100%; margin: 0;
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.pp-list {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px; background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.pp-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; text-align: left; cursor: pointer;
  font: inherit; color: var(--text); transition: background .12s, color .12s;
}
.pp-item:hover { background: var(--surface-3); }
.pp-item.is-active { background: var(--accent-soft); color: var(--accent-dark); }
.pp-item-name { font-weight: 600; font-size: 13.2px; line-height: 1.25; }
.pp-item-role { font-size: 12.2px; color: var(--muted); line-height: 1.25; }
.pp-item.is-active .pp-item-role { color: var(--accent-dark); opacity: .78; }

.pp-panes { padding: 16px; min-width: 0; }
.pp-head { display: flex; align-items: flex-start; gap: 12px; }
.pp-title { flex: 1; min-width: 0; }
.pp-name {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 650; font-size: 15.4px; color: var(--text);
}
.pp-role { font-size: 12.8px; color: var(--muted); margin-top: 2px; }
.pp-actions { display: flex; gap: 1px; flex: none; opacity: 0; transition: opacity .12s; }
.pp-actions form { display: inline-flex; }
.pp-pane:hover .pp-actions, .pp-pane:focus-within .pp-actions { opacity: 1; }
@media (hover: none) { .pp-actions { opacity: 1; } }

.pp-facts {
  display: grid; grid-template-columns: 88px minmax(0, 1fr);
  gap: 9px 16px; margin: 18px 0 0; align-items: baseline;
}
.pp-facts dt { color: var(--muted); font-size: 12.8px; }
.pp-facts dd {
  margin: 0; min-width: 0; font-weight: 600; color: var(--text);
  word-break: break-word; font-variant-numeric: tabular-nums;
}
.pp-facts dd.pp-note { font-weight: 400; color: var(--text-2); }
/* Почта кликабельна, но цветом не выделяется: при наведении курсор-палец
   и тонкая серая линия — синего текста в карточке быть не должно (v3.4.2) */
.pp-mail {
  color: var(--text); text-decoration: none;
  border-bottom: 1px solid transparent; cursor: pointer;
}
.pp-mail:hover, .pp-mail:focus-visible {
  color: var(--text); border-bottom-color: var(--border-strong);
}



@media (max-width: 720px) {
  .pp { grid-template-columns: 1fr; }
  .pp-list {
    flex-direction: row; overflow-x: auto; border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .pp-item { width: auto; flex: none; }
}

/* Журнал генерации демо-данных (v3.1) */
.dg-log {
  margin-top: 14px; max-height: 190px; overflow-y: auto;
  font-size: 12.6px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px;
}
.dg-log:empty { display: none; }
.dg-log div { padding: 2px 0; border-bottom: 1px dashed var(--border); }
.dg-log div:last-child { border-bottom: 0; }

/* ================= Проверка базы (v3.6) ================= */
.diag-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.diag-item:last-child { border-bottom: 0; padding-bottom: 0; }
.diag-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.diag-explain { color: var(--text-2); font-size: 13px; margin-top: 6px; max-width: 78ch; }
.diag-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; }
.diag-list li { margin-bottom: 3px; }
.diag-fix {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.diag-fix-head { display: flex; align-items: center; gap: 8px; }
.diag-plan { margin: 8px 0 10px; padding-left: 18px; font-size: 13px; }
.diag-plan li { margin-bottom: 3px; }
.diag-proof {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; max-width: 82ch;
}
.diag-blocked {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 10px;
  font-size: 12.5px; color: var(--text-2); max-width: 82ch;
}

/* ============ Заметки и планы (v3.7) ============ */
.note-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: 0; padding-bottom: 0; }
.note-item.done .note-main { opacity: .62; }
.note-item.done .note-head b { text-decoration: line-through; }
.note-main { flex: 1 1 auto; min-width: 0; }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-body { color: var(--text-2); font-size: 13px; margin-top: 6px; max-width: 84ch; }
.note-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.note-actions form { display: inline-flex; }

/* Инструкция по восстановлению */
ol.steps { margin: 0; padding-left: 20px; }
ol.steps li { margin-bottom: 12px; line-height: 1.55; max-width: 88ch; }
.qa { margin-bottom: 14px; max-width: 88ch; }
.qa > div { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* Список участников цели (v3.8) */
.participants { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }


/* ---------- Ход выполнения долгих операций (v3.20, UX-039) ----------
 *
 * Импорт выписки, резервная копия и выгрузка в Excel занимают секунды, а
 * иногда и минуты. Всё это время страница выглядела так же, как до нажатия:
 * человек не понимал, началось ли что-нибудь, и нажимал второй раз.
 *
 * Кнопку мы блокировали и раньше — от повторной отправки это спасало, но
 * не отвечало на вопрос «а оно вообще работает». Теперь кнопка честно
 * говорит, что занята, а на долгих операциях поверх страницы появляется
 * полоса с объяснением, что происходит и сколько это примерно займёт.
 */
.btn[data-busy-label] .busy-dot,
.btn.is-busy .busy-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  display: inline-block; animation: busy-spin .7s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }

.busy-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(2px);
}
.busy-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3);
  padding: 22px 26px; max-width: 420px; text-align: center;
}
.busy-card .busy-dot {
  width: 26px; height: 26px; border-width: 3px; color: var(--accent);
  border: 3px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; display: inline-block; animation: busy-spin .7s linear infinite;
}
.busy-title { font-weight: 600; margin-top: 12px; }
.busy-note { color: var(--text-2); font-size: 13px; margin-top: 6px; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) {
  .busy-dot { animation-duration: 2s; }
}


/* Опасное действие в строке сборки (v3.20, UX-046): отделено отступом и
   тонкой чертой от обычных кнопок, чтобы промах по привычке в него не попал */
.pick-stack .pick-danger {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border);
  border-radius: 0;
  color: var(--red);
  opacity: .85;
}
.pick-stack .pick-danger:hover { opacity: 1; }
