/* ─── Шрифт Jost ──────────────────────────────────────────────────────────────
   Приходит со своего сервера: /vendor/fonts.css подключён в index.html и
   login.html. Здесь раньше оставался @import с fonts.googleapis.com — кабинет
   всё равно ходил к Google за шрифтом на каждой загрузке. */

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── DARK MODE (default) ──────────────────────────────────────────────────── */
:root {
  --bg:             #000000;
  --bg2:            #0a0a0a;
  --bg3:            #141414;
  --bg4:            #1c1c1c;
  --border:         rgba(111,172,70,0.12);
  --border-hover:   rgba(111,172,70,0.35);
  --accent:         #6fac46;
  --accent-soft:    rgba(111,172,70,0.10);
  --accent-glow:    rgba(111,172,70,0.20);
  --text:           #f4f4f4;
  --text2:          #b0b0b0;
  --text3:          #606060;
  --red:            #f87171;
  --red-soft:       rgba(248,113,113,0.12);
  --orange:         #fb923c;
  --orange-soft:    rgba(251,146,60,0.12);
  --green:          #6fac46;
  --green-soft:     rgba(111,172,70,0.12);
  --yellow:         #facc15;
  --sidebar-w:      224px;
  --topbar-h:       58px;
  --radius:         6px;
  --radius-sm:      4px;
  --shadow:         0 4px 24px rgba(0,0,0,0.7);
  --shadow-green:   0 0 20px rgba(111,172,70,0.15);
  --transition:     0.15s ease;
  color-scheme: dark;
}

/* ─── LIGHT MODE ──────────────────────────────────────────────────────────── */
:root[data-theme="light"] {
  --bg:             #f4f4f4;
  --bg2:            #ffffff;
  --bg3:            #ececec;
  --bg4:            #e2e2e2;
  --border:         rgba(0,0,0,0.08);
  --border-hover:   rgba(111,172,70,0.4);
  --accent:         #6fac46;
  --accent-soft:    rgba(111,172,70,0.10);
  --accent-glow:    rgba(111,172,70,0.15);
  --text:           #000000;
  --text2:          #3a3a3a;
  --text3:          #888888;
  --red:            #dc2626;
  --red-soft:       rgba(220,38,38,0.10);
  --orange:         #ea580c;
  --orange-soft:    rgba(234,88,12,0.10);
  --green:          #6fac46;
  --green-soft:     rgba(111,172,70,0.12);
  --shadow:         0 2px 16px rgba(0,0,0,0.10);
  --shadow-green:   0 0 20px rgba(111,172,70,0.12);
  color-scheme: light;
}

html, body { height: 100%; }

body {
  font-family: 'Jost', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ─── Theme Toggle Button ──────────────────────────────────────────────────── */
.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-green);
}
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: block; }

/* ─── Колокольчик (системные уведомления) ─────────────────────────────────── */
.bell-wrap { position: relative; flex-shrink: 0; }
.bell-badge {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--red, #e05555);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.bell-badge.show { display: block; }
.bell-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  width: 320px;
  max-width: calc(100vw - 24px);
  display: none;
  flex-direction: column;
  padding: 4px;
}
.bell-dropdown.open { display: flex; animation: fadeIn 0.15s ease; }
.bell-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.bell-dropdown-header a { font-size: 12px; font-weight: 500; color: var(--accent); text-decoration: none; }
.bell-list { max-height: 340px; overflow-y: auto; }
.bell-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
}
.bell-item:hover { background: var(--bg3); }
.bell-item.unread { color: var(--text); font-weight: 500; }
.bell-item .bell-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--accent);
  visibility: hidden;
}
.bell-item.unread .bell-dot { visibility: visible; }
.bell-item .bell-time { display: block; font-size: 11px; color: var(--text3); font-weight: 400; margin-top: 2px; }
.bell-empty { padding: 18px 12px; font-size: 13px; color: var(--text2); text-align: center; }

/* ─── Logo Switcher ────────────────────────────────────────────────────────── */
.logo-img { display: none; margin: 0 auto; }
.sidebar-logo .logo-img { width: 115px; height: auto; object-fit: contain; }
.login-header .logo-img { width: 180px; height: auto; object-fit: contain; }

.logo-dark { display: block; }
.logo-light { display: none; }

:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: relative;
  z-index: 10;
  transition: width var(--transition), min-width var(--transition), background 0.3s, border-color 0.3s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  height: var(--topbar-h);       /* align bottom border with topbar */
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-close-btn {
  display: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--text3);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
}
.sidebar-close-btn:hover, .sidebar-close-btn:active {
  color: var(--text);
  background: var(--bg3) !important;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-align: left;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--text2);
  border-color: var(--border);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-hover);
  font-weight: 700;
}
.nav-item svg { flex-shrink: 0; opacity: 0.65; }
.nav-item.active svg { opacity: 1; color: var(--accent); }

.badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.badge.show { display: block; }

/* Маскировка реквизитов точками без type=password — чтобы браузер не предлагал
   сохранить их как логин/пароль. Глазик снимает класс и показывает значение. */
/* Заголовок секции реквизитов: «Данные юридического лица» + кнопка справа.
   display:flex держим в классе, а не инлайном, потому что JS-переключатель
   видимости реквизитов сбрасывает inline display (el.style.display=''). */
.legal-header {
  display: flex;
}

.requisite-masked {
  -webkit-text-security: disc;
  text-security: disc;
}

/* Огонёк на пункте «Профиль» — горит, пока подписка не оплачена */
.nav-pay-dot {
  margin-left: auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse-pay 1.6s infinite;
}
@keyframes pulse-pay {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Сотрудник/админ без подписки: статуса оплаты нет — убираем разделительную
   полоску, чтобы внизу сайдбара не висела пустая линия. */
.sidebar-footer.pay-hidden {
  border-top: none;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.5s;
}
.conn-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-green 2s infinite;
}
.conn-dot.offline { background: var(--red); }

