/* CRM ВИДЖИО — оформление */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --side: #17202e;
  --side-soft: #1f2b3d;
  --line: #e3e8f0;
  --text: #1b2432;
  --muted: #6b7787;
  --accent: #2f6df6;
  --accent-soft: #eaf1ff;
  --ok: #17924a;
  --warn: #c9760c;
  --fail: #c33a3a;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые display у элемента — иначе панель
   с display:flex остаётся на экране, хотя скрипт её «спрятал». */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

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

/* ---------------- Левое меню ---------------- */
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--side);
  color: #c9d3e2;
  display: flex;
  flex-direction: column;
  /* fixed, а не sticky: на длинных карточках sticky внутри flex-строки
     перестаёт держаться и меню уезжает вместе со страницей */
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
}
.brand-text { color: #fff; font-weight: 600; letter-spacing: .2px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }

.nav-dep {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: #c9d3e2;
  font-weight: 500;
}
.nav-dep:hover { background: var(--side-soft); color: #fff; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  color: #7d8ba0;
  background: rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 1px 7px;
}

.nav-sub { padding: 2px 0 6px; }
.nav-sub a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px 7px 44px;
  color: #93a1b5;
  font-size: 13px;
}
.nav-sub a:hover { color: #fff; background: var(--side-soft); }
.nav-sub a.active {
  color: #fff;
  background: var(--side-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #8fa4c6;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  padding: 0 4px;
}

.nav-icon {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: rgba(255,255,255,.12);
  flex: 0 0 18px;
}
.i-megaphone { background: #f0a13a33; box-shadow: inset 0 0 0 1px #f0a13a66; }
.i-handshake { background: #2f6df633; box-shadow: inset 0 0 0 1px #2f6df666; }
.i-users     { background: #a06df633; box-shadow: inset 0 0 0 1px #a06df666; }
.i-wallet    { background: #17924a33; box-shadow: inset 0 0 0 1px #17924a66; }
.i-wrench    { background: #6b778733; box-shadow: inset 0 0 0 1px #6b778766; }
.i-shield    { background: #c33a3a33; box-shadow: inset 0 0 0 1px #c33a3a66; }
.i-rocket    { background: #0fb3c133; box-shadow: inset 0 0 0 1px #0fb3c166; }

.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
  color: #7d8ba0;
}
.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
}

/* ---------------- Контент ---------------- */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: 248px;   /* место под фиксированное меню */
}

/* карточка обёрнута в form: обычный блок, иначе flex + sticky-панель
   раздувают высоту страницы и прокрутка уезжает за пределы содержимого */
.content > form { display: block; min-width: 0; }

.page-head {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-head h1 { margin: 0; font-size: 19px; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }

.page-body { padding: 20px 24px 40px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: #c9d2e0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2559d0; }
.btn-danger { color: var(--fail); border-color: #f0cccc; background: #fff; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.stat .num { font-size: 26px; font-weight: 600; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------------- Таблица ---------------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background: #fff;
  min-width: 180px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { background: #fafbfd; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--muted); }

/* ---------------- Форма ---------------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

.section-title {
  margin: 26px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---------------- Воронка ---------------- */
.funnel { margin-bottom: 22px; }
.funnel h3 { margin: 0 0 10px; font-size: 15px; }
.stage-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.stage-name { width: 220px; color: var(--muted); font-size: 13px; }
.stage-bar { flex: 1; height: 18px; background: #eef1f6; border-radius: 5px; overflow: hidden; }
.stage-bar i { display: block; height: 100%; background: var(--accent); }
.stage-bar i.s-S { background: var(--ok); }
.stage-bar i.s-F { background: var(--fail); }
.stage-cnt { width: 54px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Встроенный сервис ---------------- */
.embed-frame {
  flex: 1;
  border: 0;
  width: 100%;
  min-height: calc(100vh - 66px);
  background: #fff;
}
.embed-note {
  background: #fff8e6;
  border: 1px solid #f0dca8;
  color: #7a5a12;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 20px 24px;
  font-size: 13px;
}

/* ---------------- Заглушка ---------------- */
.stub { max-width: 620px; }
.stub h2 { margin-top: 0; }
.stub ul { color: var(--muted); padding-left: 18px; }
.stub li { margin-bottom: 6px; }

/* ---------------- Переключатель вида ---------------- */
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.view-switch a {
  padding: 7px 14px;
  font-size: 13px;
  color: var(--muted);
  border-right: 1px solid var(--line);
}
.view-switch a:last-child { border-right: 0; }
.view-switch a.active { background: var(--accent); color: #fff; }

.kanban-tools { display: flex; gap: 8px; }
.kanban-tools select, .kanban-tools input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  background: #fff;
}

/* ---------------- Канбан ---------------- */
.kanban {
  display: flex;
  gap: 12px;
  padding: 16px 24px 28px;
  overflow-x: auto;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.kanban-col {
  flex: 0 0 272px;
  background: #eef1f6;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 130px);
}

.kanban-col-head {
  padding: 10px 12px;
  border-top: 3px solid var(--accent);
  border-radius: 10px 10px 0 0;
  background: #fff;
}
.kanban-col-head.s-S { border-top-color: var(--ok); }
.kanban-col-head.s-F { border-top-color: var(--fail); }

.kanban-col-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-col-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.kanban-col-meta .sum { font-variant-numeric: tabular-nums; }

.kanban-cards {
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.kanban-cards.over { background: #dde6f8; border-radius: 0 0 10px 10px; }

.kanban-card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(20, 30, 50, .05);
}
.kanban-card:hover { border-color: #b9c6dc; }
.kanban-card.dragging { opacity: .45; }
.kanban-card.moved { animation: flash .9s ease; }
@keyframes flash {
  from { box-shadow: 0 0 0 2px var(--accent); }
  to   { box-shadow: 0 1px 2px rgba(20, 30, 50, .05); }
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  line-height: 1.35;
}
.kanban-card-sum {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}
.kanban-card-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.kanban-card-row span { flex: 0 0 auto; opacity: .75; }

.kanban-more {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
  padding: 6px;
}

/* ---------------- Карточка в стиле Битрикса ---------------- */
.card-head {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px 0;
}
.card-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.card-title-row h1 { margin: 0; font-size: 20px; font-weight: 600; }
.card-sum {
  font-size: 20px;
  font-weight: 600;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}
.card-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Полоска стадий — как в Битриксе: клик переводит сделку */
.stage-flow { display: flex; gap: 2px; margin: 14px 0 0; overflow-x: auto; padding-bottom: 14px; }
.stage-flow button {
  flex: 1 1 0;
  min-width: 78px;
  border: 0;
  background: #e6eaf1;
  color: var(--muted);
  font-size: 11px;
  padding: 7px 6px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-flow button:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); }
.stage-flow button:hover { background: #d6deea; }
.stage-flow button.done { background: #b9d4f5; color: #1c3f6e; }
.stage-flow button.current { background: var(--accent); color: #fff; font-weight: 600; }
.stage-flow button.current.s-S { background: var(--ok); }
.stage-flow button.current.s-F { background: var(--fail); }

.card-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; padding: 18px 24px 40px; }
@media (max-width: 1100px) { .card-body { grid-template-columns: 1fr; } }

.card-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  /* без overflow: hidden — иначе он срезает выпадающий список подсказок
     в полях «Компания» и «Контакт» */
}
.card-section > summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-section > summary::-webkit-details-marker { display: none; }
.card-section > summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
.card-section[open] > summary::before { content: "▾"; }
.card-section > summary .count { margin-left: auto; color: var(--muted); font-weight: 400; }

.card-fields { padding: 4px 16px 16px; }
.card-field {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f4f9;
  align-items: center;
}
.card-field:last-child { border-bottom: 0; }
.card-field > label { color: var(--muted); font-size: 12px; }
.card-field input, .card-field select, .card-field textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  background: transparent;
  font-family: inherit;
}
.card-field input:hover, .card-field select:hover, .card-field textarea:hover { background: #f6f8fb; }
.card-field input:focus, .card-field select:focus, .card-field textarea:focus {
  outline: none; background: #fff; border-color: var(--accent);
}

.card-aside .card-section { margin-bottom: 14px; }
.card-aside .kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.card-aside .kv span { color: var(--muted); }

.card-actions {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  gap: 10px;
  z-index: 5;
  margin-top: auto;
}

/* тело карточки не должно тянуться на всю высоту — иначе появляется пустой хвост */
.card-body { align-content: start; }

/* ---------------- Настройка полей ---------------- */
.fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.field-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row .code { color: var(--muted); font-size: 11px; }
.field-row label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.saved-note {
  background: #e8f6ec; border: 1px solid #b7e0c4; color: #1c6b36;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}

/* ---------------- Выбор компании и контакта ---------------- */
.link-picker { position: relative; display: flex; gap: 6px; align-items: center; }
.link-picker .link-search { flex: 1; min-width: 0; }
.link-add {
  flex: 0 0 26px;
  height: 26px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.link-add:hover { border-color: var(--accent); background: var(--accent-soft); }

.link-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 32px;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(20, 30, 50, .12);
  max-height: 230px;
  overflow-y: auto;
  margin-top: 3px;
}
.link-drop.open { display: block; }
.link-item { padding: 7px 11px; font-size: 13px; cursor: pointer; }
.link-item .hint { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.link-item:hover { background: var(--accent-soft); }
.link-empty { padding: 10px 11px; font-size: 12px; color: var(--muted); }

/* ---------------- Сотрудники ---------------- */
.staff-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.staff-form .field label { font-size: 12px; }
.id-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.id-chip {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}
.id-chip.known { background: #e8f6ec; border-color: #b7e0c4; color: #1c6b36; }
.id-chip .n { color: var(--muted); margin-left: 4px; }

/* ---------------- Лента карточки ---------------- */
.card-body { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1180px) { .card-body { grid-template-columns: 1fr; } }

.feed { padding: 0; }
.feed-head {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.feed-compose { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.feed-compose textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}
.feed-compose textarea:focus { outline: none; border-color: var(--accent); }

.feed-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.feed-actions select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
}
.feed-attach { padding: 6px 10px; font-size: 12px; cursor: pointer; }
.feed-actions .btn-primary { padding: 6px 12px; font-size: 12px; }

.feed-status { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 15px; }
.feed-status.error { color: var(--fail); }

.feed-list { max-height: 520px; overflow-y: auto; padding: 6px 16px 14px; }
.feed-empty { color: var(--muted); font-size: 12px; padding: 14px 0; }

.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1f4f9; }
.feed-item:last-child { border-bottom: 0; }

.feed-mark {
  flex: 0 0 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--accent);
}
.feed-item.k-file .feed-mark { background: var(--warn); }
.feed-item.k-stage .feed-mark { background: var(--ok); }
.feed-item.k-created .feed-mark { background: var(--muted); }

.feed-body { flex: 1; min-width: 0; font-size: 13px; word-wrap: break-word; }
.feed-body a { color: var(--accent); }
.feed-size { color: var(--muted); font-size: 11px; margin-left: 6px; }
.feed-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* ---------------- Дела: задачи и напоминания ---------------- */
.feed-head { display: flex; align-items: center; gap: 8px; }
.feed-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  background: #eef1f6;
  border-radius: 20px;
  padding: 2px 8px;
}
.feed-badge.overdue { background: #fdeaea; color: var(--fail); }

.tasks { padding: 8px 16px 0; }
.task {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 7px;
  background: #fff;
  transition: opacity .3s;
}
.task.s-overdue { border-left-color: var(--fail); background: #fff7f7; }
.task.s-today { border-left-color: var(--warn); background: #fffaf2; }
.task.s-done { opacity: .35; }

.task-check { margin-top: 2px; flex: 0 0 auto; cursor: pointer; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; line-height: 1.35; word-wrap: break-word; }
.task-kind {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  margin-right: 4px;
  vertical-align: 1px;
}
.task-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.task.s-overdue .task-meta { color: var(--fail); }

/* переключатель вида записи */
.feed-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.feed-tabs button {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 5px 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.feed-tabs button:hover { border-color: #c9d2e0; }
.feed-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.feed-extra { display: flex; gap: 6px; margin-top: 8px; }
.feed-extra input, .feed-extra select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
}

.feed-item.k-task .feed-mark { background: #7a5af5; }
.feed-item.k-reminder .feed-mark { background: var(--warn); }
.feed-item.k-done .feed-mark { background: var(--ok); }

/* ---------------- Доска дел ---------------- */
.overdue-text { color: var(--fail); }
.done-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

.activities .kanban-col { flex: 0 0 258px; }
.kanban-col-head.c-overdue  { border-top-color: var(--fail); }
.kanban-col-head.c-today    { border-top-color: var(--warn); }
.kanban-col-head.c-tomorrow { border-top-color: var(--accent); }
.kanban-col-head.c-week     { border-top-color: #7a5af5; }
.kanban-col-head.c-later    { border-top-color: #8fa0b5; }
.kanban-col-head.c-nodue    { border-top-color: #c3ccda; }

.act-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(20, 30, 50, .05);
  transition: opacity .3s, box-shadow .3s;
}
.act-card:hover { border-color: #b9c6dc; }
.act-card.dragging { opacity: .45; }
.act-card.moved { box-shadow: 0 0 0 2px var(--ok); }
.act-card.failed { box-shadow: 0 0 0 2px var(--fail); }
.act-card.is-done { opacity: .45; }
.act-card.is-done .act-title { text-decoration: line-through; }

.act-top { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.act-top .task-check { margin: 0; cursor: pointer; }
.act-due {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: #f0f3f8;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}
.act-due.overdue { background: #fdeaea; color: var(--fail); }

.act-title { font-size: 13px; line-height: 1.35; margin-bottom: 5px; word-wrap: break-word; }
.act-deal {
  display: block;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.act-meta { font-size: 11px; color: var(--muted); }
.act-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 0; }

/* форма нового дела на доске */
.act-new {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
}
.act-new input[type=text] { flex: 1; min-width: 220px; }
.act-new input, .act-new select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
}
.act-new .feed-status { margin: 0; }
/* атрибут hidden сам по себе не сработает: display: flex выше по приоритету */
.act-new[hidden] { display: none; }

/* ---------------- Связанные записи ---------------- */
.related { padding: 12px 16px; }
.rel-group + .rel-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 8px;
}
.rel-count {
  background: #eef1f6;
  color: var(--muted);
  border-radius: 20px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 400;
}
.rel-total { margin-left: auto; color: var(--ok); font-weight: 600; text-transform: none; }

.rel-item {
  display: block;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  background: #fff;
}
.rel-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.rel-title { display: block; line-height: 1.3; }
.rel-sum { font-size: 12px; color: var(--muted); margin-right: 8px; }
.rel-stage {
  display: inline-block;
  font-size: 11px;
  border-radius: 4px;
  padding: 0 5px;
  background: #eef1f6;
  color: var(--muted);
}
.rel-stage.s-S { background: #e5f5eb; color: var(--ok); }
.rel-stage.s-F { background: #fdeaea; color: var(--fail); }
.rel-post { font-size: 11px; color: var(--muted); }
.rel-more {
  display: block;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 7px;
}
.rec-number { color: var(--text); font-weight: 600; }

/* ---------------- Выбор колонок списка ---------------- */
.cols-wrap { position: relative; }
.cols-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 30, 50, .16);
  z-index: 40;
  display: flex;
  flex-direction: column;
  max-height: 60vh;
}
.cols-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.cols-head input {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
}
.cols-list { overflow-y: auto; padding: 6px; flex: 1; }
.cols-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
}
.cols-item:hover { background: var(--accent-soft); }
.cols-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols-tag {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.cols-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

/* ---------------- Телефония ---------------- */
.call-dir {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.call-dir.d-in { background: var(--ok); }
.call-dir.d-out { background: var(--accent); }

.call-phone { font-variant-numeric: tabular-nums; }
.call-status {
  font-size: 11px;
  border-radius: 5px;
  padding: 1px 7px;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}
.call-status.s-answered { background: #e5f5eb; color: var(--ok); }
.call-status.s-missed { background: #fdeaea; color: var(--fail); }
.call-status.s-busy, .call-status.s-failed { background: #fff4e5; color: var(--warn); }

.call-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f4f9;
  font-size: 13px;
}
.call-row:last-child { border-bottom: 0; }
.call-when { margin-left: auto; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

.mf-row { display: flex; align-items: center; gap: 6px; }
.mf-call {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  color: var(--accent);
  font-size: 13px;
}
.mf-call:hover { background: var(--accent-soft); }

/* ---------------- Права доступа ---------------- */
.roles-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 8px; }
.role-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.role-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.role-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  background: #eef1f6;
  border-radius: 20px;
  padding: 1px 8px;
}
.role-desc { font-size: 12px; color: var(--muted); margin: 6px 0 10px; line-height: 1.4; min-height: 34px; }
.role-scope { display: block; font-size: 12px; color: var(--muted); }
.role-scope select {
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.hint-line { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }

.perm-table th { position: sticky; top: 0; z-index: 2; }
.perm-table td { vertical-align: middle; }
.perm-group td {
  background: #f5f7fa;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 6px 14px;
}
.perm-section { min-width: 210px; }
.perm-code { display: block; font-size: 11px; color: var(--muted); }

select.lvl {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  background: #fff;
  min-width: 128px;
}
select.lvl-none { color: var(--muted); background: #f7f8fa; }
select.lvl-read { border-color: #b9d4f5; background: #f2f7ff; }
select.lvl-write { border-color: #f0dca8; background: #fffaf0; }
select.lvl-full { border-color: #b7e0c4; background: #f2fbf5; }

.token-note {
  background: #f2fbf5;
  border: 1px solid #b7e0c4;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.token-value {
  display: block;
  margin: 8px 0;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}
.token-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.token-form input[type=text] {
  flex: 1;
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
}
.token-form label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.token-off { opacity: .55; }
.role-pick {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 12px;
  background: #fff;
  min-width: 150px;
}
.role-pick.saved { border-color: var(--ok); background: #f2fbf5; }

/* ---------------- Дашборд ---------------- */
.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dash-kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.dash-kpi-num { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.dash-kpi-num.ok { color: var(--ok); }
.dash-kpi-num.fail { color: var(--fail); }
.dash-kpi-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dash-kpi-lbl b { color: var(--fail); font-weight: 600; }
.fail-text { color: var(--fail); }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.dash-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
  display: flex;
  flex-direction: column;
}
.dash-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dash-block-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.dash-link { font-size: 12px; color: var(--accent); }

.dash-nums {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}
.dash-nums div { display: flex; flex-direction: column; }
.dash-nums b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dash-nums b.ok { color: var(--ok); }
.dash-nums b.warn { color: var(--warn); }
.dash-nums b.fail { color: var(--fail); }
.dash-nums span { font-size: 11px; color: var(--muted); line-height: 1.3; }

.dash-sub {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  margin: 12px 0 6px;
}
.dash-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.dash-bar-lbl {
  width: 150px;
  flex: 0 0 150px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-bar-track { flex: 1; height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.dash-bar-track i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.dash-bar-val { width: 36px; text-align: right; font-variant-numeric: tabular-nums; }

.dash-leaders { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.dash-leaders b { color: var(--text); font-weight: 500; }

.dash-foot {
  margin-top: auto;
  padding-top: 10px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid #f1f4f9;
}
.nav-home { margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.07); padding-bottom: 12px; }
.nav-home.active { color: #fff; background: var(--side-soft); box-shadow: inset 3px 0 0 var(--accent); }
.i-dash { background: #ffffff22; box-shadow: inset 0 0 0 1px #ffffff55; }
.muted-link { color: var(--accent); }

/* ---------------- Вход и профиль ---------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--side);
}
.login-box {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 28px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-field { display: block; margin-bottom: 12px; }
.login-field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-remember { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.login-submit { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.login-error {
  background: #fdeaea;
  border: 1px solid #f0c4c4;
  color: var(--fail);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-hint { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }

.sidebar-foot { display: flex; align-items: center; gap: 8px; }
.who { flex: 1; min-width: 0; color: #c9d3e2; font-size: 12px; line-height: 1.3; }
.who:hover { color: #fff; }
.who-role { display: block; color: #7d8ba0; font-size: 11px; }
.logout-form { margin: 0; }
.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: #93a1b5;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
}
.logout-btn:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.feed-author-me { font-size: 12px; color: var(--muted); align-self: center; }
.acc-login { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.acc-cell .btn { padding: 3px 7px; font-size: 12px; }
.acc-modal { position: fixed; inset: 0; background: rgba(20, 30, 50, .45); display: grid; place-items: center; z-index: 100; }
.acc-modal-box { background: var(--panel); border-radius: 12px; padding: 22px 24px; width: 380px; max-width: calc(100vw - 32px); }
.acc-modal-box h3 { margin: 0 0 8px; }
.acc-modal-box p { font-size: 13px; color: var(--muted); }
.acc-creds div { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.acc-creds span { width: 60px; font-size: 12px; color: var(--muted); }
.acc-creds code { flex: 1; background: #f4f6fa; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 14px; user-select: all; }

/* ---------------- Переписка ---------------- */
.chat-history {
  max-height: 340px;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f7f8fb;
}
.msg { max-width: 88%; padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 1.4; }
.msg-in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-out.msg-failed { background: #fdeaea; color: var(--fail); border: 1px solid #f0c4c4; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; }
.msg-meta { font-size: 10.5px; opacity: .75; margin-top: 4px; }
.msg-out .msg-meta { text-align: right; }
.msg-ch { font-weight: 600; }
.chat-compose { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.chat-compose select, .chat-compose textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  background: #fff;
}
.chat-empty { padding: 14px 16px; font-size: 13px; color: var(--muted); }
.chat-note { padding: 8px 14px 12px; font-size: 11.5px; color: var(--muted); border-top: 1px solid #f1f4f9; }
.chat-note a { color: var(--accent); }

/* ---------------- Договоры ---------------- */
.contracts-summary { margin-bottom: 16px; }
.contracts-summary a.dash-kpi { text-decoration: none; color: inherit; }
.cell-wrap { white-space: normal; max-width: 260px; }
.ck { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #eef2f8; }
.ck-install { background: #e3ecff; color: #2b4fb3; }
.ck-service { background: #e4f5ea; color: #1f7a3f; }
.ck-supply  { background: #fdf0dd; color: #9a5b00; }
.cs { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef2f8; color: #4a5568; }
.cs-sent { background: #e3ecff; color: #2b4fb3; }
.cs-signed { background: #e4f5ea; color: #1f7a3f; }
.cs-done { background: #e4f5ea; color: #1f7a3f; }
.cs-cancelled { background: #fbe4e4; color: #a33; }
.fail-note { color: var(--fail); border-color: #f0cccc; }
.contract-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.contract-buttons .btn { padding: 6px 10px; font-size: 12px; }
.contracts-block .rel-item { display: flex; gap: 8px; align-items: center; }
.cp-paste textarea { width: 100%; margin-bottom: 6px; }
.cp-paste .btn { padding: 5px 10px; font-size: 12px; }
.items-table { margin-bottom: 10px; }
.items-table th, .items-table td { padding: 4px 6px; white-space: normal; }
.items-table input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.items-table input.narrow { width: 70px; }
.items-table input.num { text-align: right; }
.items-table .row-sum, .items-table .items-total { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items-table .items-total-lbl { text-align: right; color: var(--muted); }
.items-table .items-total { font-weight: 600; }
.items-table .item-del { padding: 2px 8px; }
.aside-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.status-form select { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; background: #fff; }
.tpl-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 8px; }
.tpl-title { font-weight: 600; margin-bottom: 4px; }
.tpl-status { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.tpl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-ph { margin-top: 12px; font-size: 12px; color: var(--muted); }
.tpl-ph-list { margin-top: 6px; line-height: 1.9; }
.tpl-ph-list code { background: #f3f5f9; padding: 1px 5px; border-radius: 4px; }
.vat-row { display: flex; gap: 8px; align-items: center; }
.vat-row select { flex: 0 0 auto; min-width: 200px; }
.vat-row input { flex: 1; }
.ent-card { margin-bottom: 14px; }
.ent-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ent-head h3 { margin: 0; font-size: 15px; }
.ent-head .tag { font-size: 11px; }
.ent-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.ent-actions .spacer { flex: 1; }

/* ---------------- Восстановление пароля и почта портала ---------------- */
.login-title { font-size: 18px; margin: 0 0 6px; }
.login-done {
  background: #e8f5ec;
  border: 1px solid #bfe3cb;
  color: #1f7a3f;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.mail-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mail-presets .btn { padding: 6px 10px; font-size: 12px; }
.mail-state { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; font-size: 13px; }
.mail-state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fail); }
.mail-state.on .dot { background: var(--ok, #2e7d4f); }
.mail-test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mail-test input { min-width: 240px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13px; }

/* ---------------- Телефония: внутренние номера ---------------- */
.ext-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.ext-head h3 { margin: 0; font-size: 15px; }
.ext-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.ext-card { margin-bottom: 18px; }
.tag-off { background: #f2f4f7; color: var(--muted); border-color: #e2e6ec; }
.btn-mini { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.row-off td { opacity: .55; }
code.pw { background: #f3f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* телефония: вкладки, состав групп, расписание */
.tel-tabs { margin-bottom: 16px; }
.tel-actions { margin-bottom: 12px; }
.member-list { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.member { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.member:hover { border-color: #c9d2e0; }
.member-off { opacity: .55; }
.member-ext { font-weight: 600; min-width: 38px; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-dev { color: var(--muted); font-size: 12px; }
.holidays-box { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; font-family: inherit; }
