/* ==========================================================================
   Задачи (/tasks) — what is running right now, and how to stop it.

   Built on the same two-column "list picks, pane explains" shape the rest of the
   panel already uses (see the dialogues page), not as a new pattern. The one thing
   this page does differently: it is grouped by MODULE, not flat. A flat list would
   be modules x accounts — seven times the account count — and the question this page
   answers ("what is my fleet doing") is asked per module, not per pair.
   ========================================================================== */
.tasks-page { display: grid; gap: 14px; }

.tasks-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.tasks-hero-copy h2 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.tasks-hero-copy p { color: var(--color-text-muted); font-size: 0.8rem; margin-top: 0.3rem; max-width: 62ch; }
.tasks-hero-action { flex-shrink: 0; }

.tasks-bar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* Segmented Активные/История. Anchors, not buttons: each tab is a real URL, so it
   survives a reload and can be linked to — which matters here because "the tasks
   page, history, filtered to Рассылки ЛС" is a thing worth sending to yourself. */
.tasks-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
}
.tasks-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
}
.tasks-seg-btn:hover { color: var(--color-text); }
.tasks-seg-btn.is-on { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }
.tasks-seg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 1.35em;
  height: 1.35em;
  line-height: 1;
  padding: 0 0.3rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-size: 0.68rem;
}

.tasks-chips { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.tasks-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
}
.tasks-chip:hover { color: var(--color-text); }
.tasks-chip.is-on { background: var(--color-primary-bg); border-color: transparent; color: var(--color-primary-hover); }
.tasks-chip-count { color: var(--color-text-faint); font-size: 0.7rem; }
.tasks-chip.is-on .tasks-chip-count { color: inherit; opacity: 0.7; }

.tasks-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.9fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  /* minmax(0, 1fr) rather than a bare 1fr — a `1fr` track carries an implicit
     min-width:auto and refuses to shrink below its widest child, which on a phone
     turns the log lines inside the detail pane into horizontal page scroll. Same
     fix, same reason, as the accounts grid. */
  .tasks-split { grid-template-columns: minmax(0, 1fr); }
}

.tasks-list { display: grid; gap: 12px; align-content: start; min-width: 0; }

.tasks-group {
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: 0.9rem 1rem 0.75rem;
}
.tasks-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.7rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.tasks-group-head h3 { font-size: 0.9rem; font-weight: 600; }
.tasks-group-head p { color: var(--color-text-muted); font-size: 0.72rem; margin-top: 0.15rem; }

.tasks-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast) var(--ease);
}
.tasks-row:hover { background: var(--color-surface-muted); }
/* Selection has to survive the 15s poll swapping this markup out, so it is derived
   from the ?run= in the URL server-side rather than held in JS state. */
.tasks-row.is-selected { background: var(--color-primary-bg); }
.tasks-row-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) auto minmax(0, 6rem) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.6rem;
  text-decoration: none;
  color: inherit;
}
@media (max-width: 620px) {
  .tasks-row-main { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.3rem; }
  .tasks-progress { display: none; }
}
.tasks-row-name {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tasks-row-sub { display: block; font-weight: 400; font-size: 0.72rem; color: var(--color-text-muted); }
.tasks-row-meta { font-size: 0.72rem; color: var(--color-text-muted); white-space: nowrap; }
.tasks-row-count { font-size: 0.72rem; color: var(--color-text-muted); text-align: right; white-space: nowrap; }
.tasks-row-stop { flex-shrink: 0; padding-right: 0.35rem; }

/* Only drawn for modules that actually have a configured ceiling to count toward
   (Рассылки ЛС today) — the rest run open-endedly, and a bar with an invented
   denominator would be a lie about when they finish. */
.tasks-progress {
  height: 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--color-text) 11%, transparent);
  overflow: hidden;
}
.tasks-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--color-accent); }