@keyframes pulse-green {
  0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  gap: 16px;
  transition: background 0.3s, border-color 0.3s;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
}

.page-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: var(--green);
  background: var(--green-soft);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(111,172,70,0.3);
  text-transform: uppercase;
}

.live-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.5s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.time-display {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: lowercase;
}
.btn-primary {
  background: var(--accent);
  color: #000000;
  font-weight: 700;
}
.btn-primary:hover {
  background: #7ec750;
  box-shadow: var(--shadow-green);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-text { background: transparent; color: var(--text2); padding: 0; font-size: 13px; }
.btn-text:hover { color: var(--accent); }

/* ─── Pages ───────────────────────────────────────────────────────────────── */
.pages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg4) transparent;
}
.pages::-webkit-scrollbar { width: 5px; }
.pages::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* ─── KPI Cards ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.kpi-card:hover::before { opacity: 1; }
.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-green);
  transform: translateY(-2px);
}

.kpi-icon {
  width: 42px; height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  border: 1px solid var(--border-hover);
  color: var(--accent);
}
.kpi-today .kpi-icon  { color: var(--accent); }
.kpi-month .kpi-icon  { color: var(--accent); }
.kpi-week .kpi-icon   { color: var(--accent); }
.kpi-people .kpi-icon { color: var(--accent); }

.kpi-value { font-size: 30px; font-weight: 800; line-height: 1; color: var(--text); }
.kpi-label { font-size: 12px; color: var(--text3); margin-top: 4px; font-weight: 500; text-transform: lowercase; letter-spacing: 0.03em; }
.kpi-trend { font-size: 11px; color: var(--text3); margin-left: auto; }

/* ─── Chart Cards ─────────────────────────────────────────────────────────── */
.charts-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.3s;
}
.chart-main { flex: 1; }
.chart-side { width: 280px; flex-shrink: 0; }

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chart-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.chart-subtitle { font-size: 12px; color: var(--text3); margin-top: 2px; }
.chart-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.chart-canvas-wrapper { position: relative; height: 180px; }
.donut-wrapper { display: flex; align-items: center; justify-content: center; }

.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-num { display: block; font-size: 24px; font-weight: 800; color: var(--text); }
.donut-label { font-size: 11px; color: var(--text3); }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-val { margin-left: auto; font-weight: 700; color: var(--text); }

/* ─── Section Cards ───────────────────────────────────────────────────────── */
.section-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  transition: border-color 0.3s;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }

/* ─── Alerts List ─────────────────────────────────────────────────────────── */
.alerts-list { display: flex; flex-direction: column; gap: 10px; }

