/* ============================================================
   UI KIT — единая дизайн-система панели (как на странице «Аналитика»)
   Собственные компоненты на переменных темы: работает в тёмной и светлой.
   Откат всего редизайна = убрать подключение этого файла в index.html
   ============================================================ */

:root {
  --k-radius: 18px;
  --k-radius-sm: 12px;
  --k-gap: 14px;
  --k-line: color-mix(in srgb, var(--border) 55%, transparent);
  --k-fill: color-mix(in srgb, var(--text-muted) 10%, transparent);
  --k-elev: 0 12px 32px -20px rgba(0, 0, 0, .6), 0 2px 8px -4px rgba(0, 0, 0, .28);
  --k-elev-hi: 0 20px 44px -24px rgba(0, 0, 0, .65);
}

.k { display: flex; flex-direction: column; gap: 18px; padding-bottom: 28px; }
.k * { box-sizing: border-box; }
.k .num,
.k b,
.k table td,
.k table th { font-variant-numeric: tabular-nums; }

/* ---------- ШАПКА СТРАНИЦЫ ---------- */
.k-hero {
  position: relative; overflow: hidden;
  padding: 24px 26px; border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, #fff 4%), var(--card));
  box-shadow: var(--k-elev);
}
.k-hero::after {
  content: ''; position: absolute; width: 320px; height: 320px; right: -130px; top: -180px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--acid) 12%, transparent) 0%, transparent 70%);
}
.k-hero-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; position: relative; }
.k-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted); }
.k-title { margin: 8px 0 0; font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -.025em; color: var(--text-main); }
.k-lead { margin: 10px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); max-width: 680px; }
.k-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- КНОПКИ ---------- */
.k-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .2s ease; white-space: nowrap;
}
.k-btn:hover { color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 55%, var(--border)); transform: translateY(-1px); }
.k-btn-primary {
  background: linear-gradient(135deg, var(--acid), color-mix(in srgb, var(--acid) 75%, #000 10%));
  border-color: transparent; color: #0a0a0a; font-weight: 700;
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--acid) 80%, transparent);
}
.k-btn-primary:hover { color: #0a0a0a; transform: translateY(-2px); box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--acid) 85%, transparent); }
.k-btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.k-btn-danger { color: #f43f5e; border-color: color-mix(in srgb, #f43f5e 35%, var(--border)); }
.k-btn-danger:hover { color: #f43f5e; border-color: #f43f5e; }

/* ---------- KPI ---------- */
.k-kpis { display: grid; gap: var(--k-gap); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.k-kpi {
  position: relative; overflow: hidden; padding: 18px 20px; border-radius: var(--k-radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, #fff 4%), var(--card));
  box-shadow: var(--k-elev);
  transition: transform .24s ease, box-shadow .24s ease;
  animation: kUp .4s cubic-bezier(.22,1,.36,1) backwards;
}
.k-kpi:hover { transform: translateY(-3px); box-shadow: var(--k-elev-hi); }
.k-kpi::after {
  content: ''; position: absolute; width: 130px; height: 130px; right: -55px; top: -60px; border-radius: 50%;
  background: radial-gradient(circle, var(--k-glow, transparent) 0%, transparent 70%); opacity: .6; pointer-events: none;
}
.k-kpi .k-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--k-color, var(--acid)); }
.k-kpi .k-kpi-label { font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--text-muted); }
.k-kpi .k-kpi-value { margin-top: 9px; font-size: 30px; line-height: 1; font-weight: 800; letter-spacing: -.03em; color: var(--text-main); }
.k-kpi .k-kpi-hint { margin-top: 8px; font-size: 11.5px; line-height: 1.45; color: var(--text-muted); }

/* ---------- СЕГМЕНТЫ / ФИЛЬТРЫ ---------- */
.k-segs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 5px; width: fit-content; max-width: 100%;
  border-radius: 16px; border: 1px solid var(--border); background: var(--card); box-shadow: var(--k-elev);
}
.k-seg {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 15px;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 600; letter-spacing: -.01em;
  transition: all .2s cubic-bezier(.4,0,.2,1); white-space: nowrap;
}
.k-seg:hover { background: var(--hover); color: var(--text-main); }
.k-seg.is-active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 18%, transparent), color-mix(in srgb, var(--acid) 6%, transparent));
  color: var(--text-main); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acid) 35%, transparent);
}
.k-seg .k-cnt {
  font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 8px;
  background: var(--k-fill); font-variant-numeric: tabular-nums;
}
.k-seg.is-active .k-cnt { background: color-mix(in srgb, var(--acid) 25%, transparent); }

/* ---------- ПАНЕЛЬ / КАРТОЧКА ---------- */
.k-panel {
  border-radius: var(--k-radius); border: 1px solid var(--border); background: var(--card);
  box-shadow: var(--k-elev); overflow: hidden;
  animation: kUp .45s cubic-bezier(.22,1,.36,1) backwards;
}
.k-panel-pad { padding: 20px 22px; }
.k-panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.k-panel-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: var(--text-main); }
.k-panel-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }

