/* Повторяющиеся блоки: плитки, карточки, статусы, таблицы, черновик. */

/* ─── Плитки показателей ────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 12px; }

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.tile .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650;
}
.tile .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.tile .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.alert { border-color: var(--crit); }
.tile.alert .v { color: var(--crit); }
.tile.good .v { color: var(--ok); }

/* Полоса заполнения — бюджет, доля дублей */
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); }
.bar.crit > i { background: var(--crit); }

/* ─── Карточки ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card + h2 { margin-top: 28px; }

/* ─── Статусы ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 2px 9px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ─── Таблицы ───────────────────────────────────────────────────────── */
.tablewrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow-x: auto; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }

/* ─── Черновик в модерации ──────────────────────────────────────────── */
.draft { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }

.thumb {
  border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2);
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; text-align: center; padding: 8px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Видео вписываем целиком: обрезать кадр у ролика с места события нельзя —
   именно в краях бывает то, ради чего его и сняли */
/* Высоту ограничиваем на самом плеере: у контейнера с auto-высотой
   height:100% разворачивается в натуральный размер ролика — вертикальное
   видео с телефона занимало бы всю страницу */
.thumb video { width: 100%; max-height: 300px; height: auto; object-fit: contain; display: block; }
.thumb:has(video) { padding: 0; aspect-ratio: auto; background: #000; }
.thumb + .thumb { margin-top: 8px; }

.preview {
  white-space: pre-wrap; background: var(--surface-2); border-radius: var(--r-sm);
  padding: 12px 14px; margin: 10px 0; line-height: 1.55;
  max-height: 340px; overflow-y: auto;
}
.preview b { font-weight: 700; }

.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.score { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score.hi { color: var(--crit); }
.score.mid { color: var(--warn); }
.score.lo { color: var(--muted); }

/* ─── Служебное ─────────────────────────────────────────────────────── */
.empty { color: var(--muted); text-align: center; padding: 48px 20px; }
.spinner { color: var(--muted); padding: 24px 0; }
.error { color: var(--crit); font-size: 13px; margin-top: 10px; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-sm);
  box-shadow: var(--shadow); z-index: 50; max-width: 380px;
}
.toast.err { background: var(--crit); color: #fff; }

details.expand > summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted);
  font-weight: 600; padding: 4px 0; list-style: none;
}
details.expand > summary::-webkit-details-marker { display: none; }
details.expand > summary::before { content: "▸ "; }
details.expand[open] > summary::before { content: "▾ "; }

@media (max-width: 860px) {
  .draft { grid-template-columns: 1fr; }
}

/* ─── Предпросмотр поста ────────────────────────────────────────────────
   Карточка повторяет вид сообщения в канале: модератор должен видеть то же,
   что увидит читатель, а не голый текст. */
.tg-post {
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  background: var(--surface); max-width: 460px;
}
.tg-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.tg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}

