/* ============================================================
   Visual Enhancements — унификация стилей всех разделов
   Версия 1 — подключается после всех module CSS
   ============================================================ */

/* ============================================================
   ОБЩИЕ УЛУЧШЕНИЯ
   ============================================================ */

/* Заголовок модуля — единый стиль */
.module-head h2,
.module-toolbar h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* Section label — мелкий заголовок над группой */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
  margin-bottom: 10px;
}

/* Кнопка-иконка (удалить/редактировать в строке) */
.btn-icon {
  width: 28px; height: 28px;
  border: none; background: none;
  color: var(--text2);
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); }

/* ============================================================
   ВСТРЕЧИ
   ============================================================ */
.meetings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.meeting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
  cursor: pointer;
  transition: box-shadow var(--t), transform var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meeting-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.meeting-card .mc-date {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
}
.meeting-card .mc-date .badge { margin-left: 2px; }
.meeting-card .mc-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.meeting-card .mc-sub {
  font-size: 12.5px;
  color: var(--text2);
}
.meeting-card .mc-people {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Вид встречи в модале */
.meeting-view { font-size: 13.5px; }
.mv-block { margin-bottom: 20px; }
.mv-block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text2);
  font-weight: 700;
  margin-bottom: 8px;
}
.mv-empty { color: var(--text3); font-style: italic; }

/* ============================================================
   ПОЛЬЗОВАТЕЛИ
   ============================================================ */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow var(--t), background var(--t-fast);
}
.user-card:hover { box-shadow: var(--shadow); background: var(--surface2); }

.user-card .uc-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.user-card .uc-body { flex: 1; min-width: 0; }
.user-card .uc-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card .uc-email {
  font-size: 12px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card .uc-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
}
.user-card .uc-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* Точка статуса пользователя */
.users-status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.users-status-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5,150,105,.15);
}
.users-status-dot.inactive { background: var(--text3); }

/* Инлайн-селект (смена роли) */
.inline-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.inline-select:hover, .inline-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* ============================================================
   НАСТРОЙКИ — АВТОМАТИЗАЦИИ
   ============================================================ */
.automation-templates {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.automation-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow var(--t-fast), background var(--t-fast);
}
.automation-rule:hover { box-shadow: var(--shadow); background: var(--surface2); }

.automation-rule .ar-flow {
  flex: 1;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.automation-rule .ar-flow b { font-weight: 700; color: var(--text); }
.automation-rule .ar-flow .arrow { color: var(--text3); font-size: 16px; }
.automation-rule .ar-flow span { color: var(--text2); }

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface3);
  border-radius: 999px;
  transition: background var(--t);
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* Профиль — карточки */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  max-width: 520px;
}
.settings-card .card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   FINANCE — Постоянные расходы, Зарплата, Долги
   ============================================================ */

/* Строки сумм — единый стиль */
.amount-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.amount-row:last-child { border-bottom: none; }
.amount-row .ar-label { color: var(--text2); }
.amount-row .ar-value { font-weight: 700; }

/* Сводная строка (итого) */
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 2px solid var(--border2);
  margin-top: 4px;
  font-weight: 700;
  font-size: 14px;
}

/* KPI плашки в финансах */
.finance-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.finance-kpi-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.finance-kpi-item .fki-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.finance-kpi-item .fki-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
}

/* ============================================================
   ОТЧЁТЫ — улучшенные карточки с графиком
   ============================================================ */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  margin-bottom: 16px;
}
.report-card .rc-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ============================================================
   CRM улучшения
   ============================================================ */

/* Стадии-чипы */
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Аватар-инициалы клиента */
.client-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

/* ============================================================
   ACTIVITY LOG
   ============================================================ */
.activity-timeline {
  position: relative;
  padding-left: 24px;
}
.activity-timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--border);
}
.activity-entry {
  position: relative;
  padding: 0 0 16px;
}
.activity-entry::before {
  content: '';
  position: absolute;
  left: -20px; top: 5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border2);
  border: 2px solid var(--surface);
}
.activity-entry .ae-time { font-size: 11px; color: var(--text3); margin-bottom: 2px; }
.activity-entry .ae-text { font-size: 13px; color: var(--text); }

/* ============================================================
   ПРОЕКТЫ — улучшения (быстрый просмотр состава команды)
   ============================================================ */
.project-card .pc-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.project-card .pc-progress-row .progress { flex: 1; }
.project-card .pc-pct { font-size: 12px; font-weight: 700; color: var(--text2); min-width: 32px; text-align: right; }

/* ============================================================
   ЗАДАЧИ — улучшения строк в таблице
   ============================================================ */