/* ---------- СЕТКА КАРТОЧЕК ---------- */
.k-grid { display: grid; gap: var(--k-gap); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.k-grid-wide { grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); }
.k-grid-sm { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* На широких мониторах ограничиваем число колонок: иначе карточки становятся
   узкими и длинные имена обрезаются, хотя места на экране полно */
@media (min-width: 1500px) {
  .k-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .k-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .k-grid-sm { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 2100px) {
  .k-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .k-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.k-grid > * { animation: kUp .38s cubic-bezier(.22,1,.36,1) backwards; }
.k-grid > *:nth-child(1) { animation-delay: .02s } .k-grid > *:nth-child(2) { animation-delay: .04s }
.k-grid > *:nth-child(3) { animation-delay: .06s } .k-grid > *:nth-child(4) { animation-delay: .08s }
.k-grid > *:nth-child(5) { animation-delay: .10s } .k-grid > *:nth-child(6) { animation-delay: .12s }

.k-card {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px; border-radius: var(--k-radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 97%, #fff 3%), var(--card));
  box-shadow: var(--k-elev); transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.k-card:hover { transform: translateY(-3px); box-shadow: var(--k-elev-hi); border-color: color-mix(in srgb, var(--acid) 40%, var(--border)); }
.k-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.k-card-title { margin: 0; font-size: 14.5px; font-weight: 700; line-height: 1.35; letter-spacing: -.015em; color: var(--text-main); }
.k-card-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.k-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--k-line); }

/* ---------- МЕТА-СТРОКИ ---------- */
.k-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.k-meta-item { display: flex; align-items: baseline; gap: 6px; font-size: 11.5px; color: var(--text-muted); min-width: 0; }
.k-meta-item b { color: var(--text-main); font-weight: 700; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- БЕЙДЖИ ---------- */
.k-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px;
  border-radius: 8px; font-size: 11px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
  background: var(--k-fill); color: var(--text-muted);
}
.k-badge-green { background: color-mix(in srgb, #10b981 16%, transparent); color: #10b981; }
.k-badge-amber { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #f59e0b; }
.k-badge-rose { background: color-mix(in srgb, #f43f5e 16%, transparent); color: #f43f5e; }
.k-badge-sky { background: color-mix(in srgb, #0ea5e9 16%, transparent); color: #0ea5e9; }
.k-badge-violet { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #8b5cf6; }

.k-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 8px var(--k-dot-glow, transparent); }

/* ---------- ПРОГРЕСС ---------- */
.k-prog { display: flex; align-items: center; gap: 10px; }
.k-prog .k-track { flex: 1; height: 7px; border-radius: 99px; background: var(--k-fill); overflow: hidden; min-width: 60px; }
.k-prog .k-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.k-prog .k-pct { font-size: 12.5px; font-weight: 700; color: var(--text-main); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- ТАБЛИЦА ---------- */
.k-scroll { overflow-x: auto; }
.k-table { width: 100%; border-collapse: collapse; }
.k-table thead th {
  position: sticky; top: 0; z-index: 1; padding: 13px 18px;
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); text-align: left; white-space: nowrap;
  background: color-mix(in srgb, var(--card) 92%, var(--text-main) 8%);
  border-bottom: 1px solid var(--border);
}
.k-table td { padding: 12px 18px; border-bottom: 1px solid var(--k-line); vertical-align: middle; font-size: 13px; color: var(--text-main); }
.k-table tbody tr { transition: background .16s ease; }
.k-table tbody tr:hover { background: var(--hover); }
.k-table tbody tr:last-child td { border-bottom: 0; }
.k-r { text-align: right; } .k-c { text-align: center; }
.k-soft { color: var(--text-muted); font-size: 12.5px; }
.k-strong { font-weight: 700; }
.k-trunc { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Имена в строках участников: лучше перенести на вторую строку, чем обрезать */
.k-row-name {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--text-main);
  line-height: 1.3; overflow-wrap: anywhere;
}

/* ---------- ПАГИНАЦИЯ ---------- */
.k-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding: 16px; }
.k-pager button {
  min-width: 38px; height: 38px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .18s ease; font-variant-numeric: tabular-nums;
}
.k-pager button:hover:not(:disabled) { color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 60%, var(--border)); transform: translateY(-1px); }
.k-pager button.is-active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 22%, transparent), color-mix(in srgb, var(--acid) 8%, transparent));
  color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 45%, transparent);
}
.k-pager button:disabled { opacity: .4; cursor: not-allowed; }
.k-pager .k-pager-info { margin: 0 8px; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- ПУСТО / СКЕЛЕТ ---------- */
.k-empty { padding: 60px 20px; text-align: center; }
.k-empty .k-empty-ic { font-size: 40px; opacity: .25; }
.k-empty .k-empty-tx { margin-top: 10px; font-size: 14px; color: var(--text-muted); }
.k-sk { height: 14px; border-radius: 8px; background: var(--k-fill); animation: kPulse 1.4s ease-in-out infinite; }

@keyframes kUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes kPulse { 0%,100% { opacity: .45 } 50% { opacity: .9 } }

/* ============================================================
   КАРТОЧКА ЗАДАЧИ (tk-*): статус-полоса + аватар + плотная сетка
   ============================================================ */
.tk {
  position: relative; overflow: hidden;
  border-radius: var(--k-radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 97%, #fff 3%), var(--card));
  box-shadow: var(--k-elev);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.tk:hover {
  transform: translateY(-3px);
  box-shadow: var(--k-elev-hi);
  border-color: color-mix(in srgb, var(--tk) 45%, var(--border));
}
.tk-muted { opacity: .72; }
.tk-muted:hover { opacity: 1; }

/* Полоса состояния слева — главный опознавательный знак */
.tk-strip {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--tk), color-mix(in srgb, var(--tk) 45%, transparent));
}
.tk:hover .tk-strip { box-shadow: 0 0 14px color-mix(in srgb, var(--tk) 60%, transparent); }

.tk-body { padding: 15px 17px 15px 19px; display: flex; flex-direction: column; gap: 11px; }

/* Верхняя строка: номер, состояние, срок */
.tk-top { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.tk-no { font-size: 11.5px; font-weight: 700; color: var(--text-muted); letter-spacing: -.01em; }
.tk-state {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 7px; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
}
.tk-top .k-badge { margin-left: auto; }

/* Заголовок — «имя задачи»: крупнее, с фирменным подчёркиванием в цвет статуса */
.tk-title {
  position: relative; margin: 0 0 3px; padding-bottom: 10px;
  font-size: 15.5px; line-height: 1.32; font-weight: 800; letter-spacing: -.02em;
  color: var(--text-main); overflow-wrap: anywhere;
}
.tk-title::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 36px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--tk), transparent);
  transition: width .3s cubic-bezier(.22, 1, .36, 1);
}
.tk:hover .tk-title::after { width: 64px; }

/* Описание — отдельный «лист» с боковой линией: сразу видно, где текст задачи */
.task-description-wrap {
  position: relative;
  padding: 9px 12px 9px 13px;
  border-radius: 10px;
  border-left: 2px solid color-mix(in srgb, var(--tk) 45%, transparent);
  background: color-mix(in srgb, var(--text-muted) 7%, transparent);
}
.tk-desc {
  margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-line;
}
.task-description-wrap[data-expanded="1"] .tk-desc { -webkit-line-clamp: unset; overflow: visible; }
.task-description-wrap::after { content: none !important; }
.task-description-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 7px; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 11.5px; font-weight: 700; color: var(--acid);
}
.task-description-toggle::after {
  content: '⌄'; font-size: 13px; line-height: 1; transform: translateY(-1px);
  transition: transform .2s ease;
}
.task-description-wrap[data-expanded="1"] .task-description-toggle::after { transform: rotate(180deg); }
.task-description-toggle:hover { text-decoration: underline; }

/* Люди: аватар с инициалами вместо подписей «Исполнитель / Поставил» */
.tk-people { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tk-ava {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.tk-people-txt { min-width: 0; flex: 1; }
.tk-assignee {
  font-size: 12.5px; font-weight: 700; color: var(--text-main); line-height: 1.3;
  overflow-wrap: anywhere;
}
.tk-more { margin-left: 5px; font-size: 10.5px; font-weight: 700; color: var(--text-muted); }
.tk-creator { margin-top: 2px; font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }

/* Принятие — компактная полоса вместо блока с рамкой */
.tk-accept {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--k-line); background: color-mix(in srgb, var(--text-muted) 6%, transparent);
  transition: border-color .18s ease, background .18s ease;
}
.tk-accept:hover { border-color: color-mix(in srgb, var(--acid) 45%, var(--border)); }
.tk-accept-label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.tk-accept-track { flex: 1; height: 6px; border-radius: 99px; background: var(--k-fill); overflow: hidden; }
.tk-accept-fill { display: block; height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.22,1,.36,1); }
.tk-accept-num { font-size: 12px; font-weight: 800; color: var(--text-main); }

/* Даты одной строкой — важен срок, остальное вторично */
.tk-dates {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted); line-height: 1.5;
}
.tk-dates b { color: var(--text-main); font-weight: 700; }
.tk-sep { opacity: .35; }

/* Запрос продления */
.tk-ext {
  padding: 9px 11px; border-radius: 11px;
  border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent);
  background: color-mix(in srgb, #f59e0b 9%, transparent);
}
.tk-ext-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 700; color: #f59e0b; }
.tk-ext-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Футер и кнопки одного размера */
.tk-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 11px; border-top: 1px solid var(--k-line);
}
.tk-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tk-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-muted); font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all .18s ease; white-space: nowrap;
}
.tk-btn i { font-size: 10px; }
.tk-btn:hover { color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 55%, var(--border)); transform: translateY(-1px); }
.tk-btn-ok { color: #10b981; border-color: color-mix(in srgb, #10b981 32%, var(--border)); }
.tk-btn-ok:hover { color: #10b981; border-color: #10b981; }
.tk-btn-no { color: #f43f5e; border-color: color-mix(in srgb, #f43f5e 32%, var(--border)); }
.tk-btn-no:hover { color: #f43f5e; border-color: #f43f5e; }
.tk-btn-ic { padding: 0 9px; }
.tk-check { display: inline-flex; align-items: center; cursor: pointer; }
.tk-check input { width: 17px; height: 17px; accent-color: var(--acid); cursor: pointer; }

/* ============================================================
   KSELECT — собственный выпадающий список с поиском
   ============================================================ */
.ks { position: relative; }
.ks-trigger {
  display: inline-flex; align-items: center; gap: 9px;
  width: 232px; max-width: 100%; height: 42px; padding: 0 13px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-main); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  text-align: left;
}
.ks-trigger:hover { border-color: color-mix(in srgb, var(--acid) 45%, var(--border)); transform: translateY(-1px); }
.ks.is-open .ks-trigger {
  border-color: var(--acid);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--acid) 16%, transparent);
}
.ks-ic { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.ks-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ks-arrow { font-size: 10px; color: var(--text-muted); transition: transform .22s ease; flex-shrink: 0; }
.ks.is-open .ks-arrow { transform: rotate(180deg); }

.ks-menu {
  position: absolute; z-index: 60; top: calc(100% + 7px); left: 0; min-width: 100%; width: 296px; max-width: 92vw;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, .7), 0 4px 12px -6px rgba(0, 0, 0, .4);
  overflow: hidden; opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transition: opacity .18s ease, transform .18s cubic-bezier(.22, 1, .36, 1), visibility .18s;
}
.ks.is-open .ks-menu { opacity: 1; visibility: visible; transform: none; }
.ks-menu-sm { width: 262px; }

.ks-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
}
.ks-search i { font-size: 11px; color: var(--text-muted); }
.ks-search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  color: var(--text-main); font-size: 13px; font-weight: 500;
}
.ks-search input::placeholder { color: var(--text-muted); }

