/* Адміністрування. */

/* ---------------------------------------------------------------- адмінка */
/* Дії панелі тримаються правого краю її заголовка */
.head-actions { margin-left: auto; display: flex; gap: 8px; }

/* Підказка стоїть там, де приймають рішення */
.field-help {
  margin: 7px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--muted);
}
.field-help b { color: var(--text); font-weight: 600; }

.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
/* На всю ширину розтягуються текстові поля, але не прапорці */
.form-row input:not([type="checkbox"]):not([type="radio"]),
.form-row select { width: 100%; }

/* ------------------------------------------------------------ користувачі */
.user-list { list-style: none; margin: 0; padding: 0; }
.user + .user { border-top: 1px solid var(--line); }
.user.blocked .user-main { opacity: .55; }

.user summary {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; cursor: pointer; list-style: none;
}
.user summary::-webkit-details-marker { display: none; }
.user summary:hover { background: var(--raised); }
.user[open] summary { background: var(--raised); border-bottom: 1px solid var(--line); }

.user-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.user-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-line b { font-size: 14px; font-weight: 650; }
.user-meta {
  font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.user-meta .mono { font-size: 11.5px; }
.dot-sep { color: var(--line); }
/* Керівник без жодної команди не бачить у дашборді нічого — це має впадати в око */
.needs-teams { color: var(--warn); font-weight: 550; }

.user-toggle {
  flex: none; font-size: 12.5px; font-weight: 550; color: var(--accent);
}
.user[open] .user-toggle { color: var(--muted); }
.user[open] .user-toggle::after { content: " ▾"; }
.user:not([open]) .user-toggle::after { content: " ▸"; }

/* Ролі відрізняються кольором, а не лише текстом */
.role-chip {
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted);
}
.role-chip.role-admin { color: var(--t2); border-color: color-mix(in srgb, var(--t2) 40%, transparent); }
.role-chip.role-commercial { color: var(--out); border-color: color-mix(in srgb, var(--out) 40%, transparent); }
.role-chip.role-manager { color: var(--t1); border-color: color-mix(in srgb, var(--t1) 40%, transparent); }
.role-chip.role-team_lead { color: var(--in); border-color: color-mix(in srgb, var(--in) 40%, transparent); }
.role-chip.blocked-chip { color: var(--dead); border-color: color-mix(in srgb, var(--dead) 40%, transparent); }
.role-chip.locked-chip {
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  text-transform: none; letter-spacing: 0; font-size: 11px;
}

/* Скидання лічильника — окрема дія, тож і окремий рядок під формою профілю */
.unlock-row, .unknown-locked {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 11px 16px; font-size: 12.5px; color: var(--warn);
  background: var(--warn-soft);
  border-top: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.unknown-locked { border-bottom: 1px solid var(--line); border-top: 0; }
.unknown-locked b { font-weight: 600; }

/* П'ять рядків на сторінку — тож рядок може дозволити собі два поверхи:
   зверху головне, знизу уточнення. Раніше час і країна займали власні
   колонки й тиснули решту. */
.logins td { padding: 10px 14px; vertical-align: top; }
.logins .when-cell b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.logins .when-cell .sub,
.logins .from-cell .sub { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }
.logins .from-cell .mono { font-size: 12px; }
.logins .device-cell { color: var(--muted); white-space: normal; min-width: 150px; }

/* Перехід за якорем не має ховатися під липкою шапкою */
#logins, #actions { scroll-margin-top: 70px; }

/* Найцінніша колонка журналу дій — саме та, де написано, що змінилося:
   їй і місце, тоді як решта колонок тримають рядок вузьким */
.actions td { padding: 10px 14px; vertical-align: top; }
.actions .when-cell b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.actions .when-cell .sub { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }
.actions .details-cell { white-space: normal; color: var(--muted); min-width: 240px; }

/* Гортання журналу живе всередині панелі, а не окремою карткою */
.log-pager { border-top: 1px solid var(--line); }
.log-pager .page-of {
  align-self: center; font-variant-numeric: tabular-nums;
  padding: 0 2px; color: var(--faint);
}
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.dead { background: color-mix(in srgb, var(--dead) 16%, transparent); color: var(--dead); }

/* Форма займає всю ширину картки, але сама не розтягується: чотири коротких
   поля на 1200 px змушували б возити очима через пів екрана. */
.user-form { padding: 14px 16px 18px; background: var(--raised); }
.user-form > * { max-width: 680px; }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 20px; align-items: start;
}
.user-form button { margin-top: 4px; }