.weather-preview {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.weather-preview img {
  display: block; width: min(260px, 100%); height: auto; border-radius: var(--r-sm);
  box-shadow: var(--shadow);
}
.weather-preview pre {
  margin: 0; white-space: pre-wrap; font: inherit; line-height: 1.55;
  max-width: 620px; flex: 1 1 340px;
}
.tg-name { font-weight: 600; font-size: 14px; }
.tg-media { background: #000; }
.tg-media img, .tg-media video {
  width: 100%; max-height: 320px; height: auto; object-fit: contain; display: block;
}
.tg-more {
  padding: 6px 12px; font-size: 12px; color: var(--muted); background: var(--surface-2);
}
.tg-text {
  white-space: pre-wrap; padding: 12px; line-height: 1.55; font-size: 14px;
  max-height: 380px; overflow-y: auto;
}
.tg-text b { font-weight: 700; }
.tg-foot { padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ─── Сетка расписания ──────────────────────────────────────────────────
   Дни — колонки, часы канала — строки. Сетка прокручивается вбок отдельно
   от страницы: две недели в семь колонок на узком экране не влезают. */
.sched { overflow-x: auto; }
.sched-row {
  display: grid; grid-template-columns: 56px repeat(var(--sched-days, 7), minmax(120px, 1fr));
  gap: 4px; margin-bottom: 4px;
}
.sched-head { position: sticky; top: 0; }
.sched-hour {
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
  display: flex; align-items: center;
}
.sched-day {
  font-size: 12px; font-weight: 600; text-align: center; padding: 6px 4px;
  background: var(--surface-2); border-radius: var(--r-sm);
}
.sched-cell {
  min-height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line);
  padding: 4px; font-size: 12px;
}
.sched-cell.free {
  border-style: dashed; color: var(--muted); background: transparent;
  display: flex; align-items: center; justify-content: center;
}
.sched-cell.free.open { cursor: pointer; position: relative; font-size: 16px; }
.sched-cell.free.open:hover { border-color: var(--accent); color: var(--accent); }
.sched-cell.free.unavailable { cursor: default; opacity: .55; }
.sched-cell.free.unavailable:hover { border-color: var(--line); color: var(--muted); }
.sched-cell.past { border-style: dotted; opacity: .35; }
.sched-cell.off { background: var(--surface-2); }
.sched-cell.full { background: var(--crit-soft); border-color: var(--crit-soft); }
.sched-cell.busy {
  border-color: var(--accent); background: var(--accent-soft); padding: 4px;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 3px;
}
.sched-cell.busy.published { border-color: var(--ok); background: var(--ok-soft); }

.sched-post {
  border-radius: var(--r-sm); padding: 5px 7px; background: var(--surface-2);
  border-left: 3px solid var(--muted); overflow: hidden;
}
.sched-post + .sched-post { margin-top: 0; }
.sched-post.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.sched-post.accent { background: var(--accent-soft); border-left-color: var(--accent); }
.sched-post.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.sched-time {
  display: block; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.sched-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.3;
}
.sched-post-state { display: block; font-size: 10px; margin-top: 4px; }
.sched-post-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.sched-post-actions .btn { padding: 2px 5px; font-size: 10px; }

.sched-hour.off { color: var(--warn); }
.sched-off {
  display: block; font-size: 10px; opacity: .8;
}

.sched-range { margin-bottom: 14px; align-items: center; }
.sched-range input[type="date"] { width: auto; min-width: 150px; }
.sched-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: -4px 0 12px; color: var(--muted); font-size: 12px; }
.sched-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sched-legend-mark { width: 13px; height: 13px; border: 1px solid var(--line); border-radius: 3px; }
.sched-legend-mark.planned { border-color: var(--accent); background: var(--accent-soft); }
.sched-legend-mark.published { border-color: var(--ok); background: var(--ok-soft); }
.sched-legend-mark.free { border-style: dashed; background: transparent; }
.sched-planner, .sched-queue { margin-bottom: 14px; }
.sched-planner-heading, .sched-queue-heading { margin-bottom: 10px; }
.sched-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 2fr) minmax(210px, 1.2fr) auto;
  gap: 10px; align-items: end;
}
.sched-form label { margin-top: 0; }
.sched-form .btn { min-height: 38px; white-space: nowrap; }
.sched-form-note { font-size: 12px; margin-top: 8px; }
.sched-form-error { color: var(--crit); font-size: 12px; margin-top: 4px; }
.mod-schedule-picker {
  display: grid; grid-template-columns: minmax(210px, 1fr) auto; align-items: end; gap: 10px;
  margin-top: 8px; padding: 10px; border: 1px solid var(--accent);
  border-radius: var(--r-sm); background: var(--accent-soft);
}
.mod-schedule-picker[hidden] { display: none; }
.mod-schedule-picker label { display: block; margin: 0; font-size: 12px; }
.mod-schedule-picker input { display: block; margin-top: 5px; }
.mod-schedule-picker-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mod-schedule-picker .sched-form-error { grid-column: 1 / -1; margin-top: 0; }
.sched-queue > input { max-width: 420px; margin: 4px 0 12px; }
.sched-queue-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px;
}
.sched-queue-item {
  min-width: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
}
.sched-queue-item > .row { align-items: center; gap: 8px; }
.sched-queue-item strong { font-size: 12px; }
.sched-queue-title { font-weight: 650; margin: 7px 0 4px; line-height: 1.35; }
.sched-queue-text {
  font-size: 12px; line-height: 1.4; margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sched-queue-more { grid-column: 1 / -1; font-size: 12px; }
.sched-channel-head { margin-bottom: 12px; gap: 12px; }
.sched-channel-hours { font-size: 11px; text-align: right; }

@media (max-width: 760px) {
  .sched-form { grid-template-columns: 1fr; }
  .sched-form .btn { width: 100%; }
  .mod-schedule-picker { grid-template-columns: 1fr; }
  .mod-schedule-picker-actions .btn { flex: 1; }
  .sched-channel-head { align-items: flex-start !important; flex-direction: column; }
  .sched-channel-hours { text-align: left; }
}