.alert-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
  animation: slideIn 0.3s ease;
}
.alert-row:hover { border-color: var(--border-hover); background: var(--bg4); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

.alert-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.alert-icon.parovozik { background: var(--red-soft);    color: var(--red); }
.alert-icon.door      { background: var(--orange-soft); color: var(--orange); }
.alert-icon.visitors  { background: var(--green-soft, rgba(111,172,70,0.15)); color: #6fac46; }
.alert-icon.animal    { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.alert-icon.custom    { background: var(--bg3);         color: var(--text2); }

.alert-info { flex: 1; min-width: 0; }
.alert-type { font-size: 13px; font-weight: 700; color: var(--text); }
.alert-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

.alert-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.alert-badge.red    { background: var(--red-soft);    color: var(--red); }
.alert-badge.orange { background: var(--orange-soft); color: var(--orange); }

.alert-time {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

/* ─── Alerts Table ────────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Фильтры журнала алертов: воронка + выпадающая панель ─────────────────── */
/* Раньше семь контролов стояли в ряд и переносились на вторую строку — шапка
   журнала выглядела панелью настроек. Теперь в тулбаре только воронка и
   экспорт, а состояние фильтров показывают счётчик на кнопке и чипы. */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-menu { position: relative; }

.filter-toggle { align-items: center; gap: 7px; }
/* Фильтры включены — кнопка перестаёт быть нейтральной, иначе о них забывают. */
.filter-toggle.active { color: var(--accent); border-color: var(--accent); }
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
/* display у класса перебивает браузерный [hidden] — без этого при нуле
   фильтров на кнопке висел бы бейдж «0». */
.filter-count[hidden] { display: none; }

.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: min(300px, calc(100vw - 56px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.filter-panel[hidden] { display: none; }
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filter-field .select-filter { width: 100%; }
/* Две даты в строку: по отдельности они не читаются как диапазон. */
.filter-dates { display: flex; gap: 8px; }
.filter-dates .date-filter { flex: 1; min-width: 0; }
.filter-dates .select-filter { width: 100%; }
.filter-panel-foot {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
/* Как и у счётчика: display у класса перебивает браузерный [hidden], без этого
   при пустых фильтрах в панели висела бы кнопка «Сбросить всё» и линия над ней. */
.filter-panel-foot[hidden] { display: none; }

/* Чипы включённых фильтров — под тулбаром, на всю ширину. Пока фильтров нет,
   ряда не существует вовсе (:empty), и шапка остаётся пустой. */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.filter-chips:empty { display: none; margin-top: 0; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--border-hover);
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}
.filter-chip b { color: var(--text); font-weight: 700; }
.filter-chip button {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: color var(--transition);
}
.filter-chip button:hover { color: var(--red); }

.select-filter {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition);
  font-weight: 400;
}
.select-filter:focus { border-color: var(--accent); }

/* Поля диапазона дат с подписью сверху: без значения type=date выглядит пустым
   боксом, а на iOS содержимое жмётся вправо — форсируем влево. */
.date-filter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.date-filter-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text3); padding-left: 2px;
}
.date-filter .select-filter { width: 100%; min-width: 0; text-align: left; }
.date-filter input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.date-filter input[type="date"]::-webkit-datetime-edit { text-align: left; padding: 0; }
/* iOS Safari игнорирует width:100% у нативного date-инпута (интринсик-ширина не
   сжимается) — бокс вылезал за фильтры и белую карточку. appearance:none
   заставляет его вести себя как обычный бокс. Иконку календаря мы скрываем ниже,
   а ручной отрисовки «дд.мм.гггг» больше нет, поэтому прежний баг «значок под
   текстом» не возвращается. min-height — чтобы пустое поле на iOS не схлопывалось. */
.date-filter input[type="date"] {
  -webkit-appearance: none; appearance: none;
  max-width: 100%; box-sizing: border-box;
  min-height: 31px;
}
/* Прячем нативную иконку календаря (лишний значок). Открытие календаря — по
   клику через showPicker() (см. app.monitoring.js); на телефоне тап по самому
   полю открывает нативный пикер и без иконки. На Android/десктопе поле по-
   прежнему показывает нативное «дд.мм.гггг»; на iOS Safari плейсхолдера нет. */
.date-filter input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

/* Ряд кнопок в профиле («Сохранить изменения» / «Выйти из аккаунта»).
   На десктопе — обычная ширина по содержимому (flex-wrap на всякий случай, чтобы
   при нехватке места переносились, а не уезжали). «Резиновыми» они становятся
   только на мобильном (см. медиазапрос), где иначе не влезали в ряд. */
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.alerts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.alerts-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}
.alerts-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}
.alerts-table tr:hover td { background: var(--accent-soft); }
.alerts-table .empty-cell { text-align: center; color: var(--text3); padding: 40px; }
/* Колонка «Статус» — постоянная ширина, чтобы появление/исчезновение плашки
   «Удалено сотрудником» (напр. при нажатии крестика) не перекомпоновывало
   всю таблицу и она не «съезжала». */
.alerts-table th:last-child,
.alerts-table td:last-child { width: 240px; }
/* Плашки статуса переносятся целиком (не по буквам) и при нехватке места встают
   друг под другом, увеличивая высоту строки. Ширина колонки фиксирована, а
   table-layout:fixed не даёт остальным колонкам сдвинуться. */
.status-pill, .false-pill, .staff-deleted-pill { white-space: nowrap; }
/* «Камера», «Тип нарушения», «Нарушителей», «Фото» и «Статус» центрируем под
   заголовками — короткое содержимое в левом краю широкой колонки выглядело как
   пустая дыра между колонками. «Время» оставляем слева как якорь строки. */
.alerts-table th:nth-child(3), .alerts-table td:nth-child(3),
.alerts-table th:nth-child(4), .alerts-table td:nth-child(4),
.alerts-table th:nth-child(5), .alerts-table td:nth-child(5),
.alerts-table th:nth-child(6), .alerts-table td:nth-child(6),
.alerts-table th:last-child,   .alerts-table td:last-child { text-align: center; }
/* Плашки статуса лежат во flex-контейнере (см. statusCellHtml) — text-align на
   него не действует, центрируем flex-содержимое явно. */
.alerts-table td:last-child > div { justify-content: center; }

/* Десктоп: фиксированная раскладка колонок. Ширины берутся из заголовков, а не
   из содержимого, поэтому (а) на широком мониторе свободное место распределяется
   по колонкам РОВНО, а не сваливается в одну (из-за чего «Фото»/«Статус» слипались
   справа); (б) появление плашки «Удалено сотрудником» переносит её ВНУТРИ ячейки
   «Статус» (её ширина фиксирована = 240px), не двигая остальные колонки — таблица
   не «прыгает». Включаем только на широких экранах (≥1024px): там 7 колонок
   помещаются и фикс-раскладка убирает «дыру». На узких (мобилка + планшет
   769–1023px) остаётся прежнее поведение — иначе фикс-ширины сдавливают колонки
   и длинный заголовок «Нарушителей» наползает на «Фото». */
@media (min-width: 1024px) {
  .alerts-table { table-layout: fixed; }
  /* Проценты всех колонок (включая «Статус») в сумме 94% + 40px чекбокс — без
     конфликта px/процентов, из-за которого сумма превышала ширину таблицы и
     раскладка кривилась на ~1000-1300px экранах. */
  .alerts-table th:nth-child(2) { width: 16%; }  /* Время */
  .alerts-table th:nth-child(3) { width: 12%; }  /* Камера */
  .alerts-table th:nth-child(4) { width: 18%; }  /* Тип нарушения */
  .alerts-table th:nth-child(5) { width: 17%; }  /* Нарушителей (заголовок-слово не переносится — ему запас) */
  .alerts-table th:nth-child(6) { width: 13%; }  /* Фото */
  .alerts-table th:last-child   { width: 18%; }  /* Статус: плашки стекуются, широкая не нужна */
}

.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-pill.complete { background: var(--green-soft); color: var(--green); }
.status-pill.pending  { background: var(--orange-soft); color: var(--orange); }

.event-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}
.event-tag.parovozik { background: var(--red-soft);    color: var(--red); }
.event-tag.door      { background: var(--orange-soft); color: var(--orange); }
.event-tag.visitors  { background: rgba(111,172,70,0.15);  color: #6fac46; }
.event-tag.animal    { background: rgba(139,92,246,0.15);  color: #8b5cf6; }
.event-tag.custom    { background: var(--bg3);            color: var(--text2); }

/* Плашка «Удалено сотрудником» в колонке статуса (видит только владелец) */
.staff-deleted-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--red-soft);
  color: var(--red);
}

/* «Ложное срабатывание» — отдельный цвет (фиолетовый), чтобы не путать с
   красной плашкой «Удалено сотрудником». */
.false-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

/* Плашка «Проверено» в колонке статуса — ось, независимая от «прочитано». */
.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-hover);
}

/* Плашка обсуждения в колонке статуса: сколько сообщений в чате по событию. */
.comment-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
}