.ks-list { max-height: 320px; overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.ks-list::-webkit-scrollbar { width: 8px; }
.ks-list::-webkit-scrollbar-thumb { background: var(--k-fill); border-radius: 99px; }

.ks-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 10px; background: none; cursor: pointer;
  color: var(--text-main); font-size: 13px; font-weight: 500; text-align: left;
  transition: background .14s ease;
}
.ks-opt:hover { background: var(--hover); }
.ks-opt.is-active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 16%, transparent), color-mix(in srgb, var(--acid) 5%, transparent));
  font-weight: 700;
}
.ks-opt-ava {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800;
  background: var(--k-fill); color: var(--text-muted);
}
.ks-empty { display: none; padding: 22px 12px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* ---------- ПАНЕЛЬ ФИЛЬТРОВ ЗАДАЧ ---------- */
/* Шапка: заголовок и кнопки — в одну линию, без провала слева */
.k-hero .k-hero-top { align-items: center; }
.tkf-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 16px;
}
.tkf-selects { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* Собственный вид выпадающего списка: у .input ширина 100%, из-за неё
   селекты растягивались на всю строку и вставали столбиком */
.tkf-select {
  width: 232px !important; max-width: 100%;
  height: 42px; padding: 0 38px 0 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-main);
  font-size: 13px; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.tkf-select:hover { border-color: color-mix(in srgb, var(--acid) 45%, var(--border)); }
.tkf-select:focus {
  outline: none; border-color: var(--acid);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--acid) 18%, transparent);
}
/* Пункты списка — в тон панели, а не системно-белые */
.tkf-select option {
  background: var(--card); color: var(--text-main);
  padding: 10px 12px; font-weight: 500;
}
.tkf-select option:checked { background: color-mix(in srgb, var(--acid) 22%, var(--card)); }
.tkf-block { margin-top: 16px; }
.tkf-label {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 9px;
}
.tkf-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.tkf-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: all .18s ease; white-space: nowrap;
}
.tkf-chip:hover { color: var(--text-main); transform: translateY(-1px); border-color: color-mix(in srgb, var(--acid) 45%, var(--border)); }
.tkf-cnt {
  font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 7px;
  background: var(--k-fill); font-variant-numeric: tabular-nums;
}
/* Активный фильтр подсвечивается системой js-chip (класс is-active/btn-chip-*) */
.tkf-chip.is-active,
.tkf-chip.active {
  color: var(--text-main);
  border-color: color-mix(in srgb, var(--acid) 50%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 16%, transparent), color-mix(in srgb, var(--acid) 5%, transparent));
}
.tkf-green .tkf-cnt { background: color-mix(in srgb, #10b981 18%, transparent); color: #10b981; }
.tkf-sky .tkf-cnt { background: color-mix(in srgb, #0ea5e9 18%, transparent); color: #0ea5e9; }
.tkf-violet .tkf-cnt { background: color-mix(in srgb, #8b5cf6 18%, transparent); color: #8b5cf6; }
.tkf-amber .tkf-cnt { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #f59e0b; }
.tkf-rose .tkf-cnt { background: color-mix(in srgb, #f43f5e 18%, transparent); color: #f43f5e; }

@media (max-width: 700px) {
  .tkf-selects { margin-left: 0; width: 100%; }
  .tkf-select { flex: 1; min-width: 0; }
  .tkf-chips { gap: 6px; }
  .tkf-chip { height: 32px; padding: 0 10px; font-size: 12px; }
}

/* ---------- ПАГИНАЦИЯ СПИСКОВ (серверная) ---------- */
.tg-pager-wrap {
  border-radius: var(--k-radius); border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--k-elev); padding: 14px 18px;
}
.tg-pager-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.tg-pager-head b { color: var(--text-main); font-variant-numeric: tabular-nums; }
.tg-pager-btn {
  height: 38px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .18s ease;
}
.tg-pager-btn:hover { color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 55%, var(--border)); transform: translateY(-1px); }
.tg-pager-btn-solid {
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 20%, transparent), color-mix(in srgb, var(--acid) 7%, transparent));
  color: var(--text-main); border-color: color-mix(in srgb, var(--acid) 40%, transparent);
}
.tg-pager-btn-disabled { opacity: .4; cursor: not-allowed; }

/* ---------- ЗАДАЧИ ---------- */
#tasksGrid {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
  gap: var(--k-gap) !important;
  align-items: start !important;
}
@media (min-width: 1500px) { #tasksGrid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }
@media (min-width: 2100px) { #tasksGrid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } }

.task-card { padding: 0 !important; }
.task-card .card-body { padding: 16px 18px !important; }

/* Описание: две строки, дальше по кнопке — без «выцветающего» обрыва */
.task-card .task-description-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-description-wrap[data-expanded="1"] .task-description-text { -webkit-line-clamp: unset; overflow: visible; }
.task-description-wrap::after { content: none !important; }
.task-description-toggle {
  margin-top: 5px; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--acid); text-decoration: none;
}
.task-description-toggle:hover { text-decoration: underline; }

/* Статус-пилюля в шапке карточки не должна ломать строку */
.task-card .status-pill,
.task-card .new-order-status-pill { white-space: nowrap; }

@media (max-width: 640px) {
  #tasksGrid { grid-template-columns: 1fr !important; }
  .task-card .k-meta { grid-template-columns: 1fr; }
}

/* ---------- ОБЩИЕ УЛУЧШЕНИЯ ---------- */
.void-card, .card { border-radius: var(--k-radius); }
.btn-chip { border-radius: 10px; font-weight: 600; transition: all .18s ease; }
.btn-chip:hover { transform: translateY(-1px); }
.status-pill { border-radius: 999px; font-size: 11px; font-weight: 700; }
.input, select.input, textarea.input { border-radius: var(--k-radius-sm); transition: border-color .18s ease, box-shadow .18s ease; }
.input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--acid) 18%, transparent); }
table td, table th, .text-2xl, .text-3xl, .text-xl { font-variant-numeric: tabular-nums; }

/* ============================================================
   ЧАТ (задачи и заказы): пузыри с разделением «я / собеседник»
   ============================================================ */
#messagesContainer,
.messages-container {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 18px !important;
}

.chat-message.message-bubble {
  position: relative;
  max-width: 74%; width: fit-content; min-width: 130px;
  padding: 9px 13px 7px !important;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 4px 14px -10px rgba(0, 0, 0, .5);
  animation: kUp .28s cubic-bezier(.22, 1, .36, 1) backwards;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.chat-message.message-bubble:hover { border-color: color-mix(in srgb, var(--acid) 35%, var(--border)); }

/* Чужое — слева, своё — справа зелёным */
.chat-message.is-other { align-self: flex-start; border-bottom-left-radius: 5px; }
.chat-message.is-me {
  align-self: flex-end; border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--acid) 20%, var(--card)), color-mix(in srgb, var(--acid) 9%, var(--card)));
  border-color: color-mix(in srgb, var(--acid) 32%, transparent);
}