.task-row-title {
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-row-meta {
  font-size: 11.5px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* Kanban улучшения — фиксируем ссылки */
.kanban-col { border-radius: var(--radius); }
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ============================================================
   WIKI / БАЗА ЗНАНИЙ
   ============================================================ */
.wiki-article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow var(--t), transform var(--t-fast);
}
.wiki-article-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ============================================================
   АДАПТАЦИЯ Kanban к дизайн-системе
   ============================================================ */
.kanban-card {
  transition: box-shadow var(--t), transform var(--t-fast);
}
.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ============================================================
   УЛУЧШЕНИЕ TABLE-WRAP
   ============================================================ */
.table-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.table-wrap .table { border-radius: 0; }

/* ============================================================
   ФИЛЬТРЫ — единый стиль
   ============================================================ */
.filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters-bar label { font-size: 11px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 3px; }
.filters-bar select,
.filters-bar input[type=text],
.filters-bar input[type=date] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast);
}
.filters-bar select:focus,
.filters-bar input:focus { border-color: var(--accent); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .7; }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text2); max-width: 300px; }


/* ============================================================
   ТРАНЗАКЦИИ — truncate длинных ячеек
   ============================================================ */

/* table-layout: fixed + явные ширины колонок через th */
#tx-table .table {
  table-layout: fixed;
  width: 100%;
}
#tx-table .table th:nth-child(1) { width: 90px; }   /* Дата */
#tx-table .table th:nth-child(2) { width: 150px; }  /* Карман */
#tx-table .table th:nth-child(3) { width: 120px; }  /* Категория */
#tx-table .table th:nth-child(4) { width: auto; }   /* Описание — растягивается */
#tx-table .table th:nth-child(5) { width: 140px; }  /* Проект */
#tx-table .table th:nth-child(6) { width: 110px; }  /* Сумма */
#tx-table .table th:nth-child(7) { width: 90px; }   /* Оплата */

#tx-table .table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#tx-table .table td:nth-child(6),
#tx-table .table td:nth-child(7) {
  white-space: nowrap;
  text-align: right;
}

/* form-row внутри формы транзакции */
.tx-form-row, #tx-form .form-row {
  display: flex;
  gap: 12px;
}
#tx-form .form-row .form-group {
  flex: 1;
  min-width: 0;
}

/* ============================================================
   ФОРМА — общие улучшения
   ============================================================ */

/* form-group flex fixes */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group .input,
.form-group input:not([type=checkbox]):not([type=radio]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
  font-family: var(--font);
}
.form-group .input:focus,
.form-group input:not([type=checkbox]):focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204,27,27,.08);
}

/* ============================================================
   ПОПАП ЗАДАЧИ — улучшения
   ============================================================ */

.tm-section-label {
  font-size: 10.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .06em !important;
  color: var(--text2) !important;
  margin: 18px 0 8px !important;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Правая панель задачи */
.task-modal-grid > div:last-child {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
}

/* Исполнители-чипы */
.assignee-chip {
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
}
.assignee-chip .avatar-mini {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

/* Заголовок задачи */
.tm-title-edit {
  font-size: 17px !important;
  font-weight: 700 !important;
  border-radius: var(--radius-sm) !important;
}

/* ============================================================
   ПРОЕКТЫ — карточки
   ============================================================ */

/* Убираем дублирование аватаров */
.project-card .pc-people {
  gap: 8px;
}
.project-card .avatar-mini {
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
}
.project-card .pc-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.project-card {
  gap: 10px;
}

/* ============================================================
   ДОКУМЕНТЫ — улучшения
   ============================================================ */

.doc-group {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  margin-bottom: 14px;
  background: var(--surface);
}
.doc-group-header {
  padding: 14px 18px !important;
  background: var(--surface2) !important;
  border-radius: var(--radius) var(--radius) 0 0;
}
.doc-group-title {
  font-size: 14px !important;
}
.doc-subgroup-label {
  background: var(--surface2) !important;
  color: var(--text2) !important;
  padding: 5px 18px !important;
  font-size: 10px !important;
  letter-spacing: .07em !important;
}
.doc-row {
  padding: 12px 18px !important;
  transition: background var(--t-fast) !important;
}
.doc-row:hover {
  background: var(--surface2) !important;
}
.doc-title {
  font-size: 13.5px !important;
}
.doc-meta {
  font-size: 12px !important;
  color: var(--text2) !important;
}

/* Page title */
.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 18px;
  color: var(--text);
}

/* ============================================================
   ЗАДАЧИ — компактные фильтры
   ============================================================ */

/* Строка фильтров без лишних gap */
.module-toolbar .input {
  font-size: 13px;
  padding: 7px 10px;
  height: 34px;
}

/* Архивный баннер */
.archive-banner {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 12px;
}
.archive-banner a {
  color: var(--accent);
  font-weight: 600;
}

/* Строки задач — чуть уютнее */
.table tbody tr td {
  padding: 9px 14px;
}

/* ============================================================
   MODAL — улучшения
   ============================================================ */

/* Modal footer sticky на мобилке */
.modal {
  display: flex;
  flex-direction: column;
}
.modal-body {
  flex: 1;
}

/* Кнопка удалить — явный danger */
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ============================================================
   ФИЛЬТРЫ ТРАНЗАКЦИЙ — компактнее
   ============================================================ */
.filters-bar .filter-field select,
.filters-bar .filter-field input {
  min-width: 120px;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