.thumb {
  width: 42px; height: 30px;
  border-radius: 5px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform var(--transition);
}
.thumb:hover { transform: scale(1.12); border-color: var(--accent); }

.no-photo {
  width: 42px; height: 30px;
  background: var(--bg3);
  border-radius: 5px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text3);
}

.btn-del {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 13px;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-del:hover { background: var(--red-soft); color: var(--red); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}

/* ─── Stats Summary ───────────────────────────────────────────────────────── */
.stats-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stat-row-label { font-size: 12px; color: var(--text2); font-weight: 500; }
.stat-row-val   { font-size: 18px; font-weight: 800; color: var(--accent); }

/* ─── Cameras Grid ────────────────────────────────────────────────────────── */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.camera-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition);
}
.camera-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-green);
}

.camera-header { display: flex; align-items: center; gap: 10px; }
.camera-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-green 2s infinite;
  flex-shrink: 0;
}
.camera-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239,68,68,0.45);
  animation: none;
}
/* Третье состояние: мини-ПК не на связи, про камеру ничего не известно.
   Серый, а не красный: красный утверждал бы поломку там, где её, может, нет. */
.camera-dot.unknown {
  background: var(--text3);
  box-shadow: none;
  animation: none;
}
.camera-name { font-size: 14px; font-weight: 700; color: var(--text); }
.camera-id   { font-size: 11px; color: var(--accent); font-family: monospace; }

.camera-stats { display: flex; gap: 12px; }
.camera-stat { flex: 1; }
.camera-stat-val   { font-size: 20px; font-weight: 800; color: var(--text); }
.camera-stat-label { font-size: 11px; color: var(--text3); font-weight: 500; }

.camera-last { font-size: 11px; color: var(--text3); padding-top: 8px; border-top: 1px solid var(--border); }

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  padding: 32px;
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.80);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), var(--shadow-green);
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-soft); color: var(--red); }

.modal-body img { width: 100%; border-radius: var(--radius-sm); }

/* Блок уведомлений ждёт ответа обоих запросов (почта + Telegram) и потому
   появляется позже остального профиля. Без перехода это выглядело как рывок:
   пустое место — и вдруг карточки. Проявляем мягко, со сдвигом на пару
   пикселей вверх. */
#profile-notify-section {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#profile-notify-section.is-ready { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  #profile-notify-section { transition: none; transform: none; }
}

/* ─── Уведомления в профиле: почта и Telegram рядом ───────────────────────── */
/* Каналы разные, карточка одна: две колонки на десктопе, столбик на телефоне. */
.notify-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.notify-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg3);
  padding: 16px;
  display: flex;
  flex-direction: column;
  /* Кнопка прижата к низу, чтобы у двух колонок она была на одной линии
     независимо от длины статуса. */
  min-width: 0;
}
.notify-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.notify-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-hover);
}
.notify-title { font-size: 15px; font-weight: 700; color: var(--text); }
.notify-status {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  /* Кнопка идёт сразу под строкой состояния — отступ намеренно маленький. */
  margin: 0 0 8px;
}
.notify-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  /* Раньше было margin-top:auto — кнопки прижимались к низу карточки и между
     статусом и кнопкой зияла дыра во всю оставшуюся высоту. Строки состояния
     у обоих каналов примерно равной длины, так что кнопки и без растяжки
     встают почти на одну линию. */
  margin-top: 0;
}
.notify-hint { font-size: 12px; color: var(--text3); margin: 12px 0 0; line-height: 1.5; }

/* Виды уведомлений внутри канала: канал — это «куда», а галки — «что».
   Показываются только когда канал подключён (иначе они ничего не значат). */
.notify-kinds {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0 0 12px;
}
.notify-kinds label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
  cursor: pointer;
}

/* Время сводки — одно на все каналы, поэтому стоит под сеткой, а не в карточке. */
.notify-digest {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}
.notify-digest input[type="time"] { width: auto; padding: 6px 10px; }

/* ─── Лента разборов ложных (вкладка супер-админа) ────────────────────────── */
.false-report {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  padding: 12px 14px;
}
.false-report + .false-report { margin-top: 10px; }
/* Карточка кликабельна: ведёт в кабинет владельца и открывает само событие. */
.false-report { cursor: pointer; transition: border-color var(--transition); }
.false-report:hover { border-color: var(--border-hover); }
.false-report-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.false-report-owner { font-size: 13px; font-weight: 700; color: var(--text); }
.false-report-meta { font-size: 12px; color: var(--text3); }
.false-report-time { font-size: 11px; color: var(--text3); margin-left: auto; }
.false-report-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.false-report-by { font-size: 11px; color: var(--text3); margin-top: 8px; }

/* ─── Панель статусов в карточке алерта ───────────────────────────────────── */
/* Раздельные оси вместо одного выпадающего списка: «Прочитано» и «Проверено» —
   переключатели Да/Нет, «ложное» и корзина — отдельные кнопки ниже. */
.status-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
/* Ряд плотный: после отказа от подписей-пояснений и от слов «Да/Нет» строка
   состоит из одного слова и двух иконок — прежние отступы делали её пустой. */
.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
}
.status-row + .status-row { border-top: 1px solid var(--border); }
.status-row-label { font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; }

