/*
  Оформление как в админке (frontend/src/index.css, docs/design.md): только тёмная тема, серый без оттенка,
  акцентного цвета нет. Цвет только у состояний. Размеры текста 12, 14, 16, 20, 24; отступы 4-64.
*/
:root {
  color-scheme: dark;
  --bg: #0e0e0e;
  --surface: #161616;
  --raised: #1f1f1f;
  --selected: #2a2a2a;
  --border: #2e2e2e;
  --fg: #ededed;
  --muted: #a0a0a0;
  --faint: #6f6f6f;
  --on-fg: #0e0e0e;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* Оболочка: узкое меню слева, на узком окне строка сверху. */
.shell { display: flex; min-height: 100%; }

/* Колонка меню тянется на всю высоту страницы, само меню прилипает к экрану: «Выйти» внизу видимой области. */
.nav-col { width: 208px; flex: none; background: var(--surface); }

.nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 8px 16px; }
.brand img { width: 24px; height: 24px; }

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
}
.nav a:hover { background: var(--raised); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--selected); color: var(--fg); font-weight: 600; }

.nav-bottom { margin-top: auto; }

main {
  flex: 1;
  min-width: 0;
  padding: 32px 48px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.page { max-width: 760px; display: flex; flex-direction: column; gap: 24px; }

@media (max-width: 1023px) {
  .shell { flex-direction: column; }
  .nav-col { width: auto; }
  .nav {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 8px 16px;
    gap: 4px;
  }
  .brand { padding: 0 12px 0 0; }
  .brand span { display: none; }
  .nav-bottom { margin-top: 0; margin-left: auto; }
  main { padding: 24px 16px 96px; gap: 24px; }
}

/* Кнопки: главная светлая, вторичная серая, третичная текстом. */
button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.primary { background: var(--fg); color: var(--on-fg); font-weight: 600; }
.primary:hover { background: #ffffff; }
.secondary { background: var(--raised); color: var(--fg); }
.secondary:hover { background: var(--selected); }
.tertiary { background: transparent; color: var(--muted); padding: 8px; }
.tertiary:hover { color: var(--fg); }
.tertiary.danger { color: var(--danger); }
button:disabled { color: var(--faint); cursor: default; }
.primary:disabled { background: var(--fg); color: var(--faint); }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* Состояния: точка цветом, текст обычным. */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--success); }
.dot.warn { background: var(--warning); }
.dot.error { background: var(--danger); }
.dot.off { background: var(--faint); }
.status { display: flex; align-items: center; gap: 8px; }

/* Запланированный пост. */
.planned { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.planned-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.planned-lines { display: flex; flex-direction: column; gap: 4px; }

.tg {
  background: #000000;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tg-channel { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tg-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--selected);
  display: grid; place-items: center; font-size: 12px; color: var(--fg);
}
.tg-bubble {
  background: var(--raised);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px 4px;
  max-width: 440px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.tg-time { text-align: right; font-size: 12px; color: var(--faint); margin-top: 4px; }

details.partners summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details.partners table { margin-top: 8px; }

/* Блоки формы на своей поверхности. */
.block {
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block h2 { margin-bottom: 4px; }

label.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--raised);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--fg); outline-offset: 0; }
textarea { resize: vertical; min-height: 160px; line-height: 1.5; }
.invalid { border-color: var(--danger); }
.w-80 { width: 80px; }
.w-112 { width: 112px; }
.w-wide { width: 100%; max-width: 360px; }

.form-error { color: var(--fg); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.form-error::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.form-error:empty { display: none; }

.hint { font-size: 12px; color: var(--faint); }

.ranges { border-collapse: collapse; }
.ranges th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; padding: 0 8px 4px 0; }
.ranges td { padding: 4px 8px 4px 0; }
.ranges td:first-child { color: var(--muted); padding-right: 16px; white-space: nowrap; }
.ranges input { text-align: right; font-variant-numeric: tabular-nums; }

/* Сегмент из двух положений. */
.segment { display: inline-flex; background: var(--raised); border-radius: 6px; padding: 2px; }
.segment button { padding: 6px 12px; background: transparent; color: var(--muted); }
.segment button[aria-checked="true"] { background: var(--selected); color: var(--fg); font-weight: 600; }

/* Переключатель. */
.switch {
  width: 36px; height: 20px; padding: 0; border-radius: 10px; background: var(--selected); position: relative; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
  transition: left 0.15s;
}
.switch[aria-checked="true"] { background: var(--fg); }
.switch[aria-checked="true"]::after { left: 18px; background: var(--on-fg); }

.save-bar { display: flex; gap: 12px; align-items: center; }
@media (max-width: 1023px) {
  .save-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
}

/* Таблица истории: без сетки, строка раскрывается нажатием. */
table.list { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: 8px; overflow: hidden; }
table.list th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; padding: 12px 16px 8px; }
table.list td { height: 44px; padding: 0 16px; white-space: nowrap; }
table.list td.r, table.list th.r { text-align: right; }
table.list tr.item { cursor: pointer; }
table.list tr.item:hover td { background: var(--raised); }
table.list tr.detail td { padding: 8px 16px 16px; white-space: normal; background: var(--surface); }
.chev { color: var(--faint); width: 24px; }
.detail-text { white-space: pre-wrap; max-width: 520px; line-height: 1.45; }
.history-wrap { overflow-x: auto; }

.empty { color: var(--muted); padding: 24px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--raised); color: var(--fg); padding: 12px 16px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); max-width: calc(100vw - 32px);
}

/* Страницы без меню: вход и «Пароль не задан». */
.bare { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.bare-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.bare-head { display: flex; align-items: center; gap: 12px; }
.bare-head img { width: 32px; height: 32px; }
.bare-form input { width: 100%; }
.bare-form .primary { width: 100%; }
