:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-strong: #182230;
  --text: #17202c;
  --muted: #697586;
  --muted-strong: #4b5565;
  --line: #d9e0ea;
  --line-soft: #e8edf4;
  --accent: #1769e0;
  --accent-strong: #0f56bb;
  --accent-soft: #e8f1ff;
  --ok: #067647;
  --ok-soft: #e6f4ee;
  --warn: #9a5b13;
  --warn-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 44px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-strong);
  color: #d9e4f5;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 10px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 780;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #17202c;
  font-weight: 850;
}
.nav { display: grid; gap: 4px; }
.nav a, .nav button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #d9e4f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}
.nav a:hover, .nav button:hover, .nav .active { background: rgba(255, 255, 255, .1); color: #ffffff; }
.nav form { margin: auto 0 0; }
.nav-ico {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 760;
  flex: 0 0 auto;
}
.user-mini {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}
.user-mini strong { display: block; color: #ffffff; }
.user-mini span { color: #aebbd0; font-size: 13px; }

.main { min-width: 0; padding: 22px 28px 44px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}
.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.15; margin-bottom: 4px; letter-spacing: 0; }
h2 { font-size: 19px; margin: 0 0 12px; letter-spacing: 0; }
h3 { font-size: 16px; margin-bottom: 8px; letter-spacing: 0; }
.subtle { color: var(--muted); }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-actions form { margin: 0; }
.right-actions { justify-content: flex-end; }
.btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  font-weight: 720;
  white-space: nowrap;
}
.btn:hover { border-color: #bdc8d8; background: #fbfcfe; }
.btn.primary { color: #ffffff; background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 6px 9px; font-size: 13px; }
.btn-ico {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.layout { grid-template-columns: minmax(0, 1.45fr) minmax(310px, .8fr); align-items: start; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.card { padding: 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.stat-card {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stat-value { font-size: 33px; line-height: 1; font-weight: 820; }
.stat-label { color: var(--muted); font-weight: 680; }
.stat-hint { color: var(--muted); font-size: 13px; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); }
.status-dot.warn { background: #d99112; box-shadow: 0 0 0 5px var(--warn-soft); }
.status-dot.danger { background: var(--danger); box-shadow: 0 0 0 5px var(--danger-soft); }

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message {
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--accent-soft);
  border: 1px solid #bfd8ff;
  color: #17427d;
  font-weight: 650;
}
.message.error { background: var(--danger-soft); border-color: #f2b8b0; color: var(--danger); }
.message.success { background: var(--ok-soft); border-color: #b8dfcd; color: var(--ok); }

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.groups-table th:last-child, .groups-table td:last-child {
  width: 190px;
  text-align: right;
}
.groups-table td:last-child form {
  display: flex;
  justify-content: flex-end;
  margin: 0;
}
.groups-table .title-cell {
  min-width: 260px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line-soft); padding: 13px 14px; vertical-align: top; }
th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: .04em;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
.title-cell { display: grid; gap: 4px; }
.title-cell strong { font-size: 15px; }
.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 760;
  background: #eef2f7;
  color: #364152;
  white-space: nowrap;
}
.badge.scheduled { background: var(--accent-soft); color: #174ea6; }
.badge.published { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.draft { background: var(--warn-soft); color: var(--warn); }
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  padding: 7px 11px;
  font-weight: 720;
}
.filter-pill.active { background: var(--surface-strong); border-color: var(--surface-strong); color: #ffffff; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted-strong); font-size: 13px; font-weight: 760; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--text);
  outline: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: #74a8f5;
  box-shadow: 0 0 0 4px rgba(23, 105, 224, .13);
}
textarea { min-height: 180px; resize: vertical; }
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
input[type="file"] {
  background: var(--surface-soft);
  border-style: dashed;
}
.help, .muted { color: var(--muted); font-size: 13px; }
.errorlist { color: var(--danger); margin: 0; padding-left: 20px; }
.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  background: linear-gradient(rgba(238, 241, 245, 0), var(--bg) 32%);
}
.editor-shell { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.preview {
  position: sticky;
  top: 18px;
}
.post-preview {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}
.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 12px;
}
.vk-badge { color: #ffffff; background: #1576d1; border-radius: 6px; padding: 4px 7px; font-size: 12px; font-weight: 780; }
.preview-text { white-space: pre-wrap; color: #243044; min-height: 92px; }
.preview-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.preview-images img, .thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line-soft);
}
.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.emoji-bar button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.emoji-bar button:hover {
  border-color: #bdc8d8;
  background: var(--surface-soft);
}
.log-panel {
  margin-top: 14px;
}
.log-list {
  display: grid;
  gap: 8px;
}
.log-item {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}
.log-item.error {
  border-color: #f2b8b0;
  background: var(--danger-soft);
}
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.thumb-item {
  display: grid;
  gap: 6px;
}
.thumb-item .btn {
  width: 100%;
}
.empty {
  color: var(--muted);
  padding: 22px;
  background: rgba(255, 255, 255, .68);
  border: 1px dashed #c6cfdc;
  border-radius: 8px;
}
.timeline { display: grid; gap: 10px; }
.timeline-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
}
.timeline-time { color: var(--accent); font-weight: 790; }
.series-card { display: grid; gap: 10px; }
.series-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.integration-card {
  min-height: 170px;
  display: grid;
  align-content: space-between;
  gap: 16px;
}
.integration-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #1576d1;
  font-weight: 850;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef1f5 0%, #ffffff 100%);
}
.auth-card {
  width: min(430px, 100%);
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 820; font-size: 20px; }
.auth-brand .brand-mark { background: var(--surface-strong); color: #ffffff; }

@media (max-width: 1040px) {
  .layout, .editor-shell { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-mini { display: none; }
  .main { padding: 18px; }
  .page-head { flex-direction: column; }
  .stats, .two, .three { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  th, td { min-width: 140px; }
}
@media (max-width: 560px) {
  .nav { grid-template-columns: 1fr; }
  .actions, .form-actions { width: 100%; }
  .btn { width: 100%; }
  h1 { font-size: 25px; }
  .timeline-item { grid-template-columns: 1fr; }
}