.toggle-group {
  display: inline-flex;
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg2);
}
/* Внутри — галочка и крестик вместо слов «Да/Нет»: подпись не нужна, знак
   читается быстрее и ряд получается вдвое короче. Кнопка квадратная, чтобы
   иконка стояла по центру. */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  width: 34px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--border); }
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active { background: var(--accent); color: #fff; }
/* Выбранное «Нет» — красное: цвет и есть ответ, иначе оба выбора выглядят
   одинаково утвердительно (галочка и крестик на одинаковом зелёном). */
.toggle-btn.no.active { background: var(--red); color: #fff; }
.toggle-btn.no:hover { color: var(--red); }
.toggle-btn.no.active:hover { color: #fff; }
.toggle-btn svg { vertical-align: 0; }

/* Событие уже разобрано (ложное / корзина) — состояние показываем плашкой,
   переключать «прочитано» там нечего. */
.status-banner {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 10px;
}
.status-banner.false { border-color: var(--orange); color: var(--text); }
.status-banner-text {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.status-banner-meta { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ─── «Датчик двери не отвечает» на карточке устройства ───────────────────── */
/* Оранжевая, а не красная: устройство работает, деградирует только часть
   функций (счёт входов и алерты). */
/* Иконка ВНУТРИ строки, а не отдельной колонкой (было display:flex + gap):
   при колонке обе строки текста начинались на ~32px правее, чем «74°» и
   «Аптайм» под ней, и плашка выглядела съехавшей вправо. Инлайном перенос
   ложится по левому краю бокса, как у остального содержимого карточки. */
.door-warn {
  display: block;
  /* Отступ с ОБЕИХ сторон: в модалке устройства под плашкой идёт серый бокс
     телеметрии, и без нижнего поля они слипались в одну рамку. */
  margin: 12px 0;
  padding: 8px 10px;
  border: 1px solid var(--orange);
  border-radius: var(--radius-sm);
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.door-warn svg { vertical-align: -2px; margin-right: 6px; }

/* ─── Мелкие кнопки-действия в карточке события ───────────────────────────── */
/* Один ряд неброских кнопок: «Скачать фото / Скачать видео» под медиа и
   «Отметить ложным / В корзину» под статусами. Раньше вторая пара была во всю
   ширину в столбик и весила больше самой карточки, хотя жмут их редко. */
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
/* Под панелью статусов ряд достаёт до правого края боксов статуса: последняя
   кнопка забирает остаток ширины. Делить поровну нельзя — «Отметить ложным»
   в узкой колонке ломается на две строки. У «Скачать фото / Скачать видео»
   растяжки нет: там ряд живёт под медиа и жмётся влево. */
.card-actions.fill .mini-btn:last-child { flex: 1; justify-content: center; }
.mini-btn { white-space: nowrap; }
.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }
/* Цвет действия — сразу, а не по наведению: «ложное» оранжевое, «в корзину»
   красное, возврат зелёный. Уменьшая кнопки, цвет терять нельзя — по нему их
   и находят взглядом; серыми они сливались со «Скачать фото». */
.mini-btn.accent { color: var(--accent); border-color: var(--accent); }
.mini-btn.warn   { color: var(--orange); border-color: var(--orange); }
.mini-btn.danger { color: var(--red); border-color: var(--red); }
.mini-btn.accent:hover { background: var(--accent-soft); }
.mini-btn.warn:hover   { background: var(--orange-soft); color: var(--orange); border-color: var(--orange); }
.mini-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* ─── Обсуждение события (чат в карточке алерта) ──────────────────────────── */
.comment-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  margin-bottom: 12px;
}
.comment-empty {
  font-size: 13px;
  color: var(--text3);
  padding: 10px 0;
}
.comment-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.comment-avatar {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg4);
  color: var(--text2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
/* Свои сообщения подсвечены акцентом — видно, где ты в переписке. */
.comment-item.mine .comment-avatar {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-hover);
}
.comment-body {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.comment-item.mine .comment-body {
  background: var(--accent-soft);
  border-color: var(--border-hover);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.comment-author { font-size: 12px; font-weight: 700; color: var(--text); }
.comment-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}
.comment-time { font-size: 11px; color: var(--text3); margin-left: auto; }
.comment-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition);
}
.comment-del:hover { color: var(--red); }
.comment-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.45;
  /* Текст пишет человек: переносы строк сохраняем, длинные «слова» рвём,
     иначе ссылка без пробелов растягивает модалку. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Системная запись (смена статуса) в той же ленте: обсуждение = история
   события. Строка журнала, а не реплика — без аватара и пузыря, мельче и тише
   сообщений, чтобы переписка оставалась главной. */
.comment-system {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  padding: 2px 0;
}
.comment-system-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.comment-system-text b { color: var(--text2); font-weight: 700; }
.comment-system-time { flex-shrink: 0; }

.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-input {
  flex: 1;
  min-width: 0;
  resize: vertical;
  min-height: 44px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 10px;
  transition: border-color var(--transition);
}
.comment-input:focus { outline: none; border-color: var(--border-hover); }
.comment-input::placeholder { color: var(--text3); }
.comment-send { padding: 10px 16px; font-size: 13px; font-weight: 600; white-space: nowrap; }

@media (max-width: 600px) {
  .comment-form { flex-direction: column; align-items: stretch; }
  .comment-send { justify-content: center; }
}
.modal-info { margin-top: 16px; }
/* Карточка устройства начинается с плашки статуса, а не с заголовка: общий
   отступ .modal-info опускал её ниже кнопки-крестика, и шапка выглядела
   съехавшей. В карточке события такого сдвига нет — там .modal-body. */
#device-modal-body { margin-top: 0; }
.modal-info h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.modal-info p  { font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.modal-info span { color: var(--accent); font-weight: 600; }
/* …но только в текстовых строках «поле: значение», ради которых правило и
   писалось. Внутри плашек оно ломало цвет: текст предупреждения о датчике
   становился зелёным, а точка у тега «Офлайн» — зелёной на красном. */
.modal-info .door-warn span,
.modal-info .event-tag span { color: inherit; }

/* ─── Toasts ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  /* Сквозной для кликов: тост живёт 4с в правом нижнем углу и раньше перехватывал
     нажатия по пагинации алертов под ним. Тост чисто информационный (без кнопок),
     поэтому клики безопасно пропускаем на элементы под ним. */
  pointer-events: none;
  min-width: 240px;
  max-width: 340px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--orange); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

/* ─── Sidebar Divider ─────────────────────────────────────────────────────── */
.sidebar-divider {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  opacity: 0.7;
  padding: 16px 12px 6px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

/* Первый разделитель «Супер-админ» — сразу под полоской логотипа, без своей линии */
#admin-divider {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* ─── Object Selector ─────────────────────────────────────────────────────── */
.object-selector-container {
  position: relative;
  margin-left: 14px;
}

.object-select-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}
.object-select-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.obj-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.chevron-down {
  color: var(--text3);
  transition: transform var(--transition);
}
.object-selector-container.open .chevron-down {
  transform: rotate(180deg);
}

.object-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  width: 260px;
  display: none;
  flex-direction: column;
  padding: 4px;
}
.object-dropdown.open {
  display: flex;
  animation: fadeIn 0.15s ease;
}

.object-dropdown-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text2);
  transition: all var(--transition);
}
.object-dropdown-item:hover {
  background: var(--accent-soft);
  color: var(--text);
}
.object-dropdown-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  border-left: 3px solid var(--accent);
}
.object-dropdown-item .cam-count {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 10px;
}

