/* ==========================================================================
   Админ-панель «кровмонтаж.31»
   Токены задают обе темы: компоненты не знают про светлую/тёмную,
   они используют только семантические переменные (--surface, --ink-*, …).
   ========================================================================== */

:root {
  /* Поверхности — мягкий тёплый серый, без «холодного» блеска */
  --bg: #F3F4F7;
  --bg-deep: #E8EBF1;
  --surface: #FBFBFC;
  --surface-2: #F6F7F9;
  --surface-3: #EEF0F4;
  --line: #DCE0E8;
  --line-soft: #E8EBF1;

  /* Текст — приглушённый контраст */
  --text: #1A2233;
  --text-2: #5A6575;
  --text-3: #8490A0;

  /* Акцент (янтарный, мягче неона) */
  --accent: #D9852E;
  --accent-2: #E69842;
  --accent-soft: rgba(217, 133, 46, 0.1);
  --accent-line: rgba(217, 133, 46, 0.24);
  --accent-ink: #A05F18;

  /* Основной (спокойный синий) */
  --info: #2A5A8F;
  --info-2: #3D7AB8;
  --info-soft: rgba(42, 90, 143, 0.07);
  --info-line: rgba(42, 90, 143, 0.16);
  --info-ink: #2A5A8F;

  /* Успех / опасность / ожидание — чуть приглушённые */
  --ok: #0D8F66;
  --ok-soft: rgba(13, 143, 102, 0.09);
  --ok-line: rgba(13, 143, 102, 0.2);
  --ok-ink: #067A56;
  --danger: #D04A4A;
  --danger-soft: rgba(208, 74, 74, 0.08);
  --danger-line: rgba(208, 74, 74, 0.2);
  --danger-ink: #B03A3A;
  --warn: #C9890E;
  --warn-soft: rgba(201, 137, 14, 0.1);
  --warn-ink: #A06E0A;

  /* Навигация (тёмная в обеих темах) */
  --nav-bg:
    radial-gradient(ellipse 90% 55% at 8% 0%, rgba(217, 133, 46, 0.14) 0%, transparent 58%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(61, 122, 184, 0.2) 0%, transparent 62%),
    linear-gradient(176deg, #0E1C30 0%, #153352 58%, #102845 100%);
  --nav-text: rgba(255, 255, 255, 0.68);
  --nav-text-strong: #F4F7FA;
  --nav-text-dim: rgba(255, 255, 255, 0.38);
  --nav-fill: rgba(255, 255, 255, 0.055);
  --nav-fill-2: rgba(255, 255, 255, 0.1);
  --nav-line: rgba(255, 255, 255, 0.08);

  /* Тени */
  --elev-1: 0 1px 2px rgba(26, 34, 51, 0.035), 0 1px 3px rgba(26, 34, 51, 0.04);
  --elev-2: 0 2px 4px -2px rgba(26, 34, 51, 0.04), 0 12px 24px -10px rgba(26, 34, 51, 0.1);
  --elev-3: 0 4px 8px -4px rgba(26, 34, 51, 0.05), 0 24px 48px -16px rgba(26, 34, 51, 0.16);
  --ring: 0 0 0 3px rgba(42, 90, 143, 0.14);
  --ring-accent: 0 0 0 3px rgba(217, 133, 46, 0.18);

  /* Геометрия */
  --r-xs: 10px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 100px;

  --gap: 14px;
  --pad-view: 28px;
  --sidebar-w: 268px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --duration-fast: 140ms;
  --duration: 260ms;
  --duration-slow: 480ms;

  --font: 'Figtree', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Sora', 'Figtree', system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0C131F;
  --bg-deep: #0A1018;
  --surface: #151F2E;
  --surface-2: #1A2636;
  --surface-3: #223044;
  --line: #2A3A4E;
  --line-soft: #1C2838;

  --text: #E2E8F0;
  --text-2: #8B9AAB;
  --text-3: #687889;

  --accent-soft: rgba(217, 133, 46, 0.14);
  --accent-line: rgba(217, 133, 46, 0.28);
  --accent-ink: #E5AB66;

  --info: #5B9AD6;
  --info-2: #8BB5E0;
  --info-soft: rgba(91, 154, 214, 0.12);
  --info-line: rgba(91, 154, 214, 0.26);
  --info-ink: #A3C8EC;

  --ok: #2BB88A;
  --ok-soft: rgba(43, 184, 138, 0.12);
  --ok-line: rgba(43, 184, 138, 0.24);
  --ok-ink: #6DD4AE;
  --danger: #E06B6B;
  --danger-soft: rgba(224, 107, 107, 0.12);
  --danger-line: rgba(224, 107, 107, 0.26);
  --danger-ink: #F0A8A8;
  --warn: #E0A84A;
  --warn-soft: rgba(224, 168, 74, 0.12);
  --warn-ink: #F0C878;

  --nav-bg:
    radial-gradient(ellipse 90% 55% at 6% 0%, rgba(217, 133, 46, 0.1) 0%, transparent 58%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(91, 154, 214, 0.14) 0%, transparent 62%),
    linear-gradient(176deg, #0A1018 0%, #111A27 60%, #0C131F 100%);

  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.28);
  --elev-2: 0 2px 4px -2px rgba(0, 0, 0, 0.32), 0 14px 28px -12px rgba(0, 0, 0, 0.5);
  --elev-3: 0 4px 10px -4px rgba(0, 0, 0, 0.36), 0 26px 52px -18px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(91, 154, 214, 0.2);
  --ring-accent: 0 0 0 3px rgba(217, 133, 46, 0.2);
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

body.is-login-view,
body.is-admin-view {
  overflow: hidden;
  height: 100dvh;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; }

/* Скелетон загрузки: подменяет числа, пока данные не пришли */
.is-loading .skeleton-target {
  color: transparent !important;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line-soft) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.3s infinite linear;
  user-select: none;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes navGlow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn--primary {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(160, 95, 24, 0.28), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(160, 95, 24, 0.32), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.65s var(--ease);
  pointer-events: none;
}
.btn--primary:hover:not(:disabled)::after { transform: translateX(120%); }

.btn--success {
  color: #fff;
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 1px 2px rgba(4, 120, 87, 0.28);
}
.btn--success:hover:not(:disabled) { filter: brightness(1.08); }

.btn--ghost {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--elev-1);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--info-ink);
  border-color: var(--info-line);
  background: var(--info-soft);
  transform: translateY(-1px);
  box-shadow: var(--elev-2);
}