/* Пульс збору — та сама мова смуг, застосована до здоров'я системи */
.pulse-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.pulse-head .eyebrow {
  font-size: var(--micro-size); letter-spacing: var(--micro-track); text-transform: uppercase;
  font-weight: 600; color: var(--micro-color);
}
.pulse-head .sub { font-size: 11.5px; color: var(--muted); }
.pulse-head .bad { color: var(--dead); font-weight: 600; }
.pulse {
  display: flex; align-items: flex-end; gap: 2px;
  height: 56px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
/* Синій — запуск відпрацював; янтарний — приніс нові дзвінки; червоний — помилка */
.pulse i { flex: 1; min-height: 2px; border-radius: 1px 1px 0 0; background: var(--t0); opacity: .55; }
.pulse i.fresh { background: var(--t2); opacity: 1; }
.pulse i.failed { background: var(--dead); height: 100% !important; opacity: .85; }
/* Перерваний запуск: смуга на всю висоту, але приглушена — це слід зупину, а
   не відмова збору */
.pulse i.cut { background: var(--muted); height: 100% !important; opacity: .35; }

.sync-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 28px; max-width: none; }
.sync-facts dd { font-size: 12.5px; font-weight: 500; }

.runs { font-size: 12.5px; }
.runs td { padding: 6px 12px; }
.status-ok { color: var(--in); font-weight: 600; }
.status-error { color: var(--dead); font-weight: 600; }
.status-running { color: var(--muted); }
.status-interrupted { color: var(--muted); font-weight: 500; }
.run-error { font-weight: 400; }

/* ============================================================ розділи */
/* Бокове меню розділів зліва, вміст справа. Меню липке: розділ довгий
   (журнал входів), а перейти в інший має бути можна з будь-якого місця. */