/* ─── Objects Grid ────────────────────────────────────────────────────────── */
.objects-grid {
  display: grid;
  /* min(320px, 100%): на узких экранах трек сжимается до ширины контейнера,
     иначе minmax(320px,…) заставляет карточку вылезти за правый край. */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px;
  margin-top: 16px;
}

.object-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all var(--transition);
}
.object-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-green);
}

.object-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.object-card-title   { font-size: 15px; font-weight: 700; color: var(--text); }
.object-card-address { font-size: 12px; color: var(--text2); margin-top: 4px; }

.object-card-cams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.cam-badge {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: var(--accent);
}

.object-card-stats {
  display: flex;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  gap: 16px;
}
.object-stat-item { flex: 1; }
.object-stat-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}
.object-stat-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}

.object-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ─── Team / Access ────────────────────────────────────────────────────────── */
.access-table-container { overflow-x: auto; margin-top: 16px; }

.role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.role-badge.admin  { background: var(--accent-soft);     color: var(--accent); }
.role-badge.viewer { background: rgba(148,163,184,0.12); color: var(--text2); }

/* ─── Billing ─────────────────────────────────────────────────────────────── */
.billing-current-plan {
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 16px 24px 24px;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Название тарифа и статус оплаты — на одной линии (по первой строке:
   ниже названия есть ещё строка срока действия) */
.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.plan-glow {
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

/* Зелёная надпись в левом верхнем углу карточки — без плашки-обводки */
.plan-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  display: block;
  color: var(--accent);
  margin-bottom: 14px;
}
.plan-title   { font-size: 22px; font-weight: 800; color: var(--text); }
.plan-expiry  { font-size: 13px; color: var(--text3); margin-top: 4px; }
/* Строка состава под суммой: «базовая подписка и N сценариев на M камерах» */
.plan-sub     { font-size: 13px; color: var(--text2); margin: 14px 0 0; }
.plan-sub:empty { display: none; }

.plan-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(111,172,70,0.25);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  /* Пилюлю не сжимать и не рвать текст — на узком экране она переносится
     целиком на следующую строку (plan-row: wrap), а не плющится. */
  flex-shrink: 0;
  white-space: nowrap;
}
.status-dot {
  /* flex-basis фиксирован: иначе flex сжимает точку и она перестаёт быть круглой */
  flex: 0 0 6px;
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 2s infinite;
}

/* ─── Разбор подписки ───────────────────────────────────────────────────────
   Планов Standard/Pro/Pro+ больше нет: тариф собирается из сценариев,
   включённых на каждой камере (те же цены, что в конструкторе на лендинге). */
.billing-hint {
  font-size: 12.5px;
  color: var(--text3);
  margin: 0 0 14px;
  max-width: 68ch;
  line-height: 1.5;
}

.billing-breakdown {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.bd-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}
.bd-line span { display: flex; flex-direction: column; gap: 3px; }
.bd-line i {
  font-style: normal;
  font-size: 12px;
  color: var(--text3);
}
.bd-line b { font-weight: 700; white-space: nowrap; }

/* Камера со своим набором сценариев — основная единица тарификации */
.bd-cam {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.bd-cam-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 14px;
}
.bd-cam-name { font-weight: 700; color: var(--text); }
.bd-cam-obj  { font-size: 12px; color: var(--text3); }
.bd-cam-sum  { margin-left: auto; font-weight: 700; color: var(--text); white-space: nowrap; }

.bd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.bd-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg2);
  font-size: 12px;
  color: var(--text2);
}
.bd-chip i {
  font-style: normal;
  font-weight: 700;
  color: var(--text);
}

.bd-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.bd-total b { font-size: 18px; }

/* Каталог того, что ещё не подключено: клик открывает заявку в поддержку */
.billing-addons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.addon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
}
.addon:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-2px);
}
.addon-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.addon-price { font-weight: 700; color: var(--text); white-space: nowrap; }
/* У супер-админа в боксе — на скольких камерах сценарий уже включён */
.addon-name small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text3); }
.addon.is-on { border-color: var(--accent); }

