:root {
  --green: #4a9b2f;
  --green-dark: #3b7d25;
  --orange: #f07d1a;
  --ink: #24303d;
  --muted: #8a97a3;
  --line: #e3e8ec;
  --bg: #f6f8f6;
  --topbar: 56px;     /* высота шапки: от неё считается «липкость» панели */
  --sidebar: 224px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
a { color: var(--green-dark); }

/* ---------- шапка ---------- */
.topbar {
  background: #fff;
  border-bottom: 3px solid var(--green);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: var(--topbar);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-weight: 800;
  font-size: 17px;
  color: var(--green);
}
.topbar .brand span { color: var(--muted); font-weight: 500; font-size: 13px; }
/* дата и день недели — только на главной (products.html), см. {% block topbar_date %} */
.topbar-date { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ----- шапка ТП/менеджера — та же, что и в личном кабинете (cabinet.css
   .cb-top), на любой десктопной странице, а не только своя белая (см.
   _cb_top_header.html, включается в base.html вместо обычной .topbar) ----- */
.topbar.cb-top-on-desktop {
  background: var(--green);
  border-bottom: none;
  height: auto;
  min-height: var(--topbar);
  padding: 10px 24px;
  justify-content: space-between;
}
.cb-top-on-desktop .cb-top-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cb-top-on-desktop .cb-top-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.cb-top-on-desktop .cb-top-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cb-top-on-desktop .cb-top-title { font-weight: 700; font-size: 15px; min-width: 0; color: #fff; }
.cb-top-on-desktop .cb-top-title span { font-weight: 400; opacity: .85; font-size: 12px; display: block; }
/* «Назад» в той же строке шапки, прижата к правому краю — margin-left:auto
   отодвигает её вправо независимо от justify-content родителя (.topbar).
   Общий класс для ОБЕИХ шапок — новый_дизайн (.cb-top-on-desktop) и старой
   admin-шапки (голый .topbar, см. base.html) — у обеих белый фон */
.cb-top-back {
  margin-left: auto; flex: none;
  font-weight: 600; font-size: 13px; color: var(--green-dark); text-decoration: none; white-space: nowrap;
}
/* хабургер поверх уже зелёного фона — прозрачный кружок, не сплошной зелёный квадрат */
.cb-top-on-desktop .nav-toggle { background: rgba(255, 255, 255, .18); }
.cb-top-on-desktop .nav-toggle:active { background: rgba(255, 255, 255, .3); }
/* справа в шапке — дата и день недели под ней (на месте прежней кнопки
   «Выход», она переехала вниз боковой панели, см. _sidebar_nav.html) */
.cb-top-when {
  margin-left: auto;
  text-align: right;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
}
.cb-top-when b { display: block; font-size: 16px; font-weight: 700; }
.cb-top-when span { display: block; font-size: 13.5px; opacity: .9; }

/* ---------- боковая панель ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  flex: 0 0 var(--sidebar);
  width: var(--sidebar);
  background: #fff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 14px 0 20px;
  transition: width .16s ease, flex-basis .16s ease;
}

/* ----- кнопка «свернуть панель» (только ПК: на телефоне панель и так за ☰).
   Широкие таблицы — табель на 31 день, матрица, прайс — упираются в её
   224 px, а меню при этом никуда не нужно ----- */
.side-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.side-toggle:hover { color: var(--green-dark); border-color: var(--green); }
/* закрашенная левая доля значка = панель на месте; свёрнута — доля гаснет */
body.sidebar-collapsed .side-toggle .side-toggle-fill { opacity: .25; }
/* в зелёной шапке ТП/менеджера белая кнопка была бы заплаткой */
.cb-top-on-desktop .side-toggle {
  background: rgba(255, 255, 255, .18);
  border-color: transparent;
  color: #fff;
}
.cb-top-on-desktop .side-toggle:hover { background: rgba(255, 255, 255, .3); color: #fff; }

/* Сворачиваем шириной, а не display:none — иначе не было бы плавности, а
   резкий скачок содержимого на пол-экрана читается как перезагрузка.
   Только на широком экране: на телефоне у .sidebar своя раскладка (выезжает
   поверх страницы), и отметка, оставшаяся в хранилище с большого экрана, не
   должна её ломать. */
@media (min-width: 901px) {
  body.sidebar-collapsed .sidebar {
    flex-basis: 0;
    width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border-right: none;
  }
  /* содержимое обычно упирается в max-width:1240px — предел читаемой строки.
     Но панель сворачивают ровно ради места под широкую таблицу, и держать
     после этого прежнюю рамку значило бы «нажал и ничего не изменилось» */
  body.sidebar-collapsed main { max-width: none; }
}
/* заголовок панели — «Разделы CRM» + аватарка (ссылка на личный кабинет
   у ролей, у кого он есть — см. _sidebar_nav.html). Общая разметка для
   ВСЕХ ролей — включая старый сайдбар admin/supervisor, не только
   редизайн (.sidebar-v2 ниже задаёт только свой шрифт поверх этого) */
.side-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.side-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--muted); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; overflow: hidden;
}
.side-avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-header-text { min-width: 0; }
.side-header-text b { display: block; font-size: 15px; color: var(--ink); }
.side-header-text span {
  display: block; color: var(--muted); font-size: 12px; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar nav { display: flex; flex-direction: column; }
.side-title {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 6px 18px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
  list-style: none;          /* убираем стандартный треугольник */
}
.side-title::-webkit-details-marker { display: none; }
.side-title:hover { color: var(--ink); }
/* своя стрелка: вниз у раскрытой группы, вправо у свёрнутой */
.side-title::before {
  content: "▸";
  font-size: 10px;
  transition: transform .15s;
}
.side-group[open] > .side-title::before { transform: rotate(90deg); }
/* свёрнутая группа подписывает открытую страницу — иначе неясно, где вы */
.side-group:not([open]) > .side-title[data-current]::after {
  content: "· " attr(data-current);
  color: var(--green);
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}
/* раздел строится, ссылок в нём ещё нет — держим на виду, но приглушённо */
.side-empty { margin: 0; padding: 4px 18px 10px; color: var(--muted); font-size: 12.5px; }

.sidebar nav a {
  display: block;          /* без этого пункты группы встают в строку */
  padding: 10px 18px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active {
  color: var(--green);
  border-left-color: var(--orange);
  background: var(--bg);
}
/* маркер-точка у пунктов внутри раскрывающейся группы — на глаз видно,
   что это подпункты раздела, а не сам раздел (у .side-solo точки нет —
   те уже сами оформлены как заголовок). Селектор с .sidebar намеренно —
   у ".sidebar nav a" выше специфичность (2 тип-селектора), чем у голого
   ".side-group > a" (1 класс + 1 тип), без .sidebar её padding-left
   тихо проигрывал бы шорткату "padding: 10px 18px" выше по файлу. */
.sidebar .side-group > a {
  position: relative;
  padding-left: 32px;
}
.sidebar .side-group > a::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-50%);
}
.sidebar .side-group > a.active::before { background: var(--orange); }
/* пункт без подгруппы (не раскрывается) — тот же шрифт, что у заголовка
   группы, а не у пункта внутри неё: иначе он выглядит вложенным в
   соседнюю группу выше, хотя на деле сам по себе */
.sidebar nav a.side-solo {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 6px 18px;
}
.sidebar nav a.side-solo:hover { color: var(--ink); }
.sidebar nav a.side-solo.active { color: var(--green); }
/* пункты вне группы отделяются чертой — их видно как отдельные разделы */
.side-solo:first-of-type { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.side-group { padding-bottom: 4px; }
/* раскрытая группа слегка подсвечена целиком — иначе на общем белом фоне
   непонятно, где заканчивается её список пунктов */
.side-group[open] { background: var(--bg); }

/* имя вошедшего прижато к правому краю шапки (кнопка «Выход» отсюда
   убрана — она внизу боковой панели, .side-exit) */
.topbar .exit-form { margin-left: auto; }
/* дата с днём недели — только на телефоне, на месте прежней кнопки
   «Выход»; на десктопе там имя, а дата и так есть на главной
   ({% block topbar_date %}) — второй раз не нужна */
.topbar-when { display: none; text-align: right; line-height: 1.2; white-space: nowrap; }
.topbar-when b { display: block; font-size: 15px; font-weight: 700; color: var(--ink); }
.topbar-when span { display: block; font-size: 13px; color: var(--muted); }

/* «Выход» последним пунктом боковой панели */
.side-exit { margin-top: 14px; padding: 12px 18px 0; border-top: 1px solid var(--line); }
.side-exit button {
  width: 100%;
  background: #fff;
  color: #d43b3b;
  border: 1px solid #f0c4c1;
  border-radius: 6px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.side-exit button:hover { background: #fdecea; border-color: #d43b3b; }

main { flex: 1 1 auto; min-width: 0; max-width: 1240px; margin: 0 auto; padding: 24px; }

/* таблица без рамок — для списков «поле → значение» */
table.plain { min-width: 0; background: none; }
table.plain td { border-bottom: 1px solid var(--line); padding: 8px 12px 8px 0; }
table.plain tr:last-child td { border-bottom: none; }
table.plain code { font-size: 12.5px; word-break: break-all; }
/* адреса приёмника: на телефоне длинная ссылка не должна вылезать за карточку */
td code { font-size: 12.5px; word-break: break-all; }

/* ---------- уведомления ---------- */
/* плавающие поверх страницы — видны при любой прокрутке, а не только
   когда открыт самый верх страницы (иначе на длинной странице их легко
   не заметить, особенно если фокус не наверху, как было с длинным списком
   покупателей и незаметной ошибкой про договор консигнации) */
.flashes {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: min(92vw, 560px);
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.flash {
  padding: 11px 40px 11px 16px;
  border-radius: 6px;
  border-left: 4px solid;
  box-shadow: 0 4px 16px rgba(36, 48, 61, 0.18);
  position: relative;
}
.flash.ok { background: #eaf6e5; border-color: var(--green); }
.flash.error { background: #fdecea; border-color: #d43b3b; }
.flash-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}
.flash-close:hover { color: var(--ink); }

/* подтверждение сохранения рядом с кнопкой (см. users.html) —
   без перезагрузки страницы, поэтому не общий .flash в шапке */
.save-btn-wrap { display: inline-flex; align-items: center; }
.save-confirm {
  margin-left: 10px;
  font-size: 13px;
  color: var(--green-dark);
  opacity: 0;
  transition: opacity .2s;
}
.save-confirm.show { opacity: 1; }
.save-confirm.error { color: #d43b3b; }

/* ---------- общие блоки ---------- */
.card-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
h1 { font-size: 22px; margin: 0 0 4px 0; }
h2 { font-size: 16px; margin: 0 0 14px 0; color: var(--green-dark); }
.subtitle { color: var(--muted); margin: 0 0 20px 0; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; }

/* ---------- стрелка «назад» слева от заголовка (десктоп) ---------- */
/* .subtitle несёт margin-bottom:20px сама — обёртке лишний отступ не нужен */
.page-header-back { display: flex; align-items: flex-start; gap: 12px; }
.page-header-back > div:last-child { min-width: 0; flex: 1 1 auto; }
.page-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
}
.page-back:hover { color: var(--green-dark); border-color: var(--green); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--green-dark); }
.btn.orange { background: var(--orange); }
.btn.orange:hover { background: #d66a10; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: #fff; color: #d43b3b; border: 1px solid #f0c4c1; }
.btn.danger:hover { background: #fdecea; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 13px 26px; font-size: 15px; }

/* ---------- несколько телефонов сотрудника ---------- */
.phone-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.phone-row { display: flex; gap: 6px; }
.phone-row input[type=text] { flex: 1 1 auto; min-width: 0; }
.phone-row select { flex: 0 0 auto; width: 150px; }
.phone-row-remove {
  flex: 0 0 auto; width: 30px; border: 1px solid var(--line); border-radius: var(--radius, 6px);
  background: #fff; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
}
.phone-row-remove:hover { background: #fdecea; color: #d43b3b; border-color: #f0c4c1; }

/* ---------- формы ---------- */
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
input[type=text], input[type=number], input[type=search], input[type=password],
input[type=date], input[type=month], input[type=tel], input[type=email],
textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--green); border-color: var(--green); }
textarea { resize: vertical; min-height: 72px; }
/* «Выберите файл» — это выбор локального файла, не сама загрузка; кнопка
   намеренно приглушённая, чтобы не спорить взглядом с «Загрузить»/«Сохранить» */
input[type=file] { font-size: 13px; font-family: inherit; color: var(--muted); }
input[type=file]::file-selector-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 12px;
  margin-right: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg); }
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.field { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
/* колонка сетки по умолчанию не ужимается ниже своего содержимого: широкая
   таблица внутри неё раздвигала страницу вместо того, чтобы прокручиваться */
.grid2 > *, .grid3 > * { min-width: 0; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: 17px; height: 17px; }
.checkline label { margin: 0; }

/* Поле «Теги» с подсказкой уже введённых значений (см. base.html —
   инициализироватьПолеТегов). Обёртка нужна как якорь для абсолютно
   позиционированного списка подсказок под полем. */
.tags-field { position: relative; }
.tags-suggest {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .1); padding: 6px;
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 160px; overflow-y: auto; z-index: 30;
}
.tags-suggest-item {
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: #f7f8f9; font-size: 12.5px; cursor: pointer;
}
.tags-suggest-item:hover { background: var(--green); border-color: var(--green); color: #fff; }

/* Превью у выбора файла (.file-with-preview, см. base.html) — только для
   картинок, показывается сразу после выбора файла, до отправки формы. */
.file-preview-img {
  display: block; margin-top: 8px;
  max-width: 160px; max-height: 160px;
  border: 1px solid var(--line); border-radius: 8px;
  object-fit: contain; background: #f7f8f9;
}

/* ---------- фильтры ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; }
.filters .grow { flex: 1; min-width: 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 12.5px;
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
/* «Иск в суд» — предупреждающая пометка, зелёный тут неуместен */
.chip.danger.on { background: #c62828; border-color: #c62828; color: #fff; }

/* ---------- таблица ---------- */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); background: #fafbfa; }
/* сортировка кликом по заголовку — см. базовый скрипт в base.html */
th.sortable-th { cursor: pointer; user-select: none; padding-right: 20px; position: relative; }
th.sortable-th:hover { color: var(--green-dark); }
th.sortable-th::after {
  content: "↕"; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 10px; opacity: .45;
}
th.sortable-th.sort-asc::after { content: "↑"; opacity: 1; color: var(--green-dark); }
th.sortable-th.sort-desc::after { content: "↓"; opacity: 1; color: var(--green-dark); }
tr.hidden-row td { opacity: 0.45; }
td.num { text-align: right; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
.thumb {
  width: 46px; height: 46px; object-fit: contain;
  background: var(--bg); border-radius: 4px; border: 1px solid var(--line);
}
.thumb.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--muted); text-align: center; line-height: 1.1;
}
.price-new { font-weight: 700; color: var(--green-dark); }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: 11px; font-weight: 700; background: var(--orange); color: #fff;
}
/* тип документа Поступления ДС: ПКО и Вх ПП должны различаться с первого взгляда */
.tag.pko { background: var(--green-dark); }
.tag.vhpp { background: #2f6fa8; }
/* тип документа Расхода ДС — свои цвета, чтобы не путать с Поступлением */
.tag.rko { background: #a23b3b; }
.tag.ishpp { background: #7b4fa6; }
.disc-tag {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: 11px; font-weight: 700; background: #d43b3b; color: #fff;
}
.sku { color: var(--muted); font-size: 12.5px; font-family: Consolas, monospace; }

/* ---------- Акции: список акций карточками (название + период) ---------- */
.promo-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.promo-list-card {
  position: relative;
  padding: 14px 16px;
  margin-bottom: 0;
  transition: border-color .12s, box-shadow .12s;
}
.promo-list-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.promo-list-card h2 { font-size: 14.5px; margin-bottom: 6px; }
.promo-list-card .hint { font-size: 12px; }
/* растянутая ссылка — вся карточка кликабельна, но кнопка «Скрыть» поверх
   неё остаётся своей отдельной целью клика (z-index выше) */
.promo-list-link { position: absolute; inset: 0; z-index: 1; }
.promo-hide-form { position: relative; z-index: 2; margin-top: 10px; display: inline-block; }
@media (max-width: 900px) {
  .promo-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .promo-list { grid-template-columns: 1fr; }
}
.promo-list-card.promo-hidden { opacity: .6; background: var(--bg); }

/* ---------- Акции: карточки товара, как в интернет-магазине ---------- */
.promo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.promo-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.promo-card-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg);
}
.promo-card-photo img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.promo-card-badge { position: absolute; top: 8px; right: 8px; }
.promo-card-body { padding: 10px 12px 12px; }
.promo-card-name {
  font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 4px; min-height: 2.6em;
}
.promo-card-price { margin-top: 6px; }
.promo-card-price .price-new { font-size: 15px; }
.promo-card-price .price-old { margin-left: 6px; }

@media (max-width: 640px) {
  .promo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .promo-card-body { padding: 8px 9px 10px; }
  .promo-card-name { font-size: 12.5px; }
}

/* ---------- прайс-лист: разделы и подразделы ---------- */
tr.price-group td { background: var(--bg); font-size: 14px; font-weight: 700; padding-top: 10px; padding-bottom: 10px; }
tr.price-section td { background: #fbfcfb; font-size: 13px; padding-top: 6px; padding-bottom: 6px; }

/* группа-пикер в шапке страницы: чип с многоточием открывает попап со своими подчипами */
.chip.chip-popup::after { content: " ⋯"; opacity: .6; }
.group-popup-box { width: min(480px, 100%); max-height: 80vh; }
.group-popup-actions { display: flex; gap: 8px; margin: 2px 0 14px; }

/* ---------- конструктор дерева разделов ---------- */
.tree-constructor, .tree-constructor .tree-children {
  list-style: none; margin: 0; padding: 0;
}
.tree-constructor .tree-children { margin: 2px 0 2px 22px; border-left: 1px dashed var(--line); padding-left: 14px; }
.tree-node { margin: 2px 0; border-radius: 6px; }
.tree-node.drag-over { outline: 2px dashed var(--green); outline-offset: 2px; background: var(--bg); }
.tree-node.dragging { opacity: .4; }
.tree-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; border-radius: 6px;
}
.tree-row:hover { background: var(--bg); }
.tree-handle { cursor: grab; color: var(--muted); font-size: 15px; user-select: none; }
.tree-name { font-weight: 600; }
.tree-node.moved > .tree-row .tree-name { color: var(--green-dark); }
.tree-node.moved > .tree-row .tree-name::after { content: " (перенесён)"; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.tree-move-select {
  margin-left: auto; font-size: 12px; padding: 3px 6px;
  border: 1px solid var(--line); border-radius: 5px; color: var(--muted); max-width: 220px;
}
.tree-reset { font-size: 12px; }
@media (max-width: 700px) {
  .tree-move-select { margin-left: 0; max-width: 100%; }
  .tree-row { gap: 6px; }
}

/* ---------- пагинация ---------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 7px 12px; border-radius: 6px; text-decoration: none;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.pager .now { background: var(--green); color: #fff; border-color: var(--green); }
.pager .gap { border: none; background: none; color: var(--muted); }

/* ---------- прочее ---------- */
.photo-preview {
  width: 100%; height: 200px; object-fit: contain;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
}
.log {
  background: #1e2a35; color: #d6e4ef; padding: 16px; border-radius: 6px;
  font-family: Consolas, monospace; font-size: 12.5px; white-space: pre-wrap;
  max-height: 320px; overflow: auto;
}
/* плитки сводки: каждая — отдельная карточка на своей подложке, а не просто
   число за тонкой вертикальной чертой — тесно стоящие цифры без своего
   контура читаются как одна длинная строка, особенно на телефоне, где
   строки к тому же переносятся. grid сам решает, сколько плиток в ряд
   поместится на любой ширине — без отдельных медиа-запросов под конкретное
   число колонок. auto-fit, а не auto-fill: auto-fill оставляет в сетке
   пустые «фантомные» колонки, если плиток меньше, чем помещается по
   минимальной ширине, — сумма зажата в узкую колонку и обрезается
   многоточием, хотя рядом пустует место. auto-fit схлопывает пустые
   колонки и отдаёт их ширину настоящим плиткам */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
.stat {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
/* обрезание — крайний случай, не обычный путь: JS в base.html подгоняет
   font-size под ширину карточки заранее, ellipsis подстраховывает только
   если даже минимальный размер не спас (очень узкий экран + огромное число) */
.stat .value { display: block; font-size: 22px; font-weight: 800; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* тревожное число в сводке: «без ответа» не должно выглядеть как достижение */
.stat .value.error-text { color: #d43b3b; }
.stat .label {
  display: block;
  order: -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}
/* плитка-кнопка дашборда (клик открывает детали) — тот же вид, что у
   обычной .stat, только с наведением: рамка и лёгкая тень намекают, что
   плитка кликабельна, а не просто число для чтения */
.stat-btn {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: border-color .12s, box-shadow .12s;
}
.stat-btn:hover { border-color: var(--green); box-shadow: 0 2px 10px rgba(74, 155, 47, .12); }
/* Финансовый календарь: плитки Поступления/Расход/Кредиты кликабельны
   (попап разбивки по статьям) — тот же намёк наведением, что у .stat-btn,
   но сама плитка остаётся обычным .stat (не <button>) */
.stat.stat-clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.stat.stat-clickable:hover, .stat.stat-clickable:focus-visible {
  border-color: var(--green); box-shadow: 0 2px 10px rgba(74, 155, 47, .12);
}
/* ---------- перетаскивание и выделение разделов ---------- */
.selection-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  position: sticky;
  top: 57px;
  z-index: 5;
}
.selection-bar .bar-spacer { flex: 1; }
.pick-cell { text-align: center; }
.pick-cell .pick { width: 17px; height: 17px; cursor: pointer; }
#sections-body tr { cursor: default; }
#sections-body tr.picked { background: #f2f9ef; }
#sections-body tr.dragging { opacity: 0.45; background: #eaf6e5; }
.order-cell { white-space: nowrap; }
.drag-handle {
  touch-action: none;
  display: inline-block;
  cursor: grab;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 4px 6px 4px 0;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
#sections-body tr:hover .drag-handle { color: var(--green); }
.save-note { font-size: 13px; font-weight: 600; color: var(--muted); }
.save-note.ok { color: var(--green); }
.save-note.error { color: #d43b3b; }

.cut-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}
.cut-all input { padding: 6px 8px; width: 78px; }
/* числовые поля со стрелками: держим их всегда видимыми, а не по наведению */
input.cut, input.qty {
  width: 78px;
  padding: 6px 8px;
  text-align: center;
}
input[type=number] { -moz-appearance: number-input; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  opacity: 1;
  height: 24px;
}

/* индикатор живого поиска */
.searching {
  display: none;
  color: var(--green);
  font-weight: 600;
  font-size: 12.5px;
}
.searching.on { display: inline; }

/* ---------- сведения о последней загрузке ---------- */
.last-import {
  background: #eaf6e5;
  border-color: var(--green);
}
.last-import h2 { color: var(--green-dark); }
.last-import .last-file {
  font-weight: 700;
  font-size: 15px;
  font-family: Consolas, monospace;
}

/* ---------- ход загрузки прайса ---------- */
.progress-stage {
  font-size: 17px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 14px;
}
.progress-track {
  height: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 2%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green), #6dbf46);
  background-size: 28px 28px;
  transition: width 0.5s ease;
  animation: progress-stripes 1s linear infinite;
  background-image: linear-gradient(45deg,
    rgba(255,255,255,0.22) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,0.22) 50%,
    rgba(255,255,255,0.22) 75%, transparent 75%, transparent);
}
.progress-fill.failed { background: #d43b3b; animation: none; }
@keyframes progress-stripes {
  from { background-position: 28px 0; }
  to { background-position: 0 0; }
}

/* затемнение на время отправки файла */
.sending-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 48, 61, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.sending-overlay .box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 36px;
  text-align: center;
  max-width: 420px;
}
.sending-overlay .spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- выбор формата и разделов ---------- */
.format-pick {
  flex: 1;
  min-width: 240px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 400;
  margin: 0;
  transition: background 0.15s, border-color 0.15s;
}
.format-pick:hover { border-color: var(--green); }
.format-pick.on { background: #eaf6e5; border-color: var(--green-dark); }
.format-pick input { margin-right: 8px; }
.format-pick b { font-size: 15px; }
.format-pick .hint { display: block; margin-top: 5px; }

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px 16px;
}
.section-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  font-weight: 400;
  margin: 0;
  cursor: pointer;
}
.section-pick:hover { background: var(--bg); }
.section-pick input { width: 16px; height: 16px; flex: none; }
.section-pick .section-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* фото товара: одна лента, действия иконками поверх снимка */
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.photo-tile {
  position: relative;
  width: 128px;
  height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.photo-tile.main { border-color: var(--green); }
.photo-tile { cursor: grab; }
.photo-tile.dragging { opacity: .4; cursor: grabbing; }
/* картинку тащим за плитку целиком, иначе браузер утаскивает саму картинку */
.photo-tile img { pointer-events: none; }
.photo-tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.photo-icons { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; }
.photo-icon {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.photo-icon:hover { background: #fff; border-color: var(--green); }
.photo-icon.danger:hover { border-color: #d43b3b; color: #d43b3b; }

/* рамка, куда перетаскивают файлы */
.photo-drop {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: #fff;
}
.photo-drop:hover, .photo-drop.over { border-color: var(--green); background: var(--bg); }
.photo-drop.busy { opacity: .6; pointer-events: none; }
.photo-drop-text { font-weight: 600; color: var(--ink); }

.desc-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* столбики по месяцам: без картинок и библиотек, просто полоски */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.bar-title { flex: 0 0 70px; font-size: 13px; color: var(--muted); }
.bar-track { flex: 1 1 auto; height: 18px; background: var(--bg); border-radius: 4px; }
.bar-fill { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.bar-value { flex: 0 0 170px; text-align: right; font-size: 13.5px; font-weight: 600; }

/* удаление прячется под раскрывающейся строкой: случайно не нажмётся */
.danger-zone { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.danger-zone summary { cursor: pointer; }
.danger-zone > *:not(summary) { margin-top: 8px; }
.error-text { color: #d43b3b; }

/* колонки задаются классом, а не в самом шаблоне: встроенный стиль
   сильнее правил для телефона, и страница оставалась двухколоночной */
.grid-form { grid-template-columns: 1fr 320px; align-items: start; }
.grid-narrow { grid-template-columns: 1fr 160px; align-items: end; }

.inline-form { display: inline; }
.mini-input { display: inline-block; width: auto; min-width: 170px; }

/* поле и кнопка в одну строку; на узком экране кнопка уходит под поле */
.row-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* поле поиска тянется, а список рядом занимает своё — иначе поле шириной во
   всю строку сталкивало соседей на следующую */
.row-form input[type="text"], .row-form input[type="search"] { flex: 1 1 260px; }
.row-form select { flex: 0 1 240px; width: auto; }
/* Посещения → Отчёт: расчёт времени на объезд — фиксированной ширины,
   стоит справа от поля поиска (которое тянется и занимает всё, что
   осталось). Три подписанных поля + результат заметно шире обычного
   соседа .row-form, поэтому полю поиска рядом с ним даём ужаться
   сильнее обычного (260px) — иначе на не самом широком окне калькулятор
   не помещался в строку и падал под поиск */
.row-form:has(.visits-calc) input[type="search"] { flex: 1 1 160px; min-width: 100px; }
/* тот же светло-серый фон, что у плашки результата (.visits-calc-result) —
   поля калькулятора стоят на ней, а не на белом/окаймлённом блоке */
.visits-calc {
  display: flex; align-items: center; gap: 12px;
  background: #f4f5f6; border-radius: 8px;
  padding: 6px 10px; flex: 0 0 auto; margin-left: auto;
}
/* подпись над полем, а не рядом — иначе «Кол-во визитов каждого
   покупателя» одной строкой растягивало весь блок вширь */
.visits-calc-field { display: flex; flex-direction: column; gap: 2px; }
.visits-calc .hint { white-space: nowrap; line-height: 1.2; }
.visits-calc input[type="number"] { padding: 4px 6px; }
/* результат расчёта — крупно, справа от кнопки «Сегодня» (не внутри
   .visits-calc, тот блок остаётся только полями ввода) */
/* flex-basis:0 — иначе flex-wrap решает, помещается ли строка на текущую
   строку, по её ПОЛНОЙ (немасштабированной) ширине и не влезающий целиком
   текст целиком падает на следующую строку, даже если после переноса
   остаётся много свободного места; с basis:0 браузер всегда пробует
   поместить блок в текущую строку и переносит уже сам текст внутри него */
.visits-calc-result {
  flex: 1 1 0; min-width: 160px; align-self: stretch;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: #f4f5f6; border-radius: 8px; padding: 6px 12px;
  font-size: 18px; font-weight: 700; color: var(--green-dark, #2f9e44);
}

/* поле с ошибкой: рамка и подпись под полем, чтобы ошибку было видно на месте */
.field input.bad {
  border-color: #d43b3b;
  background: #fff6f6;
}
.field-error {
  min-height: 0;
  margin-top: 4px;
  color: #d43b3b;
  font-size: 12px;
  line-height: 1.35;
}
.field-note {
  margin-top: 4px;
  color: var(--green);
  font-size: 12px;
}

/* технические описания: текст в таблице ограничиваем тремя строками */
.note-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}
.thumb.big { width: 120px; height: 120px; object-fit: contain; }
a.section-pick { text-decoration: none; color: inherit; display: block; }
a.section-pick:hover { border-color: var(--green); }

/* правка технического описания прямо в КП */
.note-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.note-block .row-between { margin-bottom: 8px; }
.note-area {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
}
.tag-edited {
  display: inline-block;
  margin-left: 8px;
  background: #fff4e2;
  color: #a8600c;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 12px;
}

/* поиск по описаниям */
.search-box { display: flex; align-items: center; gap: 14px; }
.search-box input {
  flex: 1;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.search-box .hint { white-space: nowrap; }

/* вход и первая настройка */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  background: #f4f7f5;
}
.auth-box {
  width: 380px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 30px 30px;
  box-shadow: 0 8px 30px rgba(20, 40, 25, 0.07);
}
.auth-box.wide { width: 560px; }
.auth-brand {
  font-size: 21px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -0.2px;
}
.auth-brand span { color: #24303d; }
.auth-box .field { margin-top: 14px; }
.auth-box input[type=text], .auth-box input[type=password] { width: 100%; }

/* имя вошедшего в шапке */
.topbar .who {
  color: #5d6b62;
  font-size: 13px;
  margin-right: 10px;
  white-space: nowrap;
}

/* карточка сотрудника и галочки прав */
/* сотрудников может быть много — карточка свёрнута по умолчанию, видна
   только сводная строка; сама .card-box отдаёт свои отступы кнопке и телу,
   чтобы кнопка-сводка была кликабельна во всю ширину карточки. Список
   собран плотнее обычных card-box (margin поменьше) — иначе много
   свёрнутых строк подряд выглядят слишком разрежённо */
#staff-list .staff-card { margin-bottom: 8px; transition: box-shadow .15s; }
.staff-card { padding: 0; overflow: hidden; border: none; }
.staff-card:hover { box-shadow: 0 2px 10px rgba(36, 48, 61, .07); }
.staff-summary-row { display: flex; align-items: center; gap: 14px; padding: 13px 20px; }
.staff-summary-row:hover { background: var(--bg); }
.staff-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
  flex: 1;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
}
.staff-summary:focus, .staff-summary:focus-visible, .staff-summary:active { outline: none; box-shadow: none; }
/* Firefox рисует отдельную пунктирную рамку внутри кнопки при фокусе —
   обычный outline:none её не трогает */
.staff-summary::-moz-focus-inner { border: 0; }
.staff-avatar-form { margin: 0; flex: 0 0 auto; }
/* overflow:visible — иначе кружок обрежет значок редактирования, торчащий
   за его край; фото всё равно остаётся круглым за счёт border-radius на img */
.staff-avatar-form .staff-avatar { position: relative; cursor: pointer; overflow: visible; }
.staff-avatar-edit {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; line-height: 1;
}
.staff-avatar, .motiv-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .3px;
  background: var(--muted);
}
.staff-role-pill {
  display: inline-block;
  color: #fff;
  border-radius: 3px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
  margin-left: 2px;
  background: var(--muted);
}
/* только две особые должности выделены цветом — у остальных девяти
   не тот случай, чтобы плодить радугу, всем один нейтральный тон */
.staff-avatar.role-admin, .staff-role-pill.role-admin { background: var(--green); }
.staff-avatar.role-supervisor, .staff-role-pill.role-supervisor { background: var(--orange); }
/* аутсорс — не роль, а признак «не наш сотрудник»: своя метка рядом
   с ролью, отдельным тоном, чтобы читалась с одного взгляда в списке */
.staff-role-pill.role-outsource { background: #b45309; }
.staff-col { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staff-col-name { flex: 2 1 220px; white-space: normal; }
.staff-col-name .hint { font-size: 11px; }
.staff-col-phone { flex: 1 1 130px; }
.staff-col-login { flex: 1 1 110px; }
.staff-col-login code {
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}
.staff-col-created { flex: 0 1 110px; }
.staff-col-access { flex: 0 0 auto; }
.staff-chevron { flex: 0 0 auto; color: var(--muted); transition: transform .15s; }
.staff-card.open .staff-chevron { transform: rotate(180deg); }
.staff-body { padding: 4px 20px 20px; border-top: 1px solid var(--line); }
.staff-card:target .staff-body { display: block !important; }
.staff-card:target .staff-chevron { transform: rotate(180deg); }
.staff-extra {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.tag-on, .tag-off, .tag-vacation, .tag-suspended {
  border-radius: 3px;
  padding: 2px 9px;
  font-size: 12px;
}
.tag-on { background: #e8f5e9; color: #2f7d32; }
.tag-off { background: #fdecea; color: #c62828; }
.tag-vacation { background: #e8f0fe; color: #1a56db; }
.tag-suspended { background: #fff3e0; color: #b45309; }

/* бейдж статуса в шапке карточки сотрудника — сам тег стал кнопкой,
   открывающей панель смены статуса (см. users.html) */
.staff-status-wrap { position: relative; flex: 0 0 auto; }
.staff-status-tag { flex: 0 0 auto; }
.staff-status-badge {
  border: none; cursor: pointer; font: inherit; font-weight: 700;
  line-height: 1.4;
}
.staff-status-badge:hover { filter: brightness(0.94); }
.staff-status-drop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 300px; padding: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(36, 48, 61, .12);
  font-weight: 400; font-size: 14px; color: var(--ink); text-align: left;
}
.staff-status-drop .status-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 720px) {
  .staff-status-drop { right: auto; left: 0; min-width: 260px; }
}

/* личное дело: фото, документы */
.staff-avatar, .motiv-avatar { overflow: hidden; padding: 0; }
.staff-avatar img, .motiv-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* мотивация отдела продаж: карточки сотрудников — дашборд + выбор,
   вместо выпадающего списка */
.motiv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}
.motiv-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.motiv-card:hover { border-color: var(--green); }
.motiv-card.on { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.motiv-card-head { display: flex; align-items: center; gap: 10px; }
.motiv-card-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.motiv-card-name b { display: block; font-size: 14px; }
.motiv-card-name .hint { font-size: 11.5px; }
.stats-mini {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.stats-mini > div { text-align: center; flex: 1 1 0; min-width: 0; }
.stats-mini b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-mini span { display: block; font-size: 10.5px; color: var(--muted); }
.dossier-box {
  margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: #fbfcfb;
}
.doc-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--line); gap: 10px;
}
.doc-row:last-child { border-bottom: none; }
.doc-row a { color: var(--ink); }

/* Таймлайн этапов Искового производства — карточка legal_case.html */
.legal-timeline {
  display: flex; flex-wrap: wrap; row-gap: 24px; gap: 0; padding: 6px 2px 14px;
  overflow: hidden;
}
.legal-step {
  flex: 1 1 140px; min-width: 140px; text-align: center; position: relative; padding-top: 18px;
}
.legal-step::after {
  content: ""; position: absolute; top: 5px; left: 50%; width: 100%; height: 3px;
  background: var(--line); z-index: 0;
}
.legal-step:last-child::after { display: none; }
.legal-step.done::after { background: var(--green); }
.legal-step .dot {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  border: 3px solid var(--line); z-index: 1;
}
.legal-step.done .dot { border-color: var(--green); background: var(--green); }
.legal-step.current .dot { border-color: var(--orange); background: var(--orange); }
.legal-step .name { font-size: 12px; font-weight: 600; margin-top: 8px; }
.legal-step.current .name { color: var(--orange); }
.legal-step .date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.legal-step .who { font-size: 10.5px; color: var(--muted); margin-top: 1px; font-style: italic; }
.legal-doc-kind + .legal-doc-kind { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
/* Вкладки «Документы/Отчёты» + кнопка добавления того, что относится к
   активной вкладке (карточка legal_case.html) — кнопка одна на все
   вкладки, JS переключает видимость вместе с самой панелью.
   .legal-tab-group держит вкладки и кнопку одним flex-элементом, чтобы
   «Корзина» (редкое admin-действие) переносилась строкой ниже первой —
   а сами вкладки с кнопкой не разрывались друг от друга */
.legal-tab-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.legal-tab-action form { margin: 0; }

@media (max-width: 640px) {
  /* Вкладки + кнопка добавления — в одну строку, компактнее. Специфичность
     двумя классами нужна, чтобы перебить .row-between{flex-wrap:wrap} —
     тот же класс, общий для всей вёрстки, задан ниже по файлу */
  .row-between.legal-tab-row { gap: 6px; }
  .legal-tab-group { flex-wrap: nowrap; gap: 6px; flex: 1 1 auto; }
  .legal-tab-row .tabs { flex-wrap: nowrap; gap: 4px; min-width: 0; }
  .legal-tab-row .tab { padding: 7px 8px; font-size: 12px; white-space: nowrap; }
  .legal-tab-action .btn { padding: 6px 8px; font-size: 11px; white-space: nowrap; }

  /* Таймлайн этапов — вертикальный список вместо горизонтального
     степпера: на узком экране 2 колонки в flex-wrap выглядели тесно, а
     соединительные линии (рассчитанные на один ряд) сбивали смысл */
  .legal-timeline { display: block; padding: 4px 2px 0; }
  .legal-step {
    display: grid; grid-template-columns: 22px 1fr; column-gap: 10px;
    text-align: left; min-width: 0; flex: none; padding: 0 0 20px;
  }
  .legal-step .dot {
    position: static; grid-row: 1 / -1; align-self: start; justify-self: center;
    margin-top: 3px; transform: none;
  }
  .legal-step::after { top: 3px; left: 10px; width: 3px; height: 100%; }
  .legal-step .name { margin-top: 0; }
  .legal-step .date { margin-top: 2px; }
  .legal-step .who { margin-top: 1px; }
}
.status-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.perm-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.perm-box.locked { opacity: 0.75; }
.perm-box > summary { cursor: pointer; list-style: none; }
.perm-box > summary::-webkit-details-marker { display: none; }
.perm-box > summary::after { content: '▾'; color: var(--muted); margin-left: 8px; transition: transform .15s; }
.perm-box[open] > summary::after { transform: rotate(180deg); }
/* без этого правила блок не сворачивался вовсе: display:grid у .perm-grid —
   авторский стиль, он перебивает системное скрытие содержимого закрытого
   <details> независимо от специфичности (авторские стили всегда выше
   стилей браузера по умолчанию) */
.perm-box:not([open]) .perm-grid,
.perm-box:not([open]) > p { display: none; }
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 8px;
}
.perm {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.perm.on { border-color: var(--green); background: #f3faf3; }
.perm input { margin-top: 3px; }
.perm b { display: block; font-weight: 600; font-size: 13px; }
.perm .hint { display: block; font-size: 12px; line-height: 1.35; }

/* ================================================================
   ТЕЛЕФОНЫ И ПЛАНШЕТЫ
   Программу открывают с телефона у клиента и на складе, поэтому
   узкие экраны — не «запасной» режим, а рабочий.
   ================================================================ */

/* кнопка ☰ появляется только на узких экранах */
.nav-toggle, .nav-toggle-box { display: none; }

@media (max-width: 900px) {
  /* на телефоне панель и так за ☰ — сворачивать нечего (сами правила
     сворачивания включены только на широком экране, см. .side-toggle) */
  .side-toggle { display: none; }
  .topbar {
    gap: 10px;
    padding: 0 12px;
    align-items: center;
  }
  .topbar .brand { font-size: 15px; flex: 1 1 auto; min-width: 0; white-space: nowrap; }
  .topbar .brand span { font-size: 12px; }
  /* на телефоне и так тесно (бургер + название + Выход) — дата тут не влезает */
  .topbar-date { display: none; }

  /* бургер слева от названия: панель выезжает оттуда же, откуда кнопка.
     Заливка зелёным — тот же акцент, что у кабинета (.cb-top) и у
     плавающей кнопки «Чат» (.chat-widget-toggle), а не нейтральная рамка:
     иконка «открыть меню» должна читаться как часть того же приложения */
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    font-size: 19px;
    line-height: 1;
    border: none;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    user-select: none;
  }
  .nav-toggle:active { background: var(--green-dark); }
  .topbar .exit-form { flex: 0 0 auto; margin-left: auto; display: flex; align-items: center; }
  .topbar .who { display: none; }
  .topbar-when { display: block; }

  /* панель выезжает слева поверх страницы, а не раздвигает её —
     подложка под ней (.nav-backdrop) гасит остальной экран для контраста */
  .layout { display: block; }
  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 30;
  }
  .nav-toggle-box:checked ~ .nav-backdrop { display: block; }
  .sidebar {
    width: 82%;
    max-width: 300px;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    border-right: none;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .25);
    padding: 10px 0 20px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .nav-toggle-box:checked ~ .layout .sidebar { transform: translateX(0); }
  .side-header { padding: 14px 12px 10px; }
  .side-title { padding: 8px 12px 4px; }
  .sidebar nav a { padding: 13px 12px; border-bottom: 1px solid var(--line); }
  .side-solo:first-of-type { margin-top: 0; padding-top: 13px; }

  main { padding: 12px; }
  .card-box { padding: 14px; margin-bottom: 14px; border-radius: 10px; }
  h1 { font-size: 19px; }
  .subtitle { margin-bottom: 14px; }

  /* формы в одну колонку */
  .grid2, .grid3, .grid-form, .grid-narrow,
  .perm-grid, .sections-grid { grid-template-columns: 1fr; display: grid; }

  /* палец крупнее курсора: поля и кнопки подрастают.
     16px обязателен — при меньшем шрифте iPhone приближает страницу */
  input[type=text], input[type=password], input[type=search], input[type=number],
  input[type=email], input[type=tel], select, textarea {
    font-size: 16px;
    min-height: 44px;
    width: 100%;
  }
  textarea { min-height: 96px; }
  /* у этого поля свой шрифт от родителя — на телефоне он оказывался мелким */
  .note-area { font-size: 16px; }

  /* палец не попадает в мелкие цели: фильтры-чипсы и иконки на фото подрастают */
  .chip { padding: 9px 16px; font-size: 13.5px; }
  .photo-icon { width: 34px; height: 34px; font-size: 16px; }
  .btn, .side-exit button { padding: 11px 16px; font-size: 15px; }
  .btn.small { padding: 8px 12px; font-size: 13.5px; }
  .btn.big { display: block; width: 100%; text-align: center; }

  /* ряды «слева заголовок, справа кнопка» переносим в столбец */
  .row-between { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .grow { min-width: 0; }
  .mini-input { min-width: 0; width: 100%; }
  .inline-form { display: block; }

  /* на телефоне карточки чуть теснее — так помещается 2 в ряд без слишком
     мелкого текста внутри каждой */
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .stat, .stat-btn { padding: 10px 12px; }
  .search-box { flex-direction: column; align-items: stretch; }
  .search-box .hint { white-space: normal; }

  /* сводная строка сотрудника в одну колонку — семь полей в ряд на
     телефоне не помещаются */
  .staff-summary-row { padding: 14px 16px; align-items: flex-start; flex-wrap: wrap; }
  .staff-summary { flex-wrap: wrap; gap: 4px 10px; }
  .staff-col { white-space: normal; flex-basis: auto; }
  .staff-col-name { flex-basis: 100%; }
  .staff-chevron { position: absolute; right: 16px; }
  .staff-summary { position: relative; padding-right: 34px; }
  .staff-status-wrap, .staff-status-tag { margin-top: 4px; }
}

/* ---------- таблицы превращаются в карточки ----------
   На телефоне строка на семь колонок нечитаема, поэтому таблицы
   с классом as-cards раскладываются карточками: заголовок колонки
   берётся из data-label и печатается слева от значения. */
@media (max-width: 640px) {
  /* убираем рамку и прокрутку только там, где таблица стала карточками:
     обычные таблицы должны и дальше прокручиваться внутри себя */
  .table-wrap:has(table.as-cards) { overflow: visible; border: none; background: none; }
  table.as-cards { min-width: 0; background: none; }
  table.as-cards thead { display: none; }
  table.as-cards, table.as-cards tbody, table.as-cards tr, table.as-cards td {
    display: block;
    width: auto;
  }
  table.as-cards tr {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  table.as-cards td {
    border: none;
    padding: 3px 0;
    text-align: left !important;
  }
  /* подпись колонки слева, значение справа */
  table.as-cards td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--muted);
    font-size: 12.5px;
    display: inline-block;
    min-width: 92px;
  }
  table.as-cards td:empty { display: none; }

  /* фото и галочка «в КП» — в шапке карточки */
  table.as-cards td.pick-cell {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
  }
  table.as-cards .kp-pick { width: 26px; height: 26px; }
  table.as-cards .thumb { width: 64px; height: 64px; }
  table.as-cards td.name-cell { font-size: 15px; font-weight: 600; padding-right: 38px; }
  table.as-cards td.name-cell::before { display: none; }
  table.as-cards td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  table.as-cards td.actions::before { display: none; }
  /* кнопки в подвале карточки стоят рядом, а не столбиком */
  table.as-cards td.actions > .inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    width: auto;
  }
  table.as-cards .price-new { font-size: 16px; }
  /* старая цена в карточке встаёт рядом с новой, а не отдельной строкой */
  table.as-cards td.num br { display: none; }
  table.as-cards .price-old { display: inline; margin-left: 10px; }

  /* поля количества и скидки в карточке КП — крупные и рядом с подписью */
  table.as-cards input.qty, table.as-cards input.cut {
    width: 110px;
    display: inline-block;
  }

  .stat .value { font-size: 18px; }
  .stat .label { font-size: 11px; }
}

/* нижняя панель на телефоне: итог и «Выставить КП» под рукой,
   сколько бы позиций ни было в списке */
.mobile-actionbar { display: none; }
@media (max-width: 640px) {
  .mobile-actionbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    align-items: center;
    gap: 12px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(20, 40, 25, 0.08);
  }
  .mobile-actionbar .sum { font-size: 13px; color: var(--muted); line-height: 1.25; }
  .mobile-actionbar .sum b { display: block; font-size: 17px; color: var(--ink); }
  .mobile-actionbar .btn { flex: 1; text-align: center; }
  /* чтобы панель не закрывала последнюю карточку */
  body.has-actionbar main { padding-bottom: 96px; }
}

/* нижняя панель навигации — БУКВАЛЬНО та же разметка и SVG-иконки, что в
   личном кабинете (cabinet.css .cb-tabbar, те же имена классов), только
   на десктопных страницах CRM и только у ТП/менеджера (см.
   _mobile_tabbar.html): куда бы они ни попали через поиск/хабургер, внизу
   всегда одна и та же панель — раньше здесь была отдельная реализация
   (.mobile-tabbar/.mobile-tab, эмодзи вместо SVG, белый фон, обычный
   регистр) — визуально другая, хоть и с теми же 5 пунктами. cabinet.css
   тут не подключается вовсе, поэтому те же правила приходится повторить
   под своими токенами (var(--green)/var(--line) вместо var(--cb-green)/
   var(--cb-hairline) — значения совпадают, имена разные). */
.cb-tabbar { display: none; }
@media (max-width: 640px) {
  /* на этой ширине у ТП/менеджера уже есть постоянная «Прайс» внизу —
     не дублировать её пунктом «Цены» в сайдбаре (см. _sidebar_nav.html) */
  .sidebar nav a.hide-mobile-tabbar-dup { display: none; }
  .cb-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #e9e9ea;
    border-top: 1px solid var(--line);
    z-index: 50;
  }
  .cb-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--muted);
    gap: 3px;
    min-width: 0;
  }
  .cb-tab .ic { display: flex; line-height: 1; }
  .cb-tab .ic svg { display: block; }
  .cb-tab .lbl {
    font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; font-size: 9.5px;
    text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  }
  .cb-tab.on { color: var(--green); }

  body.has-mobile-tabbar main { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 12px); }
  /* «Выставить КП» — стеком над панелью навигации, а не поверх нижнего края экрана */
  body.has-actionbar.has-mobile-tabbar main { padding-bottom: calc(60px + 96px + env(safe-area-inset-bottom, 0px)); }
  body.has-actionbar.has-mobile-tabbar .mobile-actionbar { bottom: 60px; padding-bottom: 10px; }
  body.has-mobile-tabbar .chat-widget { bottom: calc(60px + 12px + env(safe-area-inset-bottom, 0px)); }
  body.has-actionbar.has-mobile-tabbar .chat-widget { bottom: calc(60px + 96px + 12px); }
}

/* карточки на служебных страницах: описания, разделы, сотрудники, прайс */
@media (max-width: 640px) {
  /* название без подписи и во всю ширину — оно и так главное в карточке */
  table.as-cards td.name-cell, table.as-cards td.text-cell { padding-right: 0; }
  table.as-cards td.text-cell::before { display: block; margin-bottom: 2px; }
  table.as-cards .note-text { -webkit-line-clamp: 4; }

  /* строки-формы внутри карточки становятся вертикальными */
  table.as-cards .inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
  }
  table.as-cards .inline-form .mini-input { flex: 1 1 100%; min-width: 0; }
  table.as-cards .mini-input { width: 100%; }

  /* перетаскивание разделов пальцем не работает — прячем ручку,
     порядок меняется стрелками */
  table.as-cards .drag-handle { display: none; }
  table.as-cards td.order-cell { display: flex; gap: 8px; align-items: center; }
  table.as-cards td.order-cell .btn { min-width: 46px; }

  /* галочка выделения раздела — как в товарах, в углу карточки */
  table.as-cards .pick { width: 24px; height: 24px; }

  /* длинное название раздела не должно распирать ячейку сетки */
  .sections-grid > * { min-width: 0; }
  .section-pick { min-width: 0; overflow-wrap: anywhere; }

  /* панель выделения разделов не должна расползаться */
  .selection-bar { flex-wrap: wrap; gap: 10px; }
  .selection-bar .bar-spacer { display: none; }
}

/* список обновляется живым поиском */
.загружается { opacity: .55; transition: opacity .15s; }

/* ---------- чат с покупателями ---------- */
/* значок непрочитанных рядом с пунктом панели */
.side-count {
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11.5px;
  margin-left: 6px;
}
.chat-lines { max-height: 460px; overflow-y: auto; padding-right: 6px; }

/* точка у строки покупателя с непрочитанной активностью — Исковое производство */
.legal-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange); margin-right: 6px; vertical-align: middle;
}

/* ---------- колокольчик уведомлений (Исковое производство) ---------- */
.bell-wrap { position: relative; margin-left: auto; margin-right: 14px; }
.bell-btn {
  background: none; border: none; cursor: pointer; font-size: 20px;
  position: relative; padding: 4px 6px; line-height: 1;
}
.bell-count.bell-count {
  position: absolute; top: -2px; right: -2px; margin-left: 0;
  font-size: 10px; padding: 1px 5px;
}
.bell-dropdown {
  position: absolute; right: 0; top: 100%; margin-top: 6px; width: 340px;
  max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 50; padding: 6px;
}
.bell-item { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); }
.bell-item:hover { background: #f5f6f4; }
.bell-item .summary { font-size: 13px; font-weight: 600; }
.bell-item .when { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bell-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-line { display: flex; flex-direction: column; margin-bottom: 12px; }
.chat-line span {
  padding: 9px 13px;
  border-radius: 12px;
  max-width: 70%;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-line small { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
/* ответы сотрудников справа: так видно, кто последний написал */
.chat-line.them { align-items: flex-end; }
.chat-line.them span { background: var(--green); color: #fff; }
.chat-line.me span { background: var(--bg); }

/* @упоминание коллеги — Исковое производство → Сообщения */
.mention { font-weight: 700; }
.chat-line.me .mention { color: var(--green); }
.chat-line.them .mention { text-decoration: underline; }
.mention-list {
  position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 180px; overflow-y: auto;
  z-index: 5;
}
.mention-item {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: none; background: none; cursor: pointer; font: inherit; color: var(--ink);
}
.mention-item:hover, .mention-item.active { background: #f5f6f4; }

@media (max-width: 640px) {
  /* переписка на телефоне: пузырь шире, ответ и кнопка каждый во всю строку —
     иначе кнопка «Ответить» жмётся в угол и в неё трудно попасть пальцем */
  .chat-line span { max-width: 88%; }
  .chat-lines { max-height: 58vh; }
  form.row-form button { flex: 1 1 100%; }
}

/* ---------- выбор периода: годы и месяцы ----------
   Единый отбор для всех разделов: слева выпадающий список лет, рядом строка
   месяцев, справа «Сегодня». Отмечать можно сколько угодно и того и другого */
.period-toggle-btn { display: none; }
.visits-mobile-totals { display: none; }
/* заголовок попапа и крестик нужны только на телефоне, где отбор — попап;
   на десктопе он обычная часть страницы, без своей шапки. Правило должно
   стоять ДО медиа-запроса ниже: та же ловушка специфичности, что и у
   #period-pick-box — «позже в файле побеждает» при равной специфичности
   иначе перебило бы display:flex/block из-под мобильного override */
.period-pick-head { display: none; }
.period-pick-title { display: none; margin: 0; font-size: 17px; color: var(--ink); }
.period-pick-close {
  display: none;
  background: none; border: none; padding: 0;
  font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer;
}
.period-pick-close:hover { color: var(--ink); }
/* месяц на ПК — открытая лента чипов «Все Янв Фев ... Дек», без клика для
   раскрытия (как и было до появления мобильного попапа с выпадашками).
   Тоже должно стоять ДО медиа-запроса ниже — там своя, другая пара правил
   для телефона (месяц-выпадашка внутри попапа), а порядок в файле решает
   при равной специфичности одного и того же селектора */
#month-pick > .month-pick-summary { display: none; }
#month-pick > .month-chips { display: flex; }
@media (max-width: 640px) {
  /* на телефоне сам календарь (годы/месяцы/дни) съедал экран ещё до
     самого списка — прячем его за кнопкой, открывается по тапу */
  .row-form .period-toggle-btn {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
  }
  .period-toggle-icon { font-size: 18px; line-height: 1; }
  .period-toggle-label { font-weight: 600; font-size: 13px; color: var(--ink); }
  /* итоги Сводки за период — на свободном месте рядом с сузившейся кнопкой
     календаря; на десктопе не нужны (там уже видна вся таблица со своим
     «Итого»), report_totals туда и не передаётся отдельно — см. sales_visits.html */
  /* flex-basis:0 — та же грабля, что у .visits-calc-result: с flex-basis
     auto решение «влезает ли на текущую строку» браузер принимает по
     ПОЛНОЙ ширине текста («План 8  Посетил 0  Заказ 0  Оплата 0» одной
     строкой не влезает рядом с кнопкой), и переносил весь блок под низ
     вместо того, чтобы просто перенести его СОБСТВЕННЫЙ текст */
  .visits-mobile-totals {
    display: flex; flex: 1 1 0; flex-wrap: wrap; align-items: center;
    gap: 2px 10px; min-width: 0;
    background: #f4f5f6; border-radius: 8px; padding: 6px 10px;
    font-size: 11.5px; color: var(--muted); white-space: nowrap;
  }
  .visits-mobile-totals b { color: var(--ink); font-size: 12.5px; }
  /* #period-pick-box — специфичность через id, а не только класс: сама
     .period-pick описана ниже по файлу с той же специфичностью класса,
     и как правило CSS-каскада «позже в файле побеждает» перебило бы это
     display:none на любой ширине (уже наступали на эти грабли — см. память
     про точки подгрупп в сайдбаре) */
  #period-pick-box.period-pick { display: none; }
  /* открытый попап — то же самое всплывающее окно поверх страницы, что и
     «Выбор периода» в кабинете ТП (см. память «Выбор периода»): подложка
     гасит фон, сама карточка по центру со своей прокруткой */
  #period-pick-box.period-pick.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    left: 10px; right: 10px; top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    max-height: 86vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(36, 48, 61, .3);
    padding: 16px 14px;
    margin-top: 0;
  }
  .period-pick-back {
    position: fixed;
    inset: 0;
    z-index: 59;
    background: rgba(36, 48, 61, .45);
  }
  .period-pick-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
  .period-pick-title { display: block; }
  .period-pick-close { display: block; }

  /* .year-drop висел через position:absolute и не раздвигал соседей —
     на узкой ширине месяцы, перенесённые flex-wrap'ом под кнопку года,
     оказывались прямо под открытой выпадашкой. Через .period-pick для
     специфичности — сама .year-drop описана ниже по файлу с той же
     специфичностью класса, обычный порядок каскада её перебил бы. */
  .period-pick .year-drop {
    position: static;
    width: 100%;
    max-height: none;
    box-shadow: none;
    margin-top: 8px;
  }
  /* месяц на телефоне — такая же выпадашка, как и год (внутри попапа ей
     тесно открытой лентой); на ПК см. правило выше файла — там открыт
     всегда, безусловно. Открывает/закрывает JS через класс .open (см.
     комментарий в шаблоне про content-visibility у настоящих <details>) */
  #month-pick > .month-pick-summary { display: flex; }
  #month-pick > .month-chips { display: none; }
  #month-pick.open > .month-chips { display: flex; }
}

/* стрелки рядом с месяцем — только на телефоне (там весь отбор превратился
   в попап, стрелки — быстрая навигация внутри него). На ПК отбор как был,
   без стрелок — пользователь явно попросил ПК не трогать */
.month-nav { display: flex; align-items: stretch; gap: 6px; }
.month-step { display: none; }
@media (max-width: 640px) {
  .month-step { display: flex; flex-direction: column; gap: 2px; }
}
.month-step-btn {
  flex: 1;
  min-height: 18px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.month-step-btn:hover { color: var(--ink); border-color: var(--green); }
.calendar-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.period-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
/* поле поиска справа от «Сегодня» (Начисление) — form#period и .period-pick
   становятся флекс-соседями в одном ряду вместо строк друг под другом;
   .period-pick идёт первым (order:1), форма с полем поиска — следом
   (order:2), поэтому она встаёт как раз после чипов. На телефоне
   #period-pick-box.period-pick сам уходит в display:none (правило выше по
   файлу, с более высокой специфичностью через id) — форма остаётся видна
   там же, где и раньше, порядок ей уже не важен */
.card-box.period-pick-inline { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px 16px; }
.card-box.period-pick-inline #period { order: 2; margin: 0; flex: 0 1 auto; }
.card-box.period-pick-inline .period-pick { order: 1; margin-top: 0; }
/* лента месяцев (Все Янв…Дек + год + Сегодня) сама по себе широкая — на
   мониторах уже нормального рабочего размера поле встаёт сразу за
   «Сегодня» на одной строке; на более узких экранах переносится на свою
   строку под лентой (тот же .card-box, просто ниже) — тут ничего не
   ломается, тот же приём, что и у .row-form/.period-pick/.calendar-header */
.card-box.period-pick-inline #period input[type="search"] { flex: 1 1 200px; min-width: 140px; }
.year-pick { position: relative; }
/* #month-pick — обычный div (не <details>, см. комментарий в шаблоне про
   content-visibility), но несёт класс year-pick ради того же вида кнопки —
   отсюда общий селектор на оба варианта «шапки» (summary/.month-pick-summary) */
.year-pick > summary, .year-pick > .month-pick-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 104px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.year-pick > summary::-webkit-details-marker { display: none; }
.year-pick > summary::after, .year-pick > .month-pick-summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.year-pick[open] > summary, .year-pick.open > .month-pick-summary { border-color: var(--green); outline: 2px solid #e4f0de; }
.year-drop {
  position: absolute;
  z-index: 15;
  margin-top: 6px;
  min-width: 140px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(36, 48, 61, .12);
}
.year-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.year-line:hover { background: var(--bg); }
.year-line input { width: 16px; height: 16px; accent-color: var(--green); }

/* дашборд-карточки менеджеров на «Задолженности»: клик — тот же фильтр,
   что раньше был выпадающим списком, только сразу видно суммы */
.manager-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.manager-card {
  flex: 1 1 190px;
  min-width: 170px;
  max-width: 260px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
}
.manager-card:hover { border-color: var(--green); }
.manager-card.on { border-color: var(--green); background: #f2f8ef; box-shadow: 0 0 0 2px #e4f0de; }
.manager-card .name {
  font-weight: 700;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.manager-card .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.manager-card .row + .row { margin-top: 3px; }
.manager-card .row b { color: var(--ink); font-size: 14px; font-weight: 700; }
.manager-card .row.overdue b { color: var(--orange); }

/* месяцы одной лентой, как переключатель: активный выделен цветом */
.month-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--bg);
  border-radius: 10px;
}
.month-chips .chip, .today-chip {
  margin: 0;
  border: none;
  background: none;
  padding: 6px 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.month-chips .chip:hover, .today-chip:hover { background: #fff; }
.month-chips .chip.on, .today-chip.on { background: var(--green); color: #fff; }
.today-chip { border: 1px solid var(--line); background: #fff; }
.today-chip.on { border-color: var(--green); }

/* ---------- отгрузки: годы и месяцы ---------- */
.sales-year, .sales-month {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.sales-year > summary, .sales-month > summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.sales-year > summary::-webkit-details-marker,
.sales-month > summary::-webkit-details-marker { display: none; }
.sales-year > summary::before, .sales-month > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
}
.sales-year[open] > summary::before, .sales-month[open] > summary::before { content: "▾"; }
.sales-year > summary:hover, .sales-month > summary:hover { background: var(--bg); }
.sales-year > summary b { font-size: 16px; }
/* месяцы вложены и потому уже и мельче года */
.sales-month {
  margin: 0 12px 8px;
  border-color: #eef1f3;
}
.sales-month > summary { font-weight: 600; padding: 10px 14px; }
.sales-month-rows { padding: 0 12px 12px; }
.sales-month-rows .table-wrap { border: none; }

/* кнопка-ссылка: действие внутри строки таблицы, где полноценная кнопка
   разрывала бы текст */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  text-align: left;   /* браузер по умолчанию центрирует текст в <button> */
}
.link-btn:hover { color: var(--ink); }
.link-btn.danger-link:hover { color: #d43b3b; }
.hide-form { display: inline; }
td .hide-form { display: block; margin-top: 2px; }
/* исключённые покупатели: свёрнутая строка в самом низу страницы —
   инструмент нужен редко и не должен занимать рабочее поле */
.hidden-panel { margin-top: 18px; max-width: 460px; }
.hidden-panel > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  list-style: none;
}
.hidden-panel > summary::-webkit-details-marker { display: none; }
.hidden-panel > summary::before { content: "▸"; font-size: 10px; }
.hidden-panel[open] > summary::before { content: "▾"; }
.hidden-panel > summary:hover { color: var(--ink); }
.hidden-drop {
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}
.hidden-drop .hint { margin: 10px 0 0; }
.hidden-list { list-style: none; margin: 0 0 12px; padding: 0; }
.hidden-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.hidden-list li:last-child { border-bottom: none; }
.hide-add { display: flex; gap: 8px; align-items: center; }
.hide-add input { flex: 1; min-width: 0; padding: 6px 10px; font-size: 13px; }

/* ---------- аналитика продаж ---------- */
/* вкладки разрезов: один отбор периода, три взгляда на те же продажи */
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 12px;
}
.tab {
  padding: 9px 18px;
  border-radius: 8px 8px 0 0;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: none;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.tab:hover { background: var(--bg); }
.tab.on { background: var(--green); border-color: var(--green); color: #fff; }
.tabs-sort { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.tabs-sort .chip { margin-left: 6px; }

/* рост и падение к прошлому году */
.up { color: var(--green-dark); font-weight: 600; }
.down { color: #d43b3b; font-weight: 600; }
.stat-delta { font-size: 12px; margin-top: 6px; }
.stat-delta .hint { display: block; font-weight: 400; margin-top: 3px; }
/* было/стало — короткая цветная плашка вместо голого цветного текста:
   на пёстром дашборде из 7 плиток так проще выхватить взглядом рост/падение,
   чем читать текст того же веса, что и всё остальное вокруг */
.stat-delta .delta-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 700; font-size: 11.5px; }
.stat-delta.up .delta-badge { background: #e4f0de; color: var(--green-dark); }
.stat-delta.down .delta-badge { background: #fbe3e2; color: #d43b3b; }
.stat-delta.hint .delta-badge { background: var(--line); color: var(--muted); font-weight: 600; }

/* мотивация: отбор года, годовая сетка плана, итоги план/факт */
.year-switch { display: flex; align-items: center; gap: 8px; }
.year-switch select { width: auto; }
.badge-closed {
  display: inline-block; background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; font-size: 10.5px;
}
table.matrix.motiv-grid input { width: 76px; }
table.matrix.motiv-grid input.money-input { width: 76px; }
table.matrix.motiv-grid th form.hide-form { margin-top: 2px; font-weight: 400; }
table.matrix.motiv-grid .link-btn.small { font-size: 11px; }
/* три уровня выполнения показателя в «Итогах» — план/факт таблицах */
table.matrix td.fulfill-good { color: var(--green-dark); }
table.matrix td.fulfill-warn { color: var(--orange); }
table.matrix td.fulfill-bad { color: #d43b3b; cursor: help; }

table.report tfoot td { border-top: 2px solid var(--line); background: var(--bg); }
/* строка итогов над списком (Начисление → Ведомость) — тот же вид, что у
   tfoot снизу, но сама строка живёт в tbody (она не футер, а первая
   строка), поэтому граница снизу, а не сверху */
table.report tbody tr.payroll-totals-row td { border-bottom: 2px solid var(--line); background: var(--bg); }
/* автосохранение ячеек Ведомости — тот же приём, что и у клеток Табеля
   (.ts-cell.saved/.bad), только не завязан на конкретный компонент */
.payroll-cell.bad { border-color: #d43b3b; background: #fff6f6; }
.payroll-save-status.saved { color: var(--green-dark); }
.payroll-save-status.bad { color: #d43b3b; }
table.report .report-row.open { background: #f2f8ef; }
table.report .open-detail {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
  text-decoration: none;
  text-align: left;
}
table.report .open-detail::before { content: "▸ "; color: var(--muted); }
table.report .report-row.open .open-detail::before { content: "▾ "; }
table.report .open-detail:hover { text-decoration: underline; }
.detail-row > td { background: var(--bg); padding: 0; }
.detail-box { padding: 12px 16px; }
/* одна таблица занимает всю ширину, две встают рядом */
.detail-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.detail-part h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); }
.report-note { margin: 10px 2px 18px; }
.gone-box { margin-bottom: 20px; }
.gone-box > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; }
.gone-box > summary:hover { color: var(--ink); }

@media (max-width: 760px) {
  .detail-pair { grid-template-columns: 1fr; }
  .tabs { gap: 6px; }
  .tab { flex: 1; text-align: center; padding: 9px 10px; border-radius: 8px; border-bottom: 1px solid var(--line); }
  .tabs-sort { display: none; }
  /* строка-карточка: подробности разворачиваются во всю ширину */
  table.as-cards .detail-row { padding: 0; border: none; }
  table.as-cards .detail-row td { padding: 0; }
}

/* карточная раскладка ставит строкам display, из-за чего скрытая строка
   подробностей всё равно рисовалась: hidden должен побеждать */
[hidden] { display: none !important; }
/* рост к прошлому году под числом в столбце: мельче основного значения */
.small-delta { font-size: 11.5px; font-weight: 600; margin-top: 1px; }
/* заголовки-ссылки: по ним упорядочивается отчёт */
table.report thead th a { color: inherit; text-decoration: none; }
table.report thead th a:hover { color: var(--green-dark); text-decoration: underline; }
table.report thead th.sorted { color: var(--green-dark); }
table.report thead th .arrow { font-size: 9px; }

/* ---------- матрица «номенклатура × менеджеры» ---------- */
.matrix-wrap { overflow: auto; max-height: 76vh; }
/* вариант без внутренней вертикальной прокрутки (см. Табель) — таблица
   растёт вместе со страницей, скроллится только сама страница; по
   горизонтали (дни месяца) прокрутка остаётся своя, локальная */
.matrix-wrap.matrix-wrap-page { max-height: none; overflow-x: auto; overflow-y: visible; }
table.matrix { min-width: 100%; font-size: 13px; }
table.matrix th, table.matrix td { padding: 8px 12px; white-space: nowrap; }
/* шапка и первый столбец не уезжают при прокрутке — иначе непонятно,
   чья это клетка */
table.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  vertical-align: bottom;
}
table.matrix .name-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  white-space: normal;
  min-width: 240px;
  max-width: 320px;
  border-right: 1px solid var(--line);
}
table.matrix thead .name-col { z-index: 4; background: var(--bg); }
table.matrix tbody tr:hover td { background: #f2f8ef; }
table.matrix tbody tr:hover .name-col { background: #f2f8ef; }
table.matrix th a { color: inherit; text-decoration: none; }
table.matrix th a:hover { color: var(--green-dark); text-decoration: underline; }
table.matrix th.sorted { color: var(--green-dark); }
table.matrix .lead { color: var(--green-dark); font-weight: 700; }
table.matrix .total-col { border-left: 1px solid var(--line); background: #fbfcfb; }
/* итоги по столбцам внизу таблицы — не уезжают при прокрутке, как и шапка */
table.matrix tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--bg);
  border-top: 2px solid var(--line);
}
table.matrix tfoot .name-col { z-index: 4; background: var(--bg); }
table.matrix tfoot .total-col { background: var(--bg); }
/* ---------- Начисление → Табель: сетка «сотрудники × дни месяца» ---------- */
/* строится на той же матрице (липкая шапка и колонка с именем), но клетки
   узкие — 31 день должен помещаться на экран без горизонтальной прокрутки */
table.matrix.timesheet { --ts-num-w: 34px; }
table.matrix.timesheet th, table.matrix.timesheet td { padding: 4px 1px; }
/* .matrix-wrap-page не прокручивается по вертикали сам (см. ниже) — а раз
   так, у шапки нет своего скролл-бокса, относительно которого «липнуть»
   вертикально (position:sticky работает только внутри прокручивающегося
   контейнера, а не «сквозь» него до страницы, если тот же контейнер ещё
   и горизонтально прокручивается — overflow-x делает его именно таким
   контейнером). Шапка остаётся в потоке — не наезжает друг на друга и
   не переворачивается, просто уезжает вместе со страницей при скролле
   вниз; горизонтально (при скролле вправо по дням) № и Сотрудник
   по-прежнему прилипают — эта прокрутка своя, локальная, в .matrix-wrap */
/* № — своя липкая колонка перед именем (обычная .matrix её не знает,
   там первой липкой колонкой всегда была .name-col у left:0) */
table.matrix.timesheet .num-col {
  position: sticky;
  left: 0;
  z-index: 2;
  width: var(--ts-num-w);
  min-width: var(--ts-num-w);
  max-width: var(--ts-num-w);
  background: #fff;
  text-align: center;
  color: var(--muted);
  border-right: 1px solid var(--line);
}
table.matrix.timesheet thead .num-col { z-index: 4; background: var(--bg); }
table.matrix.timesheet tbody tr:hover .num-col { background: #f2f8ef; }
/* имя сдвинуто вправо ровно на ширину № — иначе они наложились бы друг на
   друга при горизонтальной прокрутке (обе колонки sticky) */
table.matrix.timesheet .name-col { left: var(--ts-num-w); min-width: 170px; max-width: 200px; padding: 4px 10px; }
table.matrix.timesheet .name-col .hint { font-size: 11px; }
table.matrix.timesheet th.ts-day { text-align: center; font-size: 12px; padding-bottom: 0; }
table.matrix.timesheet th.ts-wd {
  top: 22px;                       /* второй ряд шапки — под числами (см. комментарий выше про .matrix-wrap-page) */
  text-align: center; font-weight: 400; font-size: 10px; color: var(--muted);
  text-transform: lowercase; padding-top: 0;
}
table.matrix.timesheet th.off { color: #b45309; }
table.matrix.timesheet td.off, table.matrix.timesheet th.ts-day.off { background: #f3f5f2; }
/* нерабочий праздник РК — красным и с подсказкой (название в title), чтобы
   его не путали с обычной субботой: у бухгалтерии это разные дни */
table.matrix.timesheet th.holiday { color: #c0392b; }
table.matrix.timesheet th.ts-day.holiday { font-weight: 800; }
table.matrix.timesheet td.holiday, table.matrix.timesheet th.ts-day.holiday { background: #fdf1ef; }
table.matrix.timesheet td.holiday.pre-hire { background: #edeff1; }
table.matrix.timesheet td.ts-cell-td { padding: 1px 0; text-align: center; }
/* дни до выхода на работу: поля ввода нет вовсе — не «серое, но кликнешь и
   впишешь», а именно нечего заполнять */
table.matrix.timesheet td.ts-cell-td.pre-hire { background: #edeff1; }
.ts-pre-hire { color: #9aa5b0; font-size: 12px; }
table.matrix.timesheet .name-col .ts-hire { white-space: nowrap; }
table.matrix.timesheet td.total-col, table.matrix.timesheet th.total-col { padding: 4px 6px; }
/* через .ts-cell-td: у общего правила input[type="text"] специфичность выше
   одного класса, и голый .ts-cell проигрывал ему ширину со шрифтом */
.ts-cell-td .ts-cell {
  width: 27px; padding: 3px 0; text-align: center; font-size: 12px;
  border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: var(--ink);
}
.ts-cell-td .ts-cell:hover:not(:disabled) { border-color: var(--line); }
.ts-cell-td .ts-cell:focus { outline: none; border-color: var(--green-dark); background: #fff; }
.ts-cell-td .ts-cell:disabled { color: var(--muted); }
/* короткая зелёная вспышка — единственное подтверждение, что клетка ушла
   на сервер: кнопки «Сохранить» у табеля нет */
.ts-cell-td .ts-cell.saved { background: #e3f3dc; }
.ts-cell-td .ts-cell.bad { border-color: #c0392b; background: #fdecea; }
/* цвет по типу отметки — часы и каждая буква своим, иначе на плотной
   таблице (31 колонка, много строк) все клетки сливаются в одинаковый
   серый текст и приходится всматриваться в каждую. Идут после :disabled,
   чтобы не глохли в закрытом (только на просмотр) табеле — там читаемость
   нужна ровно так же. data-mark ставит шаблон при отрисовке и скрипт
   сохранения — после каждого AJAX-сохранения ячейки */
.ts-cell-td .ts-cell[data-mark="ч"] { color: #2f7d32; font-weight: 700; }  /* часы — зелёный, «отработано» */
.ts-cell-td .ts-cell[data-mark="В"] { color: #1565c0; font-weight: 700; }  /* выходной — синий */
.ts-cell-td .ts-cell[data-mark="О"] { color: #00897b; font-weight: 700; }  /* отпуск — бирюзовый */
.ts-cell-td .ts-cell[data-mark="Б"] { color: #e65100; font-weight: 700; }  /* больничный — янтарный */
.ts-cell-td .ts-cell[data-mark="К"] { color: #6a1b9a; font-weight: 700; }  /* командировка — фиолетовый */
.ts-cell-td .ts-cell[data-mark="П"] { color: #c62828; font-weight: 700; }  /* прогул — красный, тревожный */
.ts-cell-td .ts-cell[data-mark="З"] { color: #8d6e63; font-weight: 700; }  /* за свой счёт — коричневый */
.ts-cell-td .ts-cell[data-mark="Т"] { color: #ad1457; font-weight: 700; }  /* отстранён — тёмно-розовый, тревожный */
table.matrix.timesheet td.total-col { text-align: center; font-weight: 700; }
table.matrix.timesheet td.total-col.mark { font-weight: 400; color: var(--muted); }

/* карточка сотрудника после сохранения: якорь не должен уезжать под шапку */
.staff-card { scroll-margin-top: calc(var(--topbar) + 16px); }

/* группы номенклатуры в отчёте: свёрнутыми видны только итоги направлений */
table.report .grp-row td { font-weight: 600; }
table.report .grp-row .open-grp { font-size: 14px; font-weight: 700; color: var(--ink);
  text-decoration: none; }
table.report .grp-row .open-grp::before { content: "▸ "; color: var(--muted); font-size: 11px; }
table.report .grp-row.open .open-grp::before { content: "▾ "; }
/* уровни дерева: каждая ступень чуть правее предыдущей */
table.report .lvl-1 td:first-child { padding-left: 26px; }
table.report .lvl-2 td:first-child { padding-left: 46px; }
table.report .lvl-3 td:first-child { padding-left: 66px; }
table.report .lvl-0.grp-row td { background: var(--bg); }
table.report .lvl-1.grp-row td { background: #fbfcfb; }
table.report .grp-row.lvl-1 .open-grp { font-size: 13.5px; }
table.report .grp-row.lvl-2 .open-grp { font-size: 13px; font-weight: 600; }
/* группы в матрице «кто что продаёт» */
table.matrix .lvl-0.grp-row td, table.matrix .lvl-0.grp-row .name-col { background: var(--bg); }
table.matrix .lvl-1.grp-row td, table.matrix .lvl-1.grp-row .name-col { background: #fbfcfb; }
table.matrix .grp-row .open-grp { font-size: 13px; font-weight: 700; color: var(--ink); }
table.matrix .grp-row.lvl-1 .open-grp { font-size: 12.5px; }
table.matrix .grp-row .open-grp::before { content: "▸ "; color: var(--muted); font-size: 11px; }
table.matrix .grp-row.open .open-grp::before { content: "▾ "; }
/* каждая ступень дерева правее предыдущей */
table.matrix .lvl-1 .name-col { padding-left: 26px; }
table.matrix .lvl-2 .name-col { padding-left: 46px; }
table.matrix .lvl-3 .name-col { padding-left: 66px; }
/* товар, попавший в группу по совпадению названия, а не по артикулу */
.guessed { color: var(--muted); font-size: 12px; cursor: help; }
/* значок-подсказка рядом с заголовком/меткой — наведение показывает title */
.info-hint { color: var(--muted); font-size: 12px; cursor: help; }

/* ---------- карточка во всплывающем окне ---------- */
.card-modal { position: fixed; inset: 0; z-index: 60; display: flex;
              align-items: center; justify-content: center; padding: 24px; }
.card-modal-back { position: absolute; inset: 0; background: rgba(36, 48, 61, .45); }
.card-modal-box {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(36, 48, 61, .3);
  width: min(920px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px 24px;
}
.card-modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 24px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.card-modal-close:hover { color: var(--ink); }
.card-title { font-size: 18px; margin: 0 6px 6px 0; color: var(--ink); }
.card-sub { margin: 0 0 16px; line-height: 1.5; }
.card-stats { margin-bottom: 16px; }
@media (max-width: 700px) {
  .card-modal { padding: 10px; }
  .card-modal-box { padding: 18px 14px 16px; max-height: 92vh; }
}

/* календарь дней под лентой месяцев: виден, когда выбран один месяц */
.day-chips {
  flex: 1 0 100%;      /* своя строка под лентой месяцев */
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
  padding: 4px;
  background: var(--bg);
  border-radius: 10px;
}
.day-chips .hint { padding: 0 6px; }
/* на ПК — как и было всегда: числа свободно текущей лентой, без привязки
   к дню недели, пустые ячейки-заглушки (нужны только календарной сетке
   на телефоне, см. ниже) тут не показываем вовсе. Настоящая календарная
   сетка 7 столбцов (Пн..Вс, суббота/воскресенье всегда в конце строки,
   день 1 — с отступом-заглушками до понедельника, см. app.календарь_месяца)
   — только в мобильном попапе (медиа-запрос ниже файла) */
.day-chips .day-list { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.day-chips .chip.blank { display: none; }
.day-chips .chip {
  margin: 0;
  border: none;
  background: none;
  padding: 3px 7px;
  text-align: center;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.15;
}
.day-chips .chip.blank { cursor: default; pointer-events: none; }
.day-chips .chip b { display: block; }
/* день недели мелко под числом: сразу видно, суббота это или вторник */
.day-chips .wd { display: block; font-size: 9.5px; font-weight: 500; color: var(--muted); }
/* план/факт посещений выбранного ТП под числом — см. Отдел продаж →
   Посещения → Отчёт; на остальных отчётах day_stats не передаётся,
   блок просто не рендерится */
.day-chips .day-stat { display: block; font-size: 9.5px; font-weight: 700; color: var(--green-dark, #2f9e44); }
.day-chips .chip:hover { background: #fff; }
.day-chips .chip.on { background: var(--green); color: #fff; }
.day-chips .chip.on .wd { color: #e6f2e0; }
.day-chips .chip.on .day-stat { color: #fff; }
/* выходные и праздники: цифра красная, у праздника подпись «пр» */
.day-chips .chip.off { color: #d43b3b; }
.day-chips .chip.off .wd { color: #e08a86; }
.day-chips .chip.off.on { background: #d43b3b; color: #fff; }
.day-chips .chip.off.on .wd { color: #fadedd; }
/* сегодняшнее число — тонкая зелёная рамка, чтобы сразу видеть, где
   сегодня, даже если оно не отмечено (тот же приём, что и в личном
   кабинете, см. cabinet.css .cb-cal-cell.today). Отмеченный день и так
   выделен заливкой — рамка поверх неё не нужна */
.day-chips .chip.today:not(.on) { box-shadow: inset 0 0 0 1.5px var(--green); }
/* текущий год в списке — та же рамка, у самой строки */
.year-line.today { box-shadow: inset 0 0 0 1.5px var(--green); }

@media (max-width: 640px) {
  /* в мобильном попапе, наоборот, — настоящая календарная сетка 7 столбцов
     (Пн..Вс), суббота с воскресеньем всегда в конце строки, день 1 —
     с отступом-заглушками до понедельника (см. app.календарь_месяца);
     на ПК числа текут свободной лентой без этого — правило выше файла.
     «День:» тут не нужен — и без подписи понятно, что это дни; «Все»
     переезжает в угол блока, а числа занимают всю ширину сверху донизу,
     а не делят строку с подписью и кнопкой */
  .day-chips { position: relative; padding: 34px 4px 4px; }
  .day-chips .hint { display: none; }
  .day-chips [data-all-days] { position: absolute; top: 4px; right: 4px; }
  .day-chips .day-list { display: grid; grid-template-columns: repeat(7, 1fr); width: 100%; }
  .day-chips .chip.blank { display: block; }
}

/* ---------- телефон: звонок или WhatsApp ---------- */
.phone-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--green-dark);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
  white-space: nowrap;
}
.phone-link:hover { color: var(--green); }
.phone-menu {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.phone-menu .back { position: absolute; inset: 0; background: rgba(36, 48, 61, .35); }
.phone-menu .box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(36, 48, 61, .28);
  width: min(320px, 100%);
  padding: 18px;
  text-align: center;
}
.phone-menu .num { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.phone-menu a, .phone-menu button.cancel {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.phone-menu a.call { background: var(--green); border-color: var(--green); color: #fff; }
.phone-menu a.wa { background: #25d366; border-color: #25d366; color: #fff; }
.phone-menu button.cancel { color: var(--muted); }

/* плавающий «Чат» — коллеги + ИИ-помощник одним списком абонентов,
   WhatsApp-подобный — поверх любой страницы CRM, в правом нижнем углу */
.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));   /* не под "домиком" iPhone */
  z-index: 80;
}
/* на страницах с мобильной панелью действий (например, «Выставить КП»)
   кнопка чата иначе съезжает на панель — поднимаем её над панелью */
@media (max-width: 640px) {
  body.has-actionbar .chat-widget { bottom: calc(96px + 12px); }
}
.chat-widget-toggle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 24px rgba(36, 48, 61, .3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.chat-widget-toggle:hover { background: var(--green-dark); }
.chat-widget.open .chat-widget-toggle { display: none; }
.chat-widget-toggle .bell-count {
  position: absolute; top: -2px; right: -2px; margin-left: 0;
}

.chat-widget-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(820px, calc(100vw - 40px));
  height: min(600px, calc(100vh - 100px));
  height: min(600px, calc(100dvh - 100px));   /* учитывает адресную строку/клавиатуру телефона */
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(36, 48, 61, .3);
  display: flex;
  overflow: hidden;
}

/* левая колонка — список абонентов (ИИ закреплён сверху + переписки) */
.chat-list {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;   /* иначе список абонентов растягивает панель вместо своей внутренней прокрутки */
  background: var(--bg);
}
.chat-list-head {
  background: var(--green);
  color: #fff;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-list-close {
  background: none; border: none; color: #fff; cursor: pointer;
  width: 32px; height: 32px; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
/* переключатель «Сотрудники»/«Покупатели» — только когда сотруднику
   доступны оба вида переписки, см. _chat_widget.html */
.chat-list-tabs { display: flex; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.chat-list-tab {
  flex: 1; border: none; background: none; cursor: pointer; font: inherit;
  padding: 9px 4px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent;
}
.chat-list-tab.on { color: var(--ink); font-weight: 700; border-bottom-color: var(--green); }
.chat-list-search { padding: 8px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-list-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 20px;
  padding: 7px 12px; font-size: 13px; font-family: inherit;
}
/* overscroll-behavior — иначе на телефоне прокрутка «протекает» на
   страницу под чатом, когда список докручен до края */
.chat-list-items { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font: inherit; color: inherit; border-bottom: 1px solid var(--line);
}
.chat-list-item:hover, .chat-list-item.on { background: #eef1ee; }
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff; font-weight: 700; font-size: 14px;
}
/* фото из карточки сотрудника вместо кружка с инициалами */
img.chat-avatar { object-fit: cover; background: var(--line); }
.chat-avatar.ai { background: linear-gradient(135deg, #6a5acd, #8a6dd8); font-size: 18px; }
.chat-list-item-body { flex: 1; min-width: 0; }
.chat-list-item-top { display: flex; justify-content: space-between; gap: 6px; }
.chat-list-item-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.chat-list-item-preview {
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.chat-list-item-unread {
  background: var(--green); color: #fff; border-radius: 10px; min-width: 18px; height: 18px;
  font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}
.chat-list-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-list-section { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }

/* правая колонка — сама переписка */
.chat-conv { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-conv-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13.5px; text-align: center; padding: 20px; background: var(--bg);
}
.chat-conv-head {
  background: var(--green); color: #fff; padding: 4px 6px 4px 14px;
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.chat-conv-back { display: none; background: none; border: none; color: #fff; cursor: pointer; font-size: 20px; }
.chat-conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-close { background: none; border: none; color: #fff; cursor: pointer; width: 40px; height: 40px; font-size: 22px; line-height: 1; flex-shrink: 0; }
/* строка статуса переписки с покупателем («Свободно/В работе» + «Взять
   в работу»/«Закрыть») — раньше кнопки оформлялись инлайновым стилем
   прямо в JS (браузерное подчёркивание, цвет "inherit"/"#d33"); теперь
   классами, чтобы вид определял CSS, а не строка в _chat_widget.html.
   Без body.v2 — этот блок нигде не был оформлен вовсе, чинится для
   всех ролей разом, не только для нового дизайна */
.chat-conv-sub {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12px;
}
.chat-status-action {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--green-dark); margin-left: 10px;
}
.chat-status-action:hover { text-decoration: underline; }
.chat-status-action.danger { color: #d43b3b; }
.chat-conv-body {
  flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--bg);
}
.chat-conv-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
.chat-conv-form input[type=text] {
  flex: 1; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px;
  font-size: 13.5px; font-family: inherit; width: auto;
}
.chat-conv-attach { background: none; border: none; cursor: pointer; font-size: 20px; padding: 6px; flex-shrink: 0; }
/* display:flex — иконка-«самолётик» внутри круглой кнопки должна стоять
   ровно по центру, а не на базовой линии текста, как inline-block у .btn */
.chat-conv-send {
  width: 40px; height: 40px; border-radius: 50%; padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat-msg-typing { color: var(--muted); font-style: italic; }
.chat-msg-error { border-color: #e3b3b3 !important; background: #fdf2f2 !important; color: #a13a3a !important; }

/* дублирую чуть более компактные пузыри переписки — своя лента внутри
   .chat-conv-body, не .chat-lines (там своя шапка «Видят и пишут» для
   группового чата дела, здесь всегда 1:1 или с ИИ) */
.chat-msg { display: flex; flex-direction: column; margin-bottom: 10px; max-width: 100%; }
.chat-msg > span, .chat-msg > .bubble {
  padding: 8px 12px; border-radius: 12px; max-width: 78%; white-space: pre-wrap;
  word-break: break-word; font-size: 13.5px; line-height: 1.4; display: inline-block;
}
.chat-msg.mine { align-items: flex-end; }
.chat-msg.mine > span, .chat-msg.mine > .bubble { background: var(--green); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.theirs > span, .chat-msg.theirs > .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.chat-msg small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.chat-msg .ticks { color: var(--muted); }
.chat-msg .ticks.read { color: #4fc3f7; }

@media (max-width: 700px) {
  /* на телефоне чат занимает экран целиком, как WhatsApp: не плавающее
     окошко с полями по краям, а полноэкранный слой — иначе и мазать
     пальцем мимо, и видно прокручивающуюся страницу под ним */
  .chat-widget-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;   /* без адресной строки браузера, иначе низ уезжает */
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    flex-direction: column;
    /* «чёлка» и домашняя полоса iPhone: box-sizing:border-box глобальный,
       так что отступы съедаются изнутри 100dvh, а не добавляются к нему */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .chat-list { width: 100%; border-right: none; }
  .chat-conv-back { display: flex; align-items: center; justify-content: center; }
  /* по умолчанию список; открытая переписка перекрывает список целиком —
     как WhatsApp на телефоне, не две узкие колонки одновременно */
  .chat-widget-panel:not(.show-conv) .chat-conv { display: none; }
  .chat-widget-panel.show-conv .chat-list { display: none; }
}

@media (max-width: 480px) {
  .chat-widget { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  /* меньше 16px в поле ввода — Safari на iPhone зумит страницу при фокусе */
  .chat-conv-form input[type=text] { font-size: 16px; }
}

/* пока чат открыт на телефоне — страница под ним не прокручивается */
body.chat-open { overflow: hidden; }

/* ---------- Финансовый календарь ---------- */
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: #c23b3b; }
td.num.pos { color: var(--green-dark); }
td.num.neg { color: #c23b3b; }

.fin-cal-wrap { overflow-x: auto; }
.fin-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 6px;
  min-width: 784px;
}
.fin-cal-weekday {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.fin-cal-weekday.weekend { color: #2f6fa8; }

.fin-cal-day {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  cursor: pointer;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.fin-cal-day:hover { border-color: var(--green); }
.fin-cal-day:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.fin-cal-day.pad { border: none; background: none; cursor: default; min-height: 0; }
a.fin-cal-day { text-decoration: none; color: inherit; display: block; }
/* .fin-cal-grid.fin-cal-year-grid (обе части класса) — специфичность выше,
   чем у одноклассовых .fin-cal-grid из мобильной переопределения ниже,
   поэтому годовая сетка не зависит от порядка правил в файле */
.fin-cal-grid.fin-cal-year-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); min-width: 0; }
.fin-cal-year-grid .fin-cal-day { min-height: 118px; }
@media (max-width: 700px) {
  .fin-cal-grid.fin-cal-year-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
.fin-cal-day.weekend { background: #fafcff; }
.fin-cal-day.pos { background: #f2f8ef; }
.fin-cal-day.neg { background: #fdf1f1; }
.fin-cal-day.today { box-shadow: inset 0 0 0 2px var(--green); }
.fin-cal-day.selected { box-shadow: inset 0 0 0 2px #2f6fa8; border-color: #2f6fa8; }

.fin-cal-day-head { display: flex; align-items: center; justify-content: space-between; }
.fin-cal-day-head b { font-size: 14px; }
.fin-cal-day-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 6px;
}
.fin-cal-day-lines { margin-top: 6px; font-size: 11px; line-height: 1.5; }
.fin-cal-day-lines .line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-cal-day-lines .line.in { color: var(--green-dark); }
.fin-cal-day-lines .line.out { color: #c23b3b; }
.fin-cal-day-total {
  margin-top: 4px;
  font-weight: 800;
  font-size: 13px;
  text-align: right;
}
.fin-cal-day.pos .fin-cal-day-total { color: var(--green-dark); }
.fin-cal-day.neg .fin-cal-day-total { color: #c23b3b; }

@media (max-width: 700px) {
  .fin-cal-year { margin-left: 0; }
  .fin-cal-grid { grid-template-columns: repeat(7, minmax(96px, 1fr)); min-width: 672px; }
  .fin-cal-day { min-height: 78px; padding: 6px; }
}

/* ---------------------------------------------- Мотивация: гейт/growth */
.gate-cell { min-width: 120px; }
.gate-cell select { width: 100%; }
.gate-mults { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.gate-mults label { display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; }
.gate-mults input { width: 44px; }
.bonus-config-cell textarea { resize: vertical; }

/* -------------------------------------------------- Отдел продаж → Чек-листы */

.star-rate { display: inline-flex; gap: 2px; align-items: center; }
.star-rate .star {
  border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer;
  color: var(--line); padding: 2px;
}
.star-rate.readonly .star { cursor: default; font-size: 18px; }
.star-rate .star.on { color: #f0b429; }

.cl-criterion {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
}
.cl-criterion-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.cl-criterion textarea { width: 100%; }
.cl-criterion-photo { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cl-subgroups { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 4px; }

.cl-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.cl-photo-thumb {
  position: relative; width: 90px; height: 90px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line); flex-shrink: 0;
}
.cl-photo-thumb.small { width: 64px; height: 64px; }
.cl-photo-thumb img.cl-photo { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.cl-photo-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(20, 24, 30, .65); color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer;
}

.cl-lightbox {
  position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
}
.cl-lightbox-back { position: absolute; inset: 0; background: rgba(10, 14, 20, .86); }
.cl-lightbox img {
  position: relative; max-width: 90vw; max-height: 88vh; border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.cl-lightbox-close, .cl-lightbox-nav {
  position: absolute; z-index: 1; border: none; background: rgba(255, 255, 255, .12); color: #fff;
  cursor: pointer; border-radius: 50%;
}
.cl-lightbox-close { top: 18px; right: 22px; width: 36px; height: 36px; font-size: 18px; }
.cl-lightbox-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 22px; }
.cl-lightbox-nav.prev { left: 18px; }
.cl-lightbox-nav.next { right: 18px; }
.cl-lightbox-close:hover, .cl-lightbox-nav:hover { background: rgba(255, 255, 255, .25); }

/* Отдел продаж → Обучение: сетка карточек групп/подгрупп/материалов и вьюер */
.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.training-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--border, #e3e6ea);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.training-tile:hover {
  border-color: var(--green, #2f9e44);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.training-tile-name { font-weight: 600; margin-bottom: 4px; }

/* Вьюер — всегда во всю ширину блока, чтобы на телефоне картинка/видео
   занимали максимум экрана (сознательно НЕ уводим на отдельную вкладку,
   как это делает s-pdf на витрине — там это удобство, здесь это отдало бы
   файл системному просмотрщику телефона напрямую) */
.training-viewer {
  width: 100%;
  background: #14181e;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  user-select: none;
}
.training-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9aa3af;
  font-size: 14px;
  z-index: 0;
}
.training-viewer-frame {
  display: block;
  width: 100%;
  height: 75vh;
  border: 0;
  position: relative;
  z-index: 1;
  background: #000;
}
.training-viewer-mobile-pdf {
  height: auto;
  padding: 40px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 900px) {
  .training-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .training-viewer-frame { height: calc(100vh - 210px); }
}

/* Реклама — своя копия сетки/плитки Обучения, не общий класс: разные,
   не связанные разделы не должны шарить один CSS-неймспейс. Плитка тут
   с превью (фото/баннер сверху) вместо чистого текста-с-иконкой. */
.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.ads-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--border, #e3e6ea);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.ads-tile:hover {
  border-color: var(--green, #2f9e44);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.ads-tile-thumb {
  height: 120px;
  background: #f2f4f6 center/cover no-repeat;
  position: relative;
}
.ads-tile-icon { display: flex; align-items: center; justify-content: center; font-size: 34px; }
/* крупный значок ▶ поверх обложки видео — чтобы плитка сразу отличалась
   от фото, не только по названию файла (см. _ads_material_tile.html) */
.ads-tile-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; padding-left: 3px; /* оптический центр треугольника */
}
.ads-tile-name { font-weight: 600; padding: 10px 14px 2px; }
.ads-tile > .hint, .ads-tile-name + .hint { padding: 0 14px 12px; }

.ads-viewer { width: 100%; background: #eceff1; border-radius: 10px; overflow: hidden; }
.ads-viewer-frame { display: block; width: 100%; max-height: 75vh; border: 0; background: #eceff1; }
img.ads-viewer-frame { object-fit: contain; background: #eceff1; }

@media (max-width: 900px) {
  .ads-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

/* строка «Итого» — и под шапкой таблицы, и в подвале (Посещения →
   Отчёт → Сводка): серый фон как у th, но без uppercase/letter-spacing,
   чтобы не читалась как ещё один заголовок колонки */
.totals-row td { background: #fafbfa; font-size: 13px; }

/* Отдел продаж → Посещения */
.visits-tp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.visits-tp-card {
  background: #fff;
  border: 1px solid var(--border, #e3e6ea);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.visits-tp-card:hover {
  border-color: var(--green, #2f9e44);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.visits-tp-card-name { font-weight: 600; margin-bottom: 6px; }
.visits-tp-card-count { font-size: 20px; font-weight: 700; }
.visits-tp-card-count .hint { font-size: 13px; font-weight: 400; }
.visits-tp-card.on { border-color: var(--green, #2f9e44); background: #eaf6e5; }
.visits-tp-report-row { font-size: 13px; margin-top: 3px; }
.visits-tp-report-row .hint { display: inline-block; min-width: 92px; }
@media (max-width: 900px) {
  .visits-tp-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}
.visit-marks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.visit-marks label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.visit-extra { margin-top: 8px; }
.visit-extra summary { cursor: pointer; }
.visit-comment { width: 100%; margin-top: 6px; resize: vertical; }
.visit-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.visit-photo-thumb { position: relative; display: inline-block; }
.visit-photo-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border, #e3e6ea); }
.visit-photo-remove {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; line-height: 16px;
  border-radius: 50%; border: none; background: var(--danger, #d64545); color: #fff;
  font-size: 12px; cursor: pointer; padding: 0;
}
.visit-day-group {
  background: #fff;
  border: 1px solid var(--border, #e3e6ea);
  border-radius: 8px;
  margin: 12px 0;
}
.visit-day-group > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.visit-day-group > summary::-webkit-details-marker { display: none; }
.visit-day-group > summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
.visit-day-group[open] > summary::before { content: "▾"; }
.visit-day-group > summary:hover { background: var(--bg); }
.visit-day-group > .table-wrap { margin: 0 12px 12px; }
.visits-photo-day { display: flex; flex-direction: column; gap: 10px; }
.visits-photo-entry .visit-photo-thumb-img {
  width: 90px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border, #e3e6ea);
}

/* Отчёт → Сводка на телефоне: обычная карточка .as-cards кладёт каждую
   из 7 колонок на свою строку — с длинными подписями («План визитов»)
   и однозначными числами получалась вытянутая карточка с кучей пустого
   места. Тут вместо построчного списка — имя/день одной строкой, а
   план/факт/заказ/оплата вместе оборачиваются в компактную вторую
   строку (flex-wrap вместо display:block). */
@media (max-width: 640px) {
  table.visits-summary tbody tr, table.visits-summary tfoot tr {
    display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; row-gap: 2px;
  }
  table.visits-summary td { padding: 2px 0; }
  table.visits-summary td.visits-num-cell { order: 1; color: var(--muted); }
  table.visits-summary td.visits-num-cell::before { display: none; }
  table.visits-summary td.name-cell {
    order: 2; flex: 1 1 auto; min-width: 55%; font-size: 14px; font-weight: 600; padding-right: 0;
  }
  table.visits-summary td.visits-tp-cell { order: 3; flex: 0 0 100%; font-size: 12.5px; color: var(--muted); }
  table.visits-summary td.visits-tp-cell::before { display: none; }
  table.visits-summary td.visits-day-cell { order: 4; flex: 0 0 auto; font-size: 12.5px; color: var(--muted); }
  table.visits-summary td.visits-day-cell::before { display: none; }
  table.visits-summary td.num { order: 5; flex: 0 0 auto; font-size: 13px; }
  table.visits-summary td.num::before { min-width: 0; margin-right: 3px; }
  table.visits-summary .totals-row td.name-cell { color: var(--green-dark, #2f9e44); }
}

/* ------------------------------------ Закупки → Расчёт себестоимости */

/* компактное поле ввода в узкой ячейке таблицы — .mini-input тут не
   подходит (у него min-width:170px, для таблицы с десятком колонок
   это слишком широко) */
.costing-input {
  box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 6px; font: inherit; font-size: 13px;
}

/* .costing-input текстовый ставится в .money-input-decimal (разделитель
   тысяч + дробная часть — см. base.html), у него нет нативных стрелок
   ввода, поэтому рисуем свои поверх поля — тот же приём для любого
   .spin-money где бы он ни встретился */
.spin-money { position: relative; display: inline-block; width: 100%; }
.spin-money .money-input-decimal { width: 100%; padding-right: 18px; text-align: right; }
.spin-money-arrows {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 15px;
  display: flex; flex-direction: column;
}
.spin-money-arrows button {
  flex: 1 1 0; min-height: 0; border: none; border-left: 1px solid var(--line);
  background: #f7f8fa; color: var(--muted); cursor: pointer; padding: 0;
  font-size: 7px; line-height: 1;
}
.spin-money-arrows button:hover { background: var(--line); }
.spin-up { border-radius: 0 5px 0 0; }
.spin-down { border-radius: 0 0 5px 0; border-top: 1px solid var(--line); }

/* фиксированные (sticky) первые колонки — включаются тумблером «Фикс»,
   чтобы №/Артикул/Наименование не убегали при скролле широкой таблицы
   с наценками вправо */
.costing-fix .costing-sticky-th, .costing-fix .costing-sticky-td {
  position: sticky; background: #fff; z-index: 2;
}
.costing-fix th.costing-sticky-th:nth-child(1), .costing-fix td.costing-sticky-td:nth-child(1) { left: 0; }
.costing-fix th.costing-sticky-th:nth-child(2), .costing-fix td.costing-sticky-td:nth-child(2) { left: 40px; }
.costing-fix th.costing-sticky-th:nth-child(3), .costing-fix td.costing-sticky-td:nth-child(3) { left: 130px; }
.costing-fix thead th.costing-sticky-th { z-index: 3; }

/* разворот таблицы на весь экран — кнопка ⤢ в панели инструментов.
   Кнопка «Свернуть» лежит в разметке всегда, но видна только в этом
   режиме — иначе кнопка-переключатель ⤢ в панели инструментов уходит
   под таблицу, и свернуть обратно нечем (sticky — видна при любой
   прокрутке длинной таблицы, не только сверху) */
#costing-fullscreen-exit { display: none; }
.costing-fullscreen {
  position: fixed; inset: 12px; z-index: 70; background: #fff;
  border-radius: 10px; padding: 12px; overflow: auto; box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.costing-fullscreen #costing-fullscreen-exit {
  display: block; position: sticky; top: 0; float: right; z-index: 80; margin-bottom: 8px;
}

/* карточка наценки — перетаскивание для смены порядка (та же идея, что
   и у _prices_tree.html: состояние в JS-переменной, не в dataTransfer) */
#costing-markups .card-box.dragging { opacity: .5; }

/* ---------- Редизайн — Посещения (.visits-v2), 05.09.2026 ----------
   Шаг 4 плана (десктопные страницы ТП/менеджера) ещё не начат целиком —
   сайдбар/шапка тут не трогаются, только контент этой страницы. Шрифты
   подключает сама sales_visits.html через head_extra, поэтому все правила
   скопом под .visits-v2 и не задевают остальные десктопные страницы,
   которые используют те же общие классы (.tabs, .btn, table, .card-box). */
.visits-v2 { font-family: "Barlow", system-ui, sans-serif; --v2-corner: color-mix(in srgb, var(--ink) 35%, transparent); }
.visits-v2 h1 { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; font-size: 30px; margin: 0 0 4px; }
.visits-v2 .subtitle { font-size: 13px; }

.visits-v2 .tabs { border-bottom: 1px solid var(--line); gap: 0; margin: 18px 0 20px; }
.visits-v2 .tab {
  border: none; border-radius: 0; border-bottom: 2px solid transparent; background: none;
  padding: 10px 18px 9px; margin-bottom: -1px;
  font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.visits-v2 .tab:hover { background: none; color: var(--ink); }
.visits-v2 .tab.on { background: none; color: var(--green); border-bottom-color: var(--green); }

.visits-v2 .table-wrap { border-radius: 0; }
.visits-v2 table { font-family: "Barlow", system-ui, sans-serif; }
.visits-v2 th {
  font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; background: #fff;
}
.visits-v2 th, .visits-v2 td { border-bottom: 1px solid var(--line); }
.visits-v2 .name-cell, .visits-v2 td b { font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 15px; font-weight: 600; }
.visits-v2 tr.totals-row td, .visits-v2 tr.totals-row td b { font-family: "Barlow Condensed", system-ui, sans-serif; }

.visits-v2 .btn { border-radius: 0; font-family: "Barlow Condensed", system-ui, sans-serif; letter-spacing: .02em; }
.visits-v2 .card-box { border-radius: 0; }
.visits-v2 .card-part { font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 15px; }

.visits-v2 .visits-tp-grid { gap: 10px; }
.visits-v2 .visits-tp-card { border-radius: 0; border-color: var(--line); position: relative; }
.visits-v2 .visits-tp-card::before {
  content: ""; position: absolute; inset: -5px; pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    linear-gradient(var(--v2-corner), var(--v2-corner)), linear-gradient(90deg, var(--v2-corner), var(--v2-corner)),
    linear-gradient(var(--v2-corner), var(--v2-corner)), linear-gradient(90deg, var(--v2-corner), var(--v2-corner)),
    linear-gradient(var(--v2-corner), var(--v2-corner)), linear-gradient(90deg, var(--v2-corner), var(--v2-corner)),
    linear-gradient(var(--v2-corner), var(--v2-corner)), linear-gradient(90deg, var(--v2-corner), var(--v2-corner));
  background-size: 2px 10px, 10px 2px, 2px 10px, 10px 2px, 2px 10px, 10px 2px, 2px 10px, 10px 2px;
  background-position:
    4px 0px, 0px 4px, calc(100% - 6px) 0px, calc(100% - 10px) 4px,
    4px calc(100% - 10px), 0px calc(100% - 6px), calc(100% - 6px) calc(100% - 10px), calc(100% - 10px) calc(100% - 6px);
}
.visits-v2 .visits-tp-card-name { font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 16px; }
.visits-v2 .visits-tp-card.on { background: color-mix(in srgb, var(--green) 10%, #fff); border-color: var(--green); }
.visits-v2 .visit-day-group { border-radius: 0; }
.visits-v2 .card-modal-box { border-radius: 0; }
.visits-v2 .visit-visited-badge {
  display: inline-block; padding: 3px 9px; border: 1px solid var(--green);
  color: var(--green-dark); font-family: "Barlow Condensed", system-ui, sans-serif;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.visits-v2 .visit-modal-label {
  font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

/* ---------- Редизайн — сайдбар и шапка ТП/менеджера (шаг 4), 06.09.2026 ----------
   Сайдбар (_sidebar_nav.html) — общий шаблон для ВСЕХ ролей, поэтому новые
   правила скопом под .sidebar-v2 — класс ставит base.html только для
   это_тп_или_менеджер (sales_rep/manager/accountant/1c_operator), у
   остальных ролей (admin/supervisor/...) сайдбар остаётся прежним, пока не
   дойдёт очередь. Шапка (.topbar.cb-top-on-desktop) уже была role-scoped
   раньше (тот же список ролей) — её просто доводим до того же тихого
   белого стиля, что и .cb-top в кабинете, вместо старой зелёной заливки. */
.sidebar-v2 { font-family: "Barlow", system-ui, sans-serif; }
.sidebar-v2 .side-header-text b, .sidebar-v2 .side-header-text span { font-family: "Barlow", system-ui, sans-serif; }
.sidebar-v2 .side-avatar { font-family: "Barlow Condensed", system-ui, sans-serif; }
/* группы и одиночные пункты (.side-solo ниже) — тот же размер/регистр,
   что в референсе: обычным Title Case, не капсом мелким шрифтом —
   разница между ними только в +/− у групп, не в типографике (старый
   сайдбар admin/supervisor это различие сохраняет — правки только тут) */
.sidebar-v2 .side-title {
  font-family: "Barlow", system-ui, sans-serif;
  color: var(--ink); font-size: 15px; font-weight: 400; letter-spacing: normal;
  text-transform: none;
}
.sidebar-v2 .side-title::before { content: "+"; transform: none !important; }
.sidebar-v2 .side-group[open] > .side-title::before { content: "−"; }
.sidebar-v2 nav a { font-family: "Barlow", system-ui, sans-serif; font-weight: 400; }
.sidebar-v2 nav a.active {
  background: color-mix(in srgb, var(--green) 10%, #fff);
  border-left-color: var(--green);
  color: var(--ink);
}
.sidebar-v2 .side-group > a { padding-left: 26px; }
.sidebar-v2 .side-group > a::before { display: none; }
.sidebar-v2 nav a.side-solo {
  font-family: "Barlow", system-ui, sans-serif;
  color: var(--ink); font-size: 15px; font-weight: 400; letter-spacing: normal;
  text-transform: none;
}
.sidebar-v2 nav a.side-solo.active { color: var(--green); }
.sidebar-v2 .side-count { border-radius: 0; font-family: "Barlow Condensed", system-ui, sans-serif; }
.sidebar-v2 .side-exit button {
  border-radius: 0;
  font-family: "Barlow Condensed", system-ui, sans-serif;
}

.topbar.cb-top-on-desktop { background: #fff; border-bottom: 1px solid var(--line); }
.cb-top-on-desktop .cb-top-title { color: var(--ink); }
.cb-top-on-desktop .cb-top-title span { color: var(--muted); opacity: 1; }
.cb-top-on-desktop .side-toggle { background: #fff; border-color: var(--line); color: var(--muted); }
.cb-top-on-desktop .side-toggle:hover { background: var(--bg); color: var(--green-dark); border-color: var(--green); }
/* ☰ на телефоне (открывает тот же выезжающий сайдбар, что и в кабинете,
   см. _cb_top_header.html) — раньше остался белым по белому: правило
   .cb-top-on-desktop .nav-toggle{background:rgba(255,255,255,.18)} было
   написано для старой сплошной цветной шапки и не поправлено, когда
   шапка стала тихой белой (см. .topbar.cb-top-on-desktop выше) — кнопка
   физически была на месте и кликабельна, просто не видна */
.cb-top-on-desktop .nav-toggle { background: var(--bg); color: var(--muted); }
.cb-top-on-desktop .nav-toggle:active { background: var(--line); color: var(--ink); }

/* ---------- Редизайн — общие компоненты десктопа (body.v2), 06.09.2026 ----------
   С этого места редизайн переходит на страницу за страницей (шаг 4,
   продолжение) — а не по одной обёртке-классу на страницу, как раньше
   (.visits-v2/.promo-v2 остаются, дублирование с этим блоком безвредно).
   body.v2 ставится в base.html только это_тп_или_менеджер — общие
   компоненты (h1, .card-box, .btn, .tabs, table.as-cards, .stat, дерево
   .sales-year/.sales-month, .tag, поля форм) переезжают на новые токены
   СРАЗУ на всех их страницах, без правки каждого шаблона под свою
   обёртку. Функционал не трогается нигде — только визуал. */
body.v2 h1 { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; }
body.v2 .card-box { border-radius: 0; }
body.v2 .btn { border-radius: 0; font-family: "Barlow Condensed", system-ui, sans-serif; letter-spacing: .02em; }
/* Вкладки-«папки» из референса: плоские прямоугольники впритык (зазор
   2px) на волосяной линии, активная — цвета самой страницы, будто
   поднята к содержимому, остальные приглушённо-серые. Обычным регистром,
   не капсом — так в прототипе (проверено на живом артефакте). */
body.v2 .tabs {
  display: flex; border-bottom: 1px solid var(--line); gap: 2px; background: none;
  /* на телефоне вкладок больше, чем влезает («Не оплачено», «Иск», «Стоп»
     на Аналитике) — в референсе они прокручиваются вбок одной строкой,
     а не переносятся на вторую, где растягиваются во всю ширину */
  flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
body.v2 .tab {
  border: none; border-radius: 0; padding: 8px 14px;
  flex: none; white-space: nowrap;
  background: color-mix(in srgb, var(--ink) 6%, #fff); color: var(--muted);
  font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 14px; font-weight: 500;
  text-transform: none; letter-spacing: normal;
}
body.v2 .tab:hover { background: color-mix(in srgb, var(--ink) 3%, #fff); color: var(--ink); }
body.v2 .tab.on { background: #fff; color: var(--ink); box-shadow: inset 0 2px 0 var(--green); }
body.v2 .table-wrap { border-radius: 0; }
body.v2 table { font-family: "Barlow", system-ui, sans-serif; }
body.v2 th { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 700; letter-spacing: .04em; }
/* Плитки итогов — одна таблица с волосяными разделителями (зазор 1px,
   через который просвечивает фон-сетка), а не отдельные карточки с
   зазорами и скруглениями. Порядок как в референсе: крупное значение
   сверху, подпись капсом под ним, сравнение одной строкой
   «▲ 12% · было 17 390 000» вместо цветной «пилюли» и отдельной строки.
   Цвет стрелки оставлен смысловым (зелёная — в хорошую сторону,
   красная — в плохую); в прототипе он один на все, но значение цвета
   здесь полезнее буквального совпадения. */
/* линии рисуют сами плитки (право+низ), рамка — только верх и лево у
   сетки: если плиток не хватает на полный ряд, пустая ячейка остаётся
   пустой, а не превращается в серый прямоугольник — так было бы, будь
   разделители фоном контейнера */
body.v2 .stat-row { gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
body.v2 .stat, body.v2 .stat-btn {
  border: none; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  border-radius: 0; background: #fff; padding: 13px 14px;
}
/* последняя плитка, оставшаяся одна в ряду из двух (телефон) — во всю
   ширину, как в референсе, чтобы ряд не обрывался наполовину */
@media (max-width: 640px) {
  body.v2 .stat-row > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
body.v2 .stat-btn:hover { border: none; box-shadow: none; background: var(--bg); }
body.v2 .stat .value {
  font-family: "Barlow Condensed", system-ui, sans-serif;
  font-size: 24px; font-weight: 500; color: var(--ink);
}
/* эти три цвета несут смысл (ошибка, плюс/минус) и должны пережить
   обнуление цвета выше — правило стоит после него намеренно */
body.v2 .stat .value.error-text { color: #d43b3b; }
body.v2 .stat .value.pos { color: var(--green); }
body.v2 .stat .value.neg { color: #c23b3b; }
body.v2 .stat .label {
  order: 0; margin: 2px 0 0; font-size: 11px; font-weight: 400;
  text-transform: uppercase; letter-spacing: .06em;
}
body.v2 .stat-delta { margin-top: 3px; font-size: 11px; }
body.v2 .stat-delta .delta-badge {
  padding: 0; border-radius: 0; background: none; font-weight: 400; font-size: 11px;
}
body.v2 .stat-delta .hint { display: inline; margin: 0; }
body.v2 .stat-delta .hint::before { content: "· "; }
/* Отбор периода — одной компактной полосой, как в референсе: подпись
   «ПЕРИОД», за ней годы, месяцы, «Сегодня» и поле поиска в один ряд, а
   лента чисел (её в прототипе нет вовсе, но она нам нужна) — отдельной
   строкой под ними. Раньше это были три высокие строки друг под другом.
   Только для ПК: на телефоне весь отбор — попап поверх страницы
   (#period-pick-box.open), display:contents его бы развалил. */
@media (min-width: 641px) {
  body.v2 .period-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px;
  }
  body.v2 .period-bar::before {
    content: "Период";
    font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  }
  body.v2 .period-bar .period-pick { display: contents; }
  body.v2 .period-bar .calendar-header { gap: 6px; align-items: center; margin: 0; }
  body.v2 .period-bar #period { flex: 1 1 220px; margin: 0; order: 8; }
  body.v2 .period-bar .day-chips { order: 9; flex-basis: 100%; margin: 0; }
}
/* Мобильный отбор — переключатель День/Месяц/Год + «‹ дата ›» + «Сегодня»,
   как в референсе (живой Artifact, «Аналитика продаж» на телефоне),
   вместо прежней кнопки-календаря «📅 [подпись]». Работает поверх тех же
   чекбоксов, что и старый попап (см. скрипт в _period_pick.html) — тап по
   самой дате по-прежнему открывает полный попап с многолетним/
   многомесячным выбором, той функционал не убирался, просто скрыт за
   более быстрым путём для частого случая «один день/месяц/год». Только
   для редизайна (body.v2) — у admin/supervisor осталась прежняя кнопка. */
.period-scale, .period-nav-inline, .period-nav-today { display: none; }
@media (max-width: 640px) {
  body.v2 .row-form .period-toggle-btn { display: none; }
  body.v2 .period-scale {
    display: flex; gap: 1px; width: 100%; order: 1;
  }
  body.v2 .period-scale button {
    flex: 1; padding: 8px 0; border: 1px solid var(--line); border-radius: 0;
    background: #fff; color: var(--ink); font-family: "Barlow Condensed", system-ui, sans-serif;
    font-size: 13px; cursor: pointer;
  }
  body.v2 .period-scale button.on { background: var(--green); border-color: var(--green); color: #fff; }
  body.v2 .period-nav-inline {
    display: flex; align-items: stretch; gap: 6px; width: 100%; order: 2; margin-top: 8px;
  }
  body.v2 .period-nav-arrow {
    flex: none; width: 38px; border: 1px solid var(--line); background: #fff;
    color: var(--muted); font-size: 16px; cursor: pointer;
  }
  body.v2 .period-nav-center {
    flex: 1; border: 1px solid var(--line); background: #fff; padding: 8px 10px;
    text-align: center; cursor: pointer;
  }
  body.v2 .period-nav-center b {
    font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; font-size: 15px; color: var(--ink);
  }
  body.v2 .period-nav-today {
    display: block; width: 100%; order: 3; margin-top: 6px;
    border: none; background: none; padding: 2px 0;
    font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; font-size: 12px;
    color: var(--green-dark); cursor: pointer;
  }
  /* поле поиска и итоги «Посещений» — без явного order, поэтому встают
     ДО нового отбора (order:1/2/3 выше их не пускает наверх) — так же,
     как «Покупатель, менеджер, товар...» стоит над периодом в референсе */
  body.v2 .row-form .visits-mobile-totals { order: 4; margin-top: 8px; }
}
/* сами чипы — прямоугольные, как весь новый дизайн; лента месяцев без
   собственной серой подложки, чипы стоят каждый в своей рамке */
body.v2 .chip { border-radius: 0; font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 13px; }
body.v2 .month-chips { background: none; padding: 0; border-radius: 0; gap: 6px; }
body.v2 .month-chips .chip, body.v2 .today-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 0;
  padding: 5px 11px; font-weight: 400;
}
body.v2 .month-chips .chip.on, body.v2 .today-chip.on {
  background: var(--green); border-color: var(--green); color: #fff;
}
body.v2 .year-pick > summary, body.v2 .year-pick > .month-pick-summary,
body.v2 .month-step-btn { border-radius: 0; }
body.v2 .sales-year, body.v2 .sales-month { border-radius: 0; }
body.v2 .sales-year > summary b { font-family: "Barlow Condensed", system-ui, sans-serif; }
body.v2 .tag { border-radius: 0; }
body.v2 .field select, body.v2 .field input, body.v2 input[type=search], body.v2 input[type=text] { border-radius: 0; }
body.v2 .link-btn { font-family: "Barlow", system-ui, sans-serif; }
body.v2 .training-tile { border-radius: 0; }
body.v2 .training-tile-name { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 500; }
body.v2 .ads-tile { border-radius: 0; }
body.v2 .ads-tile-name { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 500; }

/* ---------- Чат (плавающий виджет) по референсу ----------
   Шапка — не брендовая зелёная заливка, а тёмная «чернильная» полоса;
   вкладки-«папки», как на страницах; кружок аватара — контурный с
   тёмными инициалами, а не залитый зелёным; пузыри переписки
   прямоугольные с волосяной рамкой: свои — светлой заливкой брендового
   цвета, чужие — серой поверхностью. Те же правила продублированы в
   cabinet.css: у кабинета своя таблица стилей, style.css там не
   подключается вовсе. */
body.v2 .chat-widget-panel { border-radius: 0; border: 1px solid var(--line); }
body.v2 .chat-list-head, body.v2 .chat-conv-head {
  background: var(--ink); color: #fff;
  font-family: "Barlow", system-ui, sans-serif; font-weight: 500;
}
body.v2 .chat-list-tabs { border-bottom: none; }
body.v2 .chat-list-tab {
  padding: 12px 0; font-family: "Barlow Condensed", system-ui, sans-serif; font-size: 14px;
  background: color-mix(in srgb, var(--ink) 6%, #fff);
}
body.v2 .chat-list-tab.on { background: #fff; font-weight: 500; }
body.v2 .chat-list-search input,
body.v2 .chat-conv-form input[type=text] {
  border-radius: 0; background: color-mix(in srgb, var(--ink) 4%, #fff);
}
/* фильтр «Все/Свободные/Мои» над списком покупателей — лёгкая тонировка
   и цветная рамка, а не сплошная заливка (см. тот же приём в cabinet.css) */
body.v2 #chat-list-filters .chip.on {
  background: color-mix(in srgb, var(--green) 14%, #fff);
  border-color: var(--green); color: var(--ink);
}
body.v2 .chat-list-item { padding: 12px 14px; gap: 11px; }
body.v2 .chat-avatar {
  width: 36px; height: 36px;
  background: none; border: 1px solid var(--muted); color: var(--ink);
  font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 500; font-size: 13px;
}
body.v2 img.chat-avatar { border: none; }
body.v2 .chat-avatar.ai { background: var(--green); border-color: var(--green); color: #fff; }
/* тот же кружок в тёмной шапке переписки — контур и инициалы светлые.
   В референсе аватара в этой шапке нет, но пользователь попросил оставить */
body.v2 .chat-conv-head .chat-avatar { border-color: rgba(255, 255, 255, .55); color: #fff; }
body.v2 .chat-list-item-name { font-family: "Barlow", system-ui, sans-serif; font-weight: 500; font-size: 15px; }
body.v2 .chat-msg > span, body.v2 .chat-msg > .bubble {
  border-radius: 0; border: 1px solid var(--line);
}
body.v2 .chat-msg.mine > span, body.v2 .chat-msg.mine > .bubble {
  background: color-mix(in srgb, var(--green) 12%, #fff); color: var(--ink);
}
body.v2 .chat-msg.theirs > span, body.v2 .chat-msg.theirs > .bubble {
  background: color-mix(in srgb, var(--ink) 6%, #fff);
}
body.v2 .chat-msg .ticks.read { color: var(--green); }
body.v2 .chat-conv-send { border-radius: 0; }

/* ---------- Редизайн — Акции (.promo-v2), 06.09.2026 ----------
   .card-box/.btn/.filters/h1 общие на весь десктоп — скопом под .promo-v2,
   как и раньше (.visits-v2/.sidebar-v2). Функционал (Скрыть/Показать,
   поиск по карточкам) не менялся, только визуал. */
.promo-v2 h1 { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 600; }
.promo-v2 .card-box { border-radius: 0; }
.promo-v2 .btn { border-radius: 0; font-family: "Barlow Condensed", system-ui, sans-serif; letter-spacing: .02em; }
.promo-v2 .field select, .promo-v2 .field input { border-radius: 0; }
.promo-v2 .tag { border-radius: 0; font-family: "Barlow", system-ui, sans-serif; }
.promo-v2 .promo-list-card { border-radius: 0; }
.promo-v2 .promo-list-card h2 { font-family: "Barlow Condensed", system-ui, sans-serif; }
.promo-v2 .promo-card { border-radius: 0; }
.promo-v2 .promo-card-name { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 500; }
.promo-v2 .promo-card-price .price-new { font-family: "Barlow Condensed", system-ui, sans-serif; }
.promo-v2 .disc-tag { border-radius: 0; }

/* ---- полоса демо-стенда (SALES_DEMO=1), см. _demo_banner.html ---- */
.demo-banner {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between;
  margin: 0 0 14px; padding: 9px 14px; border-radius: 10px;
  background: #e8f1fd; border: 1px solid #b9d3f5; color: #1f3a5f; font-size: 13.5px;
}
.demo-banner a { color: #1d5fc2; font-weight: 600; text-decoration: none; white-space: nowrap; }
.demo-banner a:hover { text-decoration: underline; }
.auth-box .demo-banner { margin: 0 0 16px; }
