.activity-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.activity-header {
  padding: 16px 28px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.activity-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.activity-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.activity-header-actions {
  display: flex;
  gap: 8px;
}
.activity-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
}
.activity-filter {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.activity-filter label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.activity-filter--wide {
  grid-column: span 2;
}
.activity-filter .input {
  width: 100%;
  font-size: 12px;
  padding: 6px 10px;
}
.activity-filter .input:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.activity-user-picker {
  position: relative;
}
.activity-user-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  text-align: left;
  cursor: pointer;
  background: var(--input-bg, var(--surface));
}
.activity-user-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.activity-user-trigger-caret {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.activity-user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-elev, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow: hidden;
}
.activity-user-search {
  flex-shrink: 0;
}
.activity-user-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-height: 0;
}
.activity-user-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.activity-user-row:hover { background: var(--chip-bg); }
.activity-user-row-label {
  font-weight: 500;
}
.activity-user-row-sub {
  font-size: 10px;
  color: var(--text-muted);
}
.activity-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 28px 24px;
}
.activity-state {
  padding: 24px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}
.activity-loading,
.activity-empty,
.activity-error {
  padding: 28px 0;
}
.activity-error { color: var(--danger); }
.activity-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.activity-table thead th:nth-child(1) { width: 14%; }   
.activity-table thead th:nth-child(2) { width: 14%; }   
.activity-table thead th:nth-child(3) { width: 26%; }   
.activity-table thead th:nth-child(4) { width: 24%; }   
.activity-table thead th:nth-child(5) { width: 22%; }   
.activity-th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface2);
  padding: 0;
  box-sizing: border-box;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.activity-th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  min-height: 32px;
}
.activity-row {
  transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: 0; }
.activity-row:nth-child(even) { background: var(--surface2); }
.activity-row:hover           { background: var(--chip-bg); }
.activity-cell {
  padding: 2px 4px;
  color: var(--text);
  vertical-align: middle;
  line-height: 1;
  /* table-layout: fixed по умолчанию обрезает переполнение; разрешаем длинному тексту мягко переноситься, чтобы узкая колонка не обрезала содержимое строки целиком. word-break ловит очень длинные неразрывные токены (URL, длинные ID). */
  word-break: break-word;
  overflow-wrap: break-word;
}
.activity-cell--date {
  width: 14%;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: normal;
}
.activity-cell--user { width: 14%; }
.activity-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.activity-cell--loc { width: 26%; font-size: 12px; }
.activity-loc-proj  { color: var(--text);           font-weight: 600; }
.activity-loc-board { color: var(--text-secondary); }
.activity-loc-col   { color: var(--text-muted); }
.activity-loc-sep   { color: var(--text-muted); margin: 0 4px; opacity: .7; }
.activity-cell--task { width: 24%; }
.activity-task {
  display: inline;
  font-weight: 600;
  color: var(--text);
  /* Без nowrap и без многоточия — длинный заголовок задачи должен переноситься на несколько строк, а не прятаться за «…». Правила word-break ячейки переносят и очень длинные неразрывные токены (URL, ID). */
  word-break: break-word;
  overflow-wrap: break-word;
}
.activity-task:hover {
  color: var(--accent);
  text-decoration: underline;
}
.activity-task--deleted {
  color: var(--text-muted);
  text-decoration: line-through;
  cursor: pointer;
}
.activity-task--deleted:hover {
  color: var(--danger);
  text-decoration: line-through underline;
}
.activity-trash-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  vertical-align: middle;
  white-space: nowrap;
}
.activity-cell--act { width: 22%; }
.activity-act-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.activity-act-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}
.activity-act-summary {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  word-break: break-word;
}
.evdiff-add {
  color: var(--success);
  background: var(--success-soft);
  font-weight: 500;
  padding: 0 2px;
  border-radius: 3px;
}
.evdiff-del {
  color: var(--danger);
  background: var(--danger-soft);
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(255, 92, 92, .65);
  padding: 0 2px;
  border-radius: 3px;
}
.activity-muted {
  color: var(--text-muted);
  font-style: italic;
}
.activity-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}
.activity-footer-size {
  display: flex;
  align-items: center;
  gap: 6px;
}
.activity-count {
  font-size: 11px;
  color: var(--text-muted);
}
@media (max-width: 900px) {
  .activity-cell--loc,
  .activity-table .activity-th:nth-child(3) { display: none; }
}
@media (max-width: 640px) {
  .activity-cell--user,
  .activity-table .activity-th:nth-child(2) { display: none; }
}
.activity-th--sortable {
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s;
}
.activity-th--sortable:hover {
  background: var(--chip-hover);
  color: var(--text);
}
.activity-th--sortable.active {
  color: var(--accent);
}
.activity-sort-arrow {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  opacity: .85;
}
.activity-resize-overlay {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.activity-resize-bar {
  position: fixed;
  width: 8px;
  cursor: col-resize;
  background: transparent;
  pointer-events: auto;
  transition: background .12s;
  z-index: 30;
}
.activity-resize-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 3px;
  width: 2px;
  height: 100%;
  background: var(--border);
  transition: background .12s;
}
#activity-view[hidden] ~ * .activity-resize-bar,
#activity-view[hidden] .activity-resize-bar {
  display: none;
}
.activity-resize-bar:hover,
.activity-resize-bar.dragging {
  background: var(--accent-soft);
}
.activity-resize-bar:hover::after,
.activity-resize-bar.dragging::after {
  background: var(--accent);
}
body.activity-col-resizing,
body.activity-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
.activity-th-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body:not(.theme-dark) .activity-view {
  --bg:             #f5f7fa;
  --surface:        #ffffff;
  --win-line:       rgba(0, 0, 0, .45);
  --surface-elev:   #ffffff;
  --surface2:       #f9fafb;
  --surface3:       #f3f4f6;
  --text:           #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --border:         #cbd5e1;
  --border-strong:  #94a3b8;
  --chip-bg:        #f1f5f9;
  --chip-hover:     #e2e8f0;
  --input-bg:       #ffffff;
  --accent-soft:    rgba(15, 108, 189, .12);
  --danger:         #dc2626;
  --danger-soft:    rgba(220, 38, 38, .12);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow:    0 4px 14px rgba(0, 0, 0, .10);
  color: var(--text);
  background: var(--bg);
}
body:not(.theme-dark) .activity-row:nth-child(even) {
  background: #f6f8fb;
}
body:not(.theme-dark) .activity-row:hover {
  background: #eef2f7;
}