/* Имя автора — мелко и в цвет, а не жирной строкой над текстом */
.chat-message .text-acid-text {
  font-size: 11px !important; font-weight: 700; letter-spacing: -.01em;
  color: color-mix(in srgb, var(--acid) 90%, var(--text-main)) !important;
  margin-bottom: 3px !important;
}

/* Текст сообщения */
.chat-message .text-sm { font-size: 13.5px !important; line-height: 1.5 !important; overflow-wrap: anywhere; }

/* Время — в одну строку с низом пузыря */
.chat-message .text-\[10px\]:last-child,
.chat-message > div:last-child { font-size: 10.5px !important; opacity: .7; }

/* Кнопка «Ответить»: появляется при наведении, не мешает тексту */
.chat-message-tools {
  position: absolute; top: 5px; right: 7px; z-index: 2;
  opacity: 0; transform: translateY(-2px);
  transition: opacity .18s ease, transform .18s ease;
}
.chat-message:hover .chat-message-tools { opacity: 1; transform: none; }
.chat-msg-action {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-muted);
  font-size: 10.5px; font-weight: 600; cursor: pointer; transition: all .16s ease;
}
.chat-msg-action:hover { color: var(--text-main); border-color: var(--acid); }
.chat-msg-action i { font-size: 9px; }