.btn--danger {
  color: var(--danger-ink);
  background: transparent;
  border-color: var(--danger-line);
  padding: 10px 12px;
}
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn--call {
  color: var(--ok-ink);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}
.btn--call:hover:not(:disabled) { background: var(--ok); border-color: var(--ok); color: #fff; }

.btn--sm { padding: 8px 13px; font-size: 13px; }
.btn--full { width: 100%; }
.btn--icon-text { padding: 9px 14px; }
.btn--send {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--r-md);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--info-ink); border-color: var(--info-line); background: var(--info-soft); }
.icon-btn--call { color: var(--ok-ink); }
.icon-btn--call:hover { color: var(--ok-ink); background: var(--ok-soft); border-color: var(--ok-line); }

/* ===== Плашки статусов ===== */
.status-badge,
.inbox__item-badge,
.leads__item-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
}
.status-badge--open,
.inbox__item-badge--waiting,
.status-badge--progress,
.leads__item-badge--progress { background: var(--info-soft); color: var(--info-ink); }
.status-badge--new,
.inbox__item-badge--new,
.leads__item-badge--new { background: var(--accent-soft); color: var(--accent-ink); }
.status-badge--resolved,
.status-badge--done,
.inbox__item-badge--resolved,
.leads__item-badge--done { background: var(--ok-soft); color: var(--ok-ink); }

/* ===== Поля ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}
.field input,
.inbox__search-input,
.active-chat__reply textarea {
  width: 100%;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    background var(--duration) var(--ease);
}
.field input { padding: 12px 14px; font-size: 15px; }
.field input:hover:not(:focus),
.inbox__search-input:hover:not(:focus),
.active-chat__reply textarea:hover:not(:focus) {
  border-color: color-mix(in srgb, var(--info) 30%, var(--line));
}
.field input:focus,
.inbox__search-input:focus,
.active-chat__reply textarea:focus {
  border-color: var(--info);
  box-shadow: var(--ring);
  background: var(--surface);
}
.field input::placeholder,
.inbox__search-input::placeholder,
.active-chat__reply textarea::placeholder { color: var(--text-3); }

/* ===== Экран входа ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}
.login-screen.is-hidden,
.login-screen[hidden] { display: none !important; }

.login-screen__brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
  overflow: hidden;
  background: var(--nav-bg);
  color: #fff;
}
.login-screen__brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 15% 85%, rgba(217, 133, 46, 0.14) 0%, transparent 62%),
    radial-gradient(ellipse 55% 45% at 85% 10%, rgba(64, 120, 175, 0.18) 0%, transparent 58%);
}
.login-screen__brand::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 0%, transparent 75%);
}
.login-screen__brand-inner {
  position: relative;
  z-index: 1;
  max-width: 380px;
  animation: fadeUp 0.5s var(--ease) both;
}
.login-screen__logo {
  border-radius: var(--r-md);
  margin-bottom: 24px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}
.login-screen__brand-inner h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.login-screen__brand-inner > p {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.66);
  margin-bottom: 28px;
}
.login-screen__features { list-style: none; }
.login-screen__features li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  border-top: 1px solid var(--nav-line);
}
.login-screen__features li::before {
  content: '';
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-screen__form-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  background:
    radial-gradient(ellipse 60% 45% at 85% 5%, var(--accent-soft) 0%, transparent 62%),
    radial-gradient(ellipse 55% 45% at 10% 95%, var(--info-soft) 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--elev-3);
  animation: scaleIn 0.55s var(--ease) 0.08s both;
  transition: box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.login-card:focus-within {
  border-color: var(--info-line);
  box-shadow: var(--elev-3), var(--ring);
}
.login-card__head { margin-bottom: 24px; }
.login-card__head h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-card__head p { font-size: 14px; color: var(--text-2); }
.login-error {
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger-ink);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--r-sm);
}
.login-hint {
  margin-bottom: 18px;
  font-size: 12px;
  text-align: center;
  color: var(--text-3);
}
.login-card__footer { margin-top: 22px; text-align: center; font-size: 14px; }
.login-card__footer a {
  color: var(--info-ink);
  font-weight: 600;
  text-decoration: none;
}
.login-card__footer a:hover { color: var(--accent); }

/* ===== Каркас приложения ===== */
.dashboard { display: none; }
.dashboard[hidden] { display: none !important; }
.dashboard.is-active {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  animation: fadeUp 0.45s var(--ease) both;
}

/* ===== Боковая панель ===== */
.sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 20px 14px 16px;
  overflow: hidden;
  color: var(--nav-text);
  background: var(--nav-bg);
  /* Отделяет панель от контента в тёмной теме, где фоны близки */
  box-shadow: 1px 0 0 var(--nav-line), 10px 0 36px -16px rgba(0, 0, 0, 0.45);
}
/* Тонкая сетка + шум: убирает «плоскость» тёмной панели */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 20%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 20%, #000 0%, transparent 78%);
}
.sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.sidebar > * { position: relative; z-index: 1; }

.sidebar__brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px 16px;
  border-bottom: 1px solid var(--nav-line);
}
.sidebar__brand img {
  border-radius: var(--r-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.sidebar__brand-name {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--nav-text-strong);
}
.sidebar__brand-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--nav-text-dim);
}

.sidebar__section-label {
  padding: 0 8px;
  margin-bottom: -8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nav-text-dim);
}

.sidebar__nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar__nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  text-align: left;
  color: var(--nav-text);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    transform var(--duration-fast) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.sidebar__nav-item:hover { color: var(--nav-text-strong); background: var(--nav-fill); }