.tasks-detail {
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem 1.1rem;
  min-width: 0;
  position: sticky;
  top: 0;
}
@media (max-width: 1100px) { .tasks-detail { position: static; } }
.tasks-detail.is-empty { display: flex; align-items: center; justify-content: center; min-height: 14rem; }
.tasks-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.tasks-detail-module { font-size: 0.95rem; font-weight: 600; }
.tasks-detail-account { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.15rem; }
.tasks-detail-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.tasks-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.9rem 0 1rem;
}
.tasks-facts dt { color: var(--color-text-faint); font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.075em; }
.tasks-facts dd { font-size: 0.82rem; font-weight: 600; margin-top: 0.2rem; }
.tasks-fact-wide { grid-column: 1 / -1; }

/* Плотная сетка фактов — для прогонов сбора и поиска. У прогона модуля фактов
   четыре, и он спокойно помещается обычной сеткой; у поиска их под двадцать, и
   обычной сеткой карточка уезжала за экран с двумя прокрутками подряд.
   Экономия набирается из трёх мест, а не из уменьшения кегля:
     - подпись и значение в одну строку, а не одно под другим (было две строки на
       каждый факт);
     - подписи обычным регистром без разрядки: «МИН. КОММЕНТАРИЕВ НА ПОСТ» капслоком
       не помещалось в колонку и переносилось на три строки, из-за чего строка сетки
       становилась втрое выше самой высокой соседки;
     - разделитель — тонкая линия вместо вертикальных отступов. */
.tasks-facts.is-compact {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0 1.4rem;
  margin: 0.6rem 0 0.7rem;
}
.tasks-facts.is-compact > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border);
  min-width: 0;
}
.tasks-facts.is-compact dt {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text-muted);
  /* Подпись уступает место значению, а не наоборот: длинную подпись читатель
     достроит по смыслу, обрезанное число — нет. */
  min-width: 0;
}
.tasks-facts.is-compact dd {
  margin-top: 0;
  font-size: 0.78rem;
  text-align: right;
  overflow-wrap: anywhere;
}
/* Списки во всю ширину (аккаунты, запросы, ошибки источников) остаются в два уровня:
   значение у них длиннее подписи, и прижимать его вправо не к чему. */
.tasks-facts.is-compact > .tasks-fact-wide {
  display: block;
  padding-top: 0.35rem;
}
.tasks-facts.is-compact > .tasks-fact-wide dd { text-align: left; margin-top: 0.15rem; }

/* Why a run ended. "limit_reached" is the good outcome (the campaign did its job),
   "error"/"account" are the ones worth noticing — so they are the only coloured
   ones, matching the palette's rule that saturation means state. */
.tasks-reason { display: inline-flex; align-items: baseline; gap: 0.4rem; font-size: 0.74rem; font-weight: 600; }
.tasks-reason-user { color: var(--color-text-muted); }
.tasks-reason-limit_reached { color: var(--color-success-text); }
.tasks-reason-error { color: var(--color-danger-text); }
.tasks-reason-account { color: var(--color-warning-text); }
.tasks-reason-detail { font-weight: 400; color: var(--color-text-muted); font-size: 0.72rem; }

.tasks-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.tasks-placeholder .icon { width: 1.5rem; height: 1.5rem; color: var(--color-text-faint); }
.tasks-placeholder p { font-size: 0.76rem; color: var(--color-text-faint); max-width: 40ch; }

/* ---- История: filters and pager ---- */
.tasks-filters {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
}
.tasks-filter { display: flex; flex-direction: column; gap: 0.25rem; min-width: 9rem; }
.tasks-filter > span {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
.tasks-filter .input { height: 2.1rem; font-size: 0.8rem; }
/* Pushed to the far end so the count and the reset read as the bar's result, not as
   another filter. */
.tasks-filter-summary {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}
.tasks-filter-reset { color: var(--color-primary); }
.tasks-filter-reset:hover { text-decoration: underline; }

.tasks-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.tasks-pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 0.6rem);
  background: var(--color-surface);
  font-size: 0.78rem;
  color: var(--color-text);
}
.tasks-pager-btn:hover { background: var(--color-surface-muted); }
/* The ends of the list keep their buttons in place rather than removing them — a pager
   that changes width as you reach the last page makes the target move under the cursor. */
