:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1c2331;
  --muted: #647084;
  --line: #dce3ee;
  --accent: #2f6fed;
  --accent-dark: #174fb8;
  --ok: #14845f;
  --warn: #b65a19;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
}

nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

nav form { margin: 0; }

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-head.compact {
  margin-top: 24px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; }
h2 { margin-bottom: 8px; font-size: 18px; }
p { color: var(--muted); }

.primary-link,
.button-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:hover,
.button-link:hover,
.primary-link:hover { background: var(--accent-dark); color: #fff; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.card-actions form { margin: 0; }

.card-actions > a,
.card-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
}

button.danger { background: var(--danger, #d64545); }
button.danger:hover { background: var(--danger-dark, #b83333); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.task-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.task-card dl { grid-template-columns: 150px minmax(0, 1fr); }
.task-copyright {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.group-card {
  display: flex;
  flex-direction: column;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.group-card:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(47, 111, 237, 0.12);
  transform: translateY(-1px);
}
.group-card .card-title h2 { color: var(--text); }
.group-card dl { flex: 1 1 auto; grid-template-columns: 130px 1fr; }
.group-card .button-link { background: transparent; color: var(--accent); padding: 0; min-height: 0; }
.group-card:hover .button-link { background: transparent; color: var(--accent-dark); }

.breadcrumb { margin: 0 0 6px; font-size: 14px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

.clip-section { margin-top: 22px; }
.clip-section h2 { display: flex; align-items: center; gap: 8px; }
.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 8px;
  background: var(--accent); color: #fff; border-radius: 11px; font-size: 13px;
}
.count-pill.ok { background: #2e9e6b; }

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.clip-card {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e8ee);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.clip-card.done { opacity: 0.85; }
.clip-thumb {
  position: relative;
  height: 120px;
  background: #11151c;
}
.clip-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.clip-noimg {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #8a93a6; font-size: 13px;
}
.clip-dur, .clip-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  padding: 1px 5px; border-radius: 5px; font-size: 11px;
}
.clip-badge { left: 6px; right: auto; background: rgba(46, 158, 107, 0.92); }
.clip-badge.fresh { top: 6px; bottom: auto; background: rgba(229, 95, 37, 0.95); font-weight: 600; }
.clip-body { padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.clip-time { font-size: 11px; font-weight: 600; color: var(--accent-dark, #2456c7); }
.clip-title {
  font-size: 11px; color: var(--muted, #6b7280); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.clip-body form { margin: 0; }
button.danger.small, .button-link.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.clip-body button.danger.small { min-height: 26px; padding: 0 6px; font-size: 11px; width: 100%; }

.recipients-block { border: 1px solid var(--border, #e5e8ee); border-radius: 10px; padding: 12px; }
.recipients-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.recipients-buttons { display: flex; gap: 8px; }
.recipients-progress { margin: 10px 0 4px; }
.progress-bar { height: 8px; border-radius: 999px; background: #e8edf6; overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.25s ease; }
.progress-text { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.recipients-list { max-height: 260px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.recipient-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; }
.recipient-row:hover { background: var(--bg, #f4f6fb); }
.recipient-row .muted, span.muted { color: var(--muted, #9aa3b2); font-size: 12px; }

.card,
.form-panel,
.login-panel,
.empty,
.table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
}

.pill.ok {
  background: #e6f5ef;
  color: var(--ok);
}

.pill.bad {
  background: #fdebed;
  color: #b4232c;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.error-text {
  border-left: 3px solid #b4232c;
  background: #fff4f5;
  color: #8a1f28;
  padding: 8px 10px;
}

.plain-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.help-text {
  border-left: 3px solid var(--accent);
  background: #f3f7ff;
  padding: 8px 10px;
  color: var(--muted);
}

.watermark-preview {
  display: block;
  width: 96px;
  max-height: 64px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  margin: 8px 0 12px;
  background: #fff;
}
.group-watermark-preview { margin-top: 0; }
.group-watermark-preview.disabled { opacity: 0.45; filter: grayscale(1); }

dl {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  margin: 14px 0;
}

dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }

.table-section { margin-top: 22px; overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.post-preview {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 360px;
}
.post-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex: 0 0 auto;
  background: var(--line);
}
.post-preview .post-text {
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted, #6b7280);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.num-ok { color: #16a34a; font-weight: 600; }
.num-warn { color: #d97706; font-weight: 600; }
.num-bad { color: #dc2626; font-weight: 600; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.pagination .page-info { color: var(--muted, #6b7280); font-size: 14px; }
.pagination .button-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.selected-counter {
  margin: 6px 0 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent, #2563eb);
}

.flash {
  margin-bottom: 16px;
  border: 1px solid #f1cf8a;
  background: #fff7df;
  border-radius: 8px;
  padding: 12px 14px;
}

.form-panel {
  display: grid;
  gap: 16px;
  max-width: 760px;
}

.mini-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.hint {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 14px 16px;
}

.hint h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.hint ol {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.hint li + li {
  margin-top: 5px;
}

code {
  border-radius: 4px;
  background: #eef2f7;
  padding: 1px 5px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input { width: 18px; min-height: 18px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(380px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
}

@media (max-width: 680px) {
  .topbar,
  .section-head,
  .form-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  nav { align-items: stretch; }
}

/* Панель единого расписания сообщества (страница группы) */
.schedule-card { margin-bottom: 20px; }
.schedule-card h2 { margin: 0 0 4px; }
.schedule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin: 12px 0 16px;
}
.schedule-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}
.schedule-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  min-width: 150px;
}
.schedule-form button { align-self: flex-end; }
.community-watermark-settings {
  flex: 1 0 100%;
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 10px 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.schedule-form .community-watermark-settings .check {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
}
.community-watermark-settings input[type="file"] { background: var(--panel); }
.watermark-current { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.watermark-current .watermark-preview { margin: 0; flex: 0 0 auto; }
.schedule-status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.schedule-status dt { font-weight: 700; color: var(--text); }
.schedule-status dd { margin: 0; color: var(--muted); }
.schedule-status .muted { color: var(--warn); }

@media (max-width: 680px) {
  .community-watermark-settings { grid-template-columns: 1fr; }
}

/* Статусы рассылок в таблице */
.status-error { color: var(--danger, #d64545); font-weight: 700; }
.status-sent { color: var(--ok); font-weight: 700; }
.status-processing { color: var(--accent); font-weight: 700; }
.status-pending { color: var(--warn); }
.table-section td form { margin: 0; }
