:root {
  --accent: #6C58E8;
  --bg: #F5F5FC;
  --surface: #FEFEFE;
  --text: #111632;
  --muted: #5E649C;
  --border: #E4E3F2;
  --accent-bg: #ECEBFA;
  --lavender: #B9B8EF;
  --navy: #142044;
  --ok: #16A34A;
  --ok-text: #155E3B;
  --ok-bg: #DCFCE7;
  --warn: #92400E;
  --warn-bg: #FEF3C7;
  --danger-text: #B91C1C;
  --danger-bg: #FEE2E2;
  --shadow: 0 2px 8px rgba(17,22,50,.05), 0 8px 24px rgba(108,88,232,.08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Атрибут hidden важнее display у button/блоков (иначе кнопки не скрываются) */
[hidden] { display: none !important; }

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

/* Навигация кабинета УК (11 страниц /manager/*) — см. /sidebar.css (topbar
   мобильный + сайдбар планшет/десктоп), эти правила её не касаются.
   Навигация Мика-админа (4 страницы /admin/*) не переезжала на сайдбар —
   использует плоский <nav> ниже; правила были ошибочно удалены при
   редизайне Шага 19 (регрессия, лечим здесь) и восстановлены как были. */
nav {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 20px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
  flex-wrap: nowrap;
}
nav .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  margin-right: 16px;
  text-decoration: none;
  font-size: 16px;
  white-space: nowrap;
}
nav .brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
}
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 10px;
  white-space: nowrap;
}
nav a:hover, nav a.active { background: var(--accent-bg); color: var(--accent); }
nav .spacer { flex: 1; }
nav .user { color: var(--muted); font-size: 13px; margin-right: 8px; white-space: nowrap; }
#nav-logout { margin-left: auto; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px; }

/* Прокручиваемая обёртка для таблиц (мобильные экраны) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 12px; }
.table-wrap table { margin-top: 0; }

h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; }

/* Счётчики дашборда */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card .num {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
}
.card .label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Таблицы */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: var(--surface);
  border-radius: 12px;
}
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:nth-child(even) { background: #F9F9FE; }
tbody tr:hover { background: var(--accent-bg); }
tr.emergency { background: var(--danger-bg); }
tr.emergency td { color: var(--danger-text); font-weight: 600; }
tr.emergency:hover { background: #FBD5D5; }
.sla-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--danger-text); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; }
/* Отменена жителем: остаётся в списке, но не привлекает внимания (в т.ч. аварийная) */
tr.cancelled, tr.cancelled:hover { background: transparent; }
tr.cancelled td { color: var(--muted); font-weight: 400; }
/* Заявку не открывали / непрочитан ответ жителя — полоса, как у непрочитанного уведомления; просрочка SLA (ниже) главнее */
tr.unseen td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
tr.unseen td:nth-child(-n+2) { font-weight: 600; }
tr.sla-overdue td:first-child { box-shadow: inset 4px 0 0 var(--danger-text); }
/* Сортируемые заголовки (Шаг 7, заявки) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--accent); }
.sort-arrow { font-size: 10px; }

/* Обрезка длинного текста в ячейке таблицы (Шаг 23, объявления): адаптивно
   под ширину колонки, независимо от фикс. лимита символов в JS. Полный текст —
   в атрибуте title (нативный тултип браузера на hover). */
.text-cell-truncate {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Кнопки */
button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 2px 6px rgba(108, 88, 232, 0.2);
}
button:hover, .btn:hover {
  box-shadow: 0 4px 12px rgba(108, 88, 232, 0.3);
  filter: brightness(1.05);
}
button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
button.secondary { background: var(--accent-bg); color: var(--accent); box-shadow: none; }
button.danger { background: var(--danger-text); box-shadow: none; }
button.ghost { background: transparent; color: var(--accent); box-shadow: none; border: 1px solid var(--border); }
button.ghost:hover { background: var(--accent-bg); box-shadow: none; filter: none; }
button.small { padding: 4px 10px; font-size: 13px; border-radius: 10px; }

/* Формы */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 88, 232, 0.15);
}
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
form { max-width: 420px; }

/* Локальные фильтры страниц */
.filters-section {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filters-section select { margin-bottom: 0; }
.filters-section button { margin-bottom: 0; }
.filter-select { max-width: 220px; }
.filter-select-narrow { max-width: 160px; }

/* Статусы */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent);
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--danger-bg); color: var(--danger-text); }
.badge.muted { background: var(--border); color: var(--muted); }

/* Жизненный цикл объявлений (Шаг 21): удалённая строка — приглушена и зачёркнута. */
tr.row-deleted { color: var(--muted); text-decoration: line-through; }
tr.row-deleted a { color: inherit; }