.sidebar__nav-item:active { transform: scale(0.985); }
.sidebar__nav-item.is-active {
  color: var(--nav-text-strong);
  background: linear-gradient(90deg, rgba(217, 133, 46, 0.16), var(--nav-fill-2) 55%);
  box-shadow: inset 0 0 0 1px var(--nav-line);
}
.sidebar__nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  width: 3px;
  height: 24px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px rgba(217, 133, 46, 0.55);
  animation: navGlow 2.8s var(--ease-soft) infinite;
}
.sidebar__nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  background: var(--nav-fill);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease-spring);
}
.sidebar__nav-item:hover .sidebar__nav-icon { transform: translateY(-1px); }
.sidebar__nav-item.is-active .sidebar__nav-icon {
  color: var(--accent-2);
  background: rgba(217, 133, 46, 0.18);
  transform: none;
}
.sidebar__nav-text-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.sidebar__nav-text { font-size: 14px; font-weight: 600; }
.sidebar__nav-desc {
  font-size: 11px;
  line-height: 1.25;
  color: var(--nav-text-dim);
}
.sidebar__nav-item.is-active .sidebar__nav-desc { color: rgba(255, 255, 255, 0.6); }

.sidebar__badge {
  flex-shrink: 0;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  color: #fff;
  background: var(--accent);
  border-radius: var(--r-pill);
  box-shadow: 0 2px 8px rgba(217, 133, 46, 0.45);
}
.sidebar__badge--leads { background: var(--info-2); box-shadow: 0 2px 8px rgba(64, 120, 175, 0.4); }

/* Статус на сайте */
.sidebar__schedule-group {
  padding: 12px 13px;
  background: var(--nav-fill);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-md);
}
.sidebar__status-eyebrow {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nav-text-dim);
}
.sidebar__status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--nav-text-strong);
}
.sidebar__status-dot {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #64748B;
}
.sidebar__status--online .sidebar__status-dot {
  background: #3DBF8C;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22);
  animation: pulse 2.4s infinite;
}
.sidebar__status--lunch .sidebar__status-dot {
  background: #E0A84A;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.22);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22); }
  50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.08); }
}
.sidebar__schedule { margin-top: 8px; }
.sidebar__schedule-text {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.56);
  text-wrap: pretty;
}
.sidebar__schedule-meta {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}
.sidebar__auto-reason {
  margin-top: 9px;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  color: #F7B172;
  background: rgba(217, 133, 46, 0.14);
  border: 1px solid rgba(217, 133, 46, 0.24);
  border-radius: var(--r-xs);
}

/* Подсказка */
.sidebar__help {
  margin-bottom: auto;
  padding: 12px 13px;
  background: var(--nav-fill);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-md);
}
.sidebar__help-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nav-text-dim);
}
.sidebar__help-list {
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
}
.sidebar__help-list li + li { margin-top: 4px; }

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--nav-line);
}
.sidebar__site-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  border-radius: var(--r-xs);
  transition: color 0.18s, background 0.18s;
}
.sidebar__site-link:hover { color: #fff; background: var(--nav-fill); }

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  background: var(--nav-fill);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-md);
}
.sidebar__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-radius: var(--r-xs);
}
.sidebar__user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.sidebar__user-info span:first-child {
  font-size: 13px;
  font-weight: 600;
  color: var(--nav-text-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar__user-role { font-size: 11px; color: var(--nav-text-dim); }

.sidebar__sound,
.sidebar__logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.55);
  background: var(--nav-fill);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sidebar__sound:hover { color: #fff; background: var(--nav-fill-2); }
.sidebar__sound.is-muted { color: rgba(255, 255, 255, 0.3); }
.sidebar__logout:hover {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Переключатель темы */
.theme-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-sm);
}
.theme-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  background: transparent;
  transition: color 0.18s, background 0.18s;
}
.theme-switch--sidebar {
  background: var(--nav-fill);
  border: 1px solid var(--nav-line);
}
.theme-switch--sidebar .theme-switch__btn { color: rgba(255, 255, 255, 0.55); }
.theme-switch--sidebar .theme-switch__btn:hover { color: rgba(255, 255, 255, 0.9); }
.theme-switch--sidebar .theme-switch__btn.is-active {
  color: #fff;
  background: var(--nav-fill-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.theme-switch--login {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--elev-1);
}
.theme-switch--login .theme-switch__btn { color: var(--text-3); }
.theme-switch--login .theme-switch__btn:hover { color: var(--text); }
.theme-switch--login .theme-switch__btn.is-active {
  color: var(--text);
  background: var(--surface-3);
}

/* ===== Основная область ===== */
.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.main-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.main-view.is-active {
  display: flex;
  animation: viewEnter var(--duration-slow) var(--ease) both;
}
.main-view.is-active.is-view-enter {
  animation: viewEnter 0.42s var(--ease) both;
}

.main__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 24px var(--pad-view) 4px;
  flex-shrink: 0;
}
.main__header-left { flex: 1 1 280px; min-width: 0; }
.main__header-action { margin-left: auto; flex-shrink: 0; }
.main__header-tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  flex: 0 1 auto;
  max-width: 100%;
}
.main__header-tools .btn {
  flex-shrink: 0;
  align-self: center;
}
.main__eyebrow {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.main__title {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.15;
}
.main__title-short { display: none; }
.main__subtitle {
  margin-top: 5px;
  font-size: 14px;
  color: var(--text-2);
}

/* Ряд статистики в шапке */
.stats-row {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 560px;
  margin-top: 4px;
}
.main__header-tools .stats-row,
.stats-row--compact {
  flex: 0 1 420px;
  width: auto;
  min-width: 200px;
  max-width: 420px;
  margin-top: 0;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-1);
}
.stat-card--accent {
  border-color: var(--accent-line);
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 55%),
    var(--surface);
}
.stat-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xs);
}
.stat-card__icon--blue {
  color: var(--info-ink);
  background: var(--info-soft);
  border-color: var(--info-line);
}
.stat-card__icon--green {
  color: var(--ok-ink);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}
.stat-card__body { min-width: 0; }
.stat-card__value {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
}
.stat-card--accent .stat-card__value { color: var(--accent-ink); }
.stat-card__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ===== Общая карточка-панель ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
}

/* ===== Главная ===== */
.home {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px var(--pad-view) var(--pad-view);
}
.home::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 220px;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 80% at 12% 0%, rgba(217, 133, 46, 0.12), transparent 60%),
    radial-gradient(ellipse 50% 70% at 88% 10%, rgba(26, 74, 138, 0.1), transparent 55%);
  z-index: 0;
}
[data-theme="dark"] .home::before {
  background:
    radial-gradient(ellipse 70% 90% at 10% 0%, rgba(217, 133, 46, 0.18), transparent 58%),
    radial-gradient(ellipse 55% 80% at 90% 8%, rgba(78, 143, 216, 0.12), transparent 55%);
}
.home > * { position: relative; z-index: 1; }

