/* ----------------------------------------------------------
   Питомник Селлер — refined minimalism, dark theme
   ---------------------------------------------------------- */

:root {
  /* Surface */
  --bg: #0f1620;
  --bg-card: #1b2532;
  --bg-input: #131c27;
  --line: #2a3645;
  --line-strong: #38465a;

  /* Text */
  --text: #f1f4f9;
  --text-muted: #7f91a4;
  --text-faint: #4f5d70;

  /* Accent (Timeweb) */
  --accent: #7177f8;
  --accent-hover: #8a90ff;
  --accent-press: #525aff;
  --accent-glow: rgba(113, 119, 248, 0.22);

  /* Geometry */
  --radius-card: 16px;
  --radius-control: 8px;
  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 32px 80px -24px rgba(0, 0, 0, 0.65),
    0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-base: 200ms cubic-bezier(.4, 0, .2, 1);

  /* Typography */
  --font-sans: "Inter", "Segoe UI", "Tahoma", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow-x: hidden;
}

/* --- атмосфера: один мягкий радиальный «luminance» сверху, без gradient-slop --- */
body::before {
  content: "";
  position: fixed;
  inset: -10% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(60% 70% at 50% 0%,
      rgba(113, 119, 248, 0.10) 0%,
      rgba(113, 119, 248, 0.04) 40%,
      transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* мелкая шум-плёнка, едва различима, добавляет «вещественность» поверхности */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

.auth-shell {
  width: 100%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 36px 36px;
  animation: card-in 480ms cubic-bezier(.22, 1, .36, 1) both;
}

.auth-notice {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid #d9c58a;
  border-radius: 10px;
  background: #fff8df;
  color: #5e4b16;
  font-size: 14px;
  line-height: 1.45;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* --- brand --- */
.brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 30px;
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--text);
}
.brand .hairline {
  display: block;
  height: 1px;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--accent) 28px,
    var(--line) 28px,
    var(--line) 100%);
  border-radius: 1px;
}

/* --- form --- */
form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input {
  height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 0 14px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  appearance: none;
  -webkit-appearance: none;
}
.field input:hover { border-color: var(--line-strong); }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg);
}

/* убираем стрелочки в number-инпутах и яркий autofill */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

/* --- button --- */
.btn-primary {
  margin-top: 6px;
  height: 46px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-base);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}
a.btn-primary, a.btn-ghost { margin-top: 0; }
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn-primary:active { background: var(--accent-press); transform: translateY(1px); }
.btn-primary:disabled {
  background: var(--line);
  color: var(--text-faint);
  cursor: not-allowed;
  transform: none;
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
  *, *::before, *::after { transition-duration: 0.001ms !important; }
}

/* ---------- Magic-link landing статус ---------- */
.magic-status {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- 2FA: input для кода ---------- */
.code-input {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-align: center;
  height: 52px;
  padding: 0 8px;
}
.code-input::placeholder { letter-spacing: 0.4em; }

/* ---------- App shell (dashboard) ---------- */
body.app {
  display: block;
  min-height: 100dvh;
  padding: 0;
  --sidebar-w: 248px;
  --topbar-h: 56px;
}
body.app::before { display: none; }      /* убираем «лампу» от логина */

/* checkbox-toggle для mobile (без JS) */
.nav-toggle { display: none; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #131c27;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  display: inline-block;
  flex-shrink: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group--bottom { margin-top: auto; }

.nav-group-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.nav-link.is-active {
  color: var(--text);
  background: rgba(113, 119, 248, 0.10);
  position: relative;
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-link.is-disabled {
  color: var(--text-faint);
  cursor: not-allowed;
  pointer-events: none;
}

.nav-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Topbar --- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 15;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 22, 32, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-spacer { flex: 1; }
.topbar-actions { margin: 0; }

.nav-burger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: -8px;
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-burger svg { width: 20px; height: 20px; }
.nav-burger:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-base), border-color var(--t-base), background var(--t-base);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.02);
}

