/* Экраны дашборда. Основа (цвета, шрифт, элементы) — в ui.css */

:root {
  /* Цвета линий графиков (одинаковые в CSS-легенде и в Chart.js) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --muted-line: #8a8984;
  /* Состояния (всегда со значком и подписью, не только цветом) */
  --good: #0ca30c;
  --warning: #c98500;
  --critical: #d03b3b;
  --neutral: #8a8984;
  --pos: #0b7f0b;
  --neg: #c22f2f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5;
    --series-2: #d95926;
    --muted-line: #8f8e88;
    --warning: #fab219;
    --pos: #3ccf3c;
    --neg: #ef6b6b;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5;
  --series-2: #d95926;
  --muted-line: #8f8e88;
  --warning: #fab219;
  --pos: #3ccf3c;
  --neg: #ef6b6b;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

form.inline {
  margin: 0;
}

button.small {
  margin: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.875rem;
}

.login {
  max-width: 420px;
  margin: 2rem auto;
}

.error {
  color: var(--pico-del-color);
}

.block {
  display: block;
}

.muted {
  color: var(--pico-muted-color);
}

.small,
p.muted {
  font-size: 0.875rem;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- Фильтры-вкладки ---------- */

.filters,
.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.filters a,
.tabs a,
.tabs .soon {
  flex: none;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--pico-muted-border-color);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}

.filters a[aria-current="page"],
.tabs a[aria-current="page"] {
  background: var(--pico-primary-background);
  border-color: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.tabs .soon {
  color: var(--pico-muted-color);
  border-style: dashed;
  cursor: default;
}

.count {
  opacity: 0.7;
  font-size: 0.8em;
}

/* ---------- Карточки каналов ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 1rem;
}

.card {
  margin: 0;
}

.card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title {
  font-weight: 700;
  text-decoration: none;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.95rem;
}

.facts dt {
  color: var(--pico-muted-color);
  font-weight: normal;
}

.facts dd {
  margin: 0;
}

.chip {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
  vertical-align: middle;
}

.status-active { color: var(--good); }
.status-test { color: var(--series-1); }
.status-paused { color: var(--warning); }
.status-draft,
.status-archived { color: var(--neutral); }

.sig-active { color: var(--series-1); }
.sig-new { color: var(--warning); }
.sig-closed { color: var(--pico-color); }
.sig-cancelled { color: var(--neutral); }
.chip.tier { color: var(--pico-muted-color); font-weight: normal; }

/* ---------- Страница канала ---------- */

.crumbs {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.channel-head h2 .chip {
  font-size: 0.8rem;
  margin-left: 0.4rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: var(--pico-block-spacing-vertical);
}

.tile {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tile strong {
  font-size: 1.35rem;
  line-height: 1.2;
  white-space: nowrap;
}

.chart-box {
  position: relative;
  height: 220px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.5rem;
}

.key {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.key-line { width: 16px; height: 0; border-top: 2px solid; }
.key-dash { width: 16px; height: 0; border-top: 2px dashed; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.key.series-1 { color: var(--series-1); }
.key.series-2 { color: var(--series-2); }
.key.muted-line { color: var(--muted-line); }
.key.critical { color: var(--critical); }

table.stats th[scope="row"] {
  font-weight: normal;
  color: var(--pico-muted-color);
}

/* ---------- Сигналы ---------- */

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.filter-form select,
.filter-form input,
.filter-form button {
  width: auto;
  margin: 0;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  font-size: 0.9rem;
}

.filter-form input[type="search"] {
  max-width: 9rem;
}

table.signals {
  font-size: 0.875rem;
}

table.signals td,
table.signals th {
  vertical-align: top;
  padding: 0.5rem 0.4rem;
}

.hit { font-weight: 600; }

.pager {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

/* На телефоне строка таблицы сигналов — отдельная карточка */
@media (max-width: 768px) {
  table.signals thead {
    display: none;
  }
  table.signals,
  table.signals tbody,
  table.signals tr,
  table.signals td {
    display: block;
    width: 100%;
  }
  table.signals tr {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--pico-card-background-color);
  }
  table.signals td {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 0.5rem;
    border: none;
    padding: 0.2rem 0;
    background: transparent;
  }
  table.signals td::before {
    content: attr(data-label);
    color: var(--pico-muted-color);
  }
}

/* ---------- Решения раннера, очередь, журнал ---------- */

details.run {
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding: 0.5rem 0;
  margin: 0;
}

details.run summary {
  line-height: 1.4;
}

.run-head {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  align-items: center;
}

.run-note {
  display: block;
  font-size: 0.875rem;
  margin: 0.2rem 0 0 1.2rem;
}

.run-body {
  padding: 0.5rem 0 0.5rem 1.2rem;
}

.run-body h4 {
  font-size: 0.95rem;
  margin: 0.75rem 0 0.4rem;
}

table.compact {
  font-size: 0.85rem;
}

table.compact td,
table.compact th {
  padding: 0.3rem 0.4rem;
}

ul.rejected {
  font-size: 0.85rem;
  padding-left: 1rem;
}

ul.rejected li {
  margin-bottom: 0.2rem;
}

.decision-ok { color: var(--good); }
.decision-none { color: var(--pico-muted-color); }
.decision-error { color: var(--critical); }

article.post {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.post-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: center;
  margin-bottom: 0.25rem;
  padding: 0;
  background: transparent;
  border: none;
}

.post-times {
  margin-bottom: 0.25rem;
}

.post-note {
  margin-bottom: 0.25rem;
  color: var(--warning);
}

article.post details {
  margin: 0;
}

article.post summary {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

pre.post-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.post-queued { color: var(--warning); }
.post-published { color: var(--good); }
.post-failed { color: var(--critical); }
.post-cancelled,
.post-draft { color: var(--neutral); }

.value {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 0.875rem;
}

.value pre {
  font-size: 0.8rem;
  white-space: pre-wrap;
}

table.log,
table.diff {
  font-size: 0.875rem;
}

table.log td,
table.diff td {
  vertical-align: top;
}

.value.old { color: var(--pico-muted-color); }
.value.new { font-weight: 600; }

/* ---------- Настройки ---------- */

.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  border-left: 4px solid var(--good);
  background: var(--pico-card-sectioning-background-color);
}

.notice.warn {
  border-left-color: var(--warning);
}

.notice ul {
  margin: 0.25rem 0 0;
  padding-left: 1rem;
}

.notice li {
  margin-bottom: 0.25rem;
}

.warn-text { color: var(--warning); }

.jump {
  margin-bottom: 0.5rem;
  line-height: 1.8;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row select,
.row button {
  width: auto;
  margin: 0;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 0 1rem;
}


fieldset legend {
  margin-bottom: 0.5rem;
}

label.check {
  margin-bottom: 1rem;
}

textarea.code {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.8rem;
  line-height: 1.4;
}

ul.errors li {
  color: var(--pico-del-color);
}

/* Журнал и «было → стало» на телефоне — строки-карточки, как у сигналов */
@media (max-width: 768px) {
  table.log thead,
  table.diff thead {
    display: none;
  }
  table.log, table.log tbody, table.log tr, table.log td,
  table.diff, table.diff tbody, table.diff tr, table.diff td {
    display: block;
    width: 100%;
  }
  table.log tr,
  table.diff tr {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
  }
  table.log td,
  table.diff td {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 0.5rem;
    border: none;
    padding: 0.2rem 0;
    background: transparent;
  }
  table.log td::before,
  table.diff td::before {
    content: attr(data-label);
    color: var(--pico-muted-color);
  }
}

/* ---------- Заголовок канала: названия чатов из Telegram ---------- */

.channel-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  margin: 0;
}

.tg-chat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
}

.tg-name {
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.tg-meta {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--pico-muted-color);
  white-space: nowrap;
}

.tier-mark {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 999px;
  padding: 0 0.4rem;
  margin-right: 0.25rem;
}

.channel-subtitle {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--pico-muted-color);
}

h2.channel-title {
  font-size: 1.5rem;
  line-height: 1.25;
}

h2.channel-title .tg-meta {
  font-size: 0.8rem;
}

h2.channel-title .channel-subtitle {
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

.head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.tg-info {
  margin-bottom: 0.5rem;
}

form.refresh {
  margin-bottom: 1rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
}

a.small-btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

.card-actions {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.notice ol {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* Языковая модель */
.llm-total { padding: 0.75rem 1rem; }
.warn-chip { color: var(--warning); border-color: var(--warning); }
.close-posts td, .close-posts th { vertical-align: top; }
.close-posts textarea { min-width: 16rem; margin-bottom: 0.25rem; }
.example-box { margin-top: 1rem; }
.example-box blockquote { margin: 0.5rem 0; white-space: pre-wrap; }
.unchecked { color: var(--warning); font-weight: 600; }

/* Новости */
.sent-positive { color: var(--pos); border-color: var(--pos); }
.sent-negative { color: var(--neg); border-color: var(--neg); }
.sent-neutral { color: var(--pico-muted-color); }
.imp-market { color: var(--critical); border-color: var(--critical); font-weight: 600; }
.imp-coin { color: var(--series-1); border-color: var(--series-1); }
.imp-noise { color: var(--neutral); }
.break { overflow-wrap: anywhere; }
input.short { width: 5.5em; margin-bottom: 0; }
table.news td { vertical-align: top; }
.inline-check { display: inline-flex; margin-right: 1.25rem; }
.slot-dry, .slot-posted { color: var(--good); border-color: var(--good); }
.slot-planned { color: var(--series-1); }
.slot-skipped { color: var(--warning); }
.slot-cancelled { color: var(--neutral); }
.slot-writing { color: var(--series-1); }
.slot-failed { color: var(--critical); }

/* ---------- Главный экран: строка состояния системы ---------- */

.sysline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
}
.sysline > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  list-style: none;
}
.sysline > summary::-webkit-details-marker { display: none; }
.sysline > summary::after { content: "▾"; margin-left: auto; color: var(--muted); font-size: 0.8em; }
.sysline[open] > summary::after { content: "▴"; }
.sysline.sys-critical { border-color: var(--critical); background: var(--crit-soft); }
.sysline.sys-warning { border-color: var(--warning); background: var(--warn-soft); }
.sys-more { font-size: 0.92em; }

.services {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
  gap: 0.1rem 1.5rem;
}
.service {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.45rem;
  padding: 0.25rem 0;
}
.service .muted { font-size: 0.92em; }
.service-error { flex-basis: 100%; padding-left: 1.6rem; font-size: 0.92em; overflow-wrap: anywhere; }
.state-icon {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.state-ok { background: var(--good); }
.state-warning { background: var(--warning); color: #1a1a19; }
.state-silent { background: var(--critical); }
.state-stopped, .state-never { background: var(--neutral); }
.state-text { color: var(--text-2); }
.state-text-silent, .state-text-stopped { color: var(--critical); font-weight: 600; }
.state-text-warning { color: var(--warning); }

/* ---------- Главный экран: проблемы ---------- */

.problems { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.problem {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid;
}
.problems .problem { margin: 0; }
.problem a { color: var(--text); font-weight: 500; }
.problem a::after { content: " →"; color: var(--muted); }
.problem-critical { border-color: var(--critical); background: var(--crit-soft); }
.problem-warning { border-color: var(--warning); background: var(--warn-soft); }

/* ---------- Главный экран: «Входящие» (бот добавлен в чат) ---------- */

.inbox { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.inbox-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.inbox-text { display: flex; gap: 0.5rem; align-items: baseline; min-width: 0; flex: 1 1 22rem; overflow-wrap: anywhere; }
.inbox-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.inbox-actions form { margin: 0; }
.inbox-link { display: flex; gap: 0.4rem; align-items: center; }
.inbox-link select { margin: 0; width: auto; max-width: 30rem; min-height: 24px; padding: 0.1rem 0.4rem; }
.dot-info { background: var(--accent); flex: none; }
@media (max-width: 640px) {
  .inbox-actions, .inbox-link { width: 100%; }
  .inbox-link select { flex: 1; min-width: 0; max-width: none; }
}

/* ---------- Главный экран: каналы ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin: 0.9rem 0 0.5rem;
}
.toolbar h1 { margin: 0; }
.toolbar-note { margin-left: auto; }

.seg { display: flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: var(--radius); overflow-x: auto; }
.seg a { padding: 0.2rem 0.55rem; border-radius: var(--radius-sm); color: var(--text-2); white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

.empty { padding: 1.5rem 0; }

table.channels {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
table.channels th { background: var(--surface-2); padding: 0.35rem 0.6rem; }
table.channels td { padding: 0.5rem 0.6rem; }
table.channels tbody tr:last-child td { border-bottom: 0; }
.th-note { font-weight: 400; }

.ch-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ch-link { display: flex; flex-direction: column; gap: 0.1rem; color: var(--text); font-weight: 600; }
.ch-chat { display: inline-flex; align-items: center; gap: 0.35rem; }
.ch-sub { font-size: 0.92em; margin-top: 0.15rem; }
.ch-info { font-size: 0.92em; margin-top: 0.15rem; }
.ch-info::before { content: "◦ "; }

.tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  flex: none;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
.tier-paid { color: var(--series-2); border-color: currentColor; }

.subs-line { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.subs-line + .subs-line { margin-top: 0.15rem; }
.delta { font-size: 0.92em; }
.delta:not(.pos):not(.neg) { color: var(--muted); }
.sub { font-size: 0.88em; margin-top: 0.1rem; white-space: nowrap; }

.c-actions { white-space: nowrap; text-align: right; }
.c-actions a { margin-left: 0.6rem; color: var(--text-2); }

/* На телефоне строка канала — карточка: название сверху, цифры сеткой */
@media (max-width: 760px) {
  .toolbar h1 { flex-basis: auto; }
  .toolbar-note { order: 5; margin-left: 0; flex-basis: 100%; }
  .seg { order: 4; flex-basis: 100%; }
  .toolbar .btn { margin-left: auto; }

  table.channels, table.channels tbody { display: block; background: none; border: 0; }
  table.channels thead { display: none; }
  table.channels tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
  }
  table.channels tbody tr:hover { background: var(--surface); }
  table.channels td { display: block; padding: 0; border: 0; text-align: left; }
  table.channels td.c-name { grid-column: 1 / -1; }
  table.channels td.c-subs { grid-column: 1 / -1; display: flex; gap: 1rem; flex-wrap: wrap; }
  table.channels td.c-subs .subs-line + .subs-line { margin-top: 0; }
  table.channels td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8em;
    color: var(--muted);
    margin-bottom: 0.1rem;
  }
  table.channels td.c-subs::before { flex-basis: 100%; margin-bottom: -0.6rem; }
  table.channels td.c-actions {
    grid-column: 1 / -1;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 0.45rem;
  }
  table.channels td.c-actions a { margin: 0 1rem 0 0; }
}

/* ---------- Общие панели и плотные таблицы ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.75rem;
  min-width: 0;
}
.panel h2 { font-size: 0.95rem; margin: 0; }
.panel h4 { margin: 0.5rem 0 0.25rem; color: var(--muted); font-weight: 500; }
.panel > p { margin: 0.4rem 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.6rem; margin-bottom: 0.45rem; }
.panel-head .legend { margin: 0 0 0 auto; font-size: 0.92em; }
.panel-link { margin-left: auto; color: var(--text-2); }
.panels-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 0 0.75rem; }

table.dense { margin: 0; }
table.dense th, table.dense td { padding: 0.28rem 0.45rem; }
table.dense tbody tr:last-child td, table.dense tbody tr:last-child th { border-bottom: 0; }
table.kv th[scope="row"] { color: var(--muted); font-weight: 400; white-space: nowrap; }
table.kv tfoot td { border: 0; font-size: 0.88em; padding-top: 0.1rem; }
.nowrap { white-space: nowrap; }

details.mini { margin: 0.4rem 0 0; }
details.mini > summary { color: var(--text-2); font-size: 0.95em; }
details.mini[open] > summary { margin-bottom: 0.3rem; }

.inline-form { margin: 0; }
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: 0; }

/* ---------- Страница канала: шапка и вкладки ---------- */

.ch-page-head { margin-bottom: 0.5rem; }
.ch-page-head .crumbs { display: inline-block; margin: 0 0 0.35rem; font-size: 0.95em; color: var(--text-2); }
.ch-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.ch-title { font-size: 1.1rem; margin: 0; display: flex; flex-wrap: wrap; gap: 0.15rem 1.1rem; }
.ch-title small { font-weight: 400; font-size: 0.72em; margin-left: 0.15rem; }
.ch-actions { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.ch-meta { margin: 0.25rem 0 0; }
.ch-hypothesis { display: block; margin-top: 0.1rem; }

.ch-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.ch-tabs::-webkit-scrollbar { display: none; }
.ch-tabs a {
  padding: 0.4rem 0.65rem;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.ch-tabs a:hover { color: var(--text); text-decoration: none; }
.ch-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.ch-tabs-tech { margin-left: auto; display: flex; gap: 0.1rem; }
.ch-tabs-tech a { font-size: 0.92em; color: var(--muted); }

/* ---------- Обзор канала: ключевые цифры ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.55rem 0.8rem;
  border-right: 1px solid var(--border);
  margin-right: -1px;
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 0.88em; }
.kpi-value { font-size: 1.2rem; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.kpi-sub { font-size: 0.88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Итоги лесенки: в подписях несколько чисел — переносим, а не обрезаем. */
#grid-stats .kpi-sub { white-space: normal; }

/* ---------- Настройки: оглавление сбоку ---------- */

.settings-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 1rem; align-items: start; }
.settings-nav {
  position: sticky;
  top: 56px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.settings-nav a { padding: 0.28rem 0.55rem; border-radius: var(--radius-sm); color: var(--text-2); }
.settings-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.settings-hint { font-size: 0.88em; margin: 0.6rem 0.55rem 0; }
.settings-body > article { scroll-margin-top: 56px; }
.settings-body > article > h3 { font-size: 0.95rem; }
.settings-body .notice { margin-bottom: 0.6rem; }
.grid-form { gap: 0 0.75rem; }

@media (max-width: 760px) {
  .ch-tabs-tech { margin-left: 0.5rem; padding-left: 0.5rem; border-left: 1px solid var(--border); }
  .ch-actions { margin-left: 0; flex-basis: 100%; }
  .ch-hypothesis { display: none; }
  .kpi { border-bottom: 1px solid var(--border); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.05rem; }
  .panels-2 { grid-template-columns: minmax(0, 1fr); }
  .chart-box { height: 200px; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
  .settings-nav {
    position: sticky;
    top: 44px;
    z-index: 5;
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg);
    padding: 0.3rem 0;
    margin: 0 -12px;
    padding-left: 12px;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav a { white-space: nowrap; background: var(--surface); border: 1px solid var(--border); }
  .settings-hint { display: none; }
  .settings-body > article { scroll-margin-top: 92px; }
}

/* Длинные имена полей и значения в журнале и «было → стало» переносятся, а не растягивают страницу */
table.log code, table.diff code { overflow-wrap: anywhere; word-break: break-word; }
table.log td > div, table.diff td > div { min-width: 0; }
.value pre { max-width: 100%; overflow-x: auto; }

/* ---------- Выключатель канала ---------- */

.btn-primary { }
button.btn-danger { background: var(--critical); border-color: var(--critical); }
.c-actions a.toggle-off { color: var(--critical); }
.c-actions a.toggle-on { color: var(--good); font-weight: 600; }
.toggle-list { padding-left: 1.1rem; }
.toggle-list li { margin-bottom: 0.4rem; }
article.confirm { max-width: 820px; }

/* ---------- Сброс статистики ---------- */

tr.reset-divider td { background: var(--warn-soft); color: var(--text); font-weight: 500; text-align: center; }
tr.reset-divider td::before { content: none !important; }
.stats-since { margin: 0 0 0.5rem; }

.reset-notify small { margin-left: 1.4rem; }
.reset-notify .if-on { display: none; }
.reset-notify:has(input:checked) .if-on { display: block; }
.reset-notify:has(input:checked) .if-off { display: none; }

/* ---------- Пополнения ---------- */

.btn-sm { height: 24px; padding: 0 0.55rem; font-size: 0.92em; }
.key.good { color: var(--good); }
.key-dot-line { width: 16px; height: 0; border-top: 2px dotted; }

/* ---------- Пересылка результатов и продающие ---------- */

label.check.option { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; }
label.check.option input { margin-top: 0.2rem; flex: none; }
label.check.option small { display: block; margin-top: 0.15rem; }
.recent-posts { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.recent-posts ul { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.recent-posts li { margin-bottom: 0.35rem; overflow-wrap: anywhere; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.button-row button { margin-bottom: 0; }
.report-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0; }
.report-row label.check { margin-bottom: 0.5rem; }
.report-time { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }
.report-time input { width: 5.5rem; margin: 0; }
.field-title { margin: 0.75rem 0 0.25rem; }

/* Источник сигналов: посты чужого канала как есть */
.notice.error { border-left-color: var(--critical); background: var(--crit-soft); }
.source-posts { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.source-posts h4 { margin: 0 0 0.6rem; font-size: 1rem; }
.src-posts { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.src-post { padding: 0.6rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.src-post:last-child { border-bottom: 0; }
.src-post-meta { margin-bottom: 0.25rem; }
.src-post-text { white-space: pre-wrap; font-size: 0.92rem; line-height: 1.45; }
.src-post.is-deleted .src-post-text { opacity: 0.6; text-decoration: line-through; text-decoration-color: var(--critical); }
.chip.chip-deleted { color: var(--critical); border-color: var(--critical); }
.chip.chip-ok { color: var(--good); }
.chip.chip-warn { color: var(--warning); }
.chip.chip-error { color: var(--critical); }
.chip.chip-muted { color: var(--neutral); font-weight: normal; }
.src-parse { margin-top: 0.3rem; }
.src-filter { margin: 0 0 0.6rem; }
.src-post details { margin: 0.35rem 0 0; }
.src-post-version { margin: 0.35rem 0 0 0.75rem; padding-left: 0.6rem; border-left: 2px solid var(--border); }tr.fresh td { background: var(--surface-2); }

.ads-table td.center { text-align: center; }
.ads-table input { margin: 0; }