.home-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background:
    linear-gradient(135deg, rgba(217, 133, 46, 0.06), transparent 42%),
    var(--surface);
  box-shadow: var(--elev-1);
  backdrop-filter: blur(8px);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
  animation: fadeUp 0.45s var(--ease) both;
}
.home-hero:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-2);
}
.home-hero--ok {
  border-color: var(--ok-line);
  background:
    linear-gradient(135deg, rgba(5, 150, 105, 0.07), transparent 45%),
    var(--surface);
}
.home-hero--busy {
  border-color: var(--accent-line);
  background:
    linear-gradient(135deg, rgba(217, 133, 46, 0.12), transparent 48%),
    var(--surface);
  box-shadow: var(--elev-1), 0 0 0 1px rgba(217, 133, 46, 0.06);
}
.home-hero__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
}
.home-hero--ok .home-hero__icon { color: var(--ok-ink); background: var(--ok-soft); }
.home-hero--busy .home-hero__icon { color: var(--accent-ink); background: var(--accent-soft); }
.home-hero__body { flex: 1; min-width: 0; }
.home-hero__title { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.home-hero__text {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}
.home-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.home-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 12px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-1);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform var(--duration) var(--ease-spring),
    background var(--duration) var(--ease);
  animation: fadeUp 0.5s var(--ease) both;
}
.home-kpis .kpi:nth-child(1) { animation-delay: 0.04s; }
.home-kpis .kpi:nth-child(2) { animation-delay: 0.1s; }
.home-kpis .kpi:nth-child(3) { animation-delay: 0.16s; }
.home-kpis .kpi:nth-child(4) { animation-delay: 0.22s; }
button.kpi { cursor: pointer; }
button.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--accent-line);
  box-shadow: var(--elev-2);
  background: var(--surface);
}
button.kpi:active { transform: translateY(0) scale(0.985); }
.kpi__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: var(--info-ink);
  background: var(--info-soft);
  border: 1px solid var(--info-line);
  border-radius: var(--r-xs);
}
.kpi--accent .kpi__icon {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.kpi--ok .kpi__icon {
  color: var(--ok-ink);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}
.kpi__body { min-width: 0; }
.kpi__value {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.kpi--accent .kpi__value { color: var(--accent-ink); }
.kpi__label {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-board {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.85fr);
  gap: 12px;
  align-items: start;
}
.home-board__queue,
.home-board__aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.home-panel {
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-1);
  overflow: hidden;
  backdrop-filter: blur(10px);
}
.home-panel--priority {
  border-color: var(--accent-line);
  box-shadow: var(--elev-1), inset 0 1px 0 rgba(217, 133, 46, 0.08);
}
.home-panel--traffic { min-height: 220px; }
.home-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--surface-2), transparent);
}
.home-panel__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.home-panel__count {
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: var(--r-pill);
}
.home-panel__count--accent { color: var(--accent-ink); background: var(--accent-soft); }
.home-panel__link {
  font-size: 12px;
  font-weight: 600;
  color: var(--info-ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.home-panel__link:hover { color: var(--accent); }

.home-list { list-style: none; }
.home-list__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.15s;
}
.home-list li:last-child .home-list__item { border-bottom: none; }
.home-list__item:hover { background: var(--surface-2); }
.home-list__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, var(--info), var(--info-2));
  border-radius: 10px;
}
.home-list__avatar--accent { background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.home-list__body { flex: 1; min-width: 0; }
.home-list__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.home-list__name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.home-list__time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-3);
}
.home-list__text {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-list__meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
}
.home-list__badge {
  display: inline-flex;
  margin-top: 5px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--r-pill);
}
.home-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  text-align: center;
}
.home-list__empty svg { color: var(--text-3); margin-bottom: 2px; opacity: 0.7; }
.home-list__empty strong { font-size: 13px; font-weight: 700; }
.home-list__empty span { font-size: 12px; color: var(--text-2); max-width: 220px; }

/* Мини-график трафика на главной */
.home-traffic { padding: 14px; }
.home-traffic__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.home-traffic__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.home-traffic__label { margin-top: 4px; font-size: 12px; color: var(--text-2); }
.home-traffic__today {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.home-spark {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 96px;
  padding: 8px 4px 0;
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, transparent, var(--surface-2)),
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 23px,
      var(--line-soft) 23px,
      var(--line-soft) 24px
    );
}
.home-spark__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  height: 100%;
  justify-content: flex-end;
}
.home-spark__bar {
  width: 100%;
  max-width: 28px;
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--info-2), var(--info));
  box-shadow: 0 4px 10px -6px rgba(26, 74, 138, 0.55);
  transition: height 0.7s var(--ease), background 0.35s var(--ease), box-shadow 0.35s var(--ease), transform 0.25s var(--ease);
  transform-origin: bottom center;
}
.home-spark__col:hover .home-spark__bar {
  transform: scaleY(1.04);
}
.home-spark__col.is-today .home-spark__bar {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 12px -5px rgba(217, 133, 46, 0.65);
}
.home-spark__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}

.home-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}
.home-footer__hint { font-size: 11px; line-height: 1.4; color: var(--text-3); }

/* ===== Обращения и заявки: общий двухколоночный каркас ===== */
.inbox,
.leads {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  flex: 1;
  min-height: 0;
  margin: 10px var(--pad-view) var(--pad-view);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
}

