/* ============================================================
   «Настройки» (SPEC-redesign §7, бриф §7): оглавление разделов слева,
   карточки в колонке справа. Шапка карточки — общая для своих блоков и
   для готовых «Действующие «Не проблема»» (mutes-settings.js, вид —
   css/cabinet.css) и «Пороги «Что работает»» (wins-settings.js, вид —
   css/wins.css): .card-head > div > h2.card-title + p.settings-desc.
   Чаты Telegram — css/telegram.css. Общий набор — css/pages.css.
   ============================================================ */

/* ---------- Каркас: оглавление | колонка карточек ---------- */

.st-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.st-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.st-skel { padding: 18px 16px; }

.st-nav {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto;
}
.st-nav-group { display: flex; flex-direction: column; gap: 3px; }
.st-nav-caption { padding: 0 10px 2px; font-size: 12px; font-weight: 600; color: var(--ink3); }
.st-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.st-nav-item[hidden] { display: none; }
.st-nav-link {
  display: block; padding: 6px 10px; border-radius: 6px;
  color: var(--ink2); font-size: 13px; line-height: 1.35;
  transition: background 0.14s ease-out, color 0.14s ease-out;
}
.st-nav-link:hover { background: var(--surface2); color: var(--ink); text-decoration: none; }
.st-nav-link[aria-current="true"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

/* ---------- Карточка: шапка, тело ---------- */

.st-page .card { min-width: 0; }
.st-page .card-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.st-page .card-head > div:first-child { min-width: 0; flex: 1 1 360px; }
/* Ширина — по тексту: заголовок получает фокус после перехода из оглавления
   или по ?block=, и обвод фокуса обнимает его, а не всю шапку карточки. */
.st-page .card-title { font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -0.005em; margin: 0; width: fit-content; max-width: 100%; }
.st-page .card-title:focus { outline: none; }
.st-page .card-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-page .settings-desc { margin: 4px 0 0; font-size: 13px; color: var(--ink3); line-height: 1.45; max-width: 900px; }
.st-count { font-weight: 400; color: var(--ink3); }
.st-body { padding: 14px 16px 16px; }

/* ---------- Таблицы блоков (кабинеты, архив, пользователи, «Не проблема») ---------- */

/* Та же плотная таблица, что .pg-table (css/pages.css), — и для таблицы
   «Не проблема» (mutes-settings.js), у которой класса .pg-table нет. */
.st-page .settings-table-wrap { position: relative; overflow-x: auto; }
.st-page table.settings-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
.st-page .settings-table :is(th, td) { text-align: left; vertical-align: middle; }
.st-page .settings-table thead th {
  padding: 8px 12px; font-size: 12px; font-weight: 500; color: var(--ink3);
  background: var(--surface2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.st-page .settings-table tbody :is(th, td) { padding: 8px 12px; border-bottom: 1px solid var(--line2); font-weight: 400; }
.st-page .settings-table tbody tr:last-child > * { border-bottom: 0; }
.st-page .settings-table :is(th, td):first-child { padding-left: 16px; }
.st-page .settings-table :is(th, td):last-child { padding-right: 16px; }
.st-page .settings-table thead th.num { text-align: right; }
/* «Не проблема»: таблица — во всю ширину карточки, как остальные блоки */
.st-page .mutes-body { padding: 0; }
.st-page .mutes-body > .mutes-empty { padding: 24px 16px; }
.st-page .mutes-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--line2); }
.st-page .mutes-table td { vertical-align: top; }
.settings-table .input { width: 100%; min-width: 90px; min-height: 32px; padding: 5px 9px; font-size: 13px; }
.settings-table .input-num { max-width: 120px; margin-left: auto; display: block; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.settings-table .input:disabled { background: none; border-color: transparent; color: var(--ink); opacity: 1; padding-left: 0; padding-right: 0; }
.settings-table .input-num:disabled { padding-right: 0; }
.st-act { text-align: right; white-space: nowrap; }
.st-act .btn + .btn { margin-left: 6px; }
.settings-table tbody th { font-weight: 400; }

.st-cabs { min-width: 980px; }
.st-cab { min-width: 220px; }
.st-cab-line { display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }
.st-cab-name { color: var(--ink); font-weight: 500; }
.st-cab-name:hover { color: var(--accent); }
.st-access { font-size: 11px; }
.st-search { width: 240px; max-width: 100%; min-height: 34px; }
.st-save:disabled { opacity: 0.55; }
.st-cabs tr[hidden] { display: none; }

.st-archived-table { min-width: 600px; }
.st-users-table { min-width: 760px; }
.st-user-cabs { max-width: 360px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Правила алертов ---------- */

.st-rule-list { display: flex; flex-direction: column; }
.rule-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--line2); align-items: start;
}
.rule-row:last-child { border-bottom: none; }
.rule-row .switch { margin-top: 1px; }
.rule-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rule-side { display: none; }
.rule-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.rule-desc { font-size: 13px; color: var(--ink2); max-width: 820px; line-height: 1.45; }
.rule-params { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.rule-param { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink2); }
.rule-param .input {
  width: 92px; min-height: 30px; padding: 4px 8px; font-size: 13px; text-align: right;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.rule-param .input:disabled { background: var(--surface2); border-color: transparent; color: var(--ink); opacity: 1; }
.rule-fixed { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-top: 6px; }
.rule-param-fixed { font-size: 12px; color: var(--ink3); }
.rule-param-value { color: var(--ink2); }
/* Выключенное правило — приглушённым цветом, а не прозрачностью: opacity .55
   давала 3,7:1 (находка 15 этапа A). Выключено — видно и по переключателю. */
.rule-row.disabled { background: var(--surface2); }
.rule-row.disabled .rule-title { color: var(--ink2); font-weight: 500; }
.rule-row.disabled .rule-desc { color: var(--ink2); }
.rule-row.disabled .rule-params, .rule-row.disabled .rule-fixed { display: none; }
/* Что значит «выключено»: выключатель действует сразу (SPEC-alerts-noise §4). */
.rule-off-note {
  margin-top: 4px; font-size: 12.5px; color: var(--ink2);
  border-left: 2px solid var(--line-strong); padding-left: 9px; max-width: 820px;
}
.rule-off-note[hidden] { display: none; }

/* ---------- Мой пароль ---------- */

.pass-form { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)) auto; gap: 10px; align-items: center; max-width: 900px; }
.pass-form .input { min-height: 36px; }
.pass-form .btn-primary { min-height: 36px; }
.st-pass-note { margin-top: 10px; font-size: 13px; color: var(--ink3); }
.st-pass-note:empty { display: none; }
.st-pass-note.is-err { color: var(--crit); }
.st-pass-note.is-ok { color: var(--ok); }