/* Памятка владельцу в карточке учётных данных (супер-админ) */
.instr-block { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg3); }
.instr-title { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.instr-hint { font-size: 12px; color: var(--text2); line-height: 1.5; margin: 6px 0 10px; }

.detector-cams { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.detector-cams label {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text); cursor: pointer;
}
.detector-cams label span { color: var(--text3); font-size: 12px; margin-left: auto; text-align: right; }

/* ─── Profile Form ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 24px;
}

/* ─── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 50px; height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success-checkmark { width: 80px; height: 80px; margin: 20px auto; }
.check-icon {
  width: 80px; height: 80px;
  position: relative;
  border-radius: 50%;
  box-sizing: content-box;
  border: 4px solid var(--green);
}
.check-icon::after {
  content: '';
  position: absolute;
  left: 14px; top: 38px;
  width: 18px; height: 32px;
  border-right: 4px solid var(--green);
  border-bottom: 4px solid var(--green);
  transform: rotate(45deg);
  transform-origin: 0% 100%;
  animation: checkmark 0.6s ease;
}
@keyframes checkmark {
  0%   { height: 0; width: 0; opacity: 0; }
  40%  { height: 0; width: 18px; opacity: 1; }
  100% { height: 32px; width: 18px; opacity: 1; }
}

.payment-card-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg3);
  padding: 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 20px 0;
  text-align: left;
}
.card-row { display: flex; gap: 12px; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid     { grid-template-columns: repeat(2, 1fr); }
  /* Четыре фильтра журнала проходов рядом с заголовком карточки ужимали его
     в узкую колонку — с этой ширины они переезжают на свою строку. */
  .chart-header { flex-wrap: wrap; gap: 10px; }
  .chart-header > div:first-child { flex: 1 1 100%; min-width: 0; }
  .chart-header .filter-row { width: 100%; }
  .charts-row   { flex-direction: column; }
  .chart-side   { width: 100%; }
  .billing-addons { grid-template-columns: 1fr; }
  .form-grid    { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* 100dvh, а не 100vh: на мобиле 100vh заходит под нижнюю панель браузера, и
     футер сайдбара (статус оплаты + крестик) уезжал за неё. nav при нехватке
     места скроллится, футер остаётся виден. */
  .sidebar { position: fixed; top: 0; left: -100%; height: 100dvh; transition: left 0.3s; z-index: 1000; }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
  .sidebar-nav { overflow-y: auto; }
  .sidebar-toggle { display: flex; }
  .sidebar-close-btn { display: flex; align-items: center; justify-content: center; }
  .kpi-grid  { grid-template-columns: 1fr 1fr; }
  .pages     { padding: 16px; }
  
  /* Topbar fixes for mobile */
  .topbar { 
    height: auto; 
    min-height: var(--topbar-h); 
    padding: 12px 16px; 
    flex-wrap: wrap; 
    gap: 12px; 
  }
  .topbar-left { 
    width: 100%; 
    justify-content: space-between; 
    flex-wrap: wrap; 
  }
  .topbar-right { 
    width: 100%; 
    justify-content: space-between; 
    gap: 8px;
  }
  .object-selector-container {
    flex-grow: 1;
    margin-left: 10px;
    display: flex;
    justify-content: flex-end;
  }
  
  /* Filters row fixes for mobile */
  .filter-row {
    display: grid;
    /* minmax(0,1fr), а не 1fr: иначе трек не сжимается уже min-content поля
       type=date и длинных селектов -> сетка вылезает за ширину экрана. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    margin-top: 10px;
  }
  .filter-row select, .filter-row input[type="date"], .filter-row .btn, .filter-row .date-filter {
    width: 100%;
    min-width: 0;
  }
  /* Диапазон времени журнала — на всю ширину строки (иначе спаны «с/по» и
     type=time рассыпают grid). Внутри — резиновые поля времени + кнопка. */
  .filter-row .time-range-filter { grid-column: 1 / -1; width: 100%; }
  .time-range-filter input[type="time"] { flex: 1 1 90px; min-width: 0; }
  .time-range-filter .btn { flex: 0 0 auto; width: auto; }
  /* Блок массовых действий (появляется при выборе алертов чекбоксами):
     в grid-раскладке каждый элемент — на всю ширину, иначе кнопки встают в
     колонки и ломают сетку, а «Выбрано: N» с margin-left:auto уезжает вправо. */
  .filter-row #bulk-count {
    grid-column: 1 / -1;
    margin-left: 0 !important;
    justify-content: flex-start;
  }
  .filter-row #btn-mark-read,
  .filter-row #btn-bulk-delete {
    grid-column: 1 / -1;
    justify-content: center;
  }

  /* Часы слева; колокольчик и тема — справа, колокольчик СЛЕВА от кнопки темы
     (как на десктопе). Дропдаун колокольчика привязываем к правому краю всей
     .topbar-right, а не к самому колокольчику, иначе он уезжает за левый край;
     бейдж при этом якорим к кнопке. */
  .topbar-right { justify-content: flex-end; position: relative; }
  .topbar-right .time-display { margin-right: auto; }
  .bell-wrap { position: static; }
  #bell-toggle { position: relative; }
  .bell-dropdown { right: 0; }

  /* Фильтры: длинный «view»-селект и «Применить» на всю ширину, даты — в пару.
     iOS прижимает содержимое <input type=date> вправо — возвращаем влево. */
  .filter-row #filter-marks { grid-column: 1 / -1; }
  .filter-row #btn-filter   { grid-column: 1 / -1; }
  .filter-row input[type="date"]::-webkit-date-and-time-value { text-align: left; }

  /* Кнопки профиля: на узком экране — резиновые (влезают в один ряд или
     переносятся), чтобы длинная «Выйти из аккаунта» не уезжала за край. */
  .profile-actions .btn { flex: 1 1 160px; justify-content: center; }

  /* Table scrolling for mobile */
  .alerts-table { 
    display: block; 
    overflow-x: auto; 
    white-space: nowrap; 
    width: 100%; 
    -webkit-overflow-scrolling: touch;
  }
}