/* --- Main --- */
.app-main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 32px) 24px 80px;
  /* Запрещаем main растягиваться шире viewport: иначе блочные дети с большим
     контентом (широкие таблицы) выталкивают всю страницу. */
  max-width: calc(100vw - var(--sidebar-w));
  min-width: 0;
  box-sizing: border-box;
}
.page-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 32px 32px;
  max-width: 760px;
}
.page-title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}
.page-sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-muted);
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-right: 4px;
}

/* ============================================================
   Notifications page — refined UX
   ============================================================ */
.notif-page { max-width: 1280px; display: flex; flex-direction: column; gap: 16px; }

/* ───────────── Stats ───────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 18px 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  transition: border-color var(--t-base), transform var(--t-base);
}
.stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--stat-accent, var(--accent));
}
.stat--ok      { --stat-accent: var(--success); }
.stat--info    { --stat-accent: var(--accent); }
.stat--danger  { --stat-accent: var(--danger); }
.stat--warn    { --stat-accent: var(--warning); }

.stat-ico {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--stat-accent) 14%, transparent);
  color: var(--stat-accent);
  flex-shrink: 0;
}
.stat-ico svg { width: 20px; height: 20px; }
.stat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.1;
}

/* ───────────── Filters ───────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 10px 12px;
}
.pills {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.pill {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.pill:hover { color: var(--text); }
.pill.is-on {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset;
}

.status-select {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.status-select select {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 30px 0 14px;
  cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.status-select select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.status-select .chev {
  position: absolute;
  right: 10px;
  width: 14px; height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
}
.search svg {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 0 12px 0 34px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ───────────── Table ───────────── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.ntable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.ntable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
  white-space: nowrap;
}
.ntable tbody tr {
  cursor: pointer;
  transition: background var(--t-fast);
}
.ntable tbody tr:hover { background: rgba(113,119,248,0.05); }
.ntable tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ntable tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.ntable tbody tr:last-child td { border-bottom: 0; }

.col-time    { width: 80px; white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.col-chan    { width: 130px; }
.col-tgt     { width: 200px; max-width: 240px; }
.col-status  { width: 150px; white-space: nowrap; }
.col-text    { min-width: 0; }
.col-actions { width: 90px; text-align: right; white-space: nowrap; }

.t-name    { color: var(--text); font-weight: 500; }
.t-sub     { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.t-id      { color: var(--text-faint); font-family: ui-monospace, monospace; font-size: 12px; }
.t-preview { color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; line-height: 1.45; }
.t-err     { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Channel pill */
.chan-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
.chan-pill svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.chan--tg  svg { color: #2aabee; }
.chan--max svg { color: #ff7f50; }

/* Status badges — крупнее, с точкой */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in oklab, currentColor 16%, transparent);
}
.badge-att {
  font-weight: 500;
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.75;
}
.badge--sent         { color: var(--success);  background: rgba(112,207,152,.12); border-color: rgba(112,207,152,.30); }
.badge--queued       { color: var(--accent);   background: rgba(113,119,248,.13); border-color: rgba(113,119,248,.32); }
.badge--sending      { color: var(--accent);   background: rgba(113,119,248,.13); border-color: rgba(113,119,248,.32); }
.badge--failed       { color: var(--danger);   background: rgba(255,98,112,.13);  border-color: rgba(255,98,112,.30); }
.badge--dead         { color: var(--danger);   background: rgba(255,98,112,.18);  border-color: rgba(255,98,112,.40); }
.badge--rate_limited { color: var(--warning);  background: rgba(242,201,76,.13);  border-color: rgba(242,201,76,.32); }
.badge--blocked      { color: var(--warning);  background: rgba(242,201,76,.13);  border-color: rgba(242,201,76,.32); }

/* Icon-кнопки в строке */
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius-control);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255,255,255,.02);
}
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn--row:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn--row.act-cancel:hover { color: var(--danger); border-color: var(--danger); }