/* ══════════════════════════════════════════════════════════════════
   Статистика и отчёты — сводка по сотрудникам за период.
   Живёт рядом с «Лентой событий»: та же раскладка «шапка с фильтрами +
   таблица», поэтому и стили лежат здесь, а не отдельным файлом.
   ══════════════════════════════════════════════════════════════════ */
.stats-view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.stats-header { padding: 16px 20px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.stats-header-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.stats-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); }
.stats-header-actions { margin-left: auto; display: flex; gap: 8px; }
.stats-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.stats-filter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stats-filter label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.stats-filter .input { height: 32px; font-size: 13px; }
/* Быстрый период — сегментированный переключатель */
.stats-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; height: 32px; }
.stats-seg-btn {
  border: 0; background: var(--surface); color: var(--text-secondary);
  padding: 0 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
  border-right: 1px solid var(--border);
}
.stats-seg-btn:last-child { border-right: 0; }
.stats-seg-btn:hover { background: var(--chip-bg); color: var(--text); }
.stats-seg-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
/* Выбор нескольких сотрудников */
.stats-user-picker { position: relative; }
.stats-user-trigger {
  display: flex; align-items: center; gap: 8px; min-width: 190px; height: 32px;
  text-align: left; cursor: pointer; font-size: 13px;
}
.stats-user-trigger-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-user-trigger-caret { flex-shrink: 0; color: var(--text-muted); }
.stats-user-dropdown {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg, 0 8px 28px rgba(0,0,0,.22)); padding: 8px; display: flex;
  flex-direction: column; gap: 6px;
}
.stats-user-search { height: 30px; font-size: 13px; }
.stats-user-actions { display: flex; gap: 6px; }
.stats-user-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.stats-user-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text); cursor: pointer;
}
.stats-user-item:hover { background: var(--chip-bg); }
.stats-user-item input { flex-shrink: 0; accent-color: var(--accent); }
.stats-user-item .avatar { flex-shrink: 0; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.stats-user-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* У одного выбранного сотрудника в кнопке — аватарка рядом с именем */
.stats-user-trigger-label { display: flex; align-items: center; gap: 6px; }
.stats-user-trigger-label .avatar { flex-shrink: 0; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; color: #fff; font-weight: 700; }
/* Свой период — кнопка-календарь (тот же общий пикер, что в поиске почты) */
.stats-range-btn {
  display: flex; align-items: center; gap: 8px; height: 32px; min-width: 230px;
  text-align: left; cursor: pointer; font-size: 13px;
}
.stats-range-btn .ico { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-muted); }
.stats-range-btn:hover { border-color: var(--accent); }
.stats-range-btn.on { border-color: var(--accent); color: var(--accent); }
.stats-range-btn.on .ico { color: var(--accent); }
.stats-range-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-user-empty { padding: 8px; font-size: 12px; color: var(--text-muted); }
/* Таблица */
.stats-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 20px 20px; }
.stats-state { padding: 14px 2px; font-size: 13px; color: var(--text-muted); }
.stats-state--err { color: var(--danger); }
.stats-table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-th {
  text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; color: var(--text-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; background: var(--bg);
}
.stats-th--num, .stats-td--num { text-align: right; }
/* Заголовок-сортировщик: щелчок — от большего к меньшему, ещё раз — наоборот,
   третий снимает. Стрелка показывает текущее направление. */
.stats-th[data-sort] { cursor: pointer; user-select: none; }
.stats-th[data-sort]:hover { color: var(--text); }
.stats-th-in { display: inline-flex; align-items: center; gap: 5px; }
.stats-th--num .stats-th-in { flex-direction: row-reverse; }
.stats-th-arr { font-size: 9px; line-height: 1; color: var(--accent); }
.stats-th--on { color: var(--accent); }
.stats-td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.stats-td--user { display: flex; align-items: center; gap: 8px; }
.stats-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-row:hover .stats-td { background: var(--chip-bg); }
/* Сотрудник без единого показателя за период — бледнее: строка есть (видно,
   что человека не забыли), но взгляд цепляется за работавших. */
.stats-row--idle .stats-td { color: var(--text-muted); }
.stats-total .stats-td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: 0; }