.inbox__list-wrap,
.leads__list-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.inbox__toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.filter-tabs,
.leads-filter-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.filter-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-3);
  background: transparent;
  border: none;
  border-radius: calc(var(--r-sm) - 4px);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform var(--duration-fast) var(--ease);
}
.filter-tab:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.filter-tab:active { transform: scale(0.98); }
.filter-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--elev-1), inset 0 0 0 1px var(--line);
}
[data-theme="dark"] .filter-tab.is-active {
  background: color-mix(in srgb, var(--surface) 70%, #ffffff 8%);
  box-shadow: var(--elev-1), inset 0 0 0 1px var(--line);
}
/* Подчёркивание у всех табов (прозрачное) — высота не прыгает; как в заявках */
.filter-tab::after {
  content: '';
  display: block;
  width: 16px;
  height: 2px;
  margin: 5px auto 0;
  border-radius: 2px;
  background: transparent;
  transition: background var(--duration) var(--ease);
}
.filter-tab.is-active::after {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.inbox__search-wrap { position: relative; }
.inbox__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.inbox__search-input {
  padding: 10px 12px 10px 36px;
  font-size: 13px;
  background: var(--surface);
}

.inbox__list,
.leads__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
}
.inbox__list-wrap.is-empty .inbox__list,
.leads__list-wrap.is-empty .leads__list { display: none; }
.inbox__list-wrap:not(.is-empty) .inbox__empty,
.leads__list-wrap:not(.is-empty) .inbox__empty { display: none !important; }

.inbox__item,
.leads__item {
  display: flex;
  gap: 11px;
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}
.inbox__item:hover,
.leads__item:hover { background: var(--surface-2); }
.inbox__item.is-active,
.leads__item.is-active {
  background: linear-gradient(90deg, var(--info-soft), transparent 85%);
  box-shadow: inset 3px 0 0 var(--info);
}
.inbox__item:active,
.leads__item:active { transform: scale(0.995); }
.inbox__item.is-unread .inbox__item-name { font-weight: 700; }
.inbox__item.is-resolved:not(.is-active) { opacity: 0.6; }

.inbox__item-avatar,
.leads__item-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, var(--info), var(--info-2));
  border-radius: var(--r-xs);
}
.inbox__item-avatar--accent,
.leads__item.is-new .leads__item-avatar {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.inbox__item-body,
.leads__item-body { flex: 1; min-width: 0; }
.inbox__item-top,
.leads__item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.inbox__item-name,
.leads__item-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.inbox__item-time,
.leads__item-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-3);
}
.inbox__item-preview,
.leads__item-preview {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.inbox__item-contact,
.leads__item-phone {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
}
.leads__item-phone { margin: 0 0 2px; font-weight: 600; color: var(--text-2); }
.inbox__item-unread {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  vertical-align: middle;
  background: var(--accent);
  border-radius: 50%;
}
.inbox__item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.leads__item-badge { margin-top: 7px; }
.inbox__item-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
}

/* Пустые состояния */
.inbox__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
}
.inbox__empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin-bottom: 6px;
  color: var(--info-ink);
  background:
    radial-gradient(ellipse 70% 70% at 30% 20%, var(--accent-soft) 0%, transparent 62%),
    var(--info-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-1);
}
.inbox__empty p { font-family: var(--font-display); font-size: 16px; font-weight: 800; }
.inbox__empty span {
  max-width: 250px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}

/* Заглушка правой колонки */
.inbox__chat,
.leads__detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 100% 0%, var(--info-soft) 0%, transparent 55%),
    var(--surface-2);
}
.inbox__placeholder,
.leads__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 10px;
  padding: 40px 32px;
  text-align: center;
}
.inbox__placeholder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  margin-bottom: 6px;
  color: var(--info-ink);
  background:
    radial-gradient(ellipse 80% 80% at 25% 15%, var(--accent-soft) 0%, transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--elev-2);
  animation: scaleIn 0.5s var(--ease-spring) both;
}
.inbox__placeholder h3,
.leads__placeholder h3 { font-size: 19px; font-weight: 800; }
.inbox__placeholder > p,
.leads__placeholder > p {
  max-width: 320px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}
.inbox__placeholder-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}
.tip-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.tip-chip__dot { width: 8px; height: 8px; border-radius: 50%; }
.tip-chip__dot--new { background: var(--accent); }
.tip-chip__dot--wait { background: var(--info-2); }
.tip-chip__dot--done { background: var(--ok); }

.inbox__chat.has-chat .inbox__placeholder,
.leads__detail.has-lead .leads__placeholder { display: none !important; }
.inbox__chat .active-chat,
.leads__detail .active-lead { display: none; }
.inbox__chat.has-chat .active-chat,
.leads__detail.has-lead .active-lead {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* ===== Активный диалог ===== */
.active-chat__header,
.active-lead__header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.active-chat__back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.active-chat__back:hover { color: var(--info-ink); border-color: var(--info-line); }

.active-chat__visitor-avatar,
.active-lead__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, var(--info), var(--info-2));
  border-radius: var(--r-md);
}
.active-chat__visitor-avatar--accent {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.active-chat__visitor,
.active-lead__info { flex: 1; min-width: 0; }
.active-chat__visitor-top,
.active-lead__top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.active-chat__visitor h3,
.active-lead__top h3 {
  font-size: 17px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.active-chat__contact-row,
.active-lead__contact-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  min-width: 0;
}
.active-chat__contact-row p {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.active-lead__phone {
  font-size: 14px;
  font-weight: 700;
  color: var(--info-ink);
  text-decoration: none;
}
.active-lead__phone:hover { text-decoration: underline; }
.active-chat__header time,
.active-lead__header time {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
}
.active-chat__actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.active-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--surface-2);
}
.msg { max-width: 72%; }
.msg--visitor { align-self: flex-start; }
.msg--admin { align-self: flex-end; }
.msg.msg--new { animation: msgIn 0.3s var(--ease) both; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg__bubble {
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: var(--r-lg);
  word-break: break-word;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.msg:hover .msg__bubble { transform: translateY(-1px); }
.msg--visitor .msg__bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--elev-1);
}
.msg--admin .msg__bubble {
  color: #fff;
  background: linear-gradient(140deg, var(--info), var(--info-2));
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px -8px rgba(31, 78, 150, 0.6);
}
.msg__time {
  margin-top: 4px;
  padding: 0 5px;
  font-size: 11px;
  color: var(--text-3);
  opacity: 0.75;
  transition: opacity var(--duration) var(--ease);
}
.msg:hover .msg__time { opacity: 1; }
.msg--admin .msg__time { text-align: right; }
.msg__date-divider {
  align-self: center;
  margin: 6px 0;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}