.tasks-pager-btn.is-off { opacity: 0.4; pointer-events: none; }
.tasks-pager-at { font-size: 0.78rem; color: var(--color-text-muted); }

/* Настройки, с которыми прогон начался. Отделены от фактов сверху рамкой, а не просто
   отступом: факты — про сам прогон (когда, сколько, почему кончился), а это про то, с
   чем его запускали, и путать их не надо. Сетка та же, .tasks-facts, поэтому подписи
   выстраиваются в те же колонки, что и выше. */
.tasks-snapshot { border-top: 1px solid var(--color-border); padding-top: 0.85rem; }
.tasks-snapshot h4 {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.075em;
  color: var(--color-text-muted); margin: 0;
}
.tasks-snapshot .tasks-facts { margin-bottom: 0.9rem; }
/* Правило выше идёт позже одноимённого по специфичности и перебило бы отступ плотной
   сетки обратно на просторный — поэтому повторяется здесь, а не там. */
.tasks-snapshot .tasks-facts.is-compact { margin-bottom: 0.5rem; }
/* Текст рассылки и инструкции для ИИ — единственное здесь, что читают строкой, а не
   цифрой: обычный вес, обычный кегль и перенос по словам вместо моноширинного. */
.tasks-snapshot-text {
  font-weight: 400 !important; font-size: 0.76rem !important;
  color: var(--color-text-muted); white-space: pre-wrap; overflow-wrap: anywhere;
}
.tasks-snapshot-empty {
  margin: 0.9rem 0 1rem; padding: 0.7rem 0.8rem;
  border: 1px dashed var(--color-border); border-radius: 12px;
  color: var(--color-text-muted); font-size: 0.75rem;
}

/* ==========================================================================
   Остановка задачи — она уезжает, а не исчезает между кадрами.

   Раньше остановленная строка пропадала вместе с подменой #main-content: клик,
   пустое место, и непонятно, остановилось именно то, на что нажали, или список
   просто перерисовался. Теперь строка сначала гаснет и схлопывается по высоте, и
   только потом приходит ответ сервера (submit придерживается на длительность
   анимации в pages/tasks.js).

   Высоту анимируем через max-height, а не height: реальная высота строки зависит
   от содержимого и на момент старта анимации неизвестна, а max-height с запасом
   даёт тот же схлопывающийся жест без её измерения.
   ========================================================================== */