/* Empty & loading */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 56px 16px;
  font-size: 13.5px;
}
.empty .empty-ico { color: var(--text-faint); margin-bottom: 10px; }
.empty .empty-ico svg { width: 36px; height: 36px; opacity: 0.6; }

/* Skeleton */
.sk-row td { padding: 14px 16px; }
.sk {
  background: linear-gradient(90deg,
    rgba(255,255,255,.04) 0%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 100%);
  background-size: 200% 100%;
  animation: sk-pulse 1.4s ease-in-out infinite;
  height: 12px;
  border-radius: 4px;
}
.sk-tiny { height: 9px; margin-top: 6px; opacity: 0.6; }
.sk-w-60   { width: 60px; }
.sk-w-70   { width: 70px; }
.sk-w-80   { width: 80px; }
.sk-w-90   { width: 90px; }
.sk-w-120  { width: 120px; }
.sk-w-full { width: 100%; }
@keyframes sk-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Кликабельный получатель — ссылка на диалог */
.t-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background var(--t-fast), color var(--t-fast);
}
.t-link:hover { background: rgba(113,119,248,.10); color: var(--accent); }
.t-link:hover .t-sub { color: var(--accent); }

/* Направление сообщения — маленькая стрелка перед каналом */
.dir-arrow {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
  margin-right: 6px;
  vertical-align: middle;
}
.dir-in  { background: rgba(112,207,152,.12); color: var(--success); }
.dir-out { background: rgba(113,119,248,.12); color: var(--accent); }

/* Date picker — конкретный день */
.date-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 4px 0 10px;
  height: 34px;
  gap: 6px;
}
.date-picker > svg { width: 14px; height: 14px; color: var(--text-muted); }
.date-picker input[type="date"] {
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 4px;
  color-scheme: dark;
}
.date-picker input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.date-clear {
  background: transparent; border: 0; color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 1;
}
.date-clear:hover { color: var(--text); background: rgba(255,255,255,.04); }

/* ───────────── Pagination ───────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.pager-size {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
}
.pager-size select {
  appearance: none; -webkit-appearance: none;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 0 10px;
  cursor: pointer;
}
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-info {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 100px;
  text-align: center;
}
.lk-page-summary{color:var(--text-muted);font-size:12px;text-align:center}.lk-page-summary:empty{display:none}
.lk-pagination{display:flex;align-items:center;justify-content:center;gap:12px;min-height:42px;padding:10px 14px;border-top:1px solid var(--line)}
.lk-pagination button[hidden]{display:none}.lk-pagination button{white-space:nowrap}
@media(max-width:620px){.lk-pagination{flex-wrap:wrap}.lk-page-summary{width:100%;order:-1}}

/* ───────────── Modal ───────────── */
.m-modal {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg-card);
  color: var(--text);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 32px);
  box-shadow: 0 32px 80px -16px rgba(0,0,0,.65);
}
.m-modal::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.m-card { display: flex; flex-direction: column; max-height: 84vh; }

.m-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  gap: 12px;
}
.m-head-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.m-channel { display: inline-flex; }
.m-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.m-status-row { padding: 0 20px 14px; border-bottom: 1px solid var(--line); }

.m-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.s-item { min-width: 0; }
.s-k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.s-v {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

/* Кликабельное значение в summary-grid модалки — ведёт в диалог */
.m-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(113,119,248,.4);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.m-link:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

.m-text-block { padding: 16px 20px; }
.m-text-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.m-text {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.5;
}

.m-actions {
  padding: 14px 20px 18px;
  display: flex; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--line);
}
.m-actions:empty { display: none; }
.m-err {
  width: 100%;
  font-size: 12.5px;
  color: var(--danger);
  background: rgba(255,98,112,.08);
  border: 1px solid rgba(255,98,112,.20);
  border-radius: var(--radius-control);
  padding: 8px 12px;
}