.active-chat__compose {
  flex-shrink: 0;
  padding: 14px 18px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.active-chat__compose-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.quick-replies-toggle { display: none; }
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}
.quick-reply {
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--info-ink);
  background: var(--info-soft);
  border: 1px solid var(--info-line);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.quick-reply:hover { color: #fff; background: var(--info); border-color: var(--info); }

.active-chat__reply {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.active-chat__reply textarea {
  flex: 1;
  min-height: 44px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.active-chat__hint {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: var(--text-3);
}

/* ===== Карточка заявки ===== */
.lead-workflow {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.lead-workflow__step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.lead-workflow__step.is-clickable { cursor: pointer; }
.lead-workflow__step.is-clickable:hover { border-color: var(--info-line); color: var(--text); }
.lead-workflow__dot {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.2s, box-shadow 0.2s;
}
.lead-workflow__step.is-active {
  color: var(--info-ink);
  background: var(--info-soft);
  border-color: var(--info-line);
}
.lead-workflow__step.is-active .lead-workflow__dot {
  background: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}
.lead-workflow__step.is-done {
  color: var(--ok-ink);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}
.lead-workflow__step.is-done .lead-workflow__dot { background: var(--ok); }
.lead-workflow__line {
  flex: 1;
  height: 2px;
  min-width: 12px;
  background: var(--line);
  border-radius: 2px;
}
.lead-workflow__line.is-done { background: var(--ok-line); }

.active-lead__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background: var(--surface-2);
}
.active-lead__label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.active-lead__message {
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-1);
}
.active-lead__message:empty::before {
  content: 'Клиент не оставил сообщение';
  color: var(--text-3);
  font-style: italic;
}
.active-lead__actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  padding: 14px 18px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.active-lead__actions #lead-primary-btn { order: 1; }
.active-lead__actions .btn--call { order: 2; }
.active-lead__actions #lead-delete-btn { order: 3; margin-left: auto; }

/* ===== Статистика ===== */
.analytics {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px var(--pad-view) var(--pad-view);
}

.analytics-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  overflow: hidden;
  color: #fff;
  background: var(--nav-bg);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
}
.analytics-hero__glow {
  position: absolute;
  top: -60%;
  right: -6%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(217, 133, 46, 0.34) 0%, transparent 66%);
  pointer-events: none;
}
.analytics-hero__content { position: relative; z-index: 1; min-width: 0; }
.analytics-hero__eyebrow {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.analytics-hero__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.analytics-hero__value {
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 800;
  line-height: 1;
}
.analytics-hero__trend {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.14);
}
.analytics-hero__trend.is-up { color: #6EE7B7; background: rgba(16, 185, 129, 0.24); }
.analytics-hero__trend.is-down { color: #FCA5A5; background: rgba(239, 68, 68, 0.22); }
.analytics-hero__trend.is-flat { color: rgba(255, 255, 255, 0.8); }
.analytics-hero__sub { font-size: 14px; color: rgba(255, 255, 255, 0.7); }
.analytics-hero__spark {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
  width: min(160px, 30%);
  height: 56px;
}
.analytics-spark-bar {
  flex: 1;
  min-width: 5px;
  max-width: 18px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, rgba(240, 143, 48, 0.95), rgba(217, 133, 46, 0.45));
  transition: height 0.5s var(--ease);
}

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.analytics-kpi {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-1);
}
.analytics-kpi__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
}
.analytics-kpi__icon--chat { color: var(--info-ink); background: var(--info-soft); }
.analytics-kpi__icon--leads { color: var(--accent-ink); background: var(--accent-soft); }
.analytics-kpi__icon--msg { color: var(--ok-ink); background: var(--ok-soft); }
.analytics-kpi__value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.05;
}
.analytics-kpi__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.analytics-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.analytics-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-1);
}
.analytics-metric--total { border-color: var(--info-line); }
.analytics-metric__value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}
.analytics-metric__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.analytics-metric__sub { font-size: 12px; color: var(--text-2); }

.analytics__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: var(--gap);
  align-items: start;
}
.analytics-panel {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-1);
}
.analytics-panel h3 { font-size: 15px; font-weight: 800; }
.analytics-panel__desc {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}
.analytics-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.analytics-period {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}
.analytics-period__btn {
  padding: 6px 11px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.analytics-period__btn.is-active {
  color: var(--info-ink);
  background: var(--surface);
  box-shadow: var(--elev-1);
}

.analytics-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.analytics-legend__item { display: flex; align-items: center; gap: 6px; }
.analytics-legend__dot { width: 9px; height: 9px; border-radius: 3px; }
.analytics-legend__dot--views { background: var(--info); }
.analytics-legend__dot--uniq { background: var(--accent); }

.analytics-chart-wrap {
  overflow-x: auto;
  scrollbar-width: none;
}
.analytics-chart-wrap::-webkit-scrollbar { display: none; }
.analytics-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: min(100%, 520px);
  height: 190px;
  padding: 0 4px 2px;
  border-bottom: 1px solid var(--line);
  /* Горизонтальные направляющие: числа читаются без осевой разметки */
  background-image: repeating-linear-gradient(
    to top,
    var(--line-soft) 0,
    var(--line-soft) 1px,
    transparent 1px,
    transparent 37.5px
  );
  background-position: 0 -2px;
}
.analytics-chart__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 26px;
  border-radius: var(--r-xs) var(--r-xs) 0 0;
  transition: background var(--duration) var(--ease);
}
.analytics-chart__col:hover { background: var(--surface-3); }
.analytics-chart__bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 150px;
}
.analytics-chart__bar {
  flex: 1;
  max-width: 13px;
  min-height: 3px;
  border-radius: 5px 5px 2px 2px;
  transition: height 0.75s var(--ease), filter 0.25s var(--ease), transform 0.25s var(--ease);
  transform-origin: bottom center;
}
.analytics-chart__col:hover .analytics-chart__bar {
  filter: brightness(1.08);
  transform: scaleY(1.03);
}
.analytics-chart__bar--views { background: linear-gradient(180deg, var(--info-2), var(--info)); }
.analytics-chart__bar--uniq { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.analytics-chart__tip {
  min-height: 12px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--info-ink);
}
.analytics-chart__label {
  max-width: 100%;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.analytics-side {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.analytics-ref-list,
.analytics-visit-list {
  list-style: none;
  margin-top: 12px;
}
.analytics-ref { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.analytics-ref:last-child { border-bottom: none; padding-bottom: 0; }
.analytics-ref__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13px;
}
.analytics-ref__name {
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.analytics-ref__count {
  flex-shrink: 0;
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  color: var(--info-ink);
  background: var(--info-soft);
  border-radius: var(--r-pill);
}
.analytics-ref__bar {
  height: 5px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--r-pill);
}
.analytics-ref__fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--info), var(--info-2));
  transition: width 0.6s var(--ease);
}