@keyframes tasksRowLeave {
  0%   { opacity: 1; transform: none; max-height: 8rem; }
  35%  { opacity: 0.55; transform: translateX(10px) scale(0.995); max-height: 8rem; }
  100% { opacity: 0; transform: translateX(28px) scale(0.98); max-height: 0;
         margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}
.tasks-row.is-stopping,
.tasks-group.is-stopping {
  overflow: hidden;
  pointer-events: none;
  animation: tasksRowLeave 420ms var(--ease, cubic-bezier(0.4, 0, 0.2, 1)) forwards;
}
/* Карточка модуля уезжает чуть медленнее строки — она крупнее, и на той же
   скорости жест читается как рывок. */
.tasks-group.is-stopping { animation-duration: 520ms; }
/* Останавливают всё — уходит весь список разом, но с небольшой лесенкой, чтобы
   было видно, что это много задач, а не одна. */
.tasks-list.is-stopping-all .tasks-group { animation: tasksRowLeave 520ms var(--ease, cubic-bezier(0.4, 0, 0.2, 1)) forwards; overflow: hidden; }
.tasks-list.is-stopping-all .tasks-group:nth-child(2) { animation-delay: 60ms; }
.tasks-list.is-stopping-all .tasks-group:nth-child(3) { animation-delay: 120ms; }
.tasks-list.is-stopping-all .tasks-group:nth-child(n+4) { animation-delay: 180ms; }

/* Отключённые анимации — это просьба, а не предпочтение: жест заменяется мгновенным
   исчезновением, но само действие остаётся тем же. */
@media (prefers-reduced-motion: reduce) {
  .tasks-row.is-stopping,
  .tasks-group.is-stopping,
  .tasks-list.is-stopping-all .tasks-group { animation: none; opacity: 0; }
}

/* Точка «идёт прямо сейчас». Пульсирует не сама точка, а её ореол: мигающий текст
   рядом читается как ошибка, а ровная точка с дышащим кольцом — как работа. */
.tasks-live {
  position: relative;
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--color-success-text, var(--color-accent));
  flex: none;
  vertical-align: middle;
}
.tasks-live::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--color-success-text, var(--color-accent));
  opacity: 0.5;
  animation: tasksLivePulse 2.2s ease-out infinite;
}
@keyframes tasksLivePulse {
  0%   { transform: scale(0.7); opacity: 0.55; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tasks-live::after { animation: none; opacity: 0.35; }
}

/* Строка получает видимую цель клика: до этого выделялся только фон, и на светлой
   теме разница между «навёл» и «выбрано» была почти незаметна. */
.tasks-row { position: relative; }
.tasks-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 99px;
  background: var(--color-accent);
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity var(--transition-fast) var(--ease), transform var(--transition-fast) var(--ease);
}
.tasks-row.is-selected::before { opacity: 1; transform: none; }
.tasks-row:hover::before { opacity: 0.35; transform: none; }
.tasks-row.is-past::before { display: none; }
/* Кнопка остановки видна всегда: «стоп» — то, ради чего сюда приходят, прятать его за
   наведением незачем (2026-09-04). */
.tasks-row-stop { opacity: 1; }

/* ---- Правая колонка, пока ничего не выбрано ---- */
.tasks-empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  padding: 1.75rem 1.25rem 1.5rem;
}
.tasks-empty-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius-2xl);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  color: var(--color-text-faint);
}
.tasks-empty-art svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Точка-курсор у угла карточки: она и есть подсказка «сюда попадёт выбранное». */
.tasks-empty-art i {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-surface);
}
.tasks-empty-detail strong { font-size: 0.9rem; font-weight: 600; }
.tasks-empty-detail p { font-size: 0.78rem; color: var(--color-text-muted); max-width: 34ch; }
.tasks-empty-list {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.55rem;
  padding: 0;
  list-style: none;
  text-align: left;
}
.tasks-empty-list li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.76rem;
  color: var(--color-text-faint);
}
.tasks-empty-list li::before {
  content: '';
  position: absolute;
  left: 0.3rem;
  top: 0.52em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-border-strong, var(--color-border));
}

/* ==========================================================================
   Задачи — редизайн 2026-09 (классы tk-*). Старые .tasks-row/.tasks-group оставлены
   на строках и группах: на них завязаны анимации остановки и поллинг.
   ========================================================================== */
.tk { gap: 14px; }
.tk-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; border-radius: 16px; background: var(--color-surface); border: 1px solid var(--color-border); }
.tk-hero.is-live { background: linear-gradient(135deg, color-mix(in srgb, var(--color-success) 9%, var(--color-surface)), var(--color-surface) 55%); border-color: color-mix(in srgb, var(--color-success) 30%, var(--color-border)); }
.tk-hero-main { display: flex; align-items: center; gap: 14px; flex: 1 1 22rem; min-width: 0; }
.tk-hero-ic { position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--color-primary) 12%, transparent); color: var(--color-primary); flex: none; }
.tk-hero-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-hero-ic .tasks-live { position: absolute; top: -2px; right: -2px; margin: 0; width: 9px; height: 9px; }
.tk-hero h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.tk-hero p { font-size: 12px; color: var(--color-text-muted); margin: 3px 0 0; max-width: 62ch; }
.tk-hero-mods { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-hero-mod { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); font-size: 12px; font-weight: 600; text-decoration: none; transition: border-color .15s ease; }
.tk-hero-mod:hover { border-color: var(--color-primary); color: var(--color-text); }
.tk-hero-mod.is-on { background: var(--color-primary-bg); border-color: transparent; color: var(--color-primary-hover); }
.tk-hero-mod b { font-size: 11.5px; color: var(--color-text); }
.tk-hero-action { flex: none; }

