:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #1b2733;
  --muted: #62707e;
  --line: #d7dde3;
  --accent: #1c6b73;
  --accent-ink: #ffffff;
  --cold: #8fa7bf;
  --warm: #e0a030;
  --hot: #cf402b;
  --danger: #b3261e;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181e;
    --surface: #1a232c;
    --ink: #e6ebf0;
    --muted: #9aa8b5;
    --line: #2b3945;
    --accent: #4fb3bd;
    --accent-ink: #0c1317;
    --cold: #5f7890;
    --warm: #e8b04a;
    --hot: #ef6a55;
    --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); margin: .25rem 0; }
.inline { display: inline; margin: 0; }

.bar { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.bar-nav { display: flex; gap: 1rem; align-items: center; }
.bar-nav a { text-decoration: none; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; }
.link:hover { color: var(--ink); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.narrow { max-width: 360px; margin: 3rem auto; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: .45rem .85rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.flash { list-style: none; margin: 0 0 1rem; padding: 0; }
.flash li { padding: .6rem .85rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); }

/* Список тем */
.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.topic { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.topic.off { opacity: .6; }
.topic-name { font-size: 1.1rem; font-weight: 600; text-decoration: none; display: block; }
.topic-stats { display: flex; gap: .4rem; }
.stat { min-width: 2.4rem; text-align: center; padding: .15rem .5rem; border-radius: 99px; background: var(--bg); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.hot { background: var(--hot); color: #fff; }

.empty { padding: 2.5rem 1rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { max-width: 46ch; margin: .5rem auto 1rem; color: var(--muted); }

/* Вкладки и фильтры */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .75rem; overflow-x: auto; }
.tabs a { padding: .5rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a span { font-variant-numeric: tabular-nums; opacity: .8; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
select, input[type=text], input[type=search], input[type=number], input[type=password], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .55rem;
}
.filters input[type=search] { flex: 1 1 200px; }

/* Таблица лидов */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.leads { width: 100%; border-collapse: collapse; }
.leads th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.leads td { padding: .7rem .75rem; vertical-align: top; border-bottom: 1px solid var(--line); }
.leads tr:last-child td { border-bottom: 0; }
.leads tr { box-shadow: inset 4px 0 0 var(--cold); }
.leads tr.heat-warm { box-shadow: inset 4px 0 0 var(--warm); }
.leads tr.heat-hot { box-shadow: inset 4px 0 0 var(--hot); }
.leads thead tr { box-shadow: none; }
.c-heat { white-space: nowrap; padding-left: 1.1rem !important; }
.c-heat b { margin-left: .35rem; font-variant-numeric: tabular-nums; }
.c-text { min-width: 280px; max-width: 520px; }
.c-chat, .c-date { font-size: .9rem; color: var(--muted); }
.c-date { white-space: nowrap; }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 6px; height: 14px; border-radius: 1px; background: var(--line); }
.heat-cold .meter i:nth-child(1) { background: var(--cold); }
.heat-warm .meter i:nth-child(-n+2) { background: var(--warm); }
.heat-hot .meter i { background: var(--hot); }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details .less { display: none; color: var(--muted); font-size: .85rem; }
details[open] .short { display: none; }
details[open] .less { display: inline; }
details p { margin: .25rem 0 0; white-space: normal; overflow-wrap: anywhere; }
.meta { margin-top: .35rem; display: flex; gap: .75rem; flex-wrap: wrap; font-size: .85rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* Формы */
.stack { display: grid; gap: .75rem; }
.form { max-width: 720px; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field input[type=text], .field input[type=number], .field textarea { width: 100%; }
.field input[type=checkbox] { margin-right: .4rem; }
.help { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
.has-error textarea, .has-error input { border-color: var(--danger); }
.block { margin-top: 2rem; max-width: 720px; }
table.plain { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
table.plain th, table.plain td { text-align: left; padding: .45rem .65rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.suggest { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.suggest li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.code { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; overflow-x: auto; }

/* Телефон: строки таблицы становятся карточками */
@media (max-width: 760px) {
  .leads thead { display: none; }
  .leads, .leads tbody, .leads tr, .leads td { display: block; width: 100%; }
  .leads tr { padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .leads td { border: 0; padding: .25rem .9rem; }
  .c-text { max-width: none; }
  .leads td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .leads td.c-text::before { content: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