.analytics-visit {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.analytics-visit:last-child { border-bottom: none; padding-bottom: 0; }
.analytics-visit__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
}
.analytics-visit__body { flex: 1; min-width: 0; }
.analytics-visit__source {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.analytics-visit__meta { margin-top: 1px; font-size: 11px; color: var(--text-3); }
.analytics-list__empty {
  padding: 18px 12px;
  font-size: 13px;
  text-align: center;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

.analytics__note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 13px 15px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-2);
  background: var(--info-soft);
  border: 1px solid var(--info-line);
  border-radius: var(--r-md);
}
.analytics__note svg { flex-shrink: 0; margin-top: 1px; color: var(--info-ink); }

/* ===== Тост и модалка ===== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #152033 0%, #101828 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-pill);
  box-shadow: var(--elev-3), 0 0 0 1px rgba(217, 133, 46, 0.12);
  animation: toastIn 0.4s var(--ease-spring);
  backdrop-filter: blur(12px);
}
[data-theme="dark"] .toast {
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.94); filter: blur(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); filter: none; }
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-modal[hidden] { display: none !important; }
.confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 18, 32, 0.52);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  animation: backdropIn 0.28s var(--ease) both;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
[data-theme="dark"] .confirm-modal__backdrop { background: rgba(0, 0, 0, 0.62); }
.confirm-modal__dialog {
  position: relative;
  width: min(100%, 420px);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--elev-3);
  animation: modalIn 0.36s var(--ease-spring) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
.confirm-modal__title { margin-bottom: 8px; font-size: 18px; font-weight: 800; }
.confirm-modal__text {
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}
.confirm-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* Нижний таббар — только мобильный */
.mobile-tabbar { display: none; }

/* ==========================================================================
   Адаптив
   ========================================================================== */

/* Компактный десктоп */
@media (max-width: 1280px) {
  :root { --pad-view: 20px; --sidebar-w: 244px; }
  .analytics__grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .analytics__grid { grid-template-columns: minmax(0, 1fr); }
  .analytics-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox, .leads { grid-template-columns: minmax(260px, 300px) 1fr; }
}