/* ---------- Личный Telegram ---------- */

.st-tg { display: flex; flex-direction: column; gap: 10px; }
.tg-block { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.tg-block:empty { display: none; }
.tg-block .settings-desc { margin: 0; }
.tg-code {
  font-family: var(--font-num); font-size: 18px; font-weight: 600; letter-spacing: 2px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; color: var(--ink);
}
.st-tg-state { align-self: center; }

/* ---------- Переключатель (правила, утренняя сводка) ---------- */

.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch input:disabled { cursor: default; }
.switch .track {
  position: absolute; inset: 0; border-radius: 12px; background: var(--line);
  border: 1px solid var(--line-strong); transition: background 0.16s ease-out, border-color 0.16s ease-out;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.16s ease-out;
}
.switch input:checked + .track { background: var(--ok); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: 0.6; }

/* ---------- Окно пользователя ---------- */

.st-dlg-label { display: block; font-size: 13px; font-weight: 500; color: var(--ink2); margin-bottom: 5px; }
.st-dlg-all { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 7px; cursor: pointer; }
.st-dlg-clients {
  display: grid; gap: 4px; max-height: 180px; overflow-y: auto; padding: 8px 10px;
  border: 1px solid var(--line2); border-radius: 6px; background: var(--surface2);
}
.st-dlg-clients.is-off { color: var(--ink3); }
.st-dlg-client { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.st-dlg-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--ink3); }
.st-dlg-all input, .st-dlg-client input { accent-color: var(--accent); }

/* ---------- Узкие окна ---------- */

@media (max-width: 1100px) {
  .st-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  /* Оглавление — строкой чипов над блоками, прокрутка внутри строки */
  .st-nav { position: static; max-height: none; flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .st-nav-group { flex-direction: row; gap: 6px; flex: none; }
  .st-nav-caption { display: none; }
  .st-nav-list { flex-direction: row; gap: 6px; }
  .st-nav-link { border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
}
@media (max-width: 720px) {
  .pass-form { grid-template-columns: 1fr; }
  .st-page .card-head { padding: 12px; }
  .rule-row { padding: 12px; gap: 4px 10px; }
}
