:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --accent: #8b1a1a;
  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #b3261e;
  --field-bg: #fbfbfb;
  --panel-bg: #fafafa;
  --focus-ring: rgba(139, 26, 26, .15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8e8e8;
    --muted: #9aa0a6;
    --line: #2b2f36;
    --accent: #e0685f;
    --field-bg: #1b1e24;
    --panel-bg: #181b20;
    --focus-ring: rgba(224, 104, 95, .22);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar a { color: inherit; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.who { margin-left: auto; color: var(--muted); font-size: 13px; }

/* Панель — рабочий инструмент с широкими таблицами. Ширину не ограничиваем. */
main { width: 100%; margin: 0; padding: 16px 24px 60px; }
h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 28px 0 10px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0 24px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.err { color: var(--err); border-color: currentColor; }

/* Ключ настройки под полем: по нему настройку ищут в коде и в логах. */
.setting-key { font-size: 11px; margin: -6px 0 16px; opacity: .55; }

/* Правка названия прямо в строке таблицы — отдельная страница ради одного поля не нужна. */
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit input { min-width: 260px; flex: 1 1 auto; }

/* Обложка ролика: её наличие — тот же признак готовности, что и статус рядом. */
.thumb { display: block; width: 96px; height: 54px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.thumb-empty { background: repeating-linear-gradient(45deg, transparent, transparent 5px, var(--line) 5px, var(--line) 6px); }

.cards { display: flex; flex-wrap: wrap; gap: 14px; }
.card { flex: 1 1 200px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.card .value { font-size: 24px; font-weight: 600; }
.card .label { color: var(--muted); font-size: 13px; }

button, .button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover { border-color: var(--accent); color: var(--accent); }

.muted { color: var(--muted); }
.notice { border-left: 3px solid var(--warn); padding: 10px 14px; background: rgba(154, 103, 0, .08); margin: 16px 0; }
.error { border-left: 3px solid var(--err); padding: 10px 14px; background: rgba(179, 38, 30, .08); }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }

/* Плотная таблица для рабочих списков: больше строк на экран */
table.dense th, table.dense td { padding: 5px 9px; font-size: 13.5px; }
table.dense tr:hover td { background: rgba(127, 127, 127, .07); }

.button.active { border-color: var(--accent); color: var(--accent); }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); }

/* Липкие заголовки таблиц убраны намеренно: у таблиц нет <thead>, правило
   цеплялось за первую строку и накрывало собой первую строку данных —
   казалось, что запись пропала. Прокрутка того не стоит. */

/* ---------- Формы ----------
   Браузерные поля по умолчанию остаются светлыми на тёмной теме — их нужно
   стилизовать явно, иначе на тёмном фоне получаются белые прямоугольники. */

input[type="text"],
input[type="number"],
input[type="time"],
input[type="search"],
select,
textarea {
  font: inherit;
  color: var(--fg);
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 11px;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}

textarea { line-height: 1.45; resize: vertical; }

input[type="text"]:hover,
input[type="number"]:hover,
select:hover,
textarea:hover { border-color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .65; }

select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="checkbox"] { width: auto; margin-right: 7px; accent-color: var(--accent); vertical-align: -2px; }
input[type="file"] { width: auto; max-width: 100%; color: var(--muted); font-size: 13px; }

/* Поле = подпись + контрол + пояснение под ним */
.field { margin-bottom: 18px; max-width: 640px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.field.wide { max-width: 100%; }
.field.narrow { max-width: 190px; }
.field.inline > label { display: inline; text-transform: none; font-size: inherit; color: inherit; }

/* Несколько коротких полей в ряд */
.field-row { display: flex; flex-wrap: wrap; gap: 0 22px; align-items: flex-start; }

/* Смысловые блоки формы */
.form-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-bg);
  padding: 18px 20px 4px;
  margin: 0 0 20px;
  max-width: 1000px;
}
.form-section > h2 { margin: 0 0 4px; font-size: 15px; }
.form-section > .section-hint { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.form-actions { display: flex; gap: 10px; align-items: center; margin: 24px 0 8px; }

button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button[type="submit"]:hover { opacity: .9; color: #fff; }

.preview-line {
  background: var(--field-bg);
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 9px 12px;
  margin-top: 8px;
  font-size: 13.5px;
}

/* Переключатель подписки в таблице */
table.dense button { padding: 2px 8px; font-size: 15px; line-height: 1.3; border-color: transparent; background: transparent; }
table.dense button:hover { border-color: var(--line); }
table.dense button.off { opacity: .35; }
table.dense button.off:hover { opacity: 1; }

/* Переключатель языка в шапке */
.who { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; gap: 2px; }
.lang-switch button { padding: 2px 7px; font-size: 12px; text-transform: uppercase; border-radius: 5px; }
.lang-switch button.off { opacity: .4; border-color: transparent; }
.lang-switch button.on { border-color: var(--accent); color: var(--accent); }
