/* =====================================================================
   YouTube Шайтан-машина — дизайн-система «Эфирная сетка» (ноябрь 2026)
   Плотная рабочая панель: спокойная холодная база, один синий акцент
   для действий, янтарь — только для сигнала «контент заканчивается».
   Шрифт Onest лежит в приложении — не зависит от Google Fonts.
   ===================================================================== */

@font-face {
  font-family: "Onest";
  src: url("/fonts/onest-cyrillic-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/fonts/onest-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #EEF0F4;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --surface-3: #EAEDF2;
  --border: #DEE2E9;
  --border-strong: #C7CDD8;
  --text: #11131A;
  --text-2: #353A46;
  --muted: #5F6676;
  --primary: #2146E0;
  --primary-hover: #1A39BE;
  --primary-soft: #E7ECFF;
  --primary-ink: #1A3AC2;
  --on-primary: #FFFFFF;
  --signal: #A24B06;
  --signal-strong: #F59E0B;
  --signal-soft: #FDF1DE;
  --danger: #C21D1D;
  --danger-soft: #FDE8E8;
  --success: #137A3A;
  --success-soft: #DEF5E6;
  --info: #0B6C86;
  --info-soft: #DDF2F7;
  --scrim: rgba(12, 14, 20, .52);
  --shadow-1: 0 1px 2px rgba(16, 19, 26, .05);
  --shadow-pop: 0 18px 40px -12px rgba(16, 19, 26, .28), 0 2px 6px rgba(16, 19, 26, .06);
  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Старые имена токенов — на них ссылаются встроенные стили разделов */
  --bg-panel: var(--surface);
  --bg-elevated: var(--surface);
  --text-muted: var(--muted);
  --accent: var(--primary);
  --accent-hover: var(--primary-hover);
  --accent-soft: var(--primary-soft);
  --warning: var(--signal);
  --warning-soft: var(--signal-soft);
  --radius: var(--r);
  --shadow: var(--shadow-1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0D12;
  --surface: #13161D;
  --surface-2: #191D26;
  --surface-3: #212633;
  --border: #252A36;
  --border-strong: #343B4B;
  --text: #ECEEF3;
  --text-2: #C3C8D3;
  --muted: #949BAB;
  --primary: #819CFF;
  --primary-hover: #A1B4FF;
  --primary-soft: #1C2441;
  --primary-ink: #AFC0FF;
  --on-primary: #0A0F24;
  --signal: #FBBF24;
  --signal-strong: #FBBF24;
  --signal-soft: #2D230F;
  --danger: #F87171;
  --danger-soft: #361719;
  --success: #4ADE80;
  --success-soft: #11301E;
  --info: #67D4E8;
  --info-soft: #0E2C33;
  --scrim: rgba(0, 0, 0, .62);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 18px 44px -10px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04);
}

/* ---------------------------------------------------------------- база */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "tnum" 0, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.2; }
h3 { font-size: 15px; font-weight: 650; margin: 18px 0 10px; }
button { font-family: inherit; }
code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 15px; height: 15px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); color: var(--primary-ink); }

body.in-telegram .main { padding-top: max(12px, env(safe-area-inset-top)); }
body.in-telegram .sidebar { padding-top: max(16px, env(safe-area-inset-top)); }

#app { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------- боковое меню */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  color: var(--text);
}
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }
.brand-text strong { font-size: 15.5px; font-weight: 750; letter-spacing: -0.02em; }

.nav-group { margin-bottom: 10px; }
.nav-group-title {
  font-size: 11.5px; color: var(--muted); font-weight: 500;
  padding: 6px 10px 4px;
}
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-link svg.i { color: var(--muted); transition: color .15s var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover svg.i { color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav-link.active svg.i { color: var(--primary-ink); }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding-left: 6px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-2);
  font-weight: 650; font-size: 13px; flex-shrink: 0;
}
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.who strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- основная зона */

