:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #262a33;
  --text: #e6e8ec;
  --muted: #8a8f98;
  --accent: #5b8def;
  --green: #3ecf8e;
  --yellow: #e0b13d;
  --red: #e05b5b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 24px;
}
.brand { font-weight: 700; font-size: 15px; }
.brand span { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 6px; font-size: 14px;
}
.sidebar nav a.active { background: var(--card); color: var(--text); }
.sidebar nav a:hover { color: var(--text); }
.sidebar-logout { margin-top: auto; }
.content { flex: 1; min-width: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 12px;
}
.thread-title { font-weight: 600; margin: 0 0 4px 0; }
.thread-title a { color: var(--text); text-decoration: none; }
.thread-title a:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.body-preview { color: var(--muted); font-size: 13px; margin-bottom: 10px; white-space: pre-wrap; }
textarea {
  width: 100%; min-height: 90px; background: #0d0f13; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-family: inherit;
}
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
button, input[type=submit] {
  background: var(--accent); color: white; border: none; border-radius: 6px;
  padding: 7px 14px; cursor: pointer; font-size: 13px;
}
button.secondary { background: #2a2e38; }
button.danger { background: var(--red); }
input[type=text] {
  background: #0d0f13; color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; font-size: 13px;
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.badge.new { color: var(--accent); border-color: var(--accent); }
.badge.drafted { color: var(--yellow); border-color: var(--yellow); }
.badge.replied { color: var(--green); border-color: var(--green); }
.badge.skipped { color: var(--muted); }
.badge.pending { color: var(--accent); border-color: var(--accent); }
.badge.approved { color: var(--green); border-color: var(--green); }
.badge.posted { color: var(--green); border-color: var(--green); }
.badge.rejected { color: var(--muted); }
.badge.generating { color: var(--yellow); border-color: var(--yellow); }
.badge.rendering { color: var(--yellow); border-color: var(--yellow); }
.badge.ready { color: var(--accent); border-color: var(--accent); }
.badge.uploading { color: var(--yellow); border-color: var(--yellow); }
.badge.scheduled { color: var(--accent); border-color: var(--accent); }
.badge.uploaded { color: var(--green); border-color: var(--green); }
.badge.awaiting_review { color: var(--yellow); border-color: var(--yellow); }
.badge.rendering_video { color: var(--yellow); border-color: var(--yellow); }
.badge.ready_to_publish { color: var(--accent); border-color: var(--accent); }
.badge.publishing { color: var(--yellow); border-color: var(--yellow); }
.badge.published { color: var(--green); border-color: var(--green); }
.badge.failed { color: var(--red); border-color: var(--red); }
.badge.skipped { color: var(--muted); }
.progress-track {
  width: 100%; height: 10px; border-radius: 999px; background: #0d0f13;
  border: 1px solid var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.4s ease;
}
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* v35.4: narrower/denser variant for "Последние публикации" on «Статистика» --
   the default 8px/13px table was fine for short cells, but the topic-text
   column there holds a full marketing sentence and was taking up most of
   the screen height per row (direct user complaint: "1 видео занимает куча
   места"). Only applied to the one table opted in via this class -- every
   other table on the site keeps the original spacing untouched. */
.compact-table td, .compact-table th { padding: 5px 7px; font-size: 12px; white-space: nowrap; }
.compact-table .cell-clamp {
  /* v35.5: was a 2-line clamp -- direct follow-up complaint that the row was
     still too tall ("название в таблице так и осталось большое") -- now a
     STRICT single line, whole topic/channel truncated with an ellipsis, full
     text only on hover (title=). Every row is now exactly one line tall. */
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  cursor: help;
}
form.inline { display: inline; }

.platform-card.disabled { opacity: 0.5; }
.platform-head { display: flex; align-items: center; gap: 12px; }
.platform-head > div:nth-child(2) { flex: 1; }
.platform-name { font-weight: 600; }
.platform-icon {
  width: 36px; height: 36px; border-radius: 8px; background: #0d0f13;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.platform-icon.reddit { color: #ff4500; }
.platform-icon.facebook { color: #1877f2; }
.platform-icon.x { color: var(--text); }
.platform-icon.instagram { color: #e1306c; }
.platform-icon.tiktok { color: var(--text); }
.button, a.button {
  background: var(--accent); color: white; text-decoration: none; border: none;
  border-radius: 6px; padding: 7px 14px; cursor: pointer; font-size: 13px; display: inline-block;
}
.empty-inline { color: var(--muted); font-size: 13px; margin-top: 8px; }
code { background: #0d0f13; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
h2 { margin-top: 0; }

.howto {
  margin-top: 10px; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; background: #0d0f13;
}
.howto summary {
  cursor: pointer; font-size: 13px; color: var(--accent); padding: 6px 0; user-select: none;
}
.howto[open] summary { margin-bottom: 4px; }
.howto ol { margin: 0 0 8px 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.howto li { margin-bottom: 4px; }
.howto a { color: var(--accent); }

.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-wrap { width: 100%; max-width: 340px; padding: 16px; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 4px;
}
.login-brand { text-align: center; font-size: 18px; margin-bottom: 12px; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 12px; margin-bottom: 4px; }
.login-card input {
  background: #0d0f13; color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 9px 10px; font-size: 14px;
}
.login-card button {
  margin-top: 20px; padding: 10px; font-size: 14px; border-radius: 8px;
}
.login-error {
  background: rgba(224, 91, 91, 0.12); color: var(--red); border: 1px solid var(--red);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; text-align: center;
}
.login-success {
  background: rgba(62, 207, 142, 0.12); color: var(--green); border: 1px solid var(--green);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; text-align: center;
}

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.settings-gear {
  color: var(--muted); text-decoration: none; font-size: 16px; line-height: 1;
  padding: 4px 6px; border-radius: 6px;
}
.settings-gear:hover, .settings-gear.active { color: var(--text); background: var(--card); }

.form-group { margin-bottom: 14px; max-width: 340px; }
.form-group label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.form-group input { width: 100%; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat-tile.warn .stat-value { color: var(--yellow); }
.stat-tile.warn.zero .stat-value { color: var(--text); }

.set-card { padding: 0; }
.set-card.approved { border-color: var(--green); }
.set-summary {
  list-style: none; cursor: pointer; padding: 16px; display: flex;
  align-items: center; gap: 10px; user-select: none;
}
.set-summary::-webkit-details-marker { display: none; }
.set-summary::before {
  content: "+"; flex-shrink: 0; width: 20px; height: 20px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--accent); font-size: 14px;
  line-height: 18px; text-align: center; font-weight: 700;
}
.set-card[open] > .set-summary::before { content: "−"; }
.set-summary:hover::before { border-color: var(--accent); }
.set-summary-text { flex: 1; min-width: 0; }
.set-summary .thread-title { margin: 0 0 4px 0; }
.set-summary .meta { margin: 0; }
.set-card[open] > .set-summary { border-bottom: 1px solid var(--border); }
.set-body { padding: 0 16px 16px 16px; }
@media (max-width: 720px) {
  .set-summary { flex-wrap: wrap; }
}

/* Mobile: the fixed 220px sidebar was eating most of a phone's width and
   squeezing everything else into a narrow, cramped column. Below this
   width the sidebar becomes a slim, horizontally-scrollable top bar
   instead, so the actual page content gets the full screen. */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 10px 12px; gap: 16px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand-row { flex-shrink: 0; gap: 10px; }
  .brand span { display: none; }
  .sidebar nav { flex-direction: row; gap: 2px; flex-shrink: 0; }
  .sidebar nav a { white-space: nowrap; padding: 6px 10px; }
  .sidebar-logout { margin-top: 0; flex-shrink: 0; }
  main { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-tile { padding: 10px 12px; }
  .stat-tile .stat-value { font-size: 20px; }
  table { font-size: 12px; }
  td, th { padding: 6px; white-space: nowrap; }
}