.tk-mod-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--color-primary) 12%, transparent); color: var(--color-primary); }
.tk-mod-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-mod-ic.is-sm { width: 24px; height: 24px; border-radius: 8px; } .tk-mod-ic.is-sm svg { width: 13px; height: 13px; }
.tk-mod-ic.is-lg { width: 44px; height: 44px; border-radius: 13px; } .tk-mod-ic.is-lg svg { width: 22px; height: 22px; }
.tk-group { padding: 12px 12px 8px; border-radius: 16px; }
.tk-group-head { display: flex; align-items: center; gap: 12px; padding: 2px 4px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.tk-group-copy { flex: 1; min-width: 0; }
.tk-group-copy h3 { font-size: 14px; font-weight: 700; margin: 0; }
.tk-group-copy p { font-size: 11.5px; color: var(--color-text-muted); margin: 1px 0 0; }
.tk-group-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tk-ghost { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--color-text-faint); border: 1px solid transparent; }
.tk-ghost:hover { color: var(--color-primary); border-color: var(--color-border); background: var(--color-surface-muted); }
.tk-ghost svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tk-rows { display: flex; flex-direction: column; gap: 2px; }
.tk-row { border-radius: 12px; animation: tk-rise .35s var(--ease, ease) both; }
.tk-row:nth-child(2) { animation-delay: .03s; } .tk-row:nth-child(3) { animation-delay: .06s; } .tk-row:nth-child(n+4) { animation-delay: .09s; }
@keyframes tk-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tk-row { animation: none; } }
.tk-row-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1.2fr) auto minmax(0, 8rem) auto; align-items: center; gap: 10px; padding: 8px 10px; text-decoration: none; color: inherit; }
.tk-row.is-past .tk-row-main { grid-template-columns: 34px minmax(0, 1.2fr) auto auto auto; }
@media (max-width: 700px) { .tk-row-main, .tk-row.is-past .tk-row-main { grid-template-columns: 34px minmax(0, 1fr) auto; } .tk-prog, .tk-row-count { display: none !important; } }
.tk-ava { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.tk-ava.is-col { background: color-mix(in srgb, var(--color-primary) 14%, transparent); color: var(--color-primary); border-radius: 10px; }
.tk-ava.is-col svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tk-ava.is-xs { width: 18px; height: 18px; font-size: 9px; display: inline-grid; vertical-align: middle; margin-right: 6px; }
.tk-row-name { font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 0; flex-wrap: wrap; column-gap: 8px; }
.tk-row-name small { font-weight: 400; font-size: 11.5px; color: var(--color-text-muted); }
.tk-row-meta { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; }
.tk-row-meta svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tk-prog { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-prog b { font-size: 11px; color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.tk-bar { flex: 1; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--color-text) 10%, transparent); overflow: hidden; min-width: 40px; }
.tk-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 60%, #8b7bf0)); transition: width .8s var(--ease, ease); }
.tk-bar.is-open i { width: 40%; background: repeating-linear-gradient(90deg, var(--color-primary) 0 8px, transparent 8px 12px); opacity: .55; animation: tk-flow 1.4s linear infinite; }
@keyframes tk-flow { from { transform: translateX(-12px); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .tk-bar.is-open i { animation: none; } }
.tk-bar.is-lg { height: 10px; }
.tk-row-count { font-size: 12px; color: var(--color-text); text-align: right; white-space: nowrap; font-weight: 600; }
.tk-stop { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); display: grid; place-items: center; cursor: pointer; }
.tk-stop:hover { color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border)); background: color-mix(in srgb, var(--color-danger) 8%, transparent); }
.tk-stop svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.tk-row-stop { padding-right: 6px; }
.tk-outcome { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.tk-outcome svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tk-outcome.is-user { color: var(--color-text-muted); background: color-mix(in srgb, var(--color-text) 8%, transparent); }
.tk-outcome.is-limit_reached { color: var(--color-success-text); background: color-mix(in srgb, var(--color-success) 15%, transparent); }
.tk-outcome.is-error { color: var(--color-danger-text); background: color-mix(in srgb, var(--color-danger) 14%, transparent); }
.tk-outcome.is-account { color: var(--color-warning-text); background: color-mix(in srgb, var(--color-warning) 16%, transparent); }
.tk-day { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-faint); padding: 10px 10px 4px; }
.tk-day:first-child { padding-top: 2px; }
.tk-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 16px; color: var(--color-text-muted); font-size: 13px; border-radius: 16px; border: 1px dashed var(--color-border); }
.tk-empty b { color: var(--color-text); font-size: 14px; }
.tk-empty p { font-size: 12px; color: var(--color-text-faint); max-width: 40ch; margin: 0; }
.tk-empty-art { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--color-surface-muted); color: var(--color-text-faint); margin-bottom: 6px; }
.tk-empty-art svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Карточка задачи справа */
.tk-detail { padding: 16px 16px 14px; border-radius: 16px; }
.tk-detail-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.tk-detail-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-detail-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; display: flex; align-items: center; }
.tk-detail-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.tk-live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--color-success-text); background: color-mix(in srgb, var(--color-success) 14%, transparent); padding: 2px 8px 2px 6px; border-radius: 999px; }
.tk-live-tag .tasks-live { margin: 0; }
.tk-progress-card { margin: 14px 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--color-surface-muted); border: 1px solid var(--color-border); }
.tk-progress-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: var(--color-text-muted); margin-bottom: 8px; }
.tk-progress-top b { font-size: 18px; color: var(--color-text); font-weight: 750; }
.tk-progress-foot { font-size: 11px; color: var(--color-text-faint); margin-top: 6px; text-align: right; }
.tk-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 8px; margin: 12px 0; }
.tk-fact { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 9px 11px; border-radius: 11px; background: var(--color-surface-muted); border: 1px solid var(--color-border); min-width: 0; }
.tk-fact svg { grid-row: 1 / 3; width: 16px; height: 16px; fill: none; stroke: var(--color-text-faint); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-fact span { font-size: 10.5px; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.tk-fact b { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-outcome-card { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: 12.5px; }
.tk-outcome-card svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.tk-outcome-card b { display: block; font-size: 13px; } .tk-outcome-card span { display: block; color: var(--color-text-muted); font-size: 12px; margin-top: 1px; }
.tk-outcome-card.is-user { background: color-mix(in srgb, var(--color-text) 6%, transparent); color: var(--color-text); }
.tk-outcome-card.is-limit_reached { background: color-mix(in srgb, var(--color-success) 12%, transparent); color: var(--color-success-text); }
.tk-outcome-card.is-error { background: color-mix(in srgb, var(--color-danger) 12%, transparent); color: var(--color-danger-text); }
.tk-outcome-card.is-account { background: color-mix(in srgb, var(--color-warning) 14%, transparent); color: var(--color-warning-text); }
.tk-block { border-top: 1px solid var(--color-border); padding-top: 12px; margin-top: 12px; }
.tk-block h4, .tk-details summary { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); margin: 0 0 8px; }
.tk-block h4 svg, .tk-details summary svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tk-details summary { cursor: pointer; list-style: none; user-select: none; }
.tk-details summary::-webkit-details-marker { display: none; }
.tk-details summary i { font-style: normal; margin-left: auto; font-size: 11px; color: var(--color-text-faint); }
.tk-details summary::after { content: '›'; font-size: 16px; line-height: 1; color: var(--color-text-faint); transform: rotate(90deg); transition: transform .15s ease; }
.tk-details[open] summary::after { transform: rotate(-90deg); }
.tk-snap { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 18px; margin: 0; }
.tk-snap > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--color-border); min-width: 0; }
.tk-snap > div.is-wide, .tk-snap.is-wide > div { grid-column: 1 / -1; display: block; }
.tk-snap dt { font-size: 12px; color: var(--color-text-muted); min-width: 0; }
.tk-snap dd { font-size: 12.5px; font-weight: 600; text-align: right; margin: 0; overflow-wrap: anywhere; }
.tk-snap > div.is-wide dd, .tk-snap.is-wide dd { text-align: left; margin-top: 3px; }
.tk-text { font-weight: 400 !important; font-size: 12.5px !important; color: var(--color-text-muted); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.tk-err { color: var(--color-danger-text); }
.tk-filters { border-radius: 16px; }

/* ⚡ остаток запросов в час у аккаунта — тот же значок, что в пикерах модулей. */
.tk-row-name .dm-account-budget, .tk-detail-sub .dm-account-budget { margin-left: 6px; font-size: 11.5px; font-weight: 600; }
.tk-row-name .dm-account-budget svg, .tk-detail-sub .dm-account-budget svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Мобильная раскладка задач ---- */
@media (max-width: 620px) {
  .tasks-bar { align-items: stretch; }
  .tasks-bar .account-tabs { max-width: 100%; overflow-x: auto; }
  .tk-group-head { flex-wrap: wrap; row-gap: 8px; }
  .tk-group-actions { flex: 1 1 100%; }
  .tk-group-actions form { flex: 1; }
  .tk-group-actions .btn { width: 100%; justify-content: center; }
  .tk-hero, .tk-group, .tasks-split, .tasks-list, .tasks-detail { min-width: 0; max-width: 100%; }
  .tk-detail-head { flex-wrap: wrap; }
  .tk-detail-actions { flex: 1 1 100%; display: flex; gap: 8px; }
  .tk-detail-actions > * { flex: 1; }
  .tk-detail-actions .btn { width: 100%; justify-content: center; }
}
@media (max-width: 620px) {
  .tk-hero > *, .tasks-bar > * { min-width: 0; }
  .tasks-bar .account-tabs { flex: 1 1 100%; margin: 0.5rem 0; }
  .tk-hero-main { flex-basis: 100%; }
}
@media (max-width: 620px) {
  .tasks-bar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .tk-hero-main > *, .tk-group-copy { min-width: 0; }
  .tk-hero h2, .tk-hero p, .tk-group-copy h3, .tk-group-copy p { overflow-wrap: anywhere; }
  .tk-hero-action { flex: 1 1 100%; }
  .tk-hero-action .btn { width: 100%; justify-content: center; }
}
@media (max-width: 620px) { .tk-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tk-fact { min-width: 0; } .tk-fact span, .tk-fact b { overflow-wrap: anywhere; white-space: normal; } }

/* Настройки запуска — раскрывающийся блок: заголовок-кнопка, плавное раскрытие
   (grid-template-rows 0fr → 1fr), внутри — группы «Режим и модель / Тексты / Темп /
   График / Поведение / Передача», чтобы три десятка полей читались, а не сливались. */
.tk-snap-toggle { display: flex; align-items: center; gap: 7px; width: 100%; padding: 4px 0; border: 0; background: none; color: var(--color-text-muted); font: inherit; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; text-align: left; }
.tk-snap-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-snap-toggle i { font-style: normal; margin-left: auto; font-size: 11px; color: var(--color-text-faint); }
.tk-snap-toggle:hover { color: var(--color-text); }
.tk-snap-chev { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; font-size: 16px; line-height: 1; color: var(--color-text-faint); transform: rotate(90deg); transition: transform .28s var(--ease), background .15s; }
.tk-snap-block.is-open .tk-snap-chev { transform: rotate(-90deg); }
.tk-snap-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease); }
.tk-snap-block.is-open .tk-snap-body { grid-template-rows: 1fr; }
.tk-snap-inner { min-height: 0; overflow: hidden; opacity: 0; transform: translateY(-4px); transition: opacity .25s var(--ease), transform .28s var(--ease); }
.tk-snap-block.is-open .tk-snap-inner { opacity: 1; transform: none; }
.tk-snap-note { margin: 6px 0 8px; padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 1.45; color: var(--color-text-muted); background: color-mix(in srgb, var(--color-warning-text) 9%, transparent); }
.tk-snap-group { padding-top: 10px; }
.tk-snap-group h5 { margin: 0 0 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-faint); display: flex; align-items: center; gap: 8px; }
.tk-snap-group h5::after { content: ''; flex: 1; height: 1px; background: var(--color-border); opacity: .6; }
.tk-snap dd.is-unset { color: var(--color-text-faint); font-weight: 500; font-style: italic; }
.tk-snap-live { font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-left: 6px; padding: 1px 5px; border-radius: 6px; color: var(--color-warning-text); background: color-mix(in srgb, var(--color-warning-text) 14%, transparent); vertical-align: 1px; }
/* Смена выбранной задачи: карточка справа приглушается на время запроса вместо
   перерисовки всей страницы. */
