/* Единый «пульт управления» антиспам-ботом (TMA).
 * Тёмная тема под Telegram, тот же визуальный язык, что и экран «Здоровье».
 */
:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --card: var(--tg-theme-secondary-bg-color, #181b22);
  --elev: #1f232c;
  --text: var(--tg-theme-text-color, #e7e9ee);
  --muted: var(--tg-theme-hint-color, #8a91a0);
  --line: rgba(255, 255, 255, 0.07);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --ok: #34c759;
  --warn: #ff9f0a;
  --crit: #ff3b30;
  --idle: #5e9bff;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ---------- верхняя панель ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 16px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.appbar-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7a4dff);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  clip-path: polygon(50% 0, 100% 22%, 100% 60%, 50% 100%, 0 60%, 0 22%);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--muted); text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  transition: background .2s, color .2s, transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- выбор канала ---------- */
.chan-pick { margin-top: 10px; display: flex; gap: 8px; align-items: stretch; }
.chan-pick .sel-wrap { position: relative; flex: 1; min-width: 0; }
.chan-pick select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 40px 12px 14px;
}
.chan-pick .sel-wrap::after {
  content: "";
  position: absolute; right: 16px; top: 50%;
  width: 9px; height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.chan-add {
  flex: 0 0 auto; width: 48px;
  display: grid; place-items: center;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; transition: background .2s, transform .08s;
}
.chan-add:active { transform: scale(.94); }
.chan-add svg { width: 20px; height: 20px; }

/* ---------- вкладки ---------- */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: var(--card);
  cursor: pointer;
  transition: color .2s, background .2s, transform .08s;
}
.tab svg { width: 17px; height: 17px; }
.tab:active { transform: scale(.95); }
.tab.active { color: var(--accent-text); background: var(--accent); }
.tab .tab-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
}

/* ---------- контент ---------- */
.view {
  padding: 14px 16px 48px;
  max-width: 640px; margin: 0 auto;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 0 12px;
}
.section-head h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.section-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.card h2 {
  margin: 0 0 12px; font-size: 12px; color: var(--muted);
  font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}

/* ---------- обзор: статусы и счётчики ---------- */
.hero {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px;
}
.hero .avatar { width: 46px; height: 46px; font-size: 18px; }
.hero-main { min-width: 0; }
.hero-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 10px; text-align: center;
}
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--muted); }
.stat.accent b { color: var(--warn); }
.stat.danger b { color: var(--crit); }