.main { flex: 1; min-width: 0; padding: 0 28px 64px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--topbar-h);
  margin: 0 -28px 18px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 22px; font-weight: 720; margin: 0; letter-spacing: -0.025em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 550; line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-icon { padding: 7px; min-width: 36px; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.theme-toggle { color: var(--muted); }

/* ---------------------------------------------------------------- карточки и сетки */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.card > h3:first-child, .card h3.mt-0 { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + .grid, .grid + .card { margin-top: 12px; }
@media (max-width: 1100px) {
  .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.stat-card .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-card .value {
  font-size: 27px; font-weight: 720; letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- таблицы */

.table-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
thead th {
  text-align: left; padding: 9px 12px;
  color: var(--muted); font-weight: 600; font-size: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- метки */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
  vertical-align: middle;
}
.badge svg.i { width: 13px; height: 13px; }
.badge-active, .badge-published, .badge-matched, .badge-processed { background: var(--success-soft); color: var(--success); }
.badge-paused, .badge-planned, .badge-partially_matched, .badge-draft { background: var(--signal-soft); color: var(--signal); }
.badge-archived, .badge-cancelled, .badge-error, .badge-unmatched { background: var(--danger-soft); color: var(--danger); }
.badge-in_progress, .badge-produced, .badge-scheduled, .badge-manually_fixed { background: var(--info-soft); color: var(--info); }
.badge-shorts { background: var(--signal-soft); color: var(--signal); }
.badge-long { background: var(--info-soft); color: var(--info); }
.badge-geo { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------------------------------------------------------------- формы */

input, select, textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  min-height: 36px; padding: 7px 11px;
  font-size: 13.5px; font-family: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { line-height: 1.45; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="checkbox"], input[type="radio"] {
  min-height: 0; width: 16px; height: 16px; padding: 0; margin: 0;
  accent-color: var(--primary); cursor: pointer; vertical-align: middle;
}
input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
label { font-size: 12.5px; color: var(--muted); font-weight: 500; display: block; margin-bottom: 5px; }
label.flex { color: var(--text-2); font-size: 13.5px; font-weight: 450; cursor: pointer; }
.field { margin-bottom: 14px; }
.filters-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }

/* ---------------------------------------------------------------- окна */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; overflow-y: auto;
  animation: fadeIn .16s var(--ease);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 22px;
  width: 100%; max-width: 620px;
  box-shadow: var(--shadow-pop);
  animation: popIn .2s var(--ease);
}
.modal h2 { margin: 0 0 14px; font-size: 18px; font-weight: 700; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin: 18px -22px -22px; padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- уведомления */

.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px 11px 12px;
  border-radius: 12px;
  background: #171A22; color: #F1F3F7;
  font-size: 13.5px; line-height: 1.4;
  box-shadow: var(--shadow-pop);
  border-left: 4px solid var(--primary);
  animation: popIn .2s var(--ease);
}
[data-theme="dark"] .toast { background: #F1F3F7; color: #11131A; }
.toast.success { border-left-color: #22C55E; }
.toast.error { border-left-color: #EF4444; }
.toast.info { border-left-color: #6E8BFF; }

/* ---------------------------------------------------------------- вход */

.login-wrap {
  flex: 1 1 auto; width: 100%;
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto; overscroll-behavior-y: contain;
  background:
    radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(100%, 420px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 32px;
  box-shadow: var(--shadow-pop);
}
.login-card .brand { padding: 0 0 26px; gap: 12px; }
.login-card .brand-mark { width: 38px; height: 38px; }
.login-card h1 { font-size: 25px; margin: 0 0 8px; font-weight: 720; line-height: 1.16; }
.login-card p.subtitle { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card label { color: var(--text-2); font-size: 13px; margin-bottom: 7px; }
.login-card input {
  width: 100%; min-height: 48px; padding: 11px 13px;
  font-size: 16px; line-height: 1.35;
}
.password-control { position: relative; }
.password-control input { padding-right: 52px; }
.password-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-2); }
.password-toggle:active { transform: translateY(-50%); }
.password-toggle svg { width: 20px; height: 20px; }
.login-card input:-webkit-autofill,
.login-card input:-webkit-autofill:hover,
.login-card input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px var(--surface) inset;
}
.login-card input:-webkit-autofill:focus { box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 3px var(--primary-soft); }
.form-error {
  margin: 4px 0 16px; padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 10px; background: var(--danger-soft); color: var(--danger);
  font-size: 13px; line-height: 1.4;
}
.form-error[hidden] { display: none; }
.form-error svg { width: 17px; height: 17px; margin-top: 1px; }
.login-card .btn-primary {
  min-height: 48px; padding: 11px 16px;
  white-space: normal; line-height: 1.35; font-size: 14px;
}
.login-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 20px 0 0; padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px; line-height: 1.5;
}
.login-note svg { width: 16px; height: 16px; margin-top: 2px; }
@media (max-width: 760px) {
  .login-card input:not([type="checkbox"]):not([type="radio"]) { min-height: 48px; }
}
@media (max-width: 600px) {
  .login-wrap {
    padding: 24px 20px;
    padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background: var(--surface);
  }
  .login-card { width: 100%; max-width: 440px; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .login-card .brand { padding-bottom: 30px; }
  .login-card h1 { font-size: 26px; }
}
@media (max-width: 340px) {
  .login-wrap { padding-left: 16px; padding-right: 16px; }
  .login-card h1 { font-size: 23px; }
}
@media (max-height: 620px) {
  .login-wrap { place-items: start center; }
}


/* ---------------------------------------------------------------- утилиты */

.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.spacer { flex: 1 1 auto; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-weight: 550; font-size: 13.5px; white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-ink); border-color: var(--primary); }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 34px 20px; text-align: center; color: var(--muted);
  cursor: pointer; margin-bottom: 16px; background: var(--surface-2);
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  background: var(--primary-soft); color: var(--primary-ink);
  padding: 4px 6px 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 4px;
}
.pill button {
  background: none; border: none; color: inherit; cursor: pointer;
  padding: 2px; display: inline-flex; border-radius: 50%;
}
.pill button:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------------------------------------------------------------- переключатели */

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 11px;
}
.seg button {
  border: none; background: transparent; color: var(--text-2);
  padding: 6px 13px; min-height: 30px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

.channel-tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.channel-tab {
  flex: 0 0 auto; padding: 7px 14px; min-height: 34px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  cursor: pointer; font-weight: 550; font-size: 13px; white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.channel-tab:hover { border-color: var(--border-strong); color: var(--text); }
.channel-tab.active { background: var(--text); border-color: var(--text); color: var(--surface); }

/* ---------------------------------------------------------------- контент-план */

.cp-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.view-switch { display: flex; gap: 4px; }
.month-group { padding-top: 10px; }
.month-header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 2px 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); background: var(--surface); z-index: 2;
}
.month-title { font-size: 15px; font-weight: 700; }
.month-count { background: var(--primary-soft); color: var(--primary-ink); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

.month-block { margin-bottom: 24px; }
.month-bar {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 2px 8px; margin-bottom: 2px;
  border-bottom: 2px solid var(--text);
  position: sticky; top: var(--topbar-h); z-index: 3; background: var(--bg);
}
.month-bar h3 { margin: 0; font-size: 18px; font-weight: 720; letter-spacing: -0.02em; }
.month-bar .count { color: var(--muted); font-size: 12.5px; }
.day-row {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 10px 2px; align-items: start;
}
.day-row.is-weekend { background: linear-gradient(90deg, color-mix(in srgb, var(--primary-soft) 70%, transparent), transparent 70%); }
.day-row.is-today .daynum { color: var(--primary); }
.day-row.is-today .dayname { color: var(--primary-ink); font-weight: 600; }
.day-rail { text-align: right; padding-top: 3px; }
.daynum { font-size: 24px; font-weight: 720; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.dayname { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.slot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px 8px 12px; margin-bottom: 6px;
  border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.slot:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.slot:last-child { margin-bottom: 0; }
.slot .ep {
  font-variant-numeric: tabular-nums;
  background: var(--primary-soft); color: var(--primary-ink);
  border-radius: 7px; padding: 2px 8px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.slot .name { font-weight: 620; }
.slot .vid { color: var(--muted); font-size: 12.5px; flex: 1 1 220px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .meta { color: var(--muted); font-size: 12.5px; }
.slot .edit {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex;
}
.slot .edit:hover { background: var(--primary-soft); color: var(--primary-ink); }
.nodate-note { color: var(--muted); font-size: 12.5px; padding: 4px 2px 10px; }

.weekday-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.weekday-picker button {
  width: 44px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 600;
}
.weekday-picker button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.weekday-picker button.weekend { border-style: dashed; }
.plan-preview { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 4px 0; margin-top: 10px; }
.plan-line { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; padding: 6px 12px; font-size: 13px; align-items: center; }
.plan-line + .plan-line { border-top: 1px solid var(--border); }
.plan-line .d { font-variant-numeric: tabular-nums; font-weight: 600; }
.plan-line .was { color: var(--muted); font-size: 11.5px; }

.combo { position: relative; }
.combo input { width: 100%; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop);
  max-height: 260px; overflow: auto; z-index: 20; display: none; padding: 4px;
}
.combo-list.open { display: block; }
.combo-item { padding: 8px 10px; cursor: pointer; font-size: 13.5px; border-radius: 8px; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); color: var(--primary-ink); }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.combo-hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.sched-summary { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); font-size: 13px; font-weight: 600; }
.sched-summary.warn { background: var(--signal-soft); color: var(--signal); }

.bulk-dock {
  position: sticky; bottom: 14px; z-index: 30;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-pop);
}

/* ---------------------------------------------------------------- запас контента и автоплан */

.stock-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 340px; min-height: 36px; padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--signal-strong) 55%, transparent);
  background: var(--signal-soft); color: var(--signal);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.stock-chip.is-critical { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); color: var(--danger); }
.stock-chip:hover { filter: brightness(.98); }
.stock-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.stock-chip.is-critical .stock-dot { animation: stockPulse 1.6s ease-in-out infinite; }
@keyframes stockPulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.stock-banner {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 14px 16px; margin-bottom: 16px;
  border-radius: var(--r-lg);
  background: var(--signal-soft);
  border: 1px solid color-mix(in srgb, var(--signal-strong) 40%, transparent);
}
.stock-banner-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stock-banner-main > strong { display: inline-flex; align-items: center; gap: 8px; color: var(--signal); }
.stock-banner-list { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.stock-banner-item { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.stock-banner-item.is-critical { color: var(--danger); }
.stock-banner-item .text-muted { font-weight: 450; font-size: 12.5px; }

.stock-table td { vertical-align: top; }
.stock-sub { font-size: 12.5px; margin-top: 3px; }
tr.is-muted td { opacity: .5; }

.section-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h3 { margin: 0; font-size: 16px; }
.section-note { color: var(--muted); margin: 0 0 14px; max-width: 78ch; }

.ap-form { display: grid; grid-template-columns: auto auto 1fr; gap: 0 20px; align-items: start; }
.ap-wishes { min-width: 240px; }
.ap-channel { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.ap-channel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.ap-summary { margin: 4px 0 10px; padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--primary-soft); color: var(--text); border-radius: 0 10px 10px 0; }
.ap-warning { font-size: 12.5px; color: var(--signal); margin: 3px 0; display: flex; gap: 6px; align-items: flex-start; }
.ap-items td { vertical-align: top; }
.ap-dock { margin-top: 16px; }

.scan-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px;
}
.scan-tile {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.scan-tile strong { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.scan-tile .text-muted { font-size: 12.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--border-strong); }
.status-dot.ok { background: var(--success); }
.status-dot.partial, .status-dot.running { background: var(--signal-strong); }
.status-dot.error, .status-dot.skipped { background: var(--danger); }
.status-dot.running { animation: stockPulse 1.2s ease-in-out infinite; }

.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.conf-bar { width: 44px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.conf-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.conf-bar.low > i { background: var(--signal-strong); }

.day-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.day-pick { position: relative; cursor: pointer; margin: 0; }
.day-pick input { position: absolute; opacity: 0; pointer-events: none; }
.day-pick span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 38px; padding: 0 6px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px;
}
.day-pick input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.day-pick input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- телефон */

.mobile-menu-btn { display: none; }
.mobile-only { display: none; }
.bottom-nav { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.sidebar-backdrop.show { display: block; animation: fadeIn .16s var(--ease); }

@media (max-width: 860px) {
  .ap-form { grid-template-columns: 1fr; }
  .stock-banner { flex-direction: column; align-items: stretch; }
  .stock-chip { max-width: 190px; }
  .stock-table th:nth-child(3), .stock-table td:nth-child(3) { display: none; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(84vw, 300px); height: 100dvh;
    transform: translateX(-102%);
    transition: transform .24s var(--ease);
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 0 14px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { margin: 0 -14px 12px; padding: 8px 14px; min-height: 54px; }
  .topbar h1 { font-size: 19px; }
  .theme-toggle { display: none; }
  .btn, select, input:not([type="checkbox"]):not([type="radio"]), .tab { min-height: 42px; }
  .btn-sm { min-height: 34px; }
  .card { padding: 14px; border-radius: 14px; }
  .filters-bar, .cp-toolbar { gap: 6px; }
  .filters-bar input, .filters-bar select, .cp-toolbar input, .cp-toolbar select { flex: 1 1 46%; min-width: 0; }
  .cp-toolbar .seg { flex: 1 1 100%; }
  .cp-toolbar .seg button { flex: 1; }
  .cp-toolbar .spacer { display: none; }
  .cp-toolbar .btn { flex: 1 1 46%; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 8px 9px; }
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; border-radius: 22px 22px 0 0; padding: 18px 16px;
    max-height: 92dvh; overflow-y: auto;
    animation: sheetUp .24s var(--ease);
  }
  .modal-actions {
    position: sticky; bottom: -18px; margin: 16px -16px -18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    flex-wrap: wrap; border-radius: 0;
  }
  .modal-actions .btn { flex: 1 1 auto; }
  .day-row { grid-template-columns: 52px 1fr; gap: 10px; }
  .daynum { font-size: 20px; }
  .slot .vid { flex-basis: 100%; }
  .bulk-dock { bottom: calc(76px + env(safe-area-inset-bottom)); gap: 6px; padding: 10px; }
  .bulk-dock .btn, .bulk-dock select { flex: 1 1 46%; }
  .toast-wrap { left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: none; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--border);
  }
  .bottom-nav button {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border: none; background: none; border-radius: 12px;
    color: var(--muted); font-size: 11px; font-weight: 550; cursor: pointer;
  }
  .bottom-nav button svg.i { width: 22px; height: 22px; }
  .bottom-nav button.active { color: var(--primary-ink); }
  .bottom-nav button.active svg.i { stroke-width: 2.1; }
  .bottom-nav .nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; height: 18px; min-width: 18px; font-size: 10.5px; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

@media (max-width: 560px) {
  .stock-table th:nth-child(4), .stock-table td:nth-child(4),
  .stock-table th:nth-child(5), .stock-table td:nth-child(5) { display: none; }
  .stock-table th:nth-child(8), .stock-table td:nth-child(8) { display: none; }
  .stock-table .mobile-only { display: block; }
  .stock-table .badge { white-space: normal; height: auto; padding: 3px 8px; line-height: 1.25; }
  .ap-items th:nth-child(5), .ap-items td:nth-child(5),
  .ap-items th:nth-child(6), .ap-items td:nth-child(6) { display: none; }
}
@media (max-width: 420px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
  .cp-toolbar .btn, .filters-bar input, .filters-bar select { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- кликабельные метки */

.badge-btn {
  border: none; cursor: pointer; font-family: inherit;
  transition: filter .12s var(--ease), transform .12s var(--ease);
}
.badge-btn:hover { filter: brightness(.95); }
.badge-btn:active { transform: scale(.97); }

/* ---------------------------------------------------------------- панель уведомлений */

.notif-wrap { position: relative; }
.notif-btn { position: relative; }
.notif-btn .nav-badge { position: absolute; top: 2px; right: 0; margin: 0; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 80;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn .18s var(--ease);
}
.notif-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: 14px;
}
.notif-list { max-height: min(420px, 60vh); overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; text-align: left; width: 100%;
  background: none; border-left: none; border-right: none; border-top: none;
  font-family: inherit; color: inherit;
  transition: background-color .12s var(--ease);
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.notif-item.is-unread:hover { background: var(--primary-soft); }
.notif-item .notif-ic {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.notif-item .notif-ic svg.i { width: 16px; height: 16px; }
.notif-ic.is-low { background: var(--signal-soft); color: var(--signal); }
.notif-ic.is-empty { background: var(--danger-soft); color: var(--danger); }
.notif-item .notif-body { min-width: 0; flex: 1; }
.notif-item .notif-text { font-size: 13px; line-height: 1.4; color: var(--text-2); }
.notif-item .notif-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.notif-foot {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.notif-foot .btn { flex: 1; }
.notif-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* Форма добавления «что выйдет» в модальном окне */
.planned-form {
  display: grid; grid-template-columns: 150px 1fr; gap: 8px;
  padding: 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); align-items: end;
}
.planned-form .pf-title { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .planned-form { grid-template-columns: 1fr; }
  .notif-panel { position: fixed; top: auto; right: 8px; left: 8px; width: auto; bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* Диалог с нейросетью: уточняющие вопросы перед сборкой плана */
.ap-questions { margin: 8px 0 6px; padding: 14px 16px; border: 1px solid var(--primary); border-radius: 12px; background: var(--primary-soft); }
.ap-q-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 10px; }
.ap-q-field { margin-bottom: 10px; }
.ap-q-field textarea { width: 100%; }
.ap-questions .cp-toolbar { flex-wrap: wrap; gap: 8px; }