.btn-compact { height: 36px; padding: 0 16px; font-size: 13.5px; }
.mono  { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.small { font-size: 12px; }
.muted { color: var(--text-muted); }

/* ───────────── Адаптив ───────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .filters { padding: 8px; }
  .search { min-width: 100%; order: 99; }
  .col-time { display: none; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .stat { padding: 12px 14px 12px 16px; gap: 10px; }
  .stat-ico { width: 32px; height: 32px; }
  .stat-ico svg { width: 16px; height: 16px; }
  .stat-value { font-size: 22px; }

  .ntable thead { display: none; }
  .ntable, .ntable tbody, .ntable tr, .ntable td { display: block; width: auto; }
  .ntable tbody tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    position: relative;
  }
  .ntable tbody tr:last-child { border-bottom: 0; }
  .ntable tbody td { padding: 0; border: 0; white-space: normal; }
  .col-time     { display: block; font-size: 11px; margin-bottom: 6px; }
  .col-chan     { display: inline-block; margin-right: 10px; margin-bottom: 6px; }
  .col-status   { display: inline-block; margin-bottom: 6px; }
  .col-tgt      { width: auto; margin-bottom: 6px; }
  .col-text     { margin-top: 4px; }
  .col-actions  {
    position: absolute; top: 12px; right: 12px;
    width: auto; text-align: right;
  }
  .m-summary { grid-template-columns: 1fr; }
}

/* --- Адаптив: ≤1100px = off-canvas sidebar с hamburger. -----
   Промежуточный «компактный 64px» режим НЕ используем.
   См. feedback-no-icons-only-sidebar в memory. ----------------- */
@media (max-width: 1100px) {
  body.app { --sidebar-w: 0px; }
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.5);
  }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }

  .topbar { left: 0; padding: 0 16px 0 8px; }
  .nav-burger { display: inline-flex; }
  .app-main { margin-left: 0; padding: calc(var(--topbar-h) + 24px) 20px 48px; }
}

@media (max-width: 640px) {
  .app-main { padding: calc(var(--topbar-h) + 16px) 16px 48px; }
  .page-card { padding: 24px 22px; border-radius: 14px; }
}

/* --- Login/2FA mobile (как было) --- */
@media (max-width: 420px) {
  .auth-card { padding: 32px 24px 28px; border-radius: 14px; }
  .brand h1  { font-size: 22px; }
  .code-input { font-size: 20px; letter-spacing: 0.35em; }
}

/* ============================================================
   Conversation page — messenger-like
   ============================================================ */
.chat-page {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h) - 32px);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  max-width: 880px;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.015);
  flex-shrink: 0;
}
.chat-back {
  width: 32px; height: 32px;
  border-radius: var(--radius-control);
  display: grid; place-items: center;
  color: var(--text-muted);
  border: 1px solid var(--line);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.chat-back:hover { color: var(--text); border-color: var(--line-strong); }
.chat-back svg { width: 16px; height: 16px; }

.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(113,119,248,.15);
  color: var(--accent);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-avatar.unknown { background: rgba(127,145,164,.15); color: var(--text-muted); }

.chat-peer { min-width: 0; flex: 1; }
.chat-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta { flex-shrink: 0; }
.chat-channel {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scroll-behavior: smooth;
}
.chat-loading, .chat-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 13.5px;
}

.chat-list { display: flex; flex-direction: column; gap: 6px; }

.day-sep {
  display: flex; align-items: center;
  margin: 16px 0 8px;
}
.day-sep span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  margin: 0 auto;
}

.bubble-row { display: flex; }
.bubble-in  { justify-content: flex-start; }
.bubble-out { justify-content: flex-end; }