.health-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px;
}
.health-row .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.health-row .dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.health-row .dot.warning { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.health-row .dot.critical { background: var(--crit); box-shadow: 0 0 10px var(--crit); animation: pulse 1s infinite; }
.health-row .ht { font-weight: 600; }
.health-row .hlink { margin-left: auto; color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 600; }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- списки-строки ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px;
  animation: fade .25s ease;
}
.avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #5e9bff, #7a4dff);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- бейджи и чипы ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, 0.08); color: var(--muted);
}
.badge.green { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.orange { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.badge.red { background: color-mix(in srgb, var(--crit) 22%, transparent); color: var(--crit); }
.badge.blue { background: color-mix(in srgb, var(--idle) 22%, transparent); color: var(--idle); }
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 8px;
  font-size: 11px; color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--r-sm);
  font: inherit; font-weight: 700; font-size: 14px;
  padding: 11px 16px; cursor: pointer;
  transition: transform .08s, opacity .2s, background .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-danger { background: color-mix(in srgb, var(--crit) 18%, transparent); color: var(--crit); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn-ic {
  width: 38px; height: 38px; padding: 0; border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}
.btn-ic svg { width: 18px; height: 18px; }
.btn-ic.ok { color: var(--ok); }
.btn-ic.danger { color: var(--crit); }
.btn svg { width: 17px; height: 17px; }

/* ---------- пустое состояние / ошибки ---------- */
.empty {
  text-align: center; padding: 48px 24px; color: var(--muted);
  animation: fade .3s ease;
}
.empty .emoji { font-size: 40px; }
.empty h3 { margin: 14px 0 6px; color: var(--text); font-size: 17px; }
.empty p { margin: 0 auto; max-width: 280px; font-size: 13px; line-height: 1.5; }
.empty .btn { margin-top: 18px; }

/* ---------- скелетоны загрузки ---------- */
.skel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); height: 64px; margin-bottom: 10px;
  position: relative; overflow: hidden;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  z-index: 60; max-width: 90%;
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  background: var(--elev); color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  border: 1px solid var(--line);
  opacity: 0; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.err { border-left: 4px solid var(--crit); }

/* ---------- нижний лист (формы добавления) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 640px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  transform: translateY(0);
  animation: slideup .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--muted); opacity: .5; margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 16px; font-size: 18px; font-weight: 800; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 14px;
  appearance: none; -webkit-appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }

.muted-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 10px; }
.count-hint { color: var(--muted); font-size: 12px; }
.count-hint.warn { color: var(--warn); }

/* ---------- настройки: строка, переключатель, сегменты ---------- */
.set-row { display: flex; align-items: center; gap: 14px; }
.set-row .set-main { flex: 1; min-width: 0; }
.set-row .set-title { font-weight: 600; font-size: 15px; }
.set-row .set-sub { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }

.switch { position: relative; flex: 0 0 auto; width: 46px; height: 28px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); transition: background .22s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .22s;
}
.switch input:checked ~ .track { background: var(--ok); }
.switch input:checked ~ .thumb { transform: translateX(18px); }

.seg {
  display: flex; gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px; border-radius: var(--r-sm);
}
.seg button {
  flex: 1; padding: 10px 6px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background .2s, color .2s, transform .08s;
}
.seg button:active { transform: scale(.96); }
.seg button.active { background: var(--accent); color: var(--accent-text); }

/* ---------- подписка / оплата ---------- */
.sub-card .sub-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.sub-card .sub-head .dot { margin-top: 5px; flex: 0 0 auto; }
.sub-card .sub-text { flex: 1; min-width: 0; }
.sub-card .sub-title { font-weight: 700; font-size: 15px; }
.sub-card .sub-sub { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }

.sheet-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 16px; }

/* ---------- пошаговая инструкция (онбординг) ---------- */
.steps { list-style: none; counter-reset: step; margin: 0 0 18px; padding: 0; }
.steps .step {
  counter-increment: step; position: relative;
  padding: 0 0 16px 42px; font-size: 14px; line-height: 1.45;
}
.steps .step::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font-weight: 700; font-size: 13px;
}
.steps .step:not(:last-child)::after {
  content: ""; position: absolute; left: 13px; top: 30px; bottom: 6px;
  width: 2px; background: var(--line);
}

/* ---------- живая очередь модерации ---------- */
.live-dot {
  display: inline-block; width: 8px; height: 8px; margin-left: 8px;
  border-radius: 50%; background: var(--ok); vertical-align: middle;
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5); }
  50% { opacity: .5; box-shadow: 0 0 0 5px rgba(52, 199, 89, 0); }
}
.bulk-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.bulk-bar .btn { flex: 1; }
.qtimer { font-variant-numeric: tabular-nums; }
.qtimer.urgent { background: rgba(255, 59, 48, 0.16); color: var(--crit); }
.qtimer.expired { opacity: .55; text-decoration: line-through; }
.row-title .dim { color: var(--muted); font-weight: 400; font-size: 12px; }
.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--elev); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color .2s, transform .08s, background .2s;
}
.plan:active { transform: scale(.985); }
.plan:hover { border-color: var(--accent); }
.plan-main { flex: 1; min-width: 0; }
.plan-title { font-weight: 600; font-size: 15px; }
.plan-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.plan-price { font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--warn); }
