/* Админка Stars v2. Мобильный первым: широкие таблицы скроллятся внутри себя,
   страница по горизонтали не едет. */
:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e242c;
  --line: #2a323c;
  --text: #e6eaf0;
  --dim: #8e9bab;
  --accent: #4c9aff;
  --ok: #35c37d;
  --warn: #e8b04b;
  --gold: #e8c36a;
  --err: #f2604f;
  --radius: 10px;
}

* { box-sizing: border-box; }

.chrome-top {
  position: sticky; top: 0; z-index: 20;
  flex-shrink: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

header.top {
  position: relative;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
header.top .brand { font-weight: 700; letter-spacing: .2px; color: var(--text); text-decoration: none; }
header.top a.brand:hover { text-decoration: none; }
header.top .brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-shrink: 0;
}
.bounty-eta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.bounty-eta-clock {
  font: 700 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: .3px;
  text-decoration: none;
}
a.bounty-eta-clock:hover { text-decoration: none; color: var(--accent); }
.bounty-eta.is-run .bounty-eta-clock { color: var(--warn); }
.bounty-eta-run {
  margin-left: 2px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 600 12px/1.2 inherit;
  cursor: pointer;
}
.bounty-eta-run:hover { border-color: var(--accent); color: var(--accent); }
.bounty-eta-run:disabled {
  opacity: .45;
  cursor: default;
  border-color: var(--line);
  color: var(--dim);
}
.bounty-eta.is-run .bounty-eta-run { display: none; }
header.top .who { justify-self: end; margin-left: 0; color: var(--dim); font-size: 13px; white-space: nowrap; }
.rates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
.rate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1c2420, #151c19);
  border: 1px solid rgba(38, 161, 123, .35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  white-space: nowrap;
  user-select: none;
}
.rate-ton {
  background: linear-gradient(180deg, #1b2230, #141820);
  border-color: rgba(76, 154, 255, .35);
}
.rate-stars {
  background: linear-gradient(180deg, #2a2418, #1c1810);
  border-color: rgba(232, 176, 75, .4);
}
.tether, .rate-ico {
  display: inline-flex;
  width: 22px; height: 22px;
  border-radius: 50%;
  align-items: center; justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}
.tether {
  background: radial-gradient(circle at 35% 30%, #3ad19a, #26a17b 62%, #1b7a5c);
  box-shadow: 0 0 0 2px rgba(38, 161, 123, .25);
}
.rate-ton .rate-ico {
  background: radial-gradient(circle at 35% 30%, #7eb6ff, #4c9aff 62%, #2b6fbf);
  box-shadow: 0 0 0 2px rgba(76, 154, 255, .25);
  font-size: 11px;
}
.rate-stars .rate-ico {
  background: radial-gradient(circle at 35% 30%, #f3d07a, #e8b04b 62%, #b8862e);
  box-shadow: 0 0 0 2px rgba(232, 176, 75, .25);
  font-size: 11px;
}
.rate-pair { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .4px; }
.rate-price { font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: .2px; }
.rate-ccy { color: var(--dim); font-size: 13px; }
.rate-chg {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
}
.rate-chg.up { color: var(--ok); }
.rate-chg.down { color: var(--err); }
@media (max-width: 1280px) {
  header.top { grid-template-columns: auto auto; }
  header.top .rates { grid-column: 1 / -1; justify-self: center; order: 3; }
}
@media (max-width: 720px) {
  .bounty-eta-label { display: none; }
}

nav.tabs {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
nav.tabs .tabs-start {
  grid-column: 1;
  justify-self: center;
  display: flex;
  align-items: center;
}
nav.tabs .tabs-main {
  grid-column: 2;
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
nav.tabs .tabs-grid {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  grid-template-rows: auto auto;
  gap: 6px;
}
nav.tabs .tabs-grid a { width: 100%; }
nav.tabs .tabs-extra {
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
}
nav.tabs .tabs-extra a { width: 100%; }
nav.tabs .tabs-extra-solo { grid-template-rows: auto; }
nav.tabs a {
  white-space: nowrap; padding: 7px 12px; border-radius: 999px;
  background: var(--panel-2); color: var(--text); font-size: 14px;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
nav.tabs a.active {
  background: var(--accent); color: #06101f; font-weight: 600;
}
nav.tabs a:hover { text-decoration: none; }
a#nav-io {
  position: relative;
  padding: 4px 14px;
  white-space: normal;
  font-weight: 800;
}
.nav-io-text {
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.io-live {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(232, 176, 75, .14);
  border-bottom: 1px solid rgba(232, 176, 75, .35);
  color: var(--warn); font-size: 13px;
}
.io-live[hidden] { display: none !important; }
.io-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(232, 176, 75, .7);
  animation: io-pulse 1.4s ease-out infinite;
  flex-shrink: 0;
}
@keyframes io-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 176, 75, .55); }
  70% { box-shadow: 0 0 0 8px rgba(232, 176, 75, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 176, 75, 0); }
}
.io-live a { margin-left: auto; white-space: nowrap; }

a.ai-live {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  min-height: 36px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 13px;
  text-decoration: none;
}
a.ai-live:hover { text-decoration: none; }
a.ai-live.is-run {
  background: rgba(124, 92, 255, .14);
  border-bottom-color: rgba(124, 92, 255, .4);
  color: #d4c6ff;
}
.ai-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
a.ai-live.is-run .ai-live-dot {
  background: #a78bfa;
  box-shadow: 0 0 0 0 rgba(167, 139, 250, .7);
  animation: ai-pulse 1.4s ease-out infinite;
}
@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(167, 139, 250, .55); }
  70% { box-shadow: 0 0 0 8px rgba(167, 139, 250, 0); }
  100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0); }
}
#ai-live-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-live-link { margin-left: auto; white-space: nowrap; color: var(--accent); font-size: 12px; }
a.nav-ai { position: relative; }
a.nav-ai .nav-ai-badge {
  position: absolute; top: -6px; right: -4px;
  min-width: 8px; height: 8px; padding: 0;
  font-size: 0; line-height: 0;
  background: #a78bfa;
  box-shadow: 0 0 0 2px var(--panel-2);
}
nav.tabs a.active .nav-ai-badge { background: #fff; }
nav.tabs .tabs-end {
  grid-column: 3;
  justify-self: center;
  align-self: center;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  overflow: visible;
}
a.nav-notices,
nav.tabs .tabs-end a {
  position: relative;
  padding: 11px 24px;
  font-size: 21px;
  font-weight: 600;
  text-align: center;
  overflow: visible;
}
a.nav-notices { min-width: 177px; }
.nav-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--err); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
a.nav-notices .nav-count {
  position: absolute; top: -8px; margin: 0;
  min-width: 24px; height: 24px; font-size: 12px;
}
a.nav-notices .nav-count-l { left: -4px; background: var(--accent); }
a.nav-notices .nav-count-r { right: -4px; background: var(--err); }
nav.tabs a.active .nav-count-l { background: #06101f; color: #fff; }
nav.tabs a.active .nav-count-r { background: #06101f; color: #fff; }
a#nav-io .nav-io-badge {
  position: absolute; top: 3px; right: 3px;
  width: 8px; height: 8px; min-width: 8px; padding: 0;
  font-size: 0; line-height: 0;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--panel-2);
}
nav.tabs a.active .nav-io-badge { background: #fff; }
.notice-new { border-color: rgba(76,154,255,.45); }
.notice-body {
  margin: 8px 0 0; padding: 10px; border-radius: 8px;
  background: var(--panel-2); white-space: pre-wrap; word-break: break-word;
  font-size: 13px; max-height: 240px; overflow: auto;
}

main { padding: 14px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 0 0 10px; color: var(--dim); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  margin: 0 0 14px;
  display: block;
  position: relative;
}

/* Ровно 4 в ряд на десктопе → 8 плиток лягут в 2 строки, а не 7+1 */
.grid {
  display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr);
  margin: 0 0 14px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }
.stat {
  background: var(--panel-2); border-radius: var(--radius);
  padding: 12px 12px 14px; min-height: 72px;
  display: flex; flex-direction: column; justify-content: center;
  border: 1px solid transparent;
  color: inherit;
}
a.stat { text-decoration: none; cursor: pointer; }
a.stat:hover { text-decoration: none; border-color: var(--line); background: #242b34; }
a.stat.on {
  border-color: var(--accent);
  background: rgba(76, 154, 255, .14);
}
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .k { color: var(--dim); font-size: 12px; margin-top: 6px; line-height: 1.35; }
.stat .why { color: var(--warn); font-size: 12px; margin-top: 4px; line-height: 1.35; }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tr.next-tick td { background: rgba(76, 154, 255, .08); }
.export-queue td { vertical-align: top; }
td.status-cell { white-space: normal; vertical-align: top; }
.status-since { display: inline-block; margin-left: 6px; white-space: nowrap; }
.status-note {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  max-width: 36rem;
  overflow-wrap: anywhere;
}
.status-note.err { color: var(--err); }
/* FINISHED, который ещё не уехал: жёлтый — держим по правилу, серый — уедет сам */
.status-note.warn { color: var(--warn); }
.status-note.dim { color: var(--dim); }

.badge {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.35;
  background: var(--panel-2); color: var(--dim);
  white-space: nowrap; vertical-align: middle;
}
.badge.ok { background: rgba(53,195,125,.15); color: var(--ok); }
.badge.warn { background: rgba(232,176,75,.15); color: var(--warn); }
.badge.err { background: rgba(242,96,79,.15); color: var(--err); }
.badge.acc { background: rgba(76,154,255,.15); color: var(--accent); }
.bb-bot .badge.ok, .bb-bot .badge.acc, .slot .head .badge.ok, .slot .head .badge.acc {
  min-width: 1.4em; justify-content: center; padding: 2px 7px; font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 14px; cursor: pointer;
  font-family: inherit; line-height: 1.2; vertical-align: middle;
  white-space: nowrap; text-align: center;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: #06101f; border-color: transparent; font-weight: 600; }
.btn.danger { background: rgba(242,96,79,.15); color: var(--err); border-color: rgba(242,96,79,.3); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn:disabled, .btn.spent {
  opacity: .45; color: var(--dim); cursor: default;
  border-color: rgba(255,255,255,.1);
}
.btn:disabled:hover, .btn.spent:hover { border-color: rgba(255,255,255,.1); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.workers-load {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  color: var(--text);
}
.workers-load.warn { color: var(--warn); }
/* Ряд действий в таблицах: держим кнопки в строку, не вертикально */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline-flex; margin: 0; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit;
}
textarea { min-height: 110px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
label { display: block; margin: 10px 0 4px; color: var(--dim); font-size: 13px; }
form.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
form.inline > div { flex: 1 1 160px; }

.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.msg.ok { background: rgba(53,195,125,.12); color: var(--ok); }
.msg.err { background: rgba(242,96,79,.12); color: var(--err); }
.msg.warn { background: rgba(232,176,75,.12); color: var(--warn); }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.slot { background: var(--panel-2); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.slot .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.bb-bots { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.bb-bot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; }
.bb-bot + .bb-bot { border-top: 1px solid var(--line); }
.bb-bot.is-gift-done { background: rgba(53, 195, 125, 0.26); }
.bb-bot form { margin: 0; }
.slot.is-gift-done { background: rgba(53, 195, 125, 0.22); }
.bot-done,
.bot-gift {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  margin-left: 2px;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  vertical-align: -1px;
}
.bot-done { color: var(--ok); }
.bot-gift { font-size: 13px; }
/* «засчитано N: +2 +1 +» — своя строка под ботом.
   Ждущий чип: красный, сверху вниз синяя заливка на % сделанных заданий. */
.credit-stack,
.credit-line {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 1 0 100%; min-width: 0; max-width: 100%; line-height: 1.35;
}
.credit-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px;
  max-width: 100%;
}
.credit-label { white-space: nowrap; color: var(--dim); }
.credit-label b { color: var(--text); }
.credit-chips {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 2px; max-width: 100%; flex-wrap: wrap; min-width: 0;
}
.credit-chip {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; min-width: 1.55em; padding: 0 3px; border-radius: 4px;
  font-size: 11px; font-weight: 700; line-height: 1.45;
  font-variant-numeric: tabular-nums;
  color: var(--ok); background: rgba(53,195,125,.14);
}
.credit-chip:hover { background: rgba(53,195,125,.32); text-decoration: none; }
.credit-chip.fallback { color: var(--warn); background: rgba(232,176,75,.16); }
.credit-chip.fallback:hover { background: rgba(232,176,75,.34); }
.credit-chip.start {
  color: #9ec9ff;
  background: rgba(76, 154, 255, .18);
}
.credit-chip.start:hover { background: rgba(76, 154, 255, .34); text-decoration: none; }
.credit-chip.archive {
  color: var(--ok);
  background: rgba(53,195,125,.22);
  outline: 1px dashed rgba(53,195,125,.45);
}
.credit-chip.archive:hover { background: rgba(53,195,125,.36); text-decoration: none; }
.credit-chip.waiting {
  color: #e8eef6;
  background: linear-gradient(
    to bottom,
    rgba(76,154,255,.55) var(--wait-pct, 0%),
    rgba(242,96,79,.40) var(--wait-pct, 0%)
  );
}
.credit-chip.waiting:hover {
  background: linear-gradient(
    to bottom,
    rgba(76,154,255,.75) var(--wait-pct, 0%),
    rgba(242,96,79,.58) var(--wait-pct, 0%)
  );
}
.credit-chip.lost {
  color: var(--dim);
  background: rgba(142,155,171,.28);
}
.credit-chip.lost:hover { background: rgba(142,155,171,.42); text-decoration: none; }
/* Незачёт бота: сын всё сделал, кабинет отца его не покрыл — коричневая клетка, белый «!» */
.credit-chip.missed {
  color: #fff;
  background: rgba(139,84,42,.92);
}
.credit-chip.missed:hover { background: rgba(160,98,50,1); text-decoration: none; }
/* Сын с рефом, но в бота ещё не зашёл: серая плашка, белый минус по центру */
.credit-chip.idle {
  color: #fff;
  background: rgba(142,155,171,.55);
}
.credit-chip.idle:hover { background: rgba(142,155,171,.75); text-decoration: none; }
.kv dd .credit-stack,
.kv dd .credit-line { margin-top: 6px; }
.credit-sep { display: block; flex-shrink: 0; width: 1px; height: 9px; background: rgba(142,155,171,.5); }

.credit-pop {
  display: none; position: absolute; z-index: 60;
  bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  min-width: 214px; max-width: 300px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  font-size: 12px; font-weight: 400; line-height: 1.45; color: var(--text);
  white-space: normal; text-align: left; cursor: pointer;
}
.credit-chip:hover .credit-pop, .credit-chip:focus-visible .credit-pop { display: block; }
.credit-pop-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap;
}
.credit-pop-head .badge { padding: 2px 8px; font-size: 11px; }
.credit-pop-row { display: block; color: var(--dim); }
.credit-pop-row b { color: var(--text); }
.credit-pop-open { display: block; margin-top: 5px; color: var(--accent); font-weight: 600; }
/* Чип у края экрана — сдвигаем всплывашку внутрь (класс вешает base.html) */
.credit-chip.pop-left .credit-pop { left: auto; right: -6px; transform: none; }
.credit-chip.pop-right .credit-pop { left: -6px; right: auto; transform: none; }

/* Превью бейджа «ждём зачёт»: кто именно висит, на чём и сколько уже.
   Панель лежит внутри .wait-pop с прозрачным padding-bottom — это мостик,
   по которому мышь доезжает до строк, не теряя ховер на бейдже. */
.wait-host { position: relative; display: inline-flex; }
.wait-pop {
  display: none; position: absolute; z-index: 60;
  top: 100%; left: 50%; transform: translateX(-50%);
  padding-top: 6px;
}
/* Снизу места не хватило — раскрываем вверх (класс вешает base.html) */
.wait-host.pop-up .wait-pop { top: auto; bottom: 100%; padding: 0 0 6px; }
.wait-host:hover .wait-pop, .wait-host:focus-within .wait-pop { display: block; }
.wait-pop-in {
  display: block; width: 340px; max-width: 78vw;
  max-height: 320px; overflow-y: auto;
  padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  font-size: 12px; font-weight: 400; line-height: 1.45; color: var(--text);
  white-space: normal; text-align: left;
}
.wait-pop-head { display: block; margin-bottom: 6px; color: var(--dim); }
.wait-row {
  display: block; padding: 5px 6px; border-radius: 6px; color: var(--text);
}
.wait-row + .wait-row { margin-top: 2px; }
.wait-row:hover { background: rgba(76,154,255,.12); text-decoration: none; }
.wait-row-top {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 1px;
}
.wait-row-top .badge { padding: 1px 7px; font-size: 11px; font-weight: 600; }
.wait-row-since { color: var(--dim); margin-left: auto; white-space: nowrap; }
.wait-row-sub { display: block; color: var(--dim); }
.wait-host.pop-left .wait-pop { left: auto; right: -6px; transform: none; }
.wait-host.pop-right .wait-pop { left: -6px; right: auto; transform: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; }

.login-wrap { max-width: 340px; margin: 12vh auto; }

/* Telegram Mini App: учёт safe-area и чуть плотнее на узком экране */
body.tg-miniapp main { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
body.tg-miniapp header.top .who a[href="/logout"] { display: none; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .stat { min-height: 68px; padding: 12px; }
  .stat .v { font-size: 19px; }
  .stat .k { font-size: 11px; margin-top: 5px; }
  th, td { padding: 7px 8px; }
  /* На мобилке меню переносим в несколько рядов, а не прячем в горизонтальный
     скролл — иначе средние пункты обрезаются и их не видно. */
  nav.tabs {
    display: flex; flex-wrap: wrap; padding: 6px 10px; gap: 6px;
  }
  nav.tabs .tabs-main {
    order: 1;
    flex: 1 1 100%; flex-wrap: wrap; justify-content: center; overflow: visible; gap: 6px;
  }
  nav.tabs .tabs-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 auto;
  }
  nav.tabs .tabs-grid a { white-space: normal; text-align: center; line-height: 1.2; }
  nav.tabs .tabs-start {
    order: 2; justify-self: unset;
  }
  nav.tabs .tabs-end {
    order: 2; justify-self: unset; align-self: unset; margin-left: auto; gap: 6px;
  }
  nav.tabs a { padding: 6px 10px; font-size: 13px; }
  a.nav-notices,
  nav.tabs .tabs-end a { min-width: 0; padding: 9px 18px; font-size: 20px; }
}

/* Спамблок: имя бота зачёркнуто и подсвечено красным — видно с одного взгляда */
.badge.spam { background: rgba(242,96,79,.22); color: var(--err); }
.badge.spam s { text-decoration: line-through; }
.slot.spam { background: rgba(242,96,79,.10); border: 1px solid rgba(242,96,79,.35); }
.spam-name { color: var(--err); }
.spam-name s { text-decoration: line-through; }

/* Прогресс батчей над списком рабочих */
.batches-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.batches-head h2 { margin: 0; }
.batches { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin: 0 0 14px; }
@media (max-width: 700px) { .batches { grid-template-columns: 1fr; } }
.batch { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.batch .top-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.batch .desc { color: var(--dim); font-size: 12px; margin-top: 6px; line-height: 1.4; }
.bar.tall { height: 9px; }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }

.io-stages { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
.io-stages span {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}
.io-stages span.on {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(76, 154, 255, .12);
}
.io-stages span.done {
  border-color: rgba(53, 195, 125, .45);
  color: var(--ok);
}

/* Разбивка заданий по ботам: суммарные 13/15 не говорят, на каком боте затык */
.by-bot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.by-bot .badge { font-size: 11px; padding: 1px 6px; }
.by-bot .badge.dimmed { background: var(--panel-2); color: var(--dim); }
/* Лента логов аккаунта */
.logs-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.logs-controls select, .logs-controls input { width: auto; }
.logs-controls .logs-filter { flex: 1 1 200px; min-width: 160px; }
.logs-list { max-height: 460px; overflow-y: auto; }
.logs-rows { width: 100%; table-layout: fixed; }
.logs-rows td { vertical-align: top; padding: 2px 8px 2px 0; overflow-wrap: anywhere; }
.logs-rows td:first-child { width: 150px; }
.logs-rows td:nth-child(2) { width: 80px; }
.logs-rows td:nth-child(3) { width: 150px; }
.logs-rows .logs-text { white-space: pre-wrap; word-break: break-word; }
.logs-rows .err { color: var(--err); }
.logs-rows .warn { color: var(--warn); }
.logs-box .nowrap { white-space: nowrap; }

/* Инспектор Telegram в карточке аккаунта */
.tg-cols { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .tg-cols { grid-template-columns: 1fr; } }
.tg-list { max-height: 340px; overflow-y: auto; }
.tg-box h3 { font-size: 13px; margin: 14px 0 6px; }
/* fixed — чтобы длинное сообщение переносилось, а не растягивало таблицу вбок */
.tg-box table { width: 100%; table-layout: fixed; }
.tg-box td {
  vertical-align: top;
  padding: 4px 8px 4px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tg-box .nowrap { white-space: nowrap; }
.tg-box .tg-row td { cursor: pointer; }
/* Колонки времени и автора узкие и фиксированные, текст забирает остальное */
.tg-box .tg-service td:first-child,
.tg-box .tg-chat-rows td:first-child { width: 140px; }
.tg-box .tg-service td:nth-child(2),
.tg-box .tg-chat-rows td:nth-child(2) { width: 130px; }
.tg-box .tg-dialogs td:first-child { width: 42%; }
.tg-box .tg-dialogs td:nth-child(2) { width: 90px; }
.tg-box .tg-blocked td:nth-child(2) { width: 80px; }
.tg-box .tg-blocked td:nth-child(3) { width: 110px; }
.tg-box .tg-sessions td:first-child { width: 26%; }

/* Инлайн-кнопки сообщения: подпись + куда ведёт */
.tg-btns { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.tg-btn {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.tg-btn-kind { color: var(--accent); }

/* Бота, до которого аккаунт не дошёл, видно отдельно от «дошёл, но 0 заданий» */
.by-bot .badge.todo { background: transparent; color: var(--dim); border: 1px dashed var(--line); }
.by-bot-rows { margin-top: 8px; border-collapse: collapse; }
.by-bot-rows td { padding: 3px 10px 3px 0; border: 0; vertical-align: middle; }

/* Архив переписки с ботами */
.chat-controls { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.chat-controls select { width: auto; }
.chat-list { max-height: 520px; overflow-y: auto; }
.chat-rows { width: 100%; table-layout: fixed; }
.chat-rows td {
  vertical-align: top;
  padding: 6px 10px 6px 0;
  overflow-wrap: anywhere;
  white-space: normal;
}
.chat-rows td:first-child {
  width: 88px;
  overflow: hidden;
}
.chat-rows td:nth-child(2) {
  width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-when {
  display: block;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.chat-body { white-space: pre-wrap; margin-top: 3px; }
/* Удалённое и старая версия — видно, что этого у бота уже нет */
.chat-gone { color: var(--dim); text-decoration: line-through; }

/* Логи systemd-сервисов */
.log-svc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-svc-head .btn { margin-left: auto; }
.log-pre {
  margin: 0;
  padding: 10px 12px;
  background: #0b0e12;
  border-radius: 8px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
  color: #c5ced8;
}
.log-pre.full { max-height: 70vh; }
.logs-form .logs-controls { margin-bottom: 10px; }
.logs-form input[type="datetime-local"],
.logs-form input[type="search"] { width: auto; min-width: 160px; }

/* Раздел ИИ — чат как в Cursor */
body.ai-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.ai-page main {
  flex: 1; min-height: 0; max-width: none; width: 100%; padding: 0;
  display: flex; flex-direction: column;
}
body.ai-page main > .msg { margin: 8px 14px 0; }
#ai-app {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  background: var(--bg);
}
.ai-side, .ai-tasks {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  min-height: 0;
}
.ai-tasks { border-right: 0; border-left: 1px solid var(--line); }
.ai-side-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.ai-side-head h2 { margin: 0; flex: 1; }
.ai-ws { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 0 8px; }
.ai-health { margin: 0 0 12px; }
.ai-health.ok { color: var(--ok); }
.ai-health.err { color: var(--err); }
.ai-session-list { display: flex; flex-direction: column; gap: 6px; }
.ai-session {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid transparent; background: var(--panel-2); color: var(--text);
  cursor: pointer; font: inherit;
}
.ai-session:hover { border-color: var(--line); }
.ai-session.active { border-color: var(--accent); background: rgba(76,154,255,.12); }
.ai-session b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-session .dim { font-size: 12px; max-height: 2.6em; overflow: hidden; }
.ai-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ai-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}
.ai-toolbar-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ai-sub { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-journal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.ai-journal-head h1 { margin: 0; }
.ai-journal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-journal {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
  gap: 14px;
  align-items: start;
}
.ai-zap-preamble { white-space: pre-wrap; margin: 0; }
.ai-zap h2 { color: var(--text); }
.ai-zap-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.5 inherit;
  color: var(--text);
}
.ai-act {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.ai-act:last-child { border-bottom: 0; padding-bottom: 0; }
.ai-act:first-child { padding-top: 0; }
.ai-act-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px;
}
.ai-act-story,
.ai-act-detail {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  font: 13px/1.5 inherit;
  overflow-wrap: anywhere;
}
.ai-act-story p { margin: 0 0 8px; }
.ai-act-story p:last-child { margin-bottom: 0; }
.ai-act-story ul {
  margin: 0 0 8px;
  padding-left: 18px;
}
.ai-act-story ul:last-child { margin-bottom: 0; }
.ai-act-story li { margin: 3px 0; }
.ai-act-detail {
  white-space: pre-wrap;
}
@media (max-width: 900px) {
  .ai-journal { grid-template-columns: 1fr; }
}
.ai-messages { flex: 1; overflow: auto; padding: 16px 18px 8px; }
.ai-empty { color: var(--dim); max-width: 640px; margin: 12vh auto; text-align: center; line-height: 1.5; }
.ai-msg { display: flex; margin: 0 0 12px; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble {
  max-width: min(760px, 92%);
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.ai-msg.user .ai-bubble { background: rgba(76,154,255,.14); border-color: rgba(76,154,255,.3); }
.ai-msg.system .ai-bubble { color: var(--dim); font-size: 13px; }
.ai-text { overflow-wrap: anywhere; }
.ai-text code {
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
}
.ai-code {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 8px;
  background: #0b0e12; color: #c5ced8;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto;
}
.ai-tools { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.ai-composer {
  padding: 10px 14px 14px; border-top: 1px solid var(--line); background: var(--panel);
}
.ai-composer textarea { min-height: 72px; resize: vertical; }
.ai-composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ai-task-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ai-task-form textarea { min-height: 72px; }
.ai-task {
  background: var(--panel-2); border-radius: 8px; padding: 10px; margin-bottom: 8px;
  font-size: 13px;
}
.ai-task-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
@media (max-width: 1100px) {
  #ai-app {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .ai-tasks {
    display: block;
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 260px;
  }
}
@media (max-width: 760px) {
  body.ai-page { height: auto; overflow: auto; }
  body.ai-page main { display: block; }
  #ai-app { display: block; }
  .ai-side, .ai-tasks { display: block; border: 0; max-height: 220px; }
  .ai-messages { min-height: 50vh; }
}

.io-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .55);
}
.io-modal[hidden] { display: none; }
.io-modal-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
}
.io-modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.io-modal-card p { margin: 0 0 10px; }
.io-checks { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.io-check {
  display: flex; align-items: center; gap: 8px;
  margin: 0; color: var(--text); font-size: 14px;
}
.io-check input { width: auto; }
.io-check.off { opacity: .45; }

.url-cell {
  max-width: 22rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.url-cell a { color: var(--dim); }
.task-rows .nowrap { white-space: nowrap; }
.rate-num { font-variant-numeric: tabular-nums; }
tr.task-src-on td { background: rgba(76, 154, 255, .08); }

.bounty-run { margin-bottom: 12px; }
.bounty-checked { margin-top: 10px; }
.bounty-checked summary { cursor: pointer; color: var(--dim); font-size: 13px; }
.bounty-checked-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.bounty-checked-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  font-size: 13px;
}
.bounty-findings { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.bounty-find {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.bounty-find.fixed { border-color: rgba(53,195,125,.35); }
.bounty-find.skipped { opacity: .7; }
.bounty-find-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px;
}
.bounty-find .actions { margin-top: 8px; }

/* Уникальность: «67» в любом тексте. */
.mark-67,
a .mark-67,
a:hover .mark-67,
button .mark-67,
.badge .mark-67,
.dim .mark-67,
code .mark-67,
.mono .mark-67 {
  font-weight: 700;
  color: #ff3b30;
}


