/* Админка сайтов в стиле ФКС-Центр. Эталон: mockups/admin-style/src/a5.html (рельса меню, плотная таблица)
   и src/a4.html (зона перетаскивания файла). Цвета и шрифт замерены с center-fks.ru (brand.json).
   Модули экранов (editor.js, publish.js, photo-editor.js) берут цвета только через переменные ниже. */
:root {
  /* палитра ФКС, 1-в-1 с a5 */
  --blue: #426BBD;
  --blue-h: #3A5FA9;
  --blue-soft: #F3F7FF;
  /* выбранный вариант в переключателях и вкладках: заметнее наведения (Маша 29.10.2026) */
  --sel-bg: #DCE6FA;
  --blue-line: #C9D6EF;
  --page: #FFFFFF;
  --surface: #F2F4F9;
  --tint: #FCFDFF;
  --text: #121619;
  --text2: #38444D;
  --muted: #697077;
  --line: #E3E7F0;
  --crimson: #AB093C;

  /* общие имена, которыми пользуются модули экранов */
  --accent: var(--blue);
  --accent-dark: var(--blue-h);
  --accent-soft: var(--blue-soft);
  --accent-line: var(--blue-line);
  --bg: var(--surface);
  --card: #FFFFFF;
  /* всё подключённое, работающее и опубликованное зелёное (один токен) */
  --ok: #1E7B45;
  --ok-soft: #EAF6EF;
  --ok-line: #B9DFC8;
  /* предупреждения и ошибки янтарём: красного в админке нет */
  --warn: #8a5a00;
  --warn-soft: #fbf3e2;
  --warn-line: #ecd29a;
  --danger: var(--warn);

  --font: Inter, Arial, sans-serif;
  --fs: 16px;
  --fs-s: 16px;
  --fs-m: 16px;
  --fs-l: 20px;
  --fs-xl: 34px;
  --fs-lead: 18px;
  --fs-h2: 22px;
  --fs-zone: 26px;
  --fs-hero: 44px;
  --btn-h: 48px;
  --r: 15px;
  --r-card: 15px;
  --r-btn: 8px;
  --r-pill: 30px;
  --gap: 24px;
  --rail-w: 132px;
}
@media (max-width: 760px) {
  :root { --fs-xl: 28px; --fs-l: 18px; --fs-hero: 30px; --gap: 16px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-width: 0;
  background: var(--page); color: var(--text);
  font: 400 var(--fs)/1.5 var(--font);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.8px; }
h2 { font-size: var(--fs-l); font-weight: 700; }
[hidden] { display: none !important; }

/* ── иконки ── */
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.s { width: 16px; height: 16px; stroke-width: 2.6; }

/* ── кнопки: одна высота на всю группу (--btn-h) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--btn-h); min-width: 44px; padding: 0 22px;
  border-radius: var(--r-btn); border: 2px solid var(--blue); background: #fff; color: var(--blue);
  font: 700 var(--fs)/1 var(--font); white-space: nowrap;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--blue-soft); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-h); border-color: var(--blue-h); }
.btn.ghost { border-color: var(--line); color: var(--text2); background: #fff; }
.btn.ghost:hover { border-color: var(--blue-line); color: var(--blue); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn:focus-visible, .nav:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.searchbox:focus-within, .pg-tabs a:focus-visible {
  outline: 3px solid var(--blue-line); outline-offset: 1px;
}

/* ── плашки статуса ── */
.badge {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 12px; border-radius: var(--r-pill);
  font-size: var(--fs); font-weight: 600; line-height: 1.3; white-space: nowrap;
  background: #F1F2F4; color: var(--text2);
}
.badge.on, .badge.pub { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-line); }
.badge.draft { background: #F1F2F4; color: var(--text2); }
.badge.warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #8A9099; }
.meta { color: var(--muted); font-size: var(--fs); }

/* ── поля: подпись сверху, поле под ней ── */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span:not(.hint) { font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; min-height: var(--btn-h); padding: 10px 16px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: #fff; color: var(--text); font-size: var(--fs);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.hint { color: var(--muted); font-size: var(--fs-s); font-weight: 400; }
.error { color: var(--warn); font-weight: 600; min-height: 1.5em; }

/* поиск с иконкой (a5 .field) */
.searchbox {
  display: flex; align-items: center; gap: 10px; height: var(--btn-h); padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: #fff; color: var(--muted); min-width: 0;
}
.searchbox input { border: 0; outline: 0; font: inherit; color: var(--text); background: transparent; width: 100%; min-width: 0; height: 100%; }
.searchbox input::placeholder { color: var(--muted); }
.searchbox input::-webkit-search-cancel-button { cursor: pointer; }

/* ── вход: фирменная панель слева, форма справа ── */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); background: #fff; }
.login-brand {
  display: flex; flex-direction: column; gap: 32px; padding: 56px 64px; background: var(--blue); color: #fff;
}
.login-logo { display: flex; align-items: center; justify-content: center; width: 88px; height: 88px; border-radius: 20px; background: #fff; }
.login-logo img { height: 60px; width: auto; }
.login-title { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.login-title b { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.login-title span { font-size: var(--fs-lead); opacity: .9; }
.login-sites { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: auto; }
.login-sites .sl { box-shadow: none; }
.login-sites-names { flex: 1 1 100%; font-size: var(--fs); opacity: .9; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 48px 32px; background: var(--surface); }
.login-card {
  width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 40px 32px; display: flex; flex-direction: column; gap: 20px;
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { gap: 20px; padding: 28px 20px; min-height: 42vh; }
  .login-logo { width: 64px; height: 64px; border-radius: 16px; }
  .login-logo img { height: 44px; }
  .login-title span { font-size: var(--fs); }
  .login-sites { margin-top: 0; }
  .login-form { align-items: flex-start; padding: 24px 16px; }
}

/* ── оболочка: рельса меню слева (a5) ── */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; align-self: start;
  border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 28px;
  padding: 24px 8px; background: var(--tint);
}
.rail-logo { display: block; height: 60px; width: auto; }
.rail nav { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 0 6px; flex: 1; }
.rail .rail-end { margin-top: auto; }
.nav {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px;
  color: var(--text2); font-weight: 600; text-align: center; text-decoration: none; line-height: 1.5;
  border: 0; background: none; cursor: pointer; width: 100%; font-size: var(--fs);
}
.nav .ico { width: 24px; height: 24px; }
/* на телефоне наведение «залипает» после касания: подсветка только там, где есть мышь (критик 29.10: два пункта выделены) */
@media (hover: hover) { .nav:hover { background: var(--surface); } }
.nav.on { background: var(--blue); color: #fff; }

main { padding: 40px 48px 64px; min-width: 0; }
.mlogo, .m-logout { display: none; }

/* заголовок экрана (a5 .head) */
.screen-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.screen-head h1 { margin-right: auto; min-width: 0; overflow-wrap: anywhere; }
.screen-head .searchbox { width: 340px; }

/* ── карточки и пустые состояния ── */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); padding: 24px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.empty {
  background: var(--tint); border: 2px dashed var(--blue-line); border-radius: var(--r-card);
  padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty h2 { max-width: 560px; }
.empty p { margin: 0 0 8px; color: var(--muted); max-width: 560px; }

/* ── сайты: только логотипы на белом, без цветных плашек и боковых полос ── */
.sl {
  display: flex; align-items: center; justify-content: center; flex: none; width: 56px; height: 56px;
  border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); text-decoration: none;
}
.sl img { display: block; width: auto; height: auto; max-width: 40px; max-height: 40px; }
.sl .sl-letter { font-size: var(--fs-l); color: var(--text2); }
a.sl:hover { box-shadow: inset 0 0 0 2px var(--blue-line); }
.sitelist { display: flex; flex-direction: column; gap: 12px; }
.sitelist .sc { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); min-width: 0; }
.sitelist .nm { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 200px; }
.sitelist .nm b { font-size: var(--fs-lead); line-height: 1.3; }
.sitelist .dom { font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.sitelist .sx { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; }
.sitelist .proj { color: var(--muted); line-height: 1.4; }
.stitle { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stitle h2 { font-size: var(--fs-h2); font-weight: 700; }
.site-form { display: flex; flex-direction: column; gap: 20px; margin-bottom: 16px; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px var(--gap); }
.site-grid input[type="file"] { padding: 6px 8px; cursor: pointer; }
.site-grid input[type="file"]::file-selector-button {
  height: 34px; margin-right: 12px; padding: 0 14px; border: 1px solid var(--blue-line); border-radius: 6px;
  background: var(--blue-soft); color: var(--blue); font: 600 var(--fs)/1 var(--font); cursor: pointer;
}
.site-form .error:empty { display: none; }
.site-note { padding: 12px 16px; border-radius: 10px; background: var(--surface); color: var(--text2); max-width: 920px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ── настройки ── */
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr)); gap: 28px var(--gap); }
.key-row { display: flex; gap: 12px; align-items: stretch; }
.key-row input { flex: 1; }
.field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.check-msg:empty { display: none; }
.check-msg { font-size: var(--fs-s); color: var(--muted); }
.check-msg.ok { color: var(--ok); }
.check-msg.bad { color: var(--warn); font-weight: 600; }
/* «Дополнительно» в настройках: редкие поля свёрнуты */
.keys-more { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 8px; }
.keys-more > summary { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; font-weight: 600; color: var(--text2); }
.keys-more > summary::-webkit-details-marker { display: none; }
.keys-more > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-3px) rotate(45deg); transition: transform .15s; }
.keys-more[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.keys-more > .keys { margin-top: 16px; }
.save-status { color: var(--muted); font-size: var(--fs-s); min-height: 1.5em; }
.save-status.ok { color: var(--ok); }
.save-status.bad { color: var(--warn); font-weight: 600; }

/* ── окна (photo-editor.js openModal): общий вид для редактора фото, выбора фото, публикации ── */
.pm-overlay .pm-box { border-radius: var(--r-card); box-shadow: 0 24px 64px rgba(18, 22, 25, .22); }
.pm-overlay .pm-head { padding: 16px 24px; }
.pm-overlay .pm-head h2 { font-size: var(--fs-h2); font-weight: 700; }
.pm-overlay .pm-body { padding: 24px; }
.pm-overlay .pm-foot { padding: 16px 24px; background: var(--tint); }
.pm-overlay .pe-stage { border-radius: 12px; }
.pm-overlay .btn[aria-pressed="true"] { background: var(--sel-bg); border-color: var(--blue); color: var(--blue); }

/* ── всплывающее сообщение (с одной кнопкой, например «Вернуть») ── */
.toast {
  position: fixed; left: calc(50% + var(--rail-w) / 2); bottom: 24px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 16px; max-width: calc(100% - 32px); width: max-content;
  background: var(--text); color: #fff; padding: 10px 12px 10px 20px; min-height: 52px; border-radius: var(--r-btn);
  font-weight: 600; box-shadow: 0 12px 32px rgba(18, 22, 25, .2);
}
.toast-btn {
  flex: none; height: 40px; padding: 0 16px; border: 0; border-radius: 6px; background: #fff; color: var(--text);
  font: 700 var(--fs)/1 var(--font); cursor: pointer;
}
.toast-btn:hover { background: var(--blue-soft); }
/* плашка «вышла новая версия админки»: над экраном, в общем потоке */
.app-col { min-width: 0; }
.note-slot:empty { display: none; }
.note-slot { padding: 16px 48px 0; }
.version-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 16px 12px 20px;
  border-radius: var(--r-btn); background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line), 0 8px 24px rgba(18, 22, 25, .12);
  font-weight: 600;
}
.version-note > span { flex: 1 1 280px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── телефон: меню внизу (a5) ── */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding-bottom: 84px; }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 20;
    flex-direction: row; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line); background: #fff;
  }
  .rail-logo, .rail .rail-end { display: none; }
  .screen-head .btn.m-logout { display: inline-flex; width: auto; }
  .rail nav { flex-direction: row; gap: 6px; padding: 0; flex: 1; }
  .nav { flex: 1; padding: 8px 4px; gap: 4px; min-width: 0; }
  .nav span { white-space: nowrap; }
  main { padding: 20px 16px 32px; }
  .mlogo { display: block; height: 44px; width: auto; }
  .screen-head { gap: 12px; margin-bottom: 20px; }
  .screen-head h1 { flex: 1; margin-right: 0; }
  .screen-head .searchbox, .screen-head .btn { width: 100%; }
  .card { padding: 20px 16px; }
  .toast { left: 50%; bottom: 100px; width: auto; }
  .note-slot { padding: 12px 16px 0; }
  .pm-overlay .pm-head { padding: 12px 16px; }
  .pm-overlay .pm-body { padding: 16px; }
  .pm-overlay .pm-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  /* ключ в настройках: кнопка «Проверить» под полем во всю ширину */
  .key-row { flex-direction: column; gap: 8px; }
  .key-row .btn { width: 100%; }
  .sitelist .sc { flex-wrap: wrap; padding: 16px; }
  .sitelist .sx { justify-content: flex-start; width: 100%; }
  .sitelist .sx .btn { flex: 1 1 auto; }
  .sitelist .sx .badge { flex: 1 1 100%; justify-content: flex-start; width: max-content; max-width: 100%; }
  .stitle .btn, .btn-row .btn { width: 100%; }
}

/* ── корзина вместо текста «Удалить»: нейтральный серый значок, при наведении темнее (не красный) ── */
.btn.btn-trash { width: var(--btn-h); min-width: var(--btn-h); padding: 0; border-color: var(--line); background: #fff; color: var(--muted); }
.btn.btn-trash.with-text { width: auto; padding: 0 18px; color: var(--text2); font-weight: 600; }
.btn.btn-trash:hover, .btn.btn-trash:focus-visible { border-color: #b9c1cf; background: var(--surface); color: var(--text); }
.btn.btn-trash.armed { width: auto; padding: 0 16px; border-color: #b9c1cf; background: var(--surface); color: var(--text); }
.btn.btn-trash .trash-confirm { font-weight: 600; }

/* узкий телефон: пять пунктов меню внизу (с «Расписанием» и «Помощником») по 16px не влезают — подпись видна
   у открытого раздела, у остальных значок (подпись остаётся для чтения с экрана и в подсказке) */
@media (max-width: 480px) {
  .rail nav { gap: 4px; }
  .nav { flex: 1 1 0; width: auto; }
  .nav.on { flex: 0 0 auto; padding: 8px 12px; }
  .nav:not(.on) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav:not(.on) { justify-content: center; }
}