/* ─── LOGIN PAGE ──────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(circle 1100px at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(111, 172, 70, 0.18) 0%, transparent 70%),
                    radial-gradient(circle at 100% 100%, rgba(111,172,70,0.05) 0%, transparent 50%);
  color: var(--text);
  font-family: 'Jost', sans-serif;
}

[data-theme="light"] .login-body {
  background-image: radial-gradient(circle 1100px at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(111, 172, 70, 0.3) 0%, transparent 70%),
                    radial-gradient(circle at 100% 100%, rgba(111,172,70,0.1) 0%, transparent 50%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  z-index: 10;
  animation: fadeUp 0.6s ease-out forwards;
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-top: 15px;
  letter-spacing: -0.5px;
}

.login-header p {
  color: var(--text2);
  font-size: 14px;
  margin-top: 5px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Jost', sans-serif;
  font-size: 15px;
  transition: var(--transition);
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 10px;
  justify-content: center;
}

.login-error {
  color: var(--red);
  font-size: 14px;
  text-align: center;
  margin-bottom: 15px;
  background: var(--red-soft);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.login-footer {
  text-align: center;
  margin-top: 25px;
  color: var(--text3);
  font-size: 12px;
}

/* ── Stats page: period filters, KPI deltas, heatmap ──────────────────────── */
.stats-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.seg-control {
  display: inline-flex;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-control button {
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg-control button:hover { color: var(--text); background: var(--bg3); }
.seg-control button.active {
  background: var(--accent);
  color: #fff;
}
.stats-custom-dates { display: inline-flex; align-items: center; gap: 8px; }
.stats-date-sep { color: var(--text3); }

/* Диапазон времени в журнале проходов: держим «с [время] по [время] Сброс»
   единым блоком, чтобы в .filter-row он вёл себя как один элемент (а на мобиле
   не рассыпался по ячейкам grid). */
.time-range-filter { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats-period-label { font-size: 13px; color: var(--text3); margin-left: auto; }

.kpi-delta {
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  white-space: nowrap;
}
.kpi-delta.up   { color: var(--red); }    /* больше нарушений — плохо */
.kpi-delta.down { color: var(--accent); } /* меньше — хорошо */
.kpi-delta.flat { color: var(--text3); }

/* Перерисовка: держим прошлый рендер полупрозрачным, без скелетонов */
#stats-content.loading { opacity: .45; pointer-events: none; transition: opacity .15s; }
#stats-content { transition: opacity .15s; }

/* Легенда главного графика: прямоугольник = бары, штрих = линия */
.legend-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
}
.legend-line {
  display: inline-block;
  width: 16px; height: 0;
  border-top: 2px solid currentColor;
  vertical-align: 3px;
}

/* Heatmap день недели × час */
.heatmap {
  display: grid;
  grid-template-columns: 28px repeat(24, 1fr);
  gap: 2px; /* surface gap разделяет ячейки */
  align-items: stretch;
  padding: 6px 4px 0;
}
.heatmap .hm-cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 2px;
  background: var(--bg3);
  cursor: default;
}
.heatmap .hm-cell:hover { outline: 2px solid var(--accent); outline-offset: 0; }
.heatmap .hm-rowlabel, .heatmap .hm-collabel {
  font-size: 10px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
}
.heatmap .hm-collabel { padding-top: 4px; }
.heatmap-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text2);
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.heatmap-tooltip .hm-val { font-size: 14px; font-weight: 700; color: var(--text); }

@media (max-width: 900px) {
  .stats-period-label { margin-left: 0; width: 100%; }
}

/* ─── KPI-плитки на узком телефоне ─────────────────────────────────────────
   До 768px сетка уже в две колонки, но на 390px карточка — около 170px:
   иконка 42px + значение + подпись + .kpi-trend в одну строку не влезали, и
   тренд («↓ вошло ↑ вышло» у плитки занятости) прижимался к правому краю
   поверх подписи. Колонкой, а не flex-wrap: при переносе карточки с длинной
   подписью складывались под иконку, а короткие оставались в строку — ряд
   выглядел разнобоем. Стопка одинакова для всех плиток. */
@media (max-width: 520px) {
  .kpi-card { flex-direction: column; align-items: flex-start; padding: 14px; gap: 8px; }
  .kpi-icon { width: 34px; height: 34px; }
  .kpi-icon svg { width: 18px; height: 18px; }
  .kpi-value { font-size: 24px; }
  .kpi-trend { margin-left: 0; width: 100%; }
}

/* ─── Шапка графика и фильтры журнала на узком экране ──────────────────────
   .chart-header — flex со space-between, без переноса. На «Посещениях» справа
   в ней стоит сегмент-контрол из четырёх кнопок («Сегодня / 7 дней / 30 дней /
   Диапазон»), а у журнала проходов — четыре фильтра: на телефоне они не
   помещались, выдавливали заголовок в колонку в три-четыре строки и вылезали
   за правый край карточки. Переносим на отдельную строку. */
@media (max-width: 768px) {
  .chart-header { flex-wrap: wrap; gap: 10px; }
  .chart-header > div:first-child { flex: 1 1 100%; min-width: 0; }
  .chart-header .seg-control { width: 100%; }
  .chart-header .seg-control button { flex: 1 1 0; min-width: 0; padding-left: 6px; padding-right: 6px; }
  .chart-header .filter-row { width: 100%; flex-wrap: wrap; }
  .chart-header .filter-row .select-filter { flex: 1 1 130px; min-width: 0; }
  .stats-custom-dates { display: flex; flex-wrap: wrap; }
  .stats-custom-dates .select-filter { flex: 1 1 120px; min-width: 0; }
  .stats-custom-dates .btn { flex: 1 1 100%; justify-content: center; }
  .time-range-filter { flex-wrap: wrap; }

  /* Тепловая карта: 24 колонки по часам на 390px дают ячейки по 14px и
     нечитаемые подписи. Даём ей прокрутку внутри карточки, а не ужимаем. */
  .heatmap-scroll { overflow-x: auto; }
  .heatmap { min-width: 560px; }
}

/* ─── Чекбоксы: единый стиль по сервису ────────────────────────────────────
   Зелёная галка (accent) для ВСЕХ чекбоксов — раньше новые чекбоксы без
   inline-стиля получали системный синий и выбивались (модалка сотрудника).
   Текст подписей у чекбоксов — чуть мельче основного (12px). */
input[type="checkbox"] { accent-color: var(--green); cursor: pointer; }
label:has(> input[type="checkbox"]) { font-size: 12px !important; }