/* Цитата ответа внутри пузыря */
.chat-reply-quote,
.chat-message .reply-block {
  margin-bottom: 6px; padding: 6px 10px;
  border-left: 2px solid color-mix(in srgb, var(--acid) 55%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--text-muted) 9%, transparent);
  font-size: 11.5px; line-height: 1.4; color: var(--text-muted);
}

/* Подсветка при переходе к сообщению */
.chat-message-focus {
  box-shadow: 0 0 0 2px var(--acid), 0 8px 24px -12px color-mix(in srgb, var(--acid) 70%, transparent) !important;
}
.chat-message-reply-target { border-color: var(--acid) !important; }

/* Поле ввода */
#chatModal .chat-input-row,
.chat-composer {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .chat-message.message-bubble { max-width: 88%; }
  .chat-message-tools { opacity: 1; transform: none; }
}

/* ============================================================
   НОВЫЕ ЗАКАЗЫ
   ============================================================ */
#ordersCont > .void-card,
[id^="newOrder"] .void-card { border-radius: var(--k-radius); }

/* Плитки с данными заказа: плотнее, с подписью-капсом */
.future-order-info-box {
  padding: 10px 13px !important;
  border-radius: var(--k-radius-sm) !important;
  border: 1px solid var(--k-line) !important;
  background: color-mix(in srgb, var(--text-muted) 6%, transparent) !important;
}
.future-order-info-label {
  font-size: 9.5px !important; font-weight: 700 !important;
  letter-spacing: .13em !important; text-transform: uppercase;
  color: var(--text-muted) !important;
}
.future-order-info-value {
  margin-top: 4px !important; font-size: 13.5px !important; font-weight: 700 !important;
  color: var(--text-main); overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}

/* Строка товара в заказе */
.future-order-info-box .rounded-xl {
  border-radius: 11px !important;
  border-color: var(--k-line) !important;
  transition: border-color .18s ease, background .18s ease;
}
.future-order-info-box .rounded-xl:hover {
  border-color: color-mix(in srgb, var(--acid) 40%, var(--border)) !important;
  background: var(--hover) !important;
}

/* Чипы согласования — компактные, одинаковой высоты */
.new-order-approvals > *,
[class*="approval-chip"] {
  border-radius: var(--k-radius-sm) !important;
}

/* ============================================================
   ГЛАВНАЯ: плитки быстрых действий
   ============================================================ */
.quick-card,
#content .grid > a.void-card,
#content .grid > button.void-card {
  border-radius: var(--k-radius);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.quick-card:hover { transform: translateY(-3px); box-shadow: var(--k-elev-hi); }

/* Рейтинг менеджеров на главной */
.dashboard-rank-row {
  border-radius: var(--k-radius-sm);
  transition: background .16s ease, transform .16s ease;
}
.dashboard-rank-row:hover { transform: translateX(2px); }

/* ---------- АДАПТИВ ---------- */
@media (max-width: 900px) {
  .k-title { font-size: 23px; }
  .k-hero { padding: 20px; }
}
@media (max-width: 640px) {
  .k { gap: 14px; }
  .k-grid, .k-grid-wide, .k-grid-sm { grid-template-columns: 1fr; }
  .k-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .k-kpi { padding: 14px 15px; }
  .k-kpi .k-kpi-value { font-size: 24px; }
  .k-kpi .k-kpi-hint { display: none; }
  .k-table thead th, .k-table td { padding-left: 12px; padding-right: 12px; }
  #tasksGrid { grid-template-columns: 1fr !important; }
  .task-card .task-timeline { grid-template-columns: 1fr; }
  .k-meta { grid-template-columns: 1fr; }
  .k-segs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}


/* ============================================================
   РЕАЛИЗАЦИЯ — таблица-реестр: чёткая сетка, читаемые ячейки
   ============================================================ */
.rz-wrap {
  border-radius: var(--k-radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--k-elev);
  overflow: hidden;
}
.rz-scroll { overflow: auto; max-height: calc(100vh - 330px); }
.rz-scroll::-webkit-scrollbar { width: 11px; height: 11px; }
.rz-scroll::-webkit-scrollbar-track { background: color-mix(in srgb, var(--text-muted) 6%, transparent); }
.rz-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 28%, transparent);
  border-radius: 99px; border: 3px solid var(--card);
}
.rz-scroll::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--acid) 55%, transparent); }