.tasks-detail { transition: opacity .15s ease; }
.tasks-detail.is-loading { opacity: .55; pointer-events: none; }

/* /tasks: пауза/возобновление/редактирование запуска + состояние «на паузе» */
.tk-row-acts { display: flex; align-items: center; gap: 6px; padding-right: 6px; flex-shrink: 0; }
.tk-row-acts .tk-row-stop { padding-right: 0; }
.tk-act { color: var(--color-text-muted); text-decoration: none; }
.tk-act:hover { color: var(--color-text); border-color: color-mix(in srgb, var(--color-text) 30%, var(--color-border)); background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.tk-resume:hover { color: var(--color-success-text, #16a34a); border-color: color-mix(in srgb, var(--color-success-text, #16a34a) 45%, var(--color-border)); background: color-mix(in srgb, var(--color-success-text, #16a34a) 10%, transparent); }
/* карандаш редактирования — контурная иконка (не заливка, как у стоп/паузы) */
.tk-edit svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-paused-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--color-warning-text); background: color-mix(in srgb, var(--color-warning-text) 14%, transparent);
}
.tk-paused-badge svg { width: 10px; height: 10px; fill: currentColor; stroke: none; }
.tk-paused-badge.is-safety { color: var(--color-danger-text); background: color-mix(in srgb, var(--color-danger-text) 12%, transparent); margin-right: 6px; }
.tk-paused-badge.is-safety svg { fill: none; stroke: currentColor; stroke-width: 2; }
.tk-release svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tk-release:hover { color: var(--color-danger-text); border-color: color-mix(in srgb, var(--color-danger-text) 45%, var(--color-border)); background: color-mix(in srgb, var(--color-danger-text) 10%, transparent); }
.tk-row.is-paused .tk-row-main { opacity: .62; }
.tk-row.is-paused .tasks-live { background: var(--color-warning-text); animation: none; }

/* Деталь запуска на паузе: тег «на паузе» жёлтым, точка не пульсирует */
.tk-live-tag.is-paused { color: var(--color-warning-text); background: color-mix(in srgb, var(--color-warning-text) 14%, transparent); }
.tk-live-tag.is-paused .tasks-live { background: var(--color-warning-text); animation: none; }