/* ===== Мобильная оболочка ===== */
@media (max-width: 900px) {
  :root { --pad-view: 14px; }

  /* Вход */
  .login-screen { grid-template-columns: 1fr; }
  .login-screen__brand { display: none; }
  .login-screen__form-wrap {
    min-height: 100dvh;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 18px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .login-card { max-width: 420px; padding: 24px 20px; }
  .field input { font-size: 16px; }
  .theme-switch--login {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
  }

  /* Каркас: верхняя панель, контент, таббар */
  .dashboard.is-active {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--bg);
  }

  /* Боковая панель превращается в один компактный ряд */
  .sidebar {
    grid-row: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: auto;
    flex-shrink: 0;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    overflow: visible;
  }
  .sidebar::before { display: none; }
  .sidebar__brand {
    flex: 1;
    min-width: 0;
    gap: 9px;
    padding: 0;
    border: none;
  }
  .sidebar__brand img { width: 30px; height: 30px; }
  .sidebar__brand-sub { display: none; }
  .sidebar__section-label,
  .sidebar__nav,
  .sidebar__help,
  .sidebar__schedule,
  .sidebar__site-link,
  .sidebar__user-info,
  .sidebar__avatar { display: none; }

  .sidebar__schedule-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
  }
  .sidebar__status-eyebrow { display: none; }
  .sidebar__status--chip {
    max-width: min(40vw, 150px);
    padding: 6px 10px;
    font-size: 11px;
    background: var(--nav-fill-2);
    border: 1px solid var(--nav-line);
    border-radius: var(--r-pill);
    pointer-events: none;
  }
  .sidebar__status--chip #work-status-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .sidebar__status-dot { width: 7px; height: 7px; }

  .sidebar__footer {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 0;
    border: none;
  }
  .sidebar__user { padding: 0; background: none; border: none; gap: 6px; }
  .theme-switch--sidebar { padding: 2px; }
  .theme-switch--sidebar .theme-switch__btn {
    min-width: 32px;
    padding: 6px;
    font-size: 0;
    gap: 0;
  }
  .theme-switch--sidebar .theme-switch__btn svg { width: 15px; height: 15px; }

  /* Контент */
  .main { grid-row: 2; min-height: 0; background: transparent; }
  .main__header { padding: 14px var(--pad-view) 2px; gap: 10px; }
  .main__eyebrow,
  .main__subtitle,
  .main__title-full { display: none; }
  .main__title-short { display: inline; }
  .main__title { font-size: 21px; }
  .main__header-action {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: var(--r-sm);
  }
  .main__header-action .btn__text { display: none; }

  .stats-row { max-width: none; gap: 8px; margin-top: 2px; }
  .stats-row--compact .stat-card {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px;
    text-align: center;
  }
  .stats-row--compact .stat-card__icon { display: none; }
  .stats-row--compact .stat-card__value { font-size: 19px; }
  .stats-row--compact .stat-card__label { font-size: 9px; }

  /* Главная */
  .home { padding: 6px var(--pad-view) var(--pad-view); }
  .home::before { height: 160px; }
  .home-hero { flex-wrap: wrap; padding: 12px 14px; }
  .home-hero__icon { width: 38px; height: 38px; }
  .home-hero__title { font-size: 16px; }
  .home-hero__actions { flex: 1 1 100%; }
  .home-hero__actions .btn { flex: 1; }
  .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { gap: 8px; padding: 10px; }
  .kpi__icon { width: 30px; height: 30px; }
  .kpi__value { font-size: 19px; }
  .kpi__label { font-size: 10px; }
  .home-board { grid-template-columns: minmax(0, 1fr); }

  /* Обращения / заявки */
  .inbox,
  .leads {
    display: flex;
    flex-direction: column;
    margin: 8px var(--pad-view) var(--pad-view);
    border-radius: var(--r-lg);
  }
  .inbox__list-wrap,
  .leads__list-wrap {
    flex: 1;
    min-height: 0;
    border-right: none;
  }
  .inbox__toolbar { padding: 10px; }
  .filter-tab { padding: 8px 4px; font-size: 11px; }
  .inbox__search-input { font-size: 16px; padding: 11px 12px 11px 36px; }
  .inbox__item,
  .leads__item { padding: 12px 14px; }
  .inbox__item-avatar,
  .leads__item-avatar { width: 42px; height: 42px; font-size: 14px; }
  .inbox__item-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
  }
  #view-inbox .stats-row--compact,
  #view-leads .stats-row--compact { display: none; }

  /* Диалог и заявка раскрываются на весь экран */
  .inbox:not(.is-chat-open) .inbox__chat { display: none !important; }
  .inbox.is-chat-open .inbox__list-wrap { display: none !important; }
  .inbox.is-chat-open .inbox__chat,
  .leads.is-lead-open .leads__detail {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    background: var(--surface);
  }
  .leads:not(.is-lead-open) .leads__detail { display: none !important; }
  .leads.is-lead-open .leads__list-wrap { display: none !important; }

  .dashboard.is-chat-mode,
  .dashboard.is-lead-mode { grid-template-rows: minmax(0, 1fr); }
  .dashboard.is-chat-mode .sidebar,
  .dashboard.is-lead-mode .sidebar { display: none; }
  .dashboard.is-chat-mode .main,
  .dashboard.is-lead-mode .main { grid-row: 1; }
  .dashboard.is-chat-mode #view-inbox > .main__header,
  .dashboard.is-lead-mode #view-leads > .main__header { display: none; }
  .dashboard.is-chat-mode .mobile-tabbar,
  .dashboard.is-lead-mode .mobile-tabbar {
    transform: translateY(120%);
    pointer-events: none;
  }
  body.inbox-chat-open { overflow: hidden; }

  .active-chat__back { display: flex; }
  .active-chat__header,
  .active-lead__header {
    gap: 10px;
    padding: calc(9px + env(safe-area-inset-top, 0px)) 12px 9px;
  }
  .active-chat__visitor-avatar,
  .active-lead__avatar { width: 40px; height: 40px; font-size: 15px; }
  .active-chat__visitor h3,
  .active-lead__top h3 { font-size: 16px; }
  .active-chat__header time { display: none; }
  .active-chat__actions .btn--sm {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }
  .active-chat__actions .btn__text { display: none; }
  .active-chat__actions #reopen-btn {
    width: auto;
    padding: 0 11px;
    font-size: 12px;
  }
  .active-chat__actions #reopen-btn .btn__text { display: inline; }

  .active-chat__messages { padding: 14px 12px; }
  .msg { max-width: 86%; }
  .msg__bubble { font-size: 15px; }

  .active-chat__compose {
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .active-chat__compose-label,
  .active-chat__hint { display: none; }
  .quick-replies-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
  }
  .quick-replies-toggle__chevron {
    margin-left: auto;
    transition: transform 0.25s var(--ease);
  }
  .active-chat__compose.is-replies-open .quick-replies-toggle__chevron {
    transform: rotate(180deg);
  }
  .quick-replies {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    transition: max-height 0.26s var(--ease), opacity 0.2s, margin 0.2s;
  }
  .quick-replies::-webkit-scrollbar { display: none; }
  .active-chat__compose.is-replies-open .quick-replies {
    max-height: 60px;
    margin-bottom: 9px;
    opacity: 1;
  }
  .quick-reply { flex-shrink: 0; }
  .active-chat__reply textarea { font-size: 16px; max-height: 120px; }

  .lead-workflow {
    gap: 3px;
    padding: 11px 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .lead-workflow::-webkit-scrollbar { display: none; }
  .lead-workflow__step { flex-shrink: 0; padding: 6px 10px; font-size: 11px; }
  .lead-workflow__line { min-width: 8px; }
  .active-lead__body { padding: 14px 12px; }
  .active-lead__actions {
    flex-wrap: wrap;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .active-lead__actions #lead-primary-btn,
  .active-lead__actions .btn--call { flex: 1 1 40%; justify-content: center; }

  /* Статистика */
  .analytics { padding: 8px var(--pad-view) var(--pad-view); }
  .analytics-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px;
  }
  .analytics-hero__spark { width: 100%; height: 44px; gap: 4px; }
  .analytics-spark-bar { max-width: none; }
  .analytics-kpis { gap: 8px; }
  .analytics-kpi {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }
  .analytics-kpi__icon { width: 32px; height: 32px; }
  .analytics-kpi__value { font-size: 19px; }
  .analytics-kpi__label { font-size: 11px; line-height: 1.3; }
  .analytics-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .analytics-metric { padding: 11px 12px; }
  .analytics-metric__value { font-size: 18px; }
  .analytics-side { grid-template-columns: minmax(0, 1fr); }
  .analytics-panel { padding: 15px; }
  .analytics-panel__head { flex-direction: column; align-items: stretch; gap: 10px; }
  .analytics-period { align-self: flex-start; }
  .analytics-chart { height: 165px; min-width: 100%; gap: 5px; }
  .analytics-chart__bars { height: 128px; }
  .analytics-chart__col { min-width: 22px; }

  /* Нижний таббар */
  .mobile-tabbar {
    grid-row: 3;
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 20px rgba(16, 24, 40, 0.06);
    transition: transform 0.3s var(--ease);
  }
  .mobile-tabbar__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    min-height: 48px;
    padding: 5px 4px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.18s, background 0.18s;
  }
  .mobile-tabbar__item.is-active { color: var(--info-ink); background: var(--info-soft); }
  .mobile-tabbar__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
  }
  .mobile-tabbar__label { line-height: 1.1; }
  .mobile-tabbar__badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    color: #fff;
    background: var(--accent);
    border: 2px solid var(--surface);
    border-radius: var(--r-pill);
  }

  .toast {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 28px);
    padding: 11px 18px;
    font-size: 13px;
    text-align: center;
    border-radius: var(--r-md);
  }
}

@media (max-width: 600px) {
  .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpi:last-child { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .active-lead__actions #lead-primary-btn,
  .active-lead__actions .btn--call { flex: 1 1 100%; }
  .active-lead__actions #lead-delete-btn { margin-left: 0; }
}

@media (max-width: 380px) {
  .sidebar__status--chip { display: none; }
  .mobile-tabbar__label { font-size: 9px; }
  .filter-tab { font-size: 10px; padding: 8px 2px; }
  .stats-row--compact .stat-card__value { font-size: 17px; }
}