.rz-table {
  min-width: 1748px; width: 100%; table-layout: fixed;
  border-collapse: separate; border-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.rz-col-num { width: 38px; }
.rz-col-org { width: 170px; }
.rz-col-product { width: 180px; }
.rz-col-qty { width: 58px; }
.rz-col-price { width: 72px; }
.rz-col-discount { width: 64px; }
.rz-col-rate { width: 54px; }
.rz-col-before, .rz-col-shipment { width: 112px; }
.rz-col-cash-usd { width: 90px; }
.rz-col-cash-rate { width: 72px; }
.rz-col-cash-sum { width: 112px; }
.rz-col-transfer { width: 112px; }
.rz-col-closed { width: 112px; }
.rz-col-vat { width: 112px; }
.rz-col-delivery { width: 90px; }
.rz-col-payment { width: 62px; }
.rz-col-salary { width: 95px; }
.rz-col-actions { width: 50px; }

/* ---- Шапка: два уровня, чистый фон, чёткие грани ---- */
.rz-table thead th {
  position: sticky; z-index: 5;
  padding: 0 5px; height: 34px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; line-height: 1.15; text-transform: uppercase;
  color: var(--text-muted); text-align: center; white-space: normal; overflow-wrap: anywhere;
  background: var(--rz-head, color-mix(in srgb, var(--card) 86%, var(--text-main) 14%));
  border-right: 1px solid var(--rz-line);
  border-bottom: 1px solid var(--rz-line);
}
.rz-table thead tr:first-child th { top: 0; }
.rz-table thead tr:nth-child(2) th { top: 34px; }
.rz-table thead th:last-child { border-right: 0; }

/* Группы колонок — цветом только подпись и тонкая полоса сверху */
.rz-g-ship {
  color: #38bdf8 !important;
  background: color-mix(in srgb, #0ea5e9 10%, var(--card)) !important;
  box-shadow: inset 0 3px 0 0 #0ea5e9;
}
.rz-g-cash {
  color: #34d399 !important;
  background: color-mix(in srgb, #10b981 10%, var(--card)) !important;
  box-shadow: inset 0 3px 0 0 #10b981;
}
.rz-g-ship-sub { background: color-mix(in srgb, #0ea5e9 5%, var(--card)) !important; }
.rz-g-cash-sub { background: color-mix(in srgb, #10b981 5%, var(--card)) !important; }

/* ---- Тело таблицы: видимая сетка ---- */
:root { --rz-line: color-mix(in srgb, var(--text-muted) 22%, transparent); }
.rz-table tbody td {
  padding: 0 5px; height: 44px;
  border-right: 1px solid var(--rz-line);
  border-bottom: 1px solid color-mix(in srgb, var(--text-muted) 13%, transparent);
  font-size: 12.5px; color: var(--text-main);
  background: var(--card);
}
.rz-table tbody td:last-child { border-right: 0; }
.rz-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--text-muted) 3%, var(--card)); }
.rz-table tbody tr:hover td { background: color-mix(in srgb, var(--acid) 7%, var(--card)); }

/* Начало новой организации — жирная линия сверху */
.rz-group-start td { border-top: 2px solid color-mix(in srgb, var(--acid) 45%, var(--border)); }

.rz-num { width: 46px; text-align: center; font-weight: 800; color: var(--text-muted); }
.rz-org, .rz-prod { min-width: 0; }

/* ---- Поля ввода: всегда видны, как ячейки таблицы ---- */
.rz-in {
  width: 100%; min-width: 0; height: 28px; padding: 0 5px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 20%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--text-main) 4%, transparent);
  color: var(--text-main); font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; text-align: right;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.rz-in-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}
.rz-in-wrap .rz-in {
  flex: 1 1 auto;
  min-width: 0;
  user-select: text;
}
.rz-pick-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 30px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--text-muted) 20%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--text-main) 4%, transparent);
  color: var(--text-muted);
  cursor: pointer;
}
.rz-pick-trigger:hover,
.rz-pick-trigger:focus-visible {
  color: var(--text-main);
  border-color: color-mix(in srgb, var(--acid) 45%, transparent);
  outline: none;
}
.rz-pick-trigger i { font-size: 10px; }
.rz-in::placeholder { color: color-mix(in srgb, var(--text-muted) 70%, transparent); font-weight: 500; }
.rz-in:hover { border-color: color-mix(in srgb, var(--acid) 40%, transparent); }
.rz-in:focus {
  outline: none; border-color: var(--acid); background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--acid) 18%, transparent);
}
.rz-in-text { text-align: left; font-weight: 600; }
.rz-in-org { font-weight: 700; }
.rz-price-cell { position: relative; padding-bottom: 13px !important; }
.rz-price-cell .rz-in { height: 25px; }
.rz-price-after {
  position: absolute; left: 5px; right: 5px; bottom: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: color-mix(in srgb, #0ea5e9 72%, var(--text-main));
  font-size: 9px; line-height: 11px; font-weight: 800; text-align: right;
}
.rz-in.rz-saving { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 10%, transparent); }
.rz-in.rz-saved { border-color: #10b981; background: color-mix(in srgb, #10b981 12%, transparent); }
.rz-in.rz-error { border-color: #f43f5e; background: color-mix(in srgb, #f43f5e 10%, transparent); }
.rz-in.rz-dirty:not(.rz-saving):not(.rz-error) {
  border-color: color-mix(in srgb, #38bdf8 68%, var(--border));
  box-shadow: inset 0 -2px 0 color-mix(in srgb, #38bdf8 62%, transparent);
}
.rz-cash-input-cell { background: color-mix(in srgb, #10b981 4%, var(--card)) !important; }
.rz-in-cash-sum:focus { border-color: #10b981; box-shadow: 0 0 0 3px color-mix(in srgb, #10b981 18%, transparent); }

/* ---- Расчётные колонки: не редактируются, выделены ---- */
.rz-calc-cell {
  text-align: right; font-weight: 800;
  background: color-mix(in srgb, var(--text-muted) 7%, var(--card)) !important;
}
.rz-calc-ship { color: #38bdf8; }
.rz-calc-before { color: var(--text-muted); }
.rz-calc-cash { color: #34d399; }
.rz-calc-closed {
  color: #10b981;
  background: color-mix(in srgb, #10b981 10%, var(--card)) !important;
  box-shadow: inset 2px 0 0 0 color-mix(in srgb, #10b981 45%, transparent);
}
.rz-calc-vat { color: #a78bfa; background: color-mix(in srgb, #8b5cf6 8%, var(--card)) !important; }
.rz-calc-salary { color: #fbbf24; background: color-mix(in srgb, #f59e0b 8%, var(--card)) !important; }
.rz-dash { color: color-mix(in srgb, var(--text-muted) 60%, transparent); }

/* ---- Кнопки действий в строке ---- */
.rz-act { width: 82px; text-align: center; white-space: nowrap; }
.rz-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; margin: 0 2px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-muted);
  cursor: pointer; font-size: 10px; transition: all .16s ease;
}
.rz-ic:hover { color: var(--acid); border-color: var(--acid); transform: translateY(-1px); }
.rz-ic-del:hover { color: #f43f5e; border-color: #f43f5e; }

/* ---- Итоговая строка ---- */
.rz-table tfoot td {
  position: sticky; bottom: 0; z-index: 4;
  padding: 0 10px; height: 46px;
  font-weight: 800; font-size: 13px;
  background: color-mix(in srgb, var(--card) 84%, var(--text-main) 16%);
  border-top: 2px solid var(--border);
  border-right: 1px solid var(--rz-line);
}
.rz-table tfoot .rz-total-usd td { bottom: 0; }
.rz-table tfoot .rz-total-uzs td { bottom: 46px; }
.rz-table tfoot .rz-total-usd td {
  color: color-mix(in srgb, #38bdf8 76%, var(--text-main));
  background: color-mix(in srgb, #0ea5e9 10%, var(--card));
  border-top-width: 1px;
}
.rz-table tfoot .rz-total-uzs td {
  background: color-mix(in srgb, #10b981 7%, var(--card));
}
.rz-table tfoot .rz-calc-cell {
  padding-inline: 5px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rz-table tfoot td:last-child { border-right: 0; }
.rz-total-label { text-align: right; color: var(--text-muted); letter-spacing: .045em; text-transform: uppercase; font-size: 14px; font-weight: 900; }

.rz-save-btn {
  position: relative;
  color: color-mix(in srgb, #38bdf8 78%, var(--text-main));
  border-color: color-mix(in srgb, #38bdf8 34%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, #0ea5e9 12%, var(--card)), color-mix(in srgb, #10b981 8%, var(--card)));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.rz-save-btn:hover,
.rz-save-btn.is-dirty {
  color: #e0f2fe;
  border-color: color-mix(in srgb, #38bdf8 62%, var(--border));
  box-shadow: 0 8px 24px -14px rgba(14,165,233,.75), inset 0 1px 0 rgba(255,255,255,.09);
}
.rz-save-btn.is-saving i { animation: rzSavePulse .8s ease-in-out infinite alternate; }
.rz-dirty-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #0ea5e9; color: white; font-size: 10px; font-weight: 900;
}
.rz-dirty-count[hidden] { display: none; }
@keyframes rzSavePulse { to { transform: scale(.84); opacity: .55; } }

@media (max-width: 900px) {
  .rz-scroll { max-height: none; }
  .rz-table { min-width: 1748px; }
  .rz-table tfoot .rz-calc-cell { font-size: 12px; padding-inline: 3px; }
  .rz-total-label { font-size: 12.5px; }
}

/* ---- Реализация: спокойные цвета вместо кислотных ---- */
.rz-g-ship {
  color: color-mix(in srgb, #0ea5e9 75%, var(--text-main)) !important;
  background: color-mix(in srgb, #0ea5e9 6%, var(--card)) !important;
  box-shadow: inset 0 2px 0 0 color-mix(in srgb, #0ea5e9 55%, transparent);
}
.rz-g-cash {
  color: color-mix(in srgb, #10b981 75%, var(--text-main)) !important;
  background: color-mix(in srgb, #10b981 6%, var(--card)) !important;
  box-shadow: inset 0 2px 0 0 color-mix(in srgb, #10b981 55%, transparent);
}
.rz-g-ship-sub { background: color-mix(in srgb, #0ea5e9 3%, var(--card)) !important; }
.rz-g-cash-sub { background: color-mix(in srgb, #10b981 3%, var(--card)) !important; }
.rz-calc-ship { color: color-mix(in srgb, #0ea5e9 70%, var(--text-main)); }
.rz-calc-before { color: color-mix(in srgb, var(--text-muted) 82%, var(--text-main)); }
.rz-calc-cash { color: color-mix(in srgb, #10b981 70%, var(--text-main)); }
.rz-calc-closed {
  color: color-mix(in srgb, #10b981 80%, var(--text-main));
  background: color-mix(in srgb, #10b981 6%, var(--card)) !important;
  box-shadow: inset 2px 0 0 0 color-mix(in srgb, #10b981 40%, transparent);
}
/* Значок «долг контрагента уменьшен на эту сумму» */
.rz-debt-mark { margin-left: 5px; font-size: 11px; opacity: .85; cursor: help; }
.rz-calc-vat { color: color-mix(in srgb, #8b5cf6 70%, var(--text-main)); background: color-mix(in srgb, #8b5cf6 5%, var(--card)) !important; }
.rz-calc-salary { color: color-mix(in srgb, #f59e0b 75%, var(--text-main)); background: color-mix(in srgb, #f59e0b 5%, var(--card)) !important; }
.rz-group-start td { border-top: 2px solid color-mix(in srgb, var(--text-muted) 35%, transparent); }
.rz-table tbody tr:hover td { background: color-mix(in srgb, var(--text-main) 5%, var(--card)); }

/* Первая колонка и организация прилипают при горизонтальной прокрутке */
.rz-table thead th:nth-child(1),
.rz-table tbody td:nth-child(1) { position: sticky; left: 0; z-index: 4; }
.rz-table thead th:nth-child(2),
.rz-table tbody td:nth-child(2) { position: sticky; left: 46px; z-index: 4; }
.rz-table thead th:nth-child(1),
.rz-table thead th:nth-child(2) { z-index: 6; }
.rz-table tbody td:nth-child(2) { box-shadow: 6px 0 10px -8px rgba(0, 0, 0, .5); }

/* ---- Выпадающий список для ячеек ---- */
.rz-pick {
  position: fixed; z-index: 9999;
  border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, .75), 0 4px 12px -6px rgba(0, 0, 0, .4);
  overflow: hidden; animation: kUp .16s ease backwards;
}
.rz-pick-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.rz-pick-search i { font-size: 11px; color: var(--text-muted); }
.rz-pick-search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  color: var(--text-main); font-size: 13px; font-weight: 500;
}
.rz-pick-list { max-height: 260px; overflow-y: auto; padding: 5px; }
.rz-pick-list::-webkit-scrollbar { width: 8px; }
.rz-pick-list::-webkit-scrollbar-thumb { background: var(--k-fill); border-radius: 99px; }
.rz-pick-opt {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--text-main); font-size: 12.5px; font-weight: 500;
  text-align: left; cursor: pointer; transition: background .13s ease;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
}
.rz-pick-opt:hover { background: color-mix(in srgb, var(--acid) 14%, transparent); }
.rz-pick-empty { display: none; padding: 20px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* ---- Маленькие экраны ---- */
@media (max-width: 1280px) {
  .rz-table { min-width: 1748px; }
  .rz-table tbody td { height: 38px; padding: 0 6px; }
  .rz-in { height: 28px; font-size: 12px; padding: 0 7px; }
  .rz-org, .rz-prod { min-width: 0; }
}
@media (max-width: 760px) {
  .rz-table thead th:nth-child(2),
  .rz-table tbody td:nth-child(2) { position: static; box-shadow: none; }
  .rz-table { min-width: 1748px; }
  .rz-scroll {
    width: 100%;
    max-width: 100%;
    max-height: none;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .rz-table tbody td { height: 50px; }
  .rz-in,
  .rz-pick-search input {
    height: 36px;
    font-size: 16px;
  }
  .rz-price-cell .rz-in { height: 34px; }
  .rz-pick {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-height: calc(100dvh - 24px);
  }
  .rz-pick-list { max-height: min(55dvh, 360px); }
  .k-hero-actions { width: 100%; }
  .k-hero-actions .tkf-select { flex: 1; min-width: 0; }
}

/* Desktop sidebar: compact icon rail with a centered edge control. */
@media (min-width: 768px) {
  #sidebar {
    position: relative;
    flex: 0 0 280px;
    width: 280px;
    overflow: visible;
    transition:
      width 260ms cubic-bezier(.2, .8, .2, 1),
      flex-basis 260ms cubic-bezier(.2, .8, .2, 1),
      background-color 200ms ease,
      border-color 200ms ease;
  }

  .sidebar-collapse-btn {
    position: absolute;
    z-index: 70;
    top: 50%;
    right: -18px;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--border) 68%, var(--text-muted) 32%);
    border-radius: 50%;
    background: color-mix(in srgb, var(--card) 96%, white 4%);
    color: color-mix(in srgb, var(--text-muted) 82%, white 18%);
    box-shadow:
      0 10px 24px -12px rgba(0, 0, 0, .9),
      0 0 0 4px color-mix(in srgb, var(--bg) 88%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, .07);
    cursor: pointer;
    transition:
      color 160ms ease,
      border-color 160ms ease,
      background-color 160ms ease,
      box-shadow 160ms ease,
      transform 160ms ease;
  }
  .sidebar-collapse-btn:hover,
  .sidebar-collapse-btn:focus-visible {
    color: var(--acid-text);
    border-color: color-mix(in srgb, var(--acid) 52%, var(--border));
    background: color-mix(in srgb, var(--card) 92%, var(--acid) 8%);
    box-shadow:
      0 12px 28px -13px rgba(0, 0, 0, .95),
      0 0 0 4px color-mix(in srgb, var(--bg) 82%, transparent),
      0 0 0 1px color-mix(in srgb, var(--acid) 20%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, .1);
    outline: none;
    transform: translateY(-50%) scale(1.06);
  }
  .sidebar-collapse-btn:active {
    transform: translateY(-50%) scale(.96);
  }
  .sidebar-collapse-btn i {
    font-size: 14px;
    line-height: 1;
    transition: transform 160ms ease;
  }
  #sidebar:not(.is-collapsed) .sidebar-collapse-btn:hover i { transform: translateX(-1px); }
  #sidebar.is-collapsed .sidebar-collapse-btn:hover i { transform: translateX(1px); }

  #sidebar.is-collapsed {
    flex-basis: 78px;
    width: 78px;
  }
  #sidebar.is-collapsed .sidebar-brand {
    justify-content: center;
    padding-inline: 0;
  }
  #sidebar.is-collapsed .sidebar-brand-inner > i { margin-right: 0; }
  #sidebar.is-collapsed .sidebar-brand-name,
  #sidebar.is-collapsed .nav-item span,
  #sidebar.is-collapsed .sidebar-theme-label,
  #sidebar.is-collapsed .sidebar-user-copy,
  #sidebar.is-collapsed .sidebar-profile-btn span,
  #sidebar.is-collapsed .sidebar-logout-btn span {
    display: none;
  }
  #sidebar.is-collapsed nav {
    padding-inline: 10px;
  }
  #sidebar.is-collapsed .nav-item {
    width: 52px;
    height: 48px;
    min-height: 48px;
    margin-inline: auto;
    padding: 0;
    justify-content: center;
    gap: 0;
    border-radius: 10px;
  }
  #sidebar.is-collapsed .nav-item i {
    width: 24px;
    margin: 0;
    font-size: 18px;
  }
  #sidebar.is-collapsed .sidebar-bottom {
    padding: 12px;
  }
  #sidebar.is-collapsed .sidebar-theme-row,
  #sidebar.is-collapsed .sidebar-user-row {
    justify-content: center;
    gap: 0;
  }
  #sidebar.is-collapsed .sidebar-theme-row { margin-bottom: 12px; }
  #sidebar.is-collapsed .sidebar-user-row { margin-bottom: 10px; }
  #sidebar.is-collapsed .sidebar-profile-btn,
  #sidebar.is-collapsed .sidebar-logout-btn {
    width: 44px;
    height: 40px;
    min-height: 40px;
    margin-inline: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #sidebar.is-collapsed .sidebar-profile-btn i,
  #sidebar.is-collapsed .sidebar-logout-btn i { margin: 0; }
  .sidebar-logout-btn i { margin-right: 8px; }

  body.sidebar-collapsed .rz-table thead th { font-size: 10.5px; }
  body.sidebar-collapsed .rz-table tbody td { font-size: 13.5px; }
  body.sidebar-collapsed .rz-in { font-size: 12.5px; }
  body.sidebar-collapsed .rz-price-after { font-size: 10px; }
}

@media (max-width: 767px) {
  .sidebar-collapse-btn { display: none; }
}