/* Модалка — выше сайдбара (см. /sidebar.css, z-index до 220 в drawer-режиме) */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 22, 50, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 22px;
  width: min(560px, 92vw);
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 24px 64px rgba(17, 22, 50, 0.25);
}

/* Шапка карточки: заголовок и ✕ видны при любой прокрутке длинной карточки */
.modal-head { position: sticky; top: -22px; z-index: 1; display: flex; align-items: flex-start; gap: 12px; margin: -22px -22px 0; padding: 22px 22px 8px; background: var(--surface); border-radius: 20px 20px 0 0; }
.modal-head h2 { flex: 1; margin: 0; }
.modal-x { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--accent-bg); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; }
.modal-x:hover { background: var(--lavender); }
/* Низ карточки: «Сохранить» / «Закрыть» и текст ошибки видны при любой прокрутке */
.modal-foot { position: sticky; bottom: -22px; z-index: 1; margin: 12px -22px -22px; padding: 12px 22px 22px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 20px 20px; }
.modal-foot .error-text { margin: 0 0 8px; }
.modal-foot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 767px) {
  .modal-head { top: -16px; margin: -16px -16px 0; padding: 16px 16px 8px; }
  .modal-foot { bottom: -16px; margin: 12px -16px -16px; padding: 12px 16px 16px; }
}

/* История заявки в карточке: статусы и переписка с жителем (Шаг 83) */
.request-history { margin: 0 0 12px; }
.request-history summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.request-history ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.request-history li { font-size: 14px; color: var(--muted); }
.request-history li.message { color: var(--text); background: var(--accent-bg); border-radius: 12px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.request-history li.message.failed { background: var(--warn-bg); }
.request-history li.message.resident { background: var(--surface); border: 1px solid var(--border); }
.request-history .when { display: block; font-size: 12px; color: var(--muted); }

/* Файлы (документы) жителя в карточке заявки (Шаг 88) */
.request-files { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.request-files .file-download { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: var(--accent-bg); color: var(--text); border: 0; border-radius: 12px; padding: 8px 12px; font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.request-files .file-download:hover { box-shadow: 0 0 0 2px var(--accent); }
.request-files .file-size { flex: none; color: var(--muted); font-size: 13px; }

/* Фото жителя в карточке заявки (ссылки CDN MAX) */
.request-photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.request-photos .photo-thumb { display: block; width: 96px; height: 96px; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--accent-bg); cursor: zoom-in; }
.request-photos .photo-thumb:hover { box-shadow: 0 0 0 2px var(--accent); }
.request-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.request-photos .photo-missing { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; border-radius: 12px; background: var(--accent-bg); color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }

/* Просмотр фото (ui.js openPhotoViewer) — поверх карточки заявки; тёмный фон в обеих темах */
.photo-viewer { position: fixed; inset: 0; z-index: 450; background: rgba(10, 10, 20, 0.92); color: #fff; user-select: none; }
.photo-viewer .pv-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 56px 64px; }
.photo-viewer .pv-img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; transition: transform 0.12s ease-out; touch-action: none; }
.photo-viewer .pv-img.zoomed { cursor: grab; transition: none; }
.photo-viewer .pv-note { color: rgba(255, 255, 255, 0.75); font-size: 15px; }
.photo-viewer .pv-btn { position: absolute; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.photo-viewer .pv-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.28); }
.photo-viewer .pv-btn:disabled { opacity: 0.35; cursor: default; }
.photo-viewer .pv-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.photo-viewer .pv-close { top: 12px; right: 12px; }
.photo-viewer .pv-prev { left: 12px; top: 50%; transform: translateY(-50%); font-size: 32px; }
.photo-viewer .pv-next { right: 12px; top: 50%; transform: translateY(-50%); font-size: 32px; }
.photo-viewer .pv-counter { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); font-size: 14px; color: rgba(255, 255, 255, 0.85); }
.photo-viewer .pv-zoom { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 24px; background: rgba(255, 255, 255, 0.1); }
.photo-viewer .pv-zoom .pv-btn { position: static; width: 36px; height: 36px; font-size: 20px; }
.photo-viewer .pv-zoom-label { min-width: 48px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.photo-viewer [hidden] { display: none; }
@media (max-width: 600px) {
  .photo-viewer .pv-stage { padding: 56px 8px 64px; }
  .photo-viewer .pv-prev, .photo-viewer .pv-next { top: auto; bottom: 16px; transform: none; }
}

/* Окно подтверждения / ввода (UX-1, ui.js confirmDialog/promptDialog) — поверх любых модалок */
.dialog-backdrop { z-index: 400; }
.modal.dialog { width: min(440px, 92vw); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog-text { margin: 0 0 4px; color: var(--muted); line-height: 1.45; white-space: pre-line; }
.dialog input { width: 100%; margin-top: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--danger-text); font-size: 13px; margin-top: 8px; }

/* Ссылки вне навигации */
a { color: var(--accent); }

/* Логин */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(185, 184, 239, 0.35), transparent 55%),
    var(--bg);
}
.login-wrap { padding: 16px; }
.login-card {
  background: var(--surface);
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 360px;
  max-width: 100%;
}
.login-card h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  margin-bottom: 20px;
}
.login-card h1 img {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: block;
}