/* ── Темы раздела «Статистика и отчёты» ───────────────────────────────────
   Раздел следует ТЕМЕ ПРОФИЛЯ (переключатель в меню пользователя ставит на
   body класс theme-dark) — в отличие от «Почты», которая всегда светлая.
   Выпадашка сотрудников и КАЛЕНДАРЬ периода рисуются в <body>, вложенностью в
   .stats-view их не достать — отсюда селектор по body.view-stats (класс ставит
   _applyViewDOM в js/nav.js).

   СВЕТЛАЯ. Текст здесь темнее, чем в остальных светлых разделах: это таблица
   цифр, её читают бегло и сравнивают строки — приглушённый серый (#334155 на
   вторичном тексте) для этого не годился. */
body:not(.theme-dark) .stats-view,
body:not(.theme-dark) .stats-user-dropdown,
body.view-stats:not(.theme-dark) .drp-pop {
  --bg:             #f4f6f9;
  --surface:        #ffffff;
  --win-line:       rgba(0, 0, 0, .45);
  --surface-elev:   #ffffff;
  --surface2:       #f9fafb;
  --surface3:       #f1f5f9;
  --text:           #0b1220;
  --text-secondary: #1e293b;
  --text-muted:     #475569;
  --border:         #d7dee7;
  --border-strong:  #b3bfcd;
  --chip-bg:        #eef2f7;
  --chip-hover:     #e2e8f0;
  --input-bg:       #ffffff;
  --accent:         #0b5ea8;
  --accent-rgb:     11, 94, 168;
  --accent-hover:   #094c8a;
  --accent-soft:    rgba(11, 94, 168, .14);
  --danger:         #c81e1e;
  --danger-soft:    rgba(200, 30, 30, .12);
  --success:        #15803d;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow:    0 4px 14px rgba(0, 0, 0, .10);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, .18);
  color: var(--text);
}
/* Фон — только у самого раздела. Выпадашки и календарь свой фон задают сами
   (var(--surface)); задать его и здесь — они станут цвета подложки. */
body:not(.theme-dark) .stats-view { background: var(--bg); }
body:not(.theme-dark) .stats-user-dropdown,
body.view-stats:not(.theme-dark) .drp-pop { background: var(--surface); }
/* Поля и кнопки: часть красится глобальными правилами, поэтому явно. */
body:not(.theme-dark) .stats-view .input,
body:not(.theme-dark) .stats-view .btn-secondary,
body:not(.theme-dark) .stats-user-dropdown .input,
body:not(.theme-dark) .stats-user-dropdown .btn-sm {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border-strong);
}
body:not(.theme-dark) .stats-view .btn-secondary:hover,
body:not(.theme-dark) .stats-user-dropdown .btn-sm:hover { background: var(--chip-bg); }
/* Пункт списка сотрудников — <label>, глобальные правила формы красят его
   приглушённым; на белом фоне читался плохо. */
body:not(.theme-dark) .stats-user-dropdown .stats-user-item { color: var(--text); }
/* Зебра строк: глазом легче вести строку от имени к цифрам через всю таблицу. */
body:not(.theme-dark) .stats-row:nth-child(even) .stats-td { background: #f2f6fb; }
body:not(.theme-dark) .stats-row:hover .stats-td { background: #e6edf6; }
/* Заголовки таблицы — контрастнее обычного «приглушённого»: по ним ещё и
   сортируют, они должны читаться как управляющий элемент. */
body:not(.theme-dark) .stats-th { background: var(--bg); color: #334155; }
body:not(.theme-dark) .stats-row--idle .stats-td { color: #64748b; }

/* ТЁМНАЯ. Отдельного набора переменных не нужно — берутся общие из темы
   приложения; здесь только то, что раздел красит сам. */
body.theme-dark .stats-view { background: var(--bg); color: var(--text); }
body.theme-dark .stats-row:nth-child(even) .stats-td { background: rgba(255, 255, 255, .028); }
body.theme-dark .stats-row:hover .stats-td { background: rgba(255, 255, 255, .06); }
body.theme-dark .stats-th { background: var(--bg); }