.bubble {
  max-width: min(72%, 560px);
  padding: 8px 12px 6px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.bubble-in  .bubble {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.bubble-out .bubble {
  background: linear-gradient(180deg, rgba(113,119,248,.20), rgba(82,90,255,.18));
  border: 1px solid rgba(113,119,248,.30);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.b-text { white-space: pre-wrap; }
.b-meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.bubble-out .b-meta { text-align: right; }
.b-st--sent     { color: var(--success); }
.b-st--queued,
.b-st--sending  { color: var(--accent); }
.b-st--failed,
.b-st--dead     { color: var(--danger); }
.b-st--rate_limited,
.b-st--blocked  { color: var(--warning); }

.b-err {
  margin-top: 4px;
  font-size: 11px;
  color: var(--danger);
  background: rgba(255,98,112,.08);
  border: 1px solid rgba(255,98,112,.2);
  border-radius: 6px;
  padding: 4px 8px;
}

/* mobile */
@media (max-width: 640px) {
  .chat-page { border-radius: 0; border-left: 0; border-right: 0; height: calc(100dvh - var(--topbar-h)); margin: -20px -16px -48px; }
  .bubble { max-width: 86%; }
  .chat-head { padding: 10px 12px; }
  .chat-stream { padding: 12px 10px; }
}

/* ============================================================
   Segments / Client / Broadcasts
   ============================================================ */

.stats-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.col-form { width: 100px; }
.col-num  { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.page-actions {
  display: flex; justify-content: flex-end; margin-bottom: 4px;
}

/* Client header */
.client-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
}
.client-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(113,119,248,.15);
  color: var(--accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}
.client-avatar.unknown { background: rgba(127,145,164,.15); color: var(--text-muted); }
.client-id-block { min-width: 0; flex: 1; }
.client-name { font-size: 16px; font-weight: 600; color: var(--text); }
.client-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.client-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Broadcast new form layout */
.bc-new .bc-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
}
.bc-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bc-card { padding: 20px 22px; }
.bc-h    { margin: 0 0 14px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.bc-h-sm { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }

.bc-field { margin-bottom: 14px; }
.bc-field > label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.bc-field select,
.bc-field input[type="number"],
.bc-field textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.bc-field textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
.bc-field select:focus,
.bc-field input:focus,
.bc-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.bc-counter {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.delivery { display: flex; gap: 16px; }
.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  cursor: pointer;
}
.check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
}

.bc-sample {
  list-style: none; padding: 0; margin: 0;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  max-height: 280px; overflow-y: auto;
}
.bc-sample li {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.bc-sample li:last-child { border-bottom: 0; }
.bc-sample li.muted { display: block; text-align: center; color: var(--text-muted); }
.bc-sample-id   { font-family: ui-monospace, monospace; color: var(--text-muted); }
.bc-sample-name { color: var(--text); }
.bc-sample-meta { color: var(--text-muted); font-size: 11px; }

.bc-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px;
}
.bc-warning {
  margin-top: 12px;
  background: rgba(242,201,76,.10);
  border: 1px solid rgba(242,201,76,.30);
  border-radius: var(--radius-control);
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--warning);
}

@media (max-width: 900px) {
  .bc-new .bc-row { grid-template-columns: 1fr; }
  .stats-grid--3  { grid-template-columns: 1fr; }
}

/* Switch toggle (subscribed Y/N) */
.col-toggle { width: 80px; text-align: center; }
.switch { display: inline-block; position: relative; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer;
  inset: 0;
  background: var(--line);
  transition: background var(--t-fast);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: #fff;
  transition: transform var(--t-fast);
  border-radius: 50%;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-glow); }

/* Danger ghost button (удалить клиента) */
.btn-danger {
  color: var(--danger);
  border-color: rgba(255,98,112,.35);
}
.btn-danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* Audience pills — крупнее, чем обычные фильтры */
.audience-pills .pill { padding: 8px 14px; font-size: 13px; }

/* page-actions для верхней кнопки */
.page-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