/* Адаптивность (мобильные и планшетные экраны) */
@media (max-width: 700px) {
  main { padding: 16px 12px; }
  h1 { font-size: 19px; }
  nav { padding: 8px 12px; }
  nav .brand { margin-right: 10px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card .num { font-size: 24px; }
  /* Таблицы не сжимаются в нечитаемую кашу — обёртка .table-wrap скроллится */
  .table-wrap table { min-width: 640px; }
  .filters-section { gap: 8px; }
  .filter-select, .filter-select-narrow { max-width: none; flex: 1 1 140px; }
  .modal { padding: 16px; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

/* Уведомления персоналу (колокольчик, бейдж, панель) — js/notifications.js */
.notif-bell { position: relative; margin-left: auto; border: none; background: none; font-size: 20px; line-height: 1; padding: 6px 8px; cursor: pointer; }
.notif-menu-item .notif-badge { margin-left: auto; position: static; }
.notif-badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notif-bell.urgent .notif-badge, .notif-menu-item.urgent .notif-badge { background: var(--danger-text); animation: notif-pulse 1.2s ease-in-out infinite; }
@keyframes notif-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .notif-bell.urgent .notif-badge, .notif-menu-item.urgent .notif-badge { animation: none; } }
.tour-float { position: fixed; z-index: 250; right: 64px; top: 10px; bottom: auto; width: 40px; height: 40px; padding: 0; margin: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); cursor: pointer; }
.tour-float:hover { background: var(--accent-bg); }
.notif-bell-float { display: none; }
@media (min-width: 768px) {
  /* колокольчик справа вверху: всегда на виду, не занимает места в меню */
  .notif-bell-float { display: block; position: fixed; top: 12px; right: 18px; z-index: 250; margin: 0; padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
  .notif-bell-float .notif-badge { position: absolute; top: -6px; right: -6px; }
  /* компактная кнопка тура — слева от колокольчика */
  .tour-float { top: 12px; right: 72px; width: auto; height: auto; padding: 7px 10px; }
  main > h1:first-child { padding-right: 116px; }
}
.notif-panel { position: fixed; z-index: 400; width: min(380px, calc(100vw - 16px)); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.notif-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-panel-head strong { margin-right: auto; }
.notif-sound, .notif-readall { border: none; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.notif-sound:hover, .notif-readall:hover { background: var(--accent-bg); }
.notif-sound-hint { padding: 8px 14px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.notif-list { overflow-y: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notif-item:hover { background: var(--accent-bg); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-item.urgent.unread { background: var(--danger-bg); border-left-color: var(--danger-text); }
.notif-title { font-size: 14px; }
.notif-body { font-size: 13px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 12px; color: var(--muted); margin-top: 4px; }
.notif-empty { padding: 20px 14px; color: var(--muted); text-align: center; font-size: 14px; }

/* Широкая форма с колонками (объявления): поля в ряд, радио в строку. */
form.wide-form { max-width: 760px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; align-items: start; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.radio-row label { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.radio-row input[type="radio"], .radio-row input[type="checkbox"] { width: auto; margin: 0; flex: none; }

/* Всплывающие сообщения (js/ui.js) — результат действия рядом с местом, где его ждут, вместо alert() */
.toast-box { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); cursor: pointer; background: var(--ok-bg); color: var(--ok-text); }
.toast-error { background: var(--danger-bg); color: var(--danger-text); }
.toast-info { background: var(--accent-bg); color: var(--accent); }

/* Ссылка-карточка (кликабельные счётчики дашборда) */
a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.card:hover { box-shadow: 0 4px 16px rgba(108,88,232,.18); transform: translateY(-1px); }

/* Список заявок на телефоне — карточками, а не таблицей со скроллом вбок */
@media (max-width: 700px) {
  .requests-table thead { display: none; }
  .requests-table, .requests-table tbody, .requests-table tr, .requests-table td { display: block; width: 100%; min-width: 0; }
  .table-wrap .requests-table { min-width: 0; }
  .requests-table tr { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 8px 12px; background: var(--surface); }
  .requests-table td { border: 0; padding: 2px 0; }
  .requests-table td.text-cell-truncate { max-width: none; white-space: normal; }
}

/* Выпадающая группа кнопок (Лицевые счета: «Добавить / Загрузить / Выгрузить») — без библиотек, на <details> */
.menu-drop { position: relative; display: inline-block; }
.menu-drop > summary { list-style: none; padding: 4px 10px; font-size: 13px; border-radius: 10px; user-select: none; }
.menu-drop > summary::-webkit-details-marker { display: none; }
.menu-drop > summary.secondary { background: var(--accent-bg); color: var(--accent); box-shadow: none; }
.menu-drop-list { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 240px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.menu-drop-list button { text-align: left; border: 0; white-space: nowrap; }

/* Настройки (страница «Настройки бота»): переключатели, поля и «чипы» словаря сигналов — общий input{width:100%} тут не годится */
.set-body { margin-top: 14px; max-width: 760px; }
.set-section { margin-top: 22px; }
.set-section > h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.set-section > .hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
label.set-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; margin: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.set-row .t { display: block; font-weight: 600; font-size: 14px; color: var(--text); }
.set-row .d { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); font-weight: 400; }
/* Селектор области настроек «все дома / дом» (scopeSelector.js, тариф «Для УК») */
.scope-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0 16px; padding: 12px 16px; border-radius: 14px; background: var(--accent-bg); }
.scope-bar[hidden] { display: none; }
.scope-bar .scope-label { margin: 0; font-weight: 600; font-size: 14px; }
.scope-bar select { width: auto; max-width: 100%; margin: 0; }
.scope-bar label.set-row.scope-toggle { display: flex; align-items: center; gap: 10px; padding: 0; margin: 0; border: 0; cursor: pointer; }
.scope-bar .scope-toggle[hidden] { display: none; }
.scope-bar .scope-hint { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.switch { position: relative; flex: none; width: 44px; height: 26px; margin-top: 1px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: #C9C8DE; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(17,22,50,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(108, 88, 232, .3); }
.set-field { margin-top: 12px; }
.set-field > label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.set-field input[type="text"], .set-field textarea { max-width: 100%; margin-bottom: 4px; }
.set-field textarea { min-height: 64px; }
.set-field .hint { margin: 0; font-size: 12px; color: var(--muted); }
.set-field input:disabled { opacity: .5; cursor: not-allowed; }
.rule-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }
.rule-head .ttl { font-weight: 600; font-size: 14px; color: var(--text); }
.rule-head .cnt { font-size: 12px; color: var(--muted); }
.rule-head .acts { margin-left: auto; display: flex; gap: 6px; }
.rule-sub { margin: 10px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.rule-grid { display: flex; flex-wrap: wrap; gap: 8px; }
label.rule-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1.3; cursor: pointer; user-select: none; transition: background .12s, border-color .12s; }
.rule-chip input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; padding: 0; }
.rule-chip .mark { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #B4B3CC; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: transparent; }
.rule-chip:hover { border-color: var(--lavender); }
.rule-chip.on { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.rule-chip.on .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.rule-chip.urgent.on { background: var(--danger-bg); border-color: #E9A3A3; }
.rule-chip.urgent.on .mark { background: var(--danger-text); border-color: var(--danger-text); }
.rule-chip:not(.on) .lbl { text-decoration: line-through; text-decoration-color: #B4B3CC; }
.rule-chip:focus-within { box-shadow: 0 0 0 3px rgba(108, 88, 232, .3); }
/* свои слова: чип с крестиком и «овал» ввода в конце раздела */
.rule-chip.custom { padding-right: 6px; border-style: dashed; }
.rule-chip.custom.on { border-style: solid; }
.rule-chip .chip-del { flex: none; width: 20px; height: 20px; margin: 0 0 0 2px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 15px; line-height: 20px; box-shadow: none; cursor: pointer; }
.rule-chip .chip-del:hover, .rule-chip .chip-del:focus-visible { background: var(--danger-bg); color: var(--danger-text); outline: none; }
input.chip-input { width: 170px; max-width: 100%; margin: 0; padding: 6px 12px; border: 1px dashed #B4B3CC; border-radius: 999px; font-size: 13px; line-height: 1.3; background: transparent; }
input.chip-input:focus { border-style: solid; background: var(--surface); }
input.chip-input.dup { border-color: var(--danger-text); }
.set-actions { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.set-actions button { margin: 0; }

/* Бейдж пункта меню «Входящие» (js/inbox.js): число того, что ждёт реакции; в свёрнутом меню — на иконке */
.menu-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger-text); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
html.sidebar-collapsed .menu-badge { position: absolute; top: 3px; right: 6px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
