:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #3b5bdb;
  --accent-hover: #2f4bc0;
  --danger: #d64550;
  --success: #2f9e44;
  --radius: 10px;

  /* Тёмная боковая панель */
  --rail-bg: #2f3746;
  --rail-hover: #3a4353;
  --rail-active: #39435a;
  --rail-icon-bg: #414b5c;
  --rail-avatar-bg: #5b6578;
  --rail-text: #b7c0cd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

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

/* Узкая тёмная панель слева: иконка сверху, подпись снизу (как в amoCRM) */
.layout { display: flex; min-height: 100vh; align-items: stretch; }

.rail {
  width: 78px;
  flex: 0 0 78px;
  background: var(--rail-bg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 8px 0;
}

.rail-account {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 14px;
  color: var(--rail-text);
}
.rail-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--rail-avatar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  text-transform: uppercase;
}

.rail-nav { display: flex; flex-direction: column; flex: 1; }

.rail-nav a,
.rail-logout button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 4px;
  color: var(--rail-text);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}
.rail-nav a:hover,
.rail-logout button:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail-nav a.active { background: var(--rail-active); color: #fff; font-weight: 600; }

.rail-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--rail-icon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.rail-nav a.active .rail-icon { background: var(--accent); color: #fff; }
.rail-label { display: block; }

.rail-logout { margin-top: auto; }

.main { flex: 1; min-width: 0; }

.container { max-width: 1440px; margin: 0 auto; padding: 24px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  /* липнет к верху при прокрутке — кнопки (Создать/Редактировать/Удалить)
     остаются под рукой и на длинных списках; высоту меряет sticky-head.js,
     чтобы шапка таблицы ниже (chat.css) подставляла её как свой отступ */
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--bg);
  padding: 8px 0;
}
.page-head h1 { margin: 0; }

/* Панель всегда вертикальная — на узком экране просто уже */
@media (max-width: 760px) {
  .rail { width: 62px; flex: 0 0 62px; }
  .rail-icon { width: 32px; height: 32px; font-size: 15px; }
  .rail-avatar { width: 32px; height: 32px; font-size: 14px; }
  .rail-nav a, .rail-logout button { padding: 10px 2px; font-size: 10px; }
  .container { padding: 16px 12px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

/* Широкая таблица прокручивается внутри карточки, а не растягивает страницу */
.card { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; }
th .col-btn { white-space: normal; }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: #ebfbee; color: var(--success); }
.badge-terminated { background: #fff4e6; color: #e8590c; }
.badge-closed { background: #f1f3f5; color: var(--text-muted); }
.badge-unassigned { background: #fff4e6; color: #e8590c; }
.status-new { background: #e7f5ff; color: #1971c2; }
.status-in_progress { background: #fff9db; color: #e67700; }
.status-won { background: #ebfbee; color: var(--success); }
.status-lost { background: #f1f3f5; color: var(--text-muted); }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); border-color: var(--danger); }

form.inline { display: inline; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.field textarea { resize: vertical; min-height: 70px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }

.event {
  border-left: 3px solid var(--border);
  padding: 6px 0 6px 14px;
  margin-bottom: 10px;
}
.event.handoff { border-left-color: var(--accent); }
.event.import { border-left-color: var(--text-muted); }
.event-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.event-text { white-space: pre-wrap; }

/* Список-таблица, где каждая строка — отдельная форма */
.rows { padding: 0; }
.rows-head,
.rows-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) minmax(90px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.rows-head {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.rows-row:last-child { border-bottom: none; }
.rows-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--text);
}
.rows-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rows-empty { padding: 14px 16px; }

/* Тариф по документам: ступень, граница по документам, ставка */
.rows-documents .rows-head,
.rows-documents .rows-row {
  grid-template-columns: minmax(160px, 2fr) minmax(90px, 1fr) minmax(90px, 1fr) auto;
}

/* Тарифная сетка: строки — обороты, столбцы — режимы */
.matrix { border-collapse: collapse; min-width: 100%; }
.matrix th, .matrix td { border: 1px solid var(--border); padding: 8px; vertical-align: top; }
.matrix thead th {
  background: var(--bg);
  text-align: left;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  min-width: 150px;
}
.matrix-corner { width: 230px; min-width: 230px; }
.matrix-row-head { background: var(--bg); text-align: left; font-weight: 500; }
.matrix input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.matrix .rate-cell { text-align: right; }
.band-bounds { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.band-bounds input { font-size: 13px; }
.matrix-add form { display: flex; flex-direction: column; gap: 6px; }
.link-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
  white-space: nowrap;
}
.link-danger:hover { text-decoration: underline; }

/* Список доплат с галочками */
.checklist { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checkitem {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 0;
  cursor: pointer;
}
.checkitem input { width: auto; }

.save-state { font-size: 12px; color: var(--text-muted); min-width: 76px; }
.save-state.save-ok { color: var(--success); }
.save-state.save-error { color: var(--danger); }

/* Узкое окно: поля сверху, кнопки отдельной строкой под ними */
@media (max-width: 900px) {
  .rows-head { display: none; }
  .rows-row {
    grid-template-columns: 1fr 110px;
    row-gap: 8px;
  }
  .rows-actions { grid-column: 1 / -1; }
}

/* Строка с несохранённой правкой */
.row-dirty { background: #fff9db; }
tr.row-dirty td { background: #fff9db; }
.btn-attention {
  background: var(--success);
  border-color: var(--success);
  animation: pulse-save 1.2s ease-in-out infinite;
}
@keyframes pulse-save {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.error { color: var(--danger); font-size: 14px; margin-bottom: 12px; }
.hint { color: var(--text-muted); font-size: 13px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: 320px; }

/* Свод выплат */
.payroll-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.payroll-head span { color: var(--text-muted); font-size: 14px; }
.payroll-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 17px;
}
.payroll-total strong { font-size: 22px; }
/* Обороты не переносим посреди числа — иначе разряды читаются как разные суммы */
td.num { text-align: right; white-space: nowrap; }

/* Экран массового заполнения */
.bulk-apply {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.bulk-apply select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.bulk-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.matrix .regime-system {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  background: var(--bg);
}

/* Вкладки внутри раздела */
.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.subnav a {
  padding: 9px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Доступы: моноширинный шрифт для логинов и паролей */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.secret { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret .btn { padding: 4px 10px; font-size: 12px; }
.secret-value { color: var(--danger); font-weight: 600; }

/* Сводная: первая колонка не уезжает при прокрутке вбок */
.summary-table { min-width: 100%; }
.summary-table th, .summary-table td { white-space: nowrap; font-size: 13px; }
.summary-table .sticky-col { white-space: normal; }
.summary-table .sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  white-space: normal;
  min-width: 210px;
  z-index: 1;
}
.summary-table thead .sticky-col, .summary-table tfoot .sticky-col { background: var(--bg); }
.summary-table tfoot th { background: var(--bg); border-top: 2px solid var(--border); }
.summary-table .charge { color: var(--accent); }

/* журнал правок доступов */
.link-btn {
  background: none; border: 0; padding: 0; margin-right: 12px;
  color: var(--accent); font-size: 13px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.log-row td { background: var(--bg-soft, #f7f8fa); }
.log-body ul { margin: 4px 0 10px; padding-left: 18px; }
.log-body li { margin-bottom: 2px; }

/* доступы: ссылка на платформу и замок на логине/пароле */
.with-link { display: flex; align-items: center; gap: 6px; }
.with-link input { flex: 1; min-width: 0; }
.with-link a { font-size: 15px; text-decoration: none; }
.locked { display: flex; align-items: center; gap: 4px; }
.locked input { flex: 1; min-width: 0; }
.locked input[readonly] { background: var(--bg-soft, #f1f2f4); color: var(--text-muted); }
.pencil {
  background: none; border: 0; padding: 2px; cursor: pointer;
  font-size: 13px; line-height: 1; opacity: .55;
}
.pencil:hover { opacity: 1; }
td textarea { width: 100%; resize: vertical; min-height: 64px; font: inherit; }

/* доступы: форма добавления сверху, свёрнутая */
.add-box > summary {
  cursor: pointer; font-weight: 600; font-size: 15px;
  color: var(--accent); list-style: none;
}
.add-box > summary::-webkit-details-marker { display: none; }
.add-box[open] > summary { margin-bottom: 14px; }
.no-link { margin-left: 6px; font-size: 11px; opacity: .7; }

/* --- Раздел «Задачи» --- */
.task-group td { background: #f8f9fa; border-top: 1px solid var(--border); }
.task-group strong { font-size: 14px; }
.client-search { margin-bottom: 6px; }

.status-done { background: #ebfbee; color: var(--success); }
.status-finished { background: #d3f9d8; color: #2b8a3e; }
.status-postponed { background: #f1f3f5; color: var(--text-muted); }
.status-rejected { background: #ffe3e3; color: #c92a2a; }
.status-cancelled { background: #f1f3f5; color: var(--text-muted); }
.status-awaiting_payment { background: #fff4e6; color: #e8590c; }
.status-call { background: #e5dbff; color: #6741d9; }
.status-review { background: #e3fafc; color: #0b7285; }
.status-urgent { background: #ffe3e3; color: #c92a2a; }

/* инструкция по выгрузке чеков за наличку */
.receipts-note {
  margin-top: 6px; padding: 8px 10px; border-radius: 6px;
  background: #fff; border: 1px solid var(--border);
  white-space: pre-wrap; line-height: 1.5; max-width: 900px;
}

/* Меню в заголовке колонки: сортировка, скрытие, фильтр */
.tcol { position: relative; display: inline-block; }
.tcol > summary {
  cursor: pointer; list-style: none;
  border-bottom: 1px dashed var(--border);
}
.tcol > summary::-webkit-details-marker { display: none; }
.tcol-sort { margin-left: 4px; color: var(--accent); }
/* fixed, а не absolute: у .card стоит overflow-x:auto и он обрезал бы меню */
.tcol-menu {
  position: fixed; z-index: 30; min-width: 260px; max-width: 320px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px;
  text-transform: none; font-weight: 400;
}
.tcol-action {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text);
}
.tcol-action:hover { background: #f1f3f5; }
.tcol-filter { border-top: 1px solid var(--border); margin-top: 6px; padding: 8px 10px 4px; }
.tcol-filter .tcol-input {
  width: 100%; margin-top: 4px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.filters-summary { margin-bottom: 10px; }

/* справочник платформ: только чтение */
.url-cell { word-break: break-all; font-size: 12px; }
.receipts-cell { white-space: pre-wrap; line-height: 1.45; }

/* меню столбца: сортировка, скрытие, фильтр */
th[data-menu] { position: relative; padding: 0; }
.col-btn {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 10px 12px; font: inherit; color: inherit; text-transform: inherit;
  letter-spacing: inherit; display: flex; align-items: center; gap: 6px;
}
.col-btn:hover { background: rgba(0, 0, 0, .04); }
.col-btn .caret { opacity: .45; font-size: 10px; }
th.sorted .col-btn, th.filtered .col-btn { color: var(--accent); }
th.filtered .col-btn::after { content: '•'; color: var(--accent); }

.col-menu[hidden] { display: none; }
/* position: fixed, а не absolute: карточка таблицы прокручивается вбок
   (overflow-x: auto) и обрезала бы выпавшее меню. Место считает скрипт
   (table-menu.js, place()) — координаты viewport-relative, поэтому и меню
   должно быть fixed, иначе JS посчитал бы правильно, а CSS сдвинул бы не туда. */
.col-menu {
  position: fixed; z-index: 30; min-width: 268px; max-width: 320px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(20, 25, 40, .16); padding: 6px;
  text-transform: none; letter-spacing: normal; font-weight: 400;
}
.col-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.col-menu button:hover { background: var(--bg-soft, #f1f2f4); }
.col-menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 2px; }
.col-filter { padding: 6px 10px 8px; }
.col-filter label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.col-filter input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
}
.col-hidden { display: none; }

/* столбец с активным фильтром или сортировкой: видно сразу (не только по наведению) —
   красный крестик сбоку от шапки снимает и то, и другое, без открытия меню.
   Без этого правила крестик показывался всегда, у каждого столбца сразу
   (не было самого правила в этом файле — нашлось при переносе меню столбца
   в «Авторассылки по группам», 2026-10-05) */
.col-quick-clear {
  display: none; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: var(--danger); color: #fff; cursor: pointer; font-size: 11px; line-height: 1;
  z-index: 2;
}
th.filtered .col-quick-clear, th.sorted .col-quick-clear { display: inline-flex; align-items: center; justify-content: center; }
.col-quick-clear:hover { background: #b8394a; }
th.sorted[data-dir="asc"] .col-btn::after { content: '↑'; color: var(--accent); }
th.sorted[data-dir="desc"] .col-btn::after { content: '↓'; color: var(--accent); }

/* Кнопка «+ Создать задачу»: тот же add-box, но summary выглядит кнопкой */
.add-box.task-create { padding: 12px 16px; }
.add-box.task-create > summary {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.add-box.task-create[open] { padding: 20px; }
.add-box.task-create[open] > summary { margin-bottom: 16px; }

/* обороты за квартал: итог считает программа, его не правят */
.quarter-total { text-align: right; font-weight: 600; white-space: nowrap; }

/* всё должно помещаться на экран: переносим по словам, а не тянем в ширину */
table { table-layout: auto; }
th, td { overflow-wrap: break-word; word-break: normal; }
td input, td select, td textarea { width: 100%; min-width: 0; box-sizing: border-box; }
.turnover-input { text-align: right; font-size: 13px; padding-left: 4px; padding-right: 4px; }
/* формы на отдельных страницах не растягиваем во всю ширину экрана */
.field input, .field select, .field textarea { max-width: 560px; }

/* Правка прямо в строке списка задач */
.cell-input {
  width: 100%; min-width: 7rem; padding: 5px 7px; font-size: 13px; font-family: inherit;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text);
}
.cell-input:hover { border-color: var(--border); background: #fff; }
.cell-input:focus { border-color: var(--accent); background: #fff; outline: none; }
textarea.cell-input { resize: vertical; min-height: 30px; }

/* стрелка «назад» в карточке и на формах */
.back-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px;
  border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text); font-size: 18px; line-height: 1;
  text-decoration: none;
}
.back-arrow:hover { background: var(--bg-soft, #f1f2f4); color: var(--accent); }

/* Отметка автосохранения. [hidden] нужен с !important: правила вида
   .btn { display: inline-block } иначе перебивают его. */
[hidden] { display: none !important; }
.autosave-status { display: inline-block; min-width: 5.5rem; font-size: 12px; }
.autosave-status.autosave-failed { color: var(--danger, #c92a2a); font-weight: 600; }

/* Ячейка названия задачи: поле правки и ссылка на карточку рядом */
.title-cell { display: flex; align-items: center; gap: 6px; }
.title-cell .cell-input { min-width: 22rem; }
.title-cell a { text-decoration: none; flex: none; }

/* отметка «оплачено» под суммой */
.paid-mark {
  display: block; width: 100%; margin-top: 4px;
  padding: 2px 4px; font-size: 11px; font-weight: 600;
  border: 1px solid #f19d38; border-radius: 6px;
  background: #fff4de; color: #8a5a10;          /* опл — жёлтым */
}
.paid-mark.not-paid {
  border-color: #e03131; background: #ffe9e9; color: #b02525;   /* не опл — красным */
}

/* Массовое удаление задач */
.bulk-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bulk-bar .btn[disabled] { opacity: .45; cursor: default; }
.bulk-pick, #bulk-all { width: 16px; height: 16px; cursor: pointer; }
/* у поля статуса свой фон — рамку не подсвечиваем поверх него */
.cell-input.status-pick { border-color: transparent; font-weight: 600; }

/* сверка в сводной — текст в несколько строк */
.summary-table .check-cell { white-space: normal; min-width: 0; line-height: 1.4; }

/* «Обороты» — плотная таблица-ведомость: столбцы уже, вся картина на экране */
.sheet th, .sheet td { padding: 6px 5px; font-size: 12px; vertical-align: top; }
.sheet th { font-size: 11px; letter-spacing: 0; }
.sheet .col-btn { padding: 8px 5px; }
.sheet textarea { font-size: 12px; min-height: 42px; padding: 4px 5px; }
.sheet .turnover-input { font-size: 12px; padding: 4px 4px; }
.sheet .paid-mark { font-size: 10px; padding: 1px 2px; margin-top: 2px; }
.sheet .quarter-total { font-size: 12px; }

/* суммы к уплате: оплаченные жёлтым, неоплаченные красным */
.sum-paid { color: #8a5a10; white-space: nowrap; }
.sum-unpaid { color: #b02525; white-space: nowrap; }
.summary-table .check-note { width: 100%; min-width: 0; font-size: 11px; resize: vertical; }

/* Всплывающее окно (передача задачи) */
.modal {
  border: 0; border-radius: var(--radius); padding: 24px;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(20, 25, 40, .25);
  color: var(--text); background: var(--surface);
}
.modal::backdrop { background: rgba(20, 25, 40, .45); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.handoff-target {
  margin: 0 0 14px; padding: 8px 12px; border-radius: 8px;
  background: #f1f3f5; font-weight: 600; font-size: 14px;
}

/* Шаблоны единым списком: заголовок разворачивается, шаги — отступом */
.tpl-head td { background: #f8f9fa; }
.tpl-toggle {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--accent); text-align: left;
}
.tpl-arrow { display: inline-block; width: 1em; color: var(--text-muted); }
.tpl-step > td { padding-top: 4px; padding-bottom: 4px; }
.step-line { display: flex; align-items: center; gap: 8px; padding-left: 20px; }
.step-title { flex: 1; min-width: 12rem; }
.step-performer { max-width: 15rem; }
.tpl-tools > td { padding: 14px 8px 18px 8px; }
.step-launch { max-width: 14rem; }

/* полоса «клиент уже уходил» в карточке вернувшегося */
.was-gone {
  border: 1px solid #e8a33d; background: #fff8ec;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
}
.was-gone.our-fault { border-color: var(--danger); background: #fff0f0; }

/* Зелёная кнопка — запуск процесса по клиенту */
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #2b8a3e; border-color: #2b8a3e; }

/* Жёлтая кнопка — «Завершено» в строке задачи */
.btn-warning { background: #f59f00; color: #fff; border-color: #f59f00; }
.btn-warning:hover { background: #e08e00; border-color: #e08e00; }

/* Плитки статистики */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-tile { flex: 1; min-width: 150px; text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-alarm .stat-value { color: var(--danger); }

/* уменьшение патента: уменьшен — жёлтым, нет — красным */
.reduce-mark {
  width: 100%; padding: 3px 4px; font-size: 12px; font-weight: 600;
  border: 1px solid #f19d38; border-radius: 6px;
  background: #fff4de; color: #8a5a10;
}
.reduce-mark.not-reduced {
  border-color: #e03131; background: #ffe9e9; color: #b02525;
}

/* Карточка таймера задачи */
.timer-card { border-left: 3px solid var(--success); }

/* Таймер в списке задач */
.timer-btn { padding: 6px 10px; font-size: 13px; }
.timer-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #ebfbee; border: 1px solid #b2f2bb; color: #2b8a3e;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
}
.timer-hint { margin-bottom: 12px; }

/* Глазик у поля с паролем: показать/скрыть набранное */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 40px; }
.pw-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  opacity: .45;
}
.pw-eye:hover { opacity: .8; }
.pw-eye.pw-eye-on { opacity: 1; }

/* ── Единый вид кнопок действий на странице ────────────────────────────────
   Строкой слева направо, у правого края шапки: зелёная «Создать», жёлтые
   действия над отмеченными строками (Редактировать/Включить/Выключить…),
   последней — красная (удаление или расторжение). Было два захода на этот
   блок (2026-08-18 — столбиком, 2026-10-05 — опять столбиком по ошибке) —
   оба раза ломали именно «строкой», отменено окончательно: кнопки в один
   ряд, как и просила Гульнара с самого начала (скрин-эталон — «Финансы»). */
.head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}
.head-actions form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.head-actions .btn { white-space: nowrap; padding: 4px 10px; font-size: 13px; }
.head-actions .hint { white-space: nowrap; }

/* подсказка про кнопки над таблицей */
.hint-buttons { margin: 4px 0 14px; }

/* зелёная — создание, главное действие страницы */
.btn-create { background: var(--success); color: #fff; border-color: var(--success); }
.btn-create:hover { background: #2b8a3e; border-color: #2b8a3e; }

/* серая подпись под кнопками: что они делают и что вообще на странице */
.page-note { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; max-width: 900px; }
.page-note strong { color: var(--text-muted); }

/* свёрнутая подсказка (2026-10-02, static/page-note-toggle.js): по умолчанию видна
   только кнопка, текст — после клика */
.page-note:not(.page-note-open) > .page-note-body { display: none; }
.page-note-body { margin-top: 8px; }
.page-note-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.page-note-toggle:hover { background: var(--bg); }
.page-note-toggle-icon { font-size: 11px; }


/* Логотип программы — он же кнопка аккаунта: ведёт на «О программе» */
.rail-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 12px;
  color: var(--rail-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 6px;
  text-decoration: none;
  font-size: 11px;
  text-align: center;
}
.rail-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: block;
}
.rail-brand .rail-label { font-weight: 600; color: #fff; }
.rail-brand:hover { text-decoration: none; }
.rail-brand:hover .rail-brand-icon { opacity: 0.85; }
.rail-brand.active { background: var(--rail-active); }


/* Синяя кнопка действия в шапке: по нашему порядку цветов
   зелёный — создать, жёлтый — правка, синий — переключение, красный — удаление */
.btn-toggle { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-toggle:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-toggle:disabled { opacity: 0.55; }

/* «Стоп обслуживания» из «Финансов» — клиент не платит: диалог розовым (2026-09-25) */
.wz-item.wz-stopped, .wz-chat-head.wz-stopped { background: #ffd6e7 !important; }
.wz-item.wz-stopped:hover { background: #ffc2dc !important; }
.wz-stop-badge { background: #c2255c; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 6px; white-space: nowrap; }
.wz-stop-badge.wz-stop-first { margin-left: 0; margin-right: 4px; }   /* «СТОП» впереди названия, перед кодом бухгалтера (13.10) */

.chat-line.msg-flash { animation: msgflash 4s ease-out 1; outline: 2px solid #ffd43b; border-radius: 10px; }
@keyframes msgflash { 0% { background: #fff3bf; } 70% { background: #fff3bf; } 100% { background: transparent; } }


/* ── Формы: читаемый текст сообщения и ровная вёрстка (жалоба Гульнары 2026-10-08: «текст сообщения не помещается») ── */
/* переключатели и галочки внутри .field раньше растягивались на всю ширину (общее правило для полей) и уезжали
   от своей подписи на другой край экрана */
.field input[type="radio"], .field input[type="checkbox"] { width: auto; max-width: none; min-width: 0; padding: 0; }
.field .tab-mode { display: flex; align-items: flex-start; gap: 10px; margin: 6px 0; font-size: 14px; color: var(--text); cursor: pointer; }
.field .tab-mode input { margin-top: 3px; flex: 0 0 auto; }
/* пояснения под полем — строкой под ним, а не справа за краем экрана */
.field > .hint, .field .hint { display: block; margin-top: 4px; font-size: 12.5px; line-height: 1.4; max-width: 760px; }
/* текст сообщения — большое поле во всю ширину формы, растёт вместе с текстом */
.field textarea.wz-bigtext {
  max-width: 900px; width: 100%; min-height: 280px; font-size: 15px; line-height: 1.55; padding: 12px 14px;
  resize: vertical; white-space: pre-wrap;
}
.field input[type="text"], .field input:not([type]), .field select { max-width: 760px; }
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* текст сообщения в списке — целиком, с переносами как написано (раньше обрезался до многоточия) */
.msg-cell { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 280px; max-width: 520px; font-size: 13px; line-height: 1.45; color: var(--text); }

.wz-mail-addr { font-size: 11px; font-weight: 400; color: #868e96; margin-left: 6px; word-break: break-all; }   /* адрес почты рядом с названием (14.10) */

.wz-phone { font-size: 12px; font-weight: 600; color: #3b3a36; background: #f3ede0; border-radius: 10px; padding: 0 8px; text-decoration: none; margin-left: 0; white-space: nowrap; }
.wz-phone:hover { background: #ebe1cb; }   /* телефон клиента в шапке чата (23.10): клик - позвонить и скопировать */
.wz-phone small { font-weight: 400; color: #868e96; }
.wz-nophone { font-size: 12px; color: #c92a2a; margin-left: 0; }

.wz-max-alt { margin: 8px 0; padding: 8px 12px; background: #fff4d6; border: 1px solid #e6c36a; border-radius: 8px; font-size: 14px; }
.wz-max-alt a { font-weight: 600; }

/* правки и удаления (27.10): что было до правки клиента или сотрудника, кто и когда */
.msg-revs { margin-top: 4px; font-size: 12px; color: #6b675d; }
.msg-revs summary { cursor: pointer; }
.msg-revs-client { color: #8a5a00; }
.msg-rev { margin: 2px 0 0 12px; }
.msg-rev del { color: #7a766b; }
.msg-rev-when { color: #8a8578; margin-right: 4px; }
.rev-old { color: #7a766b; }