.stats-grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* Client subscriptions — групповая отрисовка */
.sub-group {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.sub-group-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sub-channel + .sub-channel { margin-top: 18px; }
.sub-channel-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}
.sub-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.sub-row:hover { border-color: var(--line-strong); }
.sub-name { font-weight: 500; color: var(--text); }
.sub-meta { font-size: 11px; color: var(--text-muted); text-align: right; }


.last-active {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.last-active input[type="date"] {
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 12px;
  color-scheme: dark;
}

/* === Mobile sidebar overlay + close button === */
.nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 18;
  cursor: pointer;
}
.nav-toggle:checked ~ .nav-overlay { display: block; }

.sidebar-close {
  display: none;
  position: absolute;
  top: 14px; right: 12px;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  cursor: pointer;
  background: var(--bg-input);
}
.sidebar-close svg { width: 16px; height: 16px; }
.sidebar-close:hover { color: var(--text); border-color: var(--line-strong); }

/* Только на mobile показываем крестик внутри открытого sidebar */
@media (max-width: 640px) {
  .sidebar-close { display: inline-flex; }
}

/* === Mobile fixes для broadcast_new и client === */
@media (max-width: 640px) {
  /* Карточки form/preview — короче padding */
  .bc-card { padding: 16px 16px; }
  .bc-h    { font-size: 15px; margin-bottom: 12px; }
  .bc-h-sm { font-size: 11px; margin: 14px 0 6px; }

  /* Pills могут вылазить вне card — даём wrap */
  .pills { flex-wrap: wrap; }
  .audience-pills .pill { padding: 6px 10px; font-size: 12px; }

  /* Тапабельность кнопки-даты */
  .last-active { flex-direction: column; align-items: stretch; }
  .last-active .pill,
  .last-active .btn-ghost { width: 100%; }

  /* Уменьшаем topbar-title чтобы не съезжал */
  .topbar-title { font-size: 13px; }

  /* Client groups — узкие колонки в один столбец */
  .sub-grid { grid-template-columns: 1fr; }
  .sub-group { padding: 14px 14px; }
  .sub-group-title { font-size: 14px; margin-bottom: 10px; }
  .sub-row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .sub-row .sub-meta { grid-column: 1 / -1; text-align: left; }

  /* Profile/header клиента: actions переезжают вниз */
  .client-head { flex-wrap: wrap; }
  .client-actions { width: 100%; justify-content: flex-end; margin-top: 8px; }
  .client-actions .btn-ghost { padding: 6px 10px; font-size: 12px; }
}

/* ============= Маркетплейсы ============= */
.mp-list { display: flex; flex-direction: column; gap: 16px; }
.mp-placeholder { color: var(--muted); padding: 20px; text-align: center; }
.mp-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.mp-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}
.mp-card-head h3 { margin: 0; font-size: 17px; }
.mp-card-head h3 small { font-weight: 400; font-size: 13px; }
.mp-card-foot {
  display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line);
  margin-top: 12px;
}
.mp-empty { color: var(--muted); padding: 16px; text-align: center; font-size: 13px; }
.opacity-60 { opacity: 0.6; }

/* ===== Inline filters row ===== */
.filters-row {
  display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
  margin-top: 12px;
}
.field--inline { min-width: 140px; }
.field-hint { color: var(--muted); font-size: 11px; margin-top: 4px; }
.form-error { color: var(--danger, #c33); font-size: 13px; margin-top: 8px; }
.table-foot {
  display: flex; gap: 12px; justify-content: flex-end; align-items: center;
  padding: 10px 12px; border-top: 1px solid var(--line);
}

/* ===== Минималистичный <dialog> для модалок ===== */
.modal { border: none; border-radius: 12px; padding: 0; max-width: 520px; width: 90vw; }
.modal::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.modal-form { display: flex; flex-direction: column; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x {
  background: none; border: 0; cursor: pointer; font-size: 22px; line-height: 1;
  color: var(--muted); padding: 4px 8px;
}
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  padding: 12px 16px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}