.admin {
  display: grid; grid-template-columns: 228px minmax(0, 1fr);
  gap: 14px; align-items: start;
}
.admin-main { min-width: 0; }
.admin-nav {
  position: sticky; top: 78px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px; background: var(--panel);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.admin-nav-title {
  padding: 8px 12px 10px; font-family: var(--display);
  font-size: 15px; font-weight: 700; letter-spacing: -.02em;
}
.admin-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: var(--pill);
  color: var(--muted); font-size: 13.5px; font-weight: 550;
}
.admin-nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
/* Лайм — заливка активного пункту, як у сегменті вигляду в шапці */
.admin-nav a.active { background: var(--brand); color: var(--brand-ink); }
.nav-count {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--faint); font-variant-numeric: tabular-nums;
}
.admin-nav a.active .nav-count { color: var(--brand-ink); opacity: .7; }
.nav-count.bad, .nav-count.warn {
  min-width: 20px; padding: 1px 7px; border-radius: var(--pill);
  text-align: center; font-weight: 700; opacity: 1 !important;
}
.nav-count.bad { background: var(--dead); color: #fff !important; }
.nav-count.warn { background: var(--warn-soft); color: var(--warn) !important; }

/* Нагадування про блок у будь-якому розділі — клікабельне цілком */
.admin-alert { display: block; text-decoration: none; }
.admin-alert:hover { text-decoration: none; filter: brightness(1.03); }

/* Рядок інструментів під заголовком панелі: пошук, фільтри */
.admin-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.admin-toolbar .search { width: 260px; max-width: 100%; }
.admin-toolbar select { max-width: 260px; }
.seg-sm button, .seg-sm a {
  height: auto; padding: 6px 13px; border: 0; background: transparent;
  color: var(--muted); font-weight: 550; font-size: 12.5px;
  border-radius: var(--pill); white-space: nowrap;
}
.seg-sm button:hover { background: var(--panel); color: var(--text); filter: none; }
.seg-sm button.active { background: var(--brand); color: var(--brand-ink); }

/* ------------------------------------------------------- картка користувача */
.user-avatar { width: 34px; height: 34px; flex: none; font-size: 12px; }
.user.blocked .user-avatar { background: var(--raised); color: var(--faint); }
.you-chip { font-size: 11px; color: var(--faint); }

/* Редагування — дві колонки: профіль ліворуч, пароль і блок праворуч */
.user-edit {
  display: grid; grid-template-columns: minmax(0, 1fr) 387px;
  gap: 0; background: var(--raised);
}
.user-edit .user-form { background: transparent; }
.edit-title {
  margin: 0 0 12px; font-family: var(--display);
  font-size: 13.5px; font-weight: 700; letter-spacing: -.01em;
}
.user-side {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 16px 18px; border-left: 1px solid var(--line);
}
.side-card {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  padding: 14px; border-radius: var(--radius-sm); background: var(--panel);
}
.side-card .field-help { margin: 0; }
.side-warn { background: var(--warn-soft); }
.side-warn .edit-title { color: var(--warn); }

/* --------------------------------------------------------------- безпека */
.all-clear {
  margin: 0; padding: 18px 22px; font-size: 13.5px; color: var(--in); font-weight: 550;
}
.block-list { list-style: none; margin: 0; padding: 0; }
.block-list li {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--warn-soft);
}
.block-list li + li { border-top: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); }
.block-list li:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.block-kind {
  flex: none; width: 64px;
  font-size: var(--micro-size); letter-spacing: var(--micro-track); text-transform: uppercase;
  font-weight: 700; color: var(--warn);
}
.block-what { flex: 1; min-width: 200px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.block-what b { font-weight: 650; font-size: 13.5px; }
.block-what .sub { flex-basis: 100%; font-size: 12px; color: var(--muted); }

/* Інструкція відновлення — згорнута: потрібна рідко, але має бути під рукою */
.recovery > summary { list-style: none; cursor: pointer; border-bottom: 0; }
.recovery > summary::-webkit-details-marker { display: none; }
.recovery[open] > summary { border-bottom: 1px solid var(--line-soft); }
.recovery .caret { display: inline-flex; color: var(--muted); transition: transform .18s ease; }
.recovery:not([open]) .caret { transform: rotate(-90deg); }
.recovery h2 { font-size: 14px; }
.cmd {
  margin: 8px 0 14px; padding: 11px 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bar); color: var(--brand); border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------- довідник */
.help-list {
  margin: 16px 0 0; padding-left: 18px;
  font-size: 12.5px; line-height: 1.7; color: var(--muted);
}
.help-list b { color: var(--text); font-weight: 600; }

@media (max-width: 980px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  /* Меню стає горизонтальною стрічкою над вмістом */
  .admin-nav {
    position: static; flex-direction: row; overflow-x: auto;
    padding: 6px;
  }
  .admin-nav-title { display: none; }
  .admin-nav a { flex: none; white-space: nowrap; }
  .user-edit { grid-template-columns: minmax(0, 1fr); }
  .user-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .admin-toolbar .search { width: 100%; }
  .admin-toolbar .seg { width: 100%; overflow-x: auto; }
  .user-avatar { display: none; }
}

/* Поля форм у картках мали той самий фон, що й сама форма (--raised), і в
   темній темі зливалися з нею: видно було лише підписи. Тепер у поля
   контрастний фон і рамка. */
.user-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.user-form select {
  background: var(--panel); border: 1px solid var(--line);
}
.side-card input:not([type="checkbox"]) {
  background: var(--raised); border: 1px solid var(--line);
}
.user-form input:hover, .user-form select:hover, .side-card input:hover {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}
.user-form input:focus, .user-form select:focus, .side-card input:focus { border-color: var(--text); }

/* ==================================================== форма користувача */
/* Поле: підпис над полем звичайним регістром — це не службова мітка, а
   питання, на яке людина відповідає. */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .role-cards legend, .teams-picker-head legend {
  font-size: 13px; font-weight: 600; color: var(--text);
  letter-spacing: 0; text-transform: none; padding: 0;
}
.field .opt { font-weight: 400; color: var(--faint); margin-left: 4px; }
.field input, .field select { width: 100%; }
.access-select { position: relative; display: block; }
.access-select select { appearance: none; padding-right: max(30px, 12%); }
.access-select::after {
  content: ""; position: absolute; right: 5%; top: 50%;
  width: 7px; height: 7px; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* Поле та дії з паролем залишаються доступними на вузьких екранах. */
.input-action { display: flex; gap: 6px; width: 100%; }
.input-action input { flex: 1 1 0; min-width: 0; font-family: var(--mono); }
.in-field-btn {
  flex: none; align-self: center; height: 34px; padding: 0 9px; font-size: 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
}
.in-field-btn:hover { background: var(--raised); filter: none; }

/* Ролі — три картки-перемикачі з поясненням на самій картці */
.role-cards { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.role-cards legend { margin-bottom: 6px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.role-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--line);
  transition: border-color .12s ease, background .12s ease;
}
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card b { font-size: 13.5px; font-weight: 650; }
.role-card span { font-size: 12px; line-height: 1.4; color: var(--muted); }
.role-card:hover { border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.role-card:has(input:checked) { border-color: var(--text); background: var(--accent-soft); }
.role-card:has(input:checked) b { color: var(--accent); }
.role-card:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.role-cards:disabled .role-card { cursor: default; opacity: .6; }
.role-cards:disabled .role-card:has(input:checked) { opacity: 1; }

/* Команди — чипи, а не скрол-список прапорців */
.teams-wrap { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.teams-picker-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.teams-picker-head .count { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.teams-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.teams-search { flex: 1 1 200px; height: 34px; }
.link-btn {
  background: none; border: 0; padding: 0; height: auto;
  color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; filter: none; }
.team-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.team-column { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--pill); cursor: pointer;
  font-size: 12.5px; background: var(--panel); border: 1px solid var(--line);
  user-select: none; min-width: 0;
}
.team-chip span { min-width: 0; overflow-wrap: anywhere; }
.team-chip input { position: absolute; opacity: 0; pointer-events: none; }
.team-chip::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--faint);
}
.team-chip:hover { border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.team-chip:has(input:checked) { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.team-chip:has(input:checked)::before {
  border-color: var(--brand-ink); background: var(--brand-ink);
  box-shadow: inset 0 0 0 3px var(--brand);
}
.team-chip:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 1px; }
.team-chip[hidden] { display: none; }
.teams-empty { margin: 0; color: var(--muted); font-size: 12.5px; }
.teams-all {
  margin: 0 0 16px; padding: 10px 12px; font-size: 12.5px; color: var(--muted);
  background: var(--raised); border-radius: var(--radius-sm);
}
.user-edit .teams-all { background: var(--panel); }
.user-edit .user-form { padding: 18px 20px 20px; }
.user-edit .user-form > * { max-width: 720px; }

/* ------------------------------------------------------------- модальне вікно */
.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.modal::backdrop { background: rgba(9, 7, 7, .55); backdrop-filter: blur(2px); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.modal-close {
  width: 34px; height: 34px; padding: 0; justify-content: center;
  background: var(--raised); color: var(--text); font-size: 20px; font-weight: 400;
}
.modal-close:hover { filter: none; background: var(--line); }
.modal-body { padding: 20px 22px 6px; overflow-y: auto; }
.modal .field input, .modal .field select { border: 1px solid var(--line); }
.modal .role-card, .modal .team-chip { background: var(--raised); }
.modal .in-field-btn { background: var(--panel); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--line-soft);
}

@media (max-width: 720px) {
  .field-pair, .role-grid { grid-template-columns: minmax(0, 1fr); }
  .modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .modal .modal-form { height: 100%; max-height: 100dvh; }
  .modal-body { flex: 1; }
  .teams-search { flex-basis: 100%; }
}
@media (max-width: 480px) { .team-chips { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- система */
.sys-kpis {
  display: grid; gap: 12px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.sys-kpis .panel { margin-bottom: 0; }
.mgr-kpi .value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.disk-bar { display: block; height: 6px; border-radius: var(--pill); background: var(--raised); overflow: hidden; margin: 4px 0 2px; }
.disk-bar i { display: block; height: 100%; background: var(--calm-bar-hover); border-radius: var(--pill); }
.sys-warn .disk-bar i { background: var(--dead); }
.sys-warn .value { color: var(--dead); }
.sys-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sys-tables { display: flex; flex-direction: column; gap: 10px; }
.sys-tables .mgr-bucket { grid-template-columns: 170px minmax(0, 1fr) 76px 70px; }
.sys-tables .rows { text-align: right; color: var(--faint); font-size: 11.5px; }
.sys-growth { height: 140px; }
.sys-none { color: var(--muted); }
@media (max-width: 980px) {
  .sys-grid { grid-template-columns: minmax(0, 1fr); }
  .sys-tables .mgr-bucket { grid-template-columns: 120px minmax(0, 1fr) 64px; }
  .sys-tables .rows { display: none; }
}
/* ============================================================ налаштування
   Картки за змістом: дані (Київстар, склад команд, правила) ліворуч,
   підключення й службове (CRM, пошта, копії) праворуч. Заголовки нейтральні,
   як у решті адмінки; стан підключення — тихий чип справа в шапці.
   Пояснення сховані в «i», щоб форма читалася як перелік полів. */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.settings-column { display: grid; gap: 14px; min-width: 0; }
.settings-grid .panel { min-width: 0; margin-bottom: 0; }
.settings-card .panel-head { gap: 8px; }
.settings-card .panel-head .tip { margin-right: auto; }
.card-state {
  padding: 3px 10px; border-radius: var(--pill); font-size: 12px; font-weight: 600;
  background: var(--raised); color: var(--muted); white-space: nowrap;
}
.card-state.on { background: color-mix(in srgb, var(--in) 14%, transparent); color: var(--in); }
.card-link { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.settings-fields { display: grid; gap: 16px; }
.settings-fields .field, .settings-fields .field-pair { max-width: none; margin: 0; }
.settings-fields .field-pair { gap: 16px 14px; }
.settings-fields .field-pair .field { min-width: 0; }
.settings-fields .field-pair.pair-wide { grid-template-columns: minmax(0, 1fr) 112px; }
.settings-fields .field > label, .settings-fields .field-label {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0;
}
.settings-fields .field-help { margin: -4px 0 0; line-height: 1.5; }
.settings-fields textarea { width: 100%; min-height: 76px; resize: vertical; }
/* Стан секрету — та сама мова, що й стан картки, тільки менша */
.secret-state {
  margin-left: auto; padding: 1px 8px; border-radius: var(--pill);
  font-size: 11px; font-weight: 600; background: var(--raised); color: var(--faint);
}
.secret-state.on { background: color-mix(in srgb, var(--in) 14%, transparent); color: var(--in); }
.settings-check { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); cursor: pointer; }
.settings-fields .field > label.settings-check { margin-top: 2px; font-weight: 400; color: var(--muted); }
.settings-check input, .settings-switch input { width: auto; margin: 0; accent-color: var(--text); }
.settings-check.danger-check:has(input:checked) { color: var(--dead); }
.settings-switch { color: var(--text); display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.settings-switch > span { display: inline-flex; align-items: center; gap: 6px; }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
.field-inline input { width: 112px; flex: none; }

/* Перемикач джерела: радіокнопки в стилі .seg; непотрібні поля ховаються
   без JS, через :has() */
.seg-radio { width: fit-content; max-width: 100%; }
.seg-radio label { position: relative; cursor: pointer; font-size: 13px; letter-spacing: 0; text-transform: none; color: inherit; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span {
  display: block; padding: 6px 14px; border-radius: var(--pill);
  color: var(--muted); font-weight: 550; font-size: 13px; white-space: nowrap;
}
.seg-radio label:hover span { color: var(--text); }
.seg-radio input:checked + span { background: var(--brand); color: var(--brand-ink); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 1px; }
.settings-card:has(#src-sheet:checked) .roster-crm,
.settings-card:has(#src-crm:checked) .roster-sheet { display: none; }

/* Низ картки: перевірка ліворуч, «Зберегти» праворуч. Кожна картка
   зберігається окремо, тож помилка в одній не скидає введене в інших. */
.card-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0;
  padding: 12px 20px; border-top: 1px solid var(--line-soft);
}
.card-actions > button:last-child { margin-left: auto; }
.check-result { flex: 1 1 160px; min-width: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.check-result.ok { color: var(--in); font-weight: 600; }
.check-result.bad { color: var(--dead); font-weight: 600; }
.card-state.bad { background: color-mix(in srgb, var(--dead) 14%, transparent); color: var(--dead); }
.monitor-recipients { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.settings-card .monitor-facts, .settings-card .monitor-checks, .settings-card .banner { margin: 0; }
.sync-note { margin: 4px 4px 0; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .settings-card .panel-head { padding: 14px 16px; }
  .settings-card .panel-body { padding: 16px; }
  .settings-fields .field-pair.pair-wide { grid-template-columns: minmax(0, 1fr) 96px; }
  .card-actions { padding: 12px 16px; }
}
.backup-actions { white-space: nowrap; }
.backup-actions form { display: inline; margin: 0; }

/* Сповіщення про збої: три рядки стану сторожа */
.monitor .bad { color: var(--dead); font-weight: 600; }
.monitor-checks { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.monitor-checks td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.monitor-checks td:first-child { font-weight: 600; white-space: nowrap; width: 1%; }
.monitor-checks td:nth-child(2) { width: 1%; white-space: nowrap; }
.monitor-checks tr:last-child td { border-bottom: 0; }
.monitor-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 20px; margin: 0 0 16px; }
.monitor-facts dt { font-size: var(--micro-size, 12px); color: var(--micro-color, var(--faint)); margin-bottom: 2px; }
.monitor-facts dd { margin: 0; font-weight: 600; }
.monitor .banner { margin-bottom: 12px; }

/* Список виключених компаній: кілька рядків у стилі решти полів */
.field textarea {
  width: 100%; font: inherit; color: var(--text); resize: vertical;
  background: var(--raised); border: 1px solid transparent;
  border-radius: 14px; padding: 9px 16px;
}
.field textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--text); }

/* Менеджери: команда, яку не рахуємо, приглушена; застереження — помітним кольором */
.panel.team-off .panel-head h2 { opacity: .6; }
.help-list .warn-text { color: var(--sig-hot); }

.hidden-teams { margin: 12px 0; }
.hidden-teams > summary { cursor: pointer; padding: 10px 4px; color: var(--muted, inherit); }
.hidden-teams[open] > summary { margin-bottom: 8px; }
