/* ===== CSS Variables ===== */
:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    
    --success: #22c55e;
    --success-bg: #f0fdf4;
    
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    
    --info: #06b6d4;
    --info-bg: #ecfeff;
    
    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 70px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--gray-50);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.logo svg {
    flex-shrink: 0;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: var(--radius-sm);
}

.sidebar-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-600);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-item.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-external-links {
    margin: 16px 16px 0;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.sidebar-external-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.sidebar-external-link:hover {
    color: var(--primary);
}

.sidebar-external-link svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius);
    padding: 4px;
    margin: -4px;
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--gray-100);
    color: inherit;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-details {
    min-width: 0;
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Обрезка многоточием, как у .user-name (прогон 31.10.2026): вне компании
   (/og/, /profile/, /companies/, /support/) здесь адрес почты, а длинный адрес
   переносился по дефисам, длинный кусок без переноса вылезал за сайдбар:
   на десктопе поверх кнопки «Выйти», на телефоне хвост закрытого сайдбара
   торчал у левого края страницы. */
.user-role {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    padding: 10px;
    border-radius: var(--radius);
    color: var(--gray-500);
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 20px;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--gray-100);
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--gray-900);
    flex: 1;
    /* ⚠ Обрезка — в БАЗОВОМ правиле, а не только в блоке <=480px, где она
       стояла раньше. .top-bar задан жёстко height: 70px, align-items:center,
       без min-height и без overflow, а у флекс-элемента с ЗАДАННОЙ высотой
       автоматический минимум по главной оси равен этой высоте — бар не
       растягивался. Заголовок при этом переносился по словам на всех ширинах
       ОТ 481px: на ноутбучных 1280px заголовку остаётся ~360px (1280 − 260
       сайдбар − 64 padding − поиск − «← Назад к заявкам»), то есть около 30
       символов в строку, а название лида /api/lead.add собирает из name +
       company и вручную принимает до 255 символов. Три строки по 35.2px
       (line-height 1.6 от body) дают ~105px и вылезают за 70px сверху и снизу,
       а z-index: 50 печатает их ПОВЕРХ содержимого — на карточке лида под
       перекрытием оказывался переключатель статусов и переставал нажиматься.

       min-width: 0 обязателен: без него флекс-элемент не сжимается ниже
       min-content и text-overflow не срабатывает. Полное название остаётся
       доступным — оно печатается в «Ключевой информации» карточки и в <title>
       страницы (inc/layout.php). Тот же приём уже стоит у .user-name в
       сайдбаре. */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-wrapper {
    flex: 1;
    padding: 32px;
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-highlighted {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.02) 0%, rgba(139, 92, 246, 0.02) 100%);
}

.card-highlighted .card-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-bottom-color: rgba(99, 102, 241, 0.1);
}

.card-highlighted .card-title {
    color: var(--primary);
}

.card-highlighted .card-title svg {
    color: var(--primary);
}

.card-loss {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.card-loss .card-header {
    background: rgba(239, 68, 68, 0.05);
    border-bottom-color: rgba(239, 68, 68, 0.1);
}

.card-loss .card-title {
    color: var(--danger);
}

.card-loss .card-title svg {
    color: var(--danger);
}

.loss-reason-text {
    color: var(--danger);
    line-height: 1.6;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg {
    color: var(--gray-400);
}

.card-link {
    font-size: 0.875rem;
    font-weight: 500;
}

.card-body {
    padding: 24px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    padding: 8px;
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-label-important {
    color: var(--primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--gray-900);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

.form-input-important {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.03);
}

.form-input-important:focus {
    border-color: var(--primary);
    background: white;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 44px;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 6px;
}

.form-row {
    margin-bottom: 20px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

/* Highlighted Fields */
.highlighted-field {
    position: relative;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
}

/* Не display:none: он выбрасывает чекбокс из tab-order, и «Администратор»/
   «Менеджер по умолчанию» с клавиатуры были недостижимы. Тот же clip-паттерн,
   что у .sr-input; position:absolute сохраняет соседство для `+ .checkbox-custom` */
.checkbox-label input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.checkbox-label input:focus-visible + .checkbox-custom {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.checkbox-label input:disabled + .checkbox-custom {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* ===== Tables ===== */
.table-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: left;
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.cell-id {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.cell-date {
    white-space: nowrap;
}

/* Даты кабинета (formatDate, app.js crmDates, 08.11.2026): «сегодня в 14:04» и
   «2026.11.05 14:04» не рвутся посередине; точное время в title */
.local-time {
    white-space: nowrap;
}

/* Телефон в списке заявок не рвётся посередине номера: на 1440 px длинные
   имена менеджеров отжимали колонку, и «+7 930 123-45-» уезжало от «30»
   (09.10.2026, проверка адаптивности). 769-1280 px: правило ниже в @media. */
@media (min-width: 1281px) {
    .leads-table .cell-phone {
        white-space: nowrap;
    }
}

.date-main {
    display: block;
    font-weight: 500;
    color: var(--gray-900);
}

.cell-contact {
    min-width: 180px;
}

.contact-name {
    display: block;
    font-weight: 600;
    color: var(--gray-900);
}

/* Название заявки в списке: ссылка на карточку, вид прежний (тёмный текст без
   подчёркивания); строка и так подсвечивается при наведении */
a.contact-name,
a.contact-name:hover {
    color: var(--gray-900);
}

.contact-company {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.cell-actions {
    text-align: right;
    white-space: nowrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    color: var(--gray-500);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.action-btn-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Sort Links */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--gray-600);
}

.sort-link:hover {
    color: var(--gray-900);
}

.sort-link.active {
    color: var(--primary);
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge-sm {
    padding: 3px 8px;
    font-size: 0.75rem;
}

/* ===== Filters ===== */
.filters-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: 24px;
    margin-bottom: 24px;
}

.filters-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Ширину select задаёт самый длинный пункт (имя менеджера): без min-width: 0
       колонка сетки растягивалась под него, и на телефоне поля и «Скачать XLSX»
       уезжали за край карточки (09.10.2026, проверка адаптивности) */
    min-width: 0;
}

.filter-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-600);
}

.filter-input,
.filter-select {
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--gray-900);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
}

/* Дата фильтра текстом ГГГГ-ММ-ДД (app.js, initDateInputs): неверная дата */
.filter-input.is-invalid,
.filter-input.is-invalid:focus {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.filter-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    flex-direction: row;
}

.filter-toggles {
    display: flex;
    gap: 20px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--gray-600);
    cursor: pointer;
}

.toggle-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== Dashboard ===== */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: var(--primary-bg);
    color: var(--primary);
}

.stat-icon-green {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon-purple {
    background: #f5f3ff;
    color: #8b5cf6;
}

.stat-icon-orange {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-content {
    min-width: 0;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Пояснение к числу дашборда (аудит 12.11.2026: что именно считается) */
.stat-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--gray-400);
}

.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Status Distribution */
.status-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-bar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-bar-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.status-bar-count {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.status-bar-track {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-slow);
}

/* Recent Leads */
.recent-leads-list {
    display: flex;
    flex-direction: column;
}

.recent-lead-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
}

.recent-lead-item:last-child {
    border-bottom: none;
}

.recent-lead-item:hover {
    background: var(--gray-50);
}

.recent-lead-info {
    min-width: 0;
}

.recent-lead-name {
    display: block;
    font-weight: 600;
    color: var(--gray-900);
}

.recent-lead-company {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.recent-lead-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.recent-lead-date {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

/* ===== Lead Detail Page ===== */
.lead-detail-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Status Switcher */
.status-switcher {
    display: flex;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.status-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 16px;
    background: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: all var(--transition-fast);
    border-right: 1px solid var(--gray-200);
    position: relative;
}

.status-btn:last-child {
    border-right: none;
}

.status-btn:hover {
    background: var(--status-bg);
    color: var(--status-color);
}

.status-btn.active {
    background: var(--status-bg);
    color: var(--status-color);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    transition: opacity var(--transition-fast);
}

.status-btn.active .status-indicator {
    opacity: 1;
}

.status-btn.status-final {
    flex: 0.7;
}

/* Lead Content */
.lead-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
}

.lead-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.lead-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item-full {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.9375rem;
    color: var(--gray-900);
}

.info-value a {
    color: var(--primary);
}

.info-value-url {
    word-break: break-all;
    font-size: 0.8125rem;
}

.info-value-text {
    white-space: pre-wrap;
    line-height: 1.6;
}

.info-value-small {
    font-size: 0.8125rem;
    color: var(--gray-600);
    line-height: 1.4;
}

/* Highlighted Info Grid */
.info-grid-highlighted {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.info-item-highlighted {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    background: rgba(99, 102, 241, 0.03);
    border-radius: var(--radius);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.info-label-highlighted {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value-highlighted {
    font-size: 1rem;
    color: var(--gray-900);
    font-weight: 500;
}

/* Title field in Key Info */
.info-item-title {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
    border: 2px solid rgba(99, 102, 241, 0.2);
}

.info-value-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
}

.form-input-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* UTM Tags */
.utm-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.utm-tag {
    display: inline-flex;
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 50px;
    font-size: 0.8125rem;
    color: var(--gray-600);
}

/* Edit Grid */
.edit-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.edit-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* Lead Actions */
.lead-actions {
    display: flex;
    flex-wrap: wrap;   /* аудит 12.11.2026 (вечер): на 1025-1150px «Архивировать» уходила под ленту событий */
    gap: 12px;
}

/* Desktop: show actions under Analytics, hide bottom ones */
.lead-actions-desktop {
    display: flex;
}

.lead-actions-mobile {
    display: none;
    grid-column: 1 / -1;
}

/* Activity Card */
.activity-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
}

.activity-card .card-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Comment Form */
.comment-form {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.comment-form form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-input {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--gray-900);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    resize: none;
    transition: all var(--transition-fast);
}

.comment-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
}

.comment-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.attachment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.attachment-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--gray-600);
    max-width: 100%;
    position: relative;
    overflow: hidden;
}

.preview-item svg {
    flex-shrink: 0;
}

.preview-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.preview-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    margin-left: 2px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.preview-item-remove:hover {
    background: var(--gray-200);
    color: var(--danger);
}

.preview-item-size {
    font-size: 0.75rem;
    color: var(--gray-400);
    flex-shrink: 0;
}

.preview-total {
    width: 100%;
    font-size: 0.75rem;
    color: var(--gray-500);
    padding-top: 4px;
    border-top: 1px solid var(--gray-200);
    margin-top: 4px;
}

/* Upload progress styles */
.preview-item.uploading {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
}

.preview-item.done {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.preview-item.done .preview-item-icon {
    color: var(--success);
}

.preview-item.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    /* Причина отказа встаёт ОТДЕЛЬНОЙ строкой под именем файла: плитка —
       flex-строка с align-items:center, и без переноса текст либо сжал бы имя
       файла до многоточия, либо уехал под overflow:hidden. */
    flex-wrap: wrap;
}

/* Видимый текст причины отказа загрузки (markAttachmentError в карточке лида).
   Раньше причина жила ТОЛЬКО в атрибуте title: наведением курсора её читал
   десктоп, а на телефоне и планшете любой отказ выглядел словом «Ошибка». */
.preview-item-error {
    flex-basis: 100%;
    min-width: 0;
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--danger);
    white-space: normal;
    overflow-wrap: break-word;
}

.preview-item.error .preview-item-name {
    color: var(--danger);
}

.preview-item.error .preview-item-icon {
    color: var(--danger);
}

.preview-item-icon {
    flex-shrink: 0;
    color: var(--gray-500);
}

/* Progress bar */
.preview-item-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: var(--gray-200);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    overflow: hidden;
}

.preview-item-progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.15s ease-out;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.preview-item-percent {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
}

/* Comment Attachments */
.comment-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.attachment-item:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-900);
}

.attachment-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.attachment-icon {
    color: var(--gray-400);
}

.attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Activity Feed */
.activity-feed {
    padding: 16px 20px;
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child {
    border-bottom: none;
}

/* Minor activity items (status changes, assignments) */
.activity-item.activity-minor {
    padding: 8px 0;
    opacity: 0.7;
}

.activity-item.activity-minor .activity-icon {
    width: 28px;
    height: 28px;
}

.activity-item.activity-minor .activity-user {
    font-size: 0.8125rem;
}

.activity-item.activity-minor .activity-body {
    font-size: 0.8125rem;
}

.activity-status-change {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.activity-status-change svg {
    color: var(--gray-400);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-comment .activity-icon {
    background: var(--primary-bg);
    color: var(--primary);
}

.activity-status_change .activity-icon {
    background: var(--gray-100);
    color: var(--gray-400);
}

.activity-created .activity-icon {
    background: var(--success-bg);
    color: var(--success);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.activity-user {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-900);
    flex-grow: 1;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.comment-delete-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all 0.15s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.activity-item:hover .comment-delete-btn,
.comment-delete-btn:focus-visible {
    opacity: 1;
}

/* На тач-устройствах :hover нет — кнопка была невидима (opacity:0), а другого
   входа в удаление комментария в интерфейсе нет */
@media (hover: none) {
    .comment-delete-btn {
        opacity: 1;
    }
}

.comment-delete-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Гашение на время запроса: deleteComment (pages/leads/show.php) ставит
   disabled всем корзинам, но без правила кнопка продолжала «краснеть» под
   курсором и выглядела живой — на медленном пуле менеджер жал ещё раз и
   потом F5. Зеркало .status-btn:disabled; pointer-events глушит :hover,
   второй селектор перебивает opacity:1 от наведения на строку ленты. */
.comment-delete-btn:disabled,
.activity-item:hover .comment-delete-btn:disabled {
    opacity: 0.4;
    cursor: progress;
    pointer-events: none;
    color: var(--gray-400);
    background: none;
}

/* Отключённый селект (user-form.php: свой статус админ не меняет) был
   пиксель-в-пиксель как живой: .form-select жёстко красит фон/текст и прячет
   системную стрелку (appearance: none), браузерного вида disabled не
   оставалось — спасала только подсказка текстом ниже. */
.form-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--gray-100);
}

.activity-body {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.activity-body p {
    margin: 0;
}

/* Пузырь текста комментария. Класс переименован из .activity-comment: то же
   имя носит модификатор элемента ленты (activity-<type>, см. show.php), и
   фон gray-50 ложился на ВСЮ строку комментария — пузырь сливался с ней, а
   .activity-card .activity-comment перебивал паддинг строки (7px/9px вместо
   8px/14px у остальных типов). .activity-comment .activity-icon выше — это
   именно модификатор, его не трогать. */
.comment-bubble {
    background: var(--gray-50);
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--gray-700);
    line-height: 1.5;
}

/* Empty Activity */
.empty-activity {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state svg {
    margin-bottom: 16px;
    color: var(--gray-300);
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9375rem;
}

/* 404 внутри кабинета для вошедшего (404.php, аудит 12.11.2026) */
.error-page-cabinet .error-code {
    margin-bottom: 12px;
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--gray-300);
}

.error-page-cabinet p {
    margin-bottom: 20px;
}

.error-page-cabinet .error-links {
    margin: 20px 0 0;
}

/* Ссылка «Справка» под кнопкой: на телефоне была 59x17, поля дают зону под палец (вечер 12.11.2026) */
@media (pointer: coarse) {
    .error-page-cabinet .error-links a {
        display: inline-block;
        padding: 12px 16px;
        margin: -12px -16px;
    }
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Role Badges ===== */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.role-admin {
    background: var(--primary-bg);
    color: var(--primary);
}

.role-user {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ===== User Cell ===== */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-muted {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* ===== Form Pages ===== */
.lead-form-page,
.admin-form-page {
    max-width: 800px;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ===== Profile Page ===== */
.profile-page {
    max-width: 800px;
}

.profile-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Удаление аккаунта (/delete-account/, аудит 12.11.2026). Гостю страница рисуется в пустом контейнере без
   сайдбара: карточки прилипали к левому верхнему углу, маркеры списка выходили за карточку, абзацы и кнопка
   шли вплотную (сброс отступов в начале файла). */
.app-container-plain:has(> .account-delete) {
    justify-content: center;
    padding: 32px 16px;
}

.account-delete {
    width: 100%;
}

.account-delete-title {
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.account-delete .card-body > * + * {
    margin-top: 12px;
}

.account-delete .card-body ul {
    padding-left: 1.25rem;
}

.account-delete .card-body li + li {
    margin-top: 4px;
}

.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--gray-100);
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 3rem;
    font-weight: 700;
}

.avatar-actions {
    display: flex;
    gap: 10px;
}

.avatar-hint {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Длинный email переносится по символам и вплотную прилипал к подписи
       («Emailvodkin@…» на 360 px, 09.10.2026, проверка адаптивности) */
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .info-label {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9375rem;
}

.info-row .info-value {
    font-weight: 500;
    text-align: right;
}

.password-form {
    max-width: 400px;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ===== Responsive ===== */
@media (max-width: 1280px) {
    .lead-content {
        grid-template-columns: 1fr 350px;
    }
}

@media (max-width: 1024px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .lead-content {
        grid-template-columns: 1fr;
    }

    /* Аудит 12.11.2026 (решение владельца): в одной колонке лента событий идёт после карточки с
       контактами, как на телефоне; раньше здесь стоял order: -1 и до 1024px лента была над карточкой */
    
    .activity-card {
        min-height: auto;
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: flex;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .top-bar {
        padding: 0 20px;
    }
    
    .content-wrapper {
        padding: 20px;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .filters-row {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: row;
    }
    
    .status-switcher {
        flex-wrap: wrap;
    }
    
    .status-btn {
        flex: 1 1 calc(33.333% - 1px);
        border-bottom: 1px solid var(--gray-200);
        padding: 14px 12px;
        font-size: 0.8125rem;
    }
    
    /* .status-btn:nth-child(3|4|5|6) удалены: правила были мёртвыми — ниже, в том
       же брейкпоинте, .status-switcher скрыт целиком, а шестого статуса не бывает */

    /* .status-name{display:none} удалён: правило было мёртвым — ниже, в том же
       брейкпоинте ≤768px, .status-switcher скрывается ЦЕЛИКОМ, а статус на
       телефоне меняет .status-dropdown-mobile. Подписи кнопок гасить незачем. */
    .status-indicator {
        width: 16px;
        height: 16px;
    }
    
    .info-grid,
    .info-grid-highlighted,
    .edit-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row-2 {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Mobile: hide desktop actions, show mobile actions */
    .lead-actions-desktop {
        display: none;
    }
    
    .lead-actions-mobile {
        display: flex;
        flex-direction: column;
    }
    
    .lead-actions-mobile form,
    .lead-actions-mobile .btn {
        width: 100%;
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 14px;
    }
    
    .page-title {
        font-size: 1.125rem;
    }
    
    .modal {
        max-width: 100%;
        margin: 10px;
    }
}

@media (max-width: 768px) {
    .global-search-form {
        display: none;
    }
}

@media (max-width: 480px) {
    /* Кнопки шапки НЕ прячем.

       $headerActions (inc/layout.php) — ЕДИНСТВЕННОЕ место, где живут
       «Новый лид» (список заявок и дашборд) и «Добавить пользователя»
       (админка): дубля этих кнопок в разметке страниц нет. Прежнее
       display:none гасило их заодно с поиском, и на любом телефоне
       (360-430 CSS-px) попасть в /leads/create/ и /admin/users/create/ было
       нельзя вовсе — входа в интерфейсе не оставалось.

       Место в шапке есть: .global-search-form скрыт уже на 768px, а его работу
       берёт блок .mobile-search. Поэтому кнопку достаточно ужать; заголовок
       (на карточке это название лида, оно длинное) обрезается многоточием уже
       базовым правилом .page-title — иначе он выталкивал бы кнопку за край. */
    .top-bar {
        padding: 0 12px;
        gap: 10px;
    }

    /* Обрезка переехала в базовое правило .page-title — здесь её больше нет. */

    .top-bar-actions {
        flex-shrink: 0;
    }

    .top-bar-actions .btn {
        padding: 8px 12px;
        font-size: 0.8125rem;
        gap: 6px;
    }
    
    .card-header {
        padding: 16px 18px;
    }
    
    .card-body {
        padding: 18px;
    }
}

/* ===== Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Telegram Integration ===== */
.telegram-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.telegram-connected {
    background: var(--success-bg);
    border: 1px solid #bbf7d0;
}

.telegram-not-connected {
    background: var(--warning-bg);
    border: 1px solid #fde68a;
}

.telegram-status .status-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.telegram-connected .status-icon {
    background: var(--success);
    color: white;
}

.telegram-not-connected .status-icon {
    background: var(--warning);
    color: white;
}

.telegram-status .status-text {
    flex: 1;
    min-width: 0;
}

.telegram-status .status-text strong {
    display: block;
    font-size: 1rem;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.telegram-status .status-text span {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.telegram-unlink-form {
    flex-shrink: 0;
}

.telegram-binding {
    margin-top: 8px;
}

.binding-instruction {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.binding-option {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.option-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.option-content {
    flex: 1;
    min-width: 0;
}

.option-content p {
    margin: 0 0 12px 0;
    color: var(--gray-600);
    font-size: 0.9375rem;
}

.btn-telegram {
    background: linear-gradient(135deg, #0088cc 0%, #0077b5 100%);
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
}

.btn-telegram:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
    color: white;
}

.binding-code-wrapper {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

/* «Перевыпустить код» под блоком кода привязки: отдельная строка, а не третья
   кнопка в ряду — действие разрушительное (прежний код гаснет немедленно) и
   не должно стоять вплотную к «скопировать». */
.binding-reissue-form {
    margin-top: 10px;
}

.binding-code {
    flex: 1;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    color: var(--gray-800);
    word-break: break-all;
}

.btn-copy {
    flex-shrink: 0;
    padding: 12px;
}

/* ===== Spam Button ===== */
.btn-spam {
    background: #1f2937;
    color: white;
    border: 1px solid #1f2937;
}

.btn-spam:hover {
    background: #111827;
    border-color: #111827;
    color: white;
}

/* ===== Loss Reason in Feed ===== */
.loss-reason-feed {
    margin-top: 10px;
    padding: 12px;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    color: var(--danger);
}

.loss-reason-feed strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.loss-reason-feed p {
    margin: 0;
    line-height: 1.5;
}

/* ===== Duplicate Request Event ===== */
.activity-duplicate_request {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid rgba(249, 115, 22, 0.3);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 8px;
}

.activity-duplicate_request .activity-icon {
    background: #ffedd5;
    color: #ea580c;
}

.activity-duplicate_request .activity-content {
    background: white;
    border-radius: calc(var(--radius) - 2px);
    padding: 12px;
}

.duplicate-request-content {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--gray-700);
}

.duplicate-request-content strong {
    color: var(--gray-800);
    font-weight: 600;
}

/* ===== Fix Activity Status Change Layout ===== */
.activity-status-change {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.activity-status-change svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

/* Fix for status badge in activity */
.activity-body .status-badge-sm {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* ===== Field Change Event =====
   Событие 'field_change' пишет api/leads/update.php (правка полей карточки).
   Раскладка — та же, что у .activity-status-change выше: строка «Поле: было →
   стало» с переносом на узком экране. Своих классов под неё в исходном CSS
   старого CRM не было — событие туда не писалось вовсе. */
.activity-field-change {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.activity-field-change svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.field-change-name {
    color: var(--gray-500);
    font-weight: 600;
}

.field-change-name::after {
    content: ':';
}

.field-change-old {
    color: var(--gray-500);
    text-decoration: line-through;
    word-break: break-word;
}

.field-change-new {
    color: var(--gray-800);
    font-weight: 600;
    word-break: break-word;
}

/* ===== Activity Item Fix ===== */
.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
    align-items: flex-start;
}

.activity-item.activity-minor {
    padding: 10px 0;
}

.activity-item.activity-minor .activity-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
}

.activity-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Status badges for dark backgrounds */
.status-badge[style*="background: #1f2937"] {
    color: white !important;
}

/* ===== Global Search in Header ===== */
.global-search-form {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
}

.global-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search-icon {
    position: absolute;
    left: 14px;
    color: var(--gray-400);
    pointer-events: none;
}

.global-search-input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--gray-900);
    background: var(--gray-100);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.global-search-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.global-search-input::placeholder {
    color: var(--gray-400);
}

.global-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--gray-400);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.global-search-clear:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

.global-search-input:not(:placeholder-shown) {
    padding-right: 36px;
}

/* ===== Status Checkboxes Filter ===== */
.status-filter-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.filter-label-inline {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
}

.status-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--status-bg);
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.status-checkbox:hover {
    border-color: var(--status-color);
}

.status-checkbox:has(input:checked) {
    background: var(--status-color);
    border-color: var(--status-color);
}

/* clip вместо display:none — иначе фильтр статусов недостижим с клавиатуры
   (см. .checkbox-label input) */
.status-checkbox input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.status-checkbox:has(input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.status-checkbox-box {
    width: 16px;
    height: 16px;
    border: 2px solid var(--status-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.status-checkbox:has(input:checked) .status-checkbox-box {
    border-color: white;
    background: transparent;
}

.status-checkbox input:checked + .status-checkbox-box::after {
    content: '';
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 1px;
}

.status-checkbox-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--status-color);
}

.status-checkbox:has(input:checked) .status-checkbox-label {
    color: white;
}

/* ===== Bright Status Switcher ===== */
.status-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 16px;
    background: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: all var(--transition-fast);
    border-right: 1px solid var(--gray-200);
    position: relative;
}

.status-btn:hover {
    background: var(--status-bg);
    color: var(--status-color);
}

.status-btn.active {
    background: var(--status-color) !important;
    color: white !important;
    font-weight: 700;
}

.status-btn .status-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--status-color);
    opacity: 0.4;
    transition: all var(--transition-fast);
}

.status-btn.active .status-indicator {
    background: white;
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

/* ===== Telegram Debug Link ===== */
.telegram-debug-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--gray-400);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.telegram-debug-link:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ===== Call Event Styles ===== */
.activity-call {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.activity-call .activity-icon {
    background: #dcfce7;
    color: #16a34a;
}

.call-event-content {
    background: white;
    border-radius: calc(var(--radius) - 2px);
    padding: 12px;
}

.call-event-header {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.call-event-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.call-detail {
    display: flex;
    align-items: center;
    gap: 4px;
}

.call-detail-label {
    color: var(--gray-500);
}

/* Подпись зоны у «Времени АТС»: строка приходит от телефонии по её часам и к
   зоне пользователя не приводится (разбор — в pages/leads/show.php). Держим
   тише самого значения, но ЧИТАЕМОЙ: единственный канал title недоступен на
   тач-устройствах, поэтому текст видимый, а title лишь уточняет. */
.call-detail-hint {
    color: var(--gray-400);
    font-size: 0.75rem;
    white-space: nowrap;
}

.call-recordings {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.call-recording-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.call-recording-player audio {
    flex: 1;
    height: 36px;
    min-width: 0;
}

.call-recording-player audio::-webkit-media-controls-panel {
    background: var(--gray-50);
}

.call-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.call-download-btn:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* Comment attachments with audio */
.comment-attachments .call-recording-player {
    width: 100%;
    margin-top: 8px;
}

/* Call event inside activity feed needs padding */
.activity-item.activity-call {
    padding: 8px;
}

.activity-item.activity-call .activity-content {
    background: transparent;
}

/* Mobile responsive for audio player */
@media (max-width: 480px) {
    .call-recording-player {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .call-recording-player audio {
        width: 100%;
    }
    
    .call-download-btn {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .call-download-btn::after {
        content: 'Скачать';
        font-size: 0.8125rem;
        font-weight: 500;
    }
    
    .call-event-details {
        flex-direction: column;
        gap: 4px;
    }
}

/* ===== Activity Feed Padding Fix ===== */
.activity-feed {
    padding: 0;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    align-items: flex-start;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item.activity-minor {
    padding: 10px 20px;
}

/* Comment form in activity */
.comment-form {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ===== Archive Toggle ===== */
.archive-toggle-row {
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    margin-top: 12px;
}

.archive-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--gray-500);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.archive-link:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.archive-link-active {
    background: var(--gray-700);
    color: white;
}

.archive-link-active:hover {
    background: var(--gray-800);
    color: white;
}

.archive-close {
    margin-left: 4px;
    font-size: 1rem;
    line-height: 1;
}

/* ===== Mobile Status Dropdown ===== */
.status-dropdown-mobile {
    display: none;
    width: 100%;
    margin-bottom: 24px;
}

/* Кнопка «Изменить причину отказа» под мобильным селектом (show.php) */
.status-dropdown-mobile .btn {
    width: 100%;
    margin-top: 8px;
}

/* Визуально скрытый input внутри label-кнопки (файл, чекбокс): в отличие от
   атрибута hidden остаётся в tab-order — кнопку можно активировать с клавиатуры */
.sr-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
label.btn:focus-within,
.attachment-btn:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Погашенная кнопка. До этого правила НИ ОДНОГО :disabled в файле не было:
   гард двойной отправки (initSubmitGuard в app.js, #comment-submit в карточке)
   гасил кнопку, а она выглядела и приподнималась под курсором как живая —
   менеджер жал ещё раз, потом F5 и терял заполненную форму */
.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: progress;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

/* Те же правила для переключателя статусов карточки: .status-btn и мобильный
   select — НЕ .btn, а setStatusControlsDisabled() (pages/leads/show.php) гасит
   именно их. Без правила они выглядели живыми и подсвечивались под курсором
   на время запроса — менеджер жал ещё раз и потом F5 */
.status-btn:disabled,
.status-dropdown-mobile select:disabled {
    opacity: 0.6;
    cursor: progress;
    pointer-events: none;
}

/* ===== Mobile Search ===== */
.mobile-search {
    display: none;
}

.status-dropdown-mobile select {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    box-shadow: var(--shadow-sm);
}

.status-dropdown-mobile select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

/* ===== Mobile Responsive Improvements ===== */
@media (max-width: 768px) {
    /* Show mobile status dropdown, hide buttons */
    .status-dropdown-mobile {
        display: block;
        margin-bottom: 12px;
    }
    
    .status-switcher {
        display: none;
    }
    
    /* Mobile-friendly table */
    .data-table {
        display: block;
    }
    
    .data-table thead {
        display: none;
    }
    
    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .data-table tbody tr {
        display: flex;
        flex-direction: column;
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-md);
        padding: 12px;
        gap: 8px;
        box-shadow: var(--shadow-sm);
    }
    
    .data-table tbody tr:hover {
        background: white;
        box-shadow: var(--shadow-md);
    }
    
    .data-table td {
        padding: 0;
        border-bottom: none;
        font-size: 0.8125rem;
    }
    
    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.6875rem;
        font-weight: 600;
        color: var(--gray-500);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        margin-bottom: 2px;
    }
    
    .data-table .cell-id {
        order: -1;
        font-size: 0.75rem;
    }
    
    .data-table .cell-id::before {
        display: none;
    }
    
    .data-table .cell-contact {
        min-width: unset;
    }
    
    .data-table .cell-contact .contact-name {
        font-size: 0.9375rem;
        line-height: 1.3;
    }
    
    .data-table .cell-contact .contact-company {
        font-size: 0.75rem;
    }
    
    .data-table .cell-date {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .data-table .cell-date .date-main {
        display: inline;
        font-size: 0.8125rem;
    }
    
    .data-table .cell-phone {
        font-size: 0.8125rem;
    }
    
    .data-table .cell-manager {
        font-size: 0.8125rem;
    }
    
    .data-table .cell-actions {
        display: none;
    }
    
    .data-table .cell-status {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .data-table .cell-status .status-badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    
    /* Filter row improvements */
    .status-filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
    
    .status-checkbox {
        width: 100%;
        justify-content: flex-start;
        padding: 5px 10px;
        font-size: 0.8125rem;
    }
    
    .status-checkbox-label {
        font-size: 0.75rem;
    }
    
    /* Date inputs full width */
    .filters-row {
        grid-template-columns: 1fr;
    }
    
    .filter-input.filter-date {
        width: 100%;
    }
    
    /* Cards on mobile */
    .filters-card {
        padding: 14px;
        margin-bottom: 16px;
    }
    
    .table-card {
        border-radius: var(--radius-md);
        border: none;
        box-shadow: none;
        background: transparent;
    }

    /* Аудит 12.11.2026: карточка таблицы на телефоне прозрачная, и боковой отступ строк (12px) сдвигал
       карточки заявок, сотрудников и ключей внутрь относительно поиска, фильтров и прочих блоков */
    .table-card .data-table tbody {
        padding-left: 0;
        padding-right: 0;
    }

    /* Lead detail page - move activity to bottom */
    .lead-content {
        display: flex;
        flex-direction: column;
    }
    
    .lead-sidebar {
        order: 10;
    }
    
    .lead-main {
        order: 1;
    }
    
    .lead-actions {
        order: 11;
    }
    
    /* Show mobile search */
    .mobile-search {
        display: block;
        margin-bottom: 12px;
    }
    
    .mobile-search-form {
        width: 100%;
    }
    
    .mobile-search-wrapper {
        position: relative;
        display: flex;
        align-items: center;
    }
    
    .mobile-search-icon {
        position: absolute;
        left: 12px;
        color: var(--gray-400);
        pointer-events: none;
    }
    
    .mobile-search-input {
        width: 100%;
        padding: 10px 14px 10px 38px;
        font-family: inherit;
        font-size: 0.9375rem;
        color: var(--gray-900);
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-lg);
        transition: all var(--transition-fast);
    }
    
    .mobile-search-input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-bg);
    }
    
    .mobile-search-input::placeholder {
        color: var(--gray-400);
    }
    
    .mobile-search-clear {
        position: absolute;
        right: 8px;
        background: none;
        border: none;
        padding: 6px;
        cursor: pointer;
        color: var(--gray-400);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-search-clear:hover {
        background: var(--gray-100);
        color: var(--gray-600);
    }
}

@media (max-width: 480px) {
    .content-wrapper {
        padding: 10px;
    }
    
    .filters-card {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-actions {
        width: 100%;
    }
    
    .filter-actions .btn {
        flex: 1;
        font-size: 0.8125rem;
        padding: 8px 12px;
    }
    
    .archive-toggle-row {
        padding-top: 8px;
        margin-top: 8px;
    }
    
    .archive-link {
        width: 100%;
        justify-content: center;
        font-size: 0.75rem;
    }
    
    /* Even more compact cards on small screens */
    .data-table tbody {
        gap: 8px;
        padding: 8px;
    }
    
    .data-table tbody tr {
        padding: 10px;
        gap: 6px;
    }
    
    .data-table td {
        font-size: 0.75rem;
    }
    
    .data-table td::before {
        font-size: 0.625rem;
        margin-bottom: 1px;
    }
    
    .data-table .cell-contact .contact-name {
        font-size: 0.875rem;
    }
    
    .data-table .cell-status .status-badge {
        font-size: 0.6875rem;
        padding: 3px 8px;
    }
    
    .mobile-search-input {
        padding: 8px 12px 8px 36px;
        font-size: 0.875rem;
    }
    
    .filter-label {
        font-size: 0.75rem;
    }
    
    .filter-input,
    .filter-select {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
}

/* ─── Дополнения новой версии (перенос на платформу) ────────────────────────
   Выход стал POST-формой (GET-ссылку /logout мог бы дёрнуть <img> с чужого
   сайта). .sidebar-footer — flex со space-between, и обёртка-форма стала бы
   лишним flex-элементом, сдвинув кнопку; display:contents делает её
   «прозрачной» для раскладки — кнопка остаётся на прежнем месте. */
.logout-form { display: contents; }

/* Правило .logout-btn (стр. 248) писалось под <a> и задаёт только padding,
   радиус и цвет. У <button> поверх этого остаются браузерные дефолты — рамка,
   серый фон, своя типографика и line-height, — из-за чего иконка выхода
   выглядела громоздким «квадратом с обводкой» и не совпадала по высоте с
   блоком пользователя. Сбрасываем их и центрируем иконку. */
button.logout-btn {
    border: 0;
    background: none;
    font: inherit;
    line-height: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}

/* ─── Аватары и присутствие пользователей ─────────────────────────────── */
.user-avatar-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-size);
    height: var(--avatar-size);
    min-width: var(--avatar-size);
    flex-shrink: 0;
    border-radius: 50%;
}

.user-avatar-wrap > img,
.user-avatar-wrap > .user-avatar,
.user-avatar-wrap > .user-avatar-sm,
.user-avatar-wrap > .avatar-placeholder,
.user-avatar-wrap > .activity-user-avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.presence-indicator {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: clamp(9px, calc(var(--avatar-size) * 0.23), 18px);
    height: clamp(9px, calc(var(--avatar-size) * 0.23), 18px);
    border: clamp(2px, calc(var(--avatar-size) * 0.035), 3px) solid white;
    border-radius: 50%;
    background: var(--gray-400);
    box-sizing: border-box;
}

.user-avatar-wrap.is-online .presence-indicator {
    background: var(--success);
}

.user-avatar-wrap.is-offline .presence-indicator {
    background: var(--gray-400);
}

.avatar-preview {
    overflow: visible;
    background: transparent;
}

.activity-user-avatar-img,
.activity-user-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-user-avatar-img {
    object-fit: cover;
}

.activity-user-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
}

/* ─── Компактная лента событий ─────────────────────────────────────────── */
.activity-card .activity-item {
    gap: 9px;
    padding: 8px 14px;
}

.activity-card .activity-item.activity-minor {
    padding: 6px 14px;
    opacity: 0.8;
}

.activity-card .activity-icon,
.activity-card .activity-item.activity-minor .activity-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
}

.activity-card .activity-header {
    gap: 6px;
    margin-bottom: 2px;
    min-height: 18px;
}

.activity-card .activity-user,
.activity-card .activity-item.activity-minor .activity-user {
    font-size: 0.8125rem;
}

.activity-card .activity-time {
    font-size: 0.6875rem;
    white-space: nowrap;
}

.activity-card .activity-body,
.activity-card .activity-item.activity-minor .activity-body {
    font-size: 0.8125rem;
    line-height: 1.35;
}

.activity-card .comment-bubble {
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.activity-card .activity-status-change {
    gap: 5px;
}

.activity-card .activity-body .status-badge-sm {
    padding: 2px 7px;
    font-size: 0.6875rem;
}

.activity-card .activity-duplicate_request {
    margin: 0;
    padding: 7px 14px;
    border-width: 0 0 1px;
    border-radius: 0;
}

.activity-card .activity-duplicate_request .activity-content,
.activity-card .call-event-content {
    padding: 0;
    background: transparent;
}

.activity-card .duplicate-request-content {
    font-size: 0.8125rem;
    line-height: 1.4;
}

.activity-card .activity-item.activity-call {
    padding: 8px 14px;
}

.activity-card .call-event-header {
    margin-bottom: 4px;
    font-size: 0.8125rem;
}

.activity-card .call-event-details {
    gap: 4px 10px;
    margin-bottom: 6px;
    font-size: 0.75rem;
}

.activity-card .call-recordings {
    margin-top: 6px;
    padding-top: 6px;
}

.activity-card .call-recording-player {
    padding: 5px 8px;
}

.activity-card .call-recording-player audio {
    height: 30px;
}

.activity-card .loss-reason-feed {
    margin-top: 5px;
    padding: 7px 9px;
}

.activity-card .loss-reason-feed strong {
    margin-bottom: 2px;
    font-size: 0.6875rem;
}

.activity-card .comment-attachments {
    gap: 6px;
    margin-top: 6px;
}

/* ─── Мобильный спойлер фильтров ───────────────────────────────────────── */
.mobile-filters-toggle {
    display: none;
}

@media (max-width: 768px) {
    .filters-card {
        padding: 0;
        overflow: hidden;
    }

    .mobile-filters-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 48px;
        padding: 12px 14px;
        border: 0;
        background: white;
        color: var(--gray-800);
        font: inherit;
        font-weight: 700;
        text-align: left;
        cursor: pointer;
    }

    .mobile-filters-toggle:focus-visible {
        outline: 3px solid var(--primary-bg);
        outline-offset: -3px;
    }

    .mobile-filters-chevron {
        width: 9px;
        height: 9px;
        margin: -4px 4px 0 12px;
        border-right: 2px solid var(--gray-500);
        border-bottom: 2px solid var(--gray-500);
        transform: rotate(45deg);
        transition: transform var(--transition-fast);
    }

    .filters-card.filters-open .mobile-filters-chevron {
        margin-top: 4px;
        transform: rotate(225deg);
    }

    .filters-card .filters-form {
        display: none;
        padding: 14px;
        border-top: 1px solid var(--gray-100);
    }

    .filters-card.filters-open .filters-form {
        display: flex;
    }
}

/* ─── Перенос длинных неразрывных строк (ссылки клиента) ────────────────────
   .card и .activity-content стоят с overflow:hidden, а перечисленные ниже блоки
   печатают пользовательский ввод. Без переноса 200-символьная ссылка с
   utm-метками — ровно то, что клиенты вставляют в «Сообщение», и то, что
   crmLogDuplicateRequest() кладёт в событие повторного обращения, — уходила за
   край карточки и МОЛЧА срезалась: её не видно и не выделить.
   white-space:pre-wrap у .info-value-text не спасает: он переносит только по
   пробелам. Тот же приём уже применён у .info-value-url, .field-change-old/new,
   .binding-code и .message-text (pages/leads/telegram-history.php).
   word-break — фолбэк для браузеров без overflow-wrap:anywhere. */
.info-value,
.info-value-text,
.info-value-small,
.info-value-highlighted,
.info-value-title,
.utm-tag,
.comment-bubble,
.duplicate-request-content,
.loss-reason-text,
.loss-reason-feed p {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ─── SaaS: компании, переключатель, настройки (28.09.2026) ────────────────
   Всё ниже — дописано к перенесённому CSS старого CRM, существующие правила не
   тронуты. Классы общие для вёрстки (inc/layout.php), профиля и страниц
   настроек компании (pages/settings/*, pages/companies/*). */

/* Видимое только экранному диктору (подпись к числу на значке). Тот же
   clip-паттерн, что у .sr-input, но имя не про поле ввода. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Высота сайдбара на телефоне. 100vh у мобильных браузеров включает панель
   адреса, и низ сайдбара уезжал под неё; теперь там переключатель компаний,
   профиль и выход, то есть единственный путь в другую компанию. dvh — видимая
   высота; без поддержки остаётся прежнее 100vh. */
@supports (height: 100dvh) {
    .sidebar {
        height: 100dvh;
    }
}

/* Быстрые ссылки компании (настройка «Сайдбар»): название до 100 символов, и
   без обрезки длинное выталкивало бы значок за край сайдбара. */
.sidebar-external-link span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Переключатель компаний (низ сайдбара, над блоком пользователя) ─────── */
.company-switcher {
    position: relative;
    padding: 12px 16px 0;
    border-top: 1px solid var(--gray-100);
}

/* Одна линия между навигацией и низом сайдбара: у .sidebar-footer своя
   border-top, и под переключателем она дала бы вторую черту. */
.company-switcher + .sidebar-footer {
    border-top: none;
    padding-top: 12px;
}

.company-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-800);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.company-switcher-btn:hover,
.company-switcher.open .company-switcher-btn {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.company-switcher-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.company-switcher-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.company-switcher-caption {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.company-switcher-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-switcher-chevron {
    flex-shrink: 0;
    color: var(--gray-400);
    transition: transform var(--transition-fast);
}

/* Меню раскрывается вверх: стрелка «вверх» в покое, «вниз» у открытого */
.company-switcher.open .company-switcher-chevron {
    transform: rotate(180deg);
}

/* Меню — поверх навигации, по ширине сайдбара. Потолок высоты со своей
   прокруткой: у человека может быть много компаний, а страница под меню
   прокручиваться не должна (overscroll-behavior).

   ⚠ Потолок — от места НАД переключателем, а не долей окна. Меню растёт вверх
   от низа сайдбара, под ним ~141px (переключатель и блок пользователя), и
   прежний min(70vh, 480px) при высоте окна меньше ~460px (телефон в альбомной
   ориентации шире 768px, масштаб 200%) поднимал верх меню за край экрана:
   заголовок и первая компания становились недоступны, прокрутка внутри меню
   их не возвращала. 150px = ~141px под меню плюс запас. Единица — та же, что
   у высоты .sidebar (vh, а при поддержке dvh — ниже в @supports). Точный
   потолок по месту над кнопкой ставит initCompanySwitcher() (app.js) при
   каждом раскрытии; это правило — страховка на случай, если расчёт не сработал. */
.company-menu {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 6px);
    z-index: 110;
    max-height: min(480px, max(80px, calc(100vh - 150px)));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* Те же единицы, что у высоты .sidebar: 100vh считается от БОЛЬШОГО вьюпорта
   (без панели адреса), и на Android в альбомной ориентации верх меню уходил бы
   за край на высоту панели. ⚠ Блок стоит ПОСЛЕ базового правила: @supports
   специфичности не добавляет, и выше по файлу его перебило бы правило с vh. */
@supports (height: 100dvh) {
    .company-menu {
        max-height: min(480px, max(80px, calc(100dvh - 150px)));
    }
}

.company-menu[hidden] {
    display: none;
}

.company-menu-title {
    padding: 6px 10px 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.company-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
}

.company-menu-item:hover,
.company-menu-item:focus-visible {
    background: var(--gray-100);
    color: var(--gray-900);
    outline: none;
}

.company-menu-item:focus-visible {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.company-menu-item.is-current {
    color: var(--primary);
    font-weight: 700;
}

.company-menu-item svg {
    flex-shrink: 0;
    color: var(--gray-400);
}

.company-menu-item.is-current svg {
    color: var(--primary);
}

.company-menu-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-menu-sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--gray-100);
}

/* ─── Значки ролей и счётчики ─────────────────────────────────────────────
   База .badge и серый .badge-muted — выше (раздел Badges). */
.badge-owner {
    background: #fef3c7;
    color: #b45309;
}

.badge-admin {
    background: var(--primary-bg);
    color: var(--primary);
}

/* Счётчик (приглашения на кнопке переключателя и т.п.): круглый при одной
   цифре, растягивается при двух и более. */
.badge-count {
    flex-shrink: 0;
    min-width: 20px;
    justify-content: center;
    padding: 1px 7px;
    font-size: 0.75rem;
    line-height: 1.4;
    background: var(--primary);
    color: white;
}

/* Приглушённая пояснительная строка (под формами, в пустых списках). */
.muted-hint {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--gray-500);
}

/* Моноширинный фрагмент в строке (префикс ключа, uuid в пояснении). */
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

/* ─── Вкладки настроек компании ───────────────────────────────────────────
   <nav class="settings-tabs"><a href="..." class="active">Компания</a>...</nav>
   Плашки с переносом, а не полоса с подчёркиванием. На телефоне (до 768 px)
   одна строка с прокруткой вбок: перенос занимал три строки. Что за краем,
   подсказывают тени по бокам, активную вкладку в видимую часть прокручивает
   initSettingsTabs() (app.js). */
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
    padding: 6px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.settings-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* 12px, а не 14px (аудит 12.11.2026): восемь вкладок не помещались в 900px на 7px, и «Трекинг»
       одна уезжала на вторую строку на любом широком экране */
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.settings-tabs a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.settings-tabs a.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.settings-tabs a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

@media (max-width: 768px) {
    /* Тени прокрутки: белые полосы (local) едут с содержимым и закрывают тень
       (scroll) у края, до которого дошли; у края с продолжением тень видна */
    .settings-tabs {
        position: relative;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        background:
            linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)) left / 40px 100% no-repeat local,
            linear-gradient(to left, white 30%, rgba(255, 255, 255, 0)) right / 40px 100% no-repeat local,
            radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0)) left / 12px 100% no-repeat scroll,
            radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0)) right / 12px 100% no-repeat scroll,
            white;
    }

    .settings-tabs::-webkit-scrollbar {
        display: none;
    }

    .settings-tabs a {
        flex-shrink: 0;
    }
}

/* ─── Редактор списка строк (ссылки сайдбара, услуги) ─────────────────────
   <div class="row-editor">
     <div class="row-editor-item">
       <div class="row-editor-fields">
         <input class="form-input"> <input class="form-input row-editor-wide">
       </div>
       <div class="row-editor-actions"><button class="action-btn">…</button>…</div>
     </div>
   </div>
   <div class="row-editor-empty">Список пуст</div>
   <div class="row-editor-footer">[Добавить] [Сохранить]</div> */
.row-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row-editor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.row-editor-fields {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 10px;
}

.row-editor-fields > * {
    flex: 1;
    min-width: 0;
}

.row-editor-fields > .row-editor-wide {
    flex: 2;
}

/* Поля можно класть и прямо в строку, без .row-editor-fields (так сделаны
   pages/settings/sidebar.php и services.php). min-width: 0 обязателен: у
   <input> свой внутренний минимум ширины, и без него две колонки с кнопками
   вылезали бы за карточку на планшетной ширине. Второе поле (адрес ссылки)
   шире первого (названия). */
.row-editor-item > .form-input {
    flex: 1;
    min-width: 0;
}

.row-editor-item > .form-input + .form-input {
    flex: 2;
}

.row-editor-item .form-input {
    padding: 10px 12px;
    background: white;
}

.row-editor-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* «Вверх» у первой строки и «вниз» у последней гасятся атрибутом disabled */
.row-editor-actions button:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.row-editor-empty {
    padding: 16px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
}

.row-editor-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

/* ─── Показ секрета один раз (выпущенный API-ключ) ────────────────────────
   <div class="key-reveal-warning">Ключ показан один раз…</div>
   <div class="key-reveal">
     <code class="key-reveal-value" id="newApiKey">crm_…</code>
     <button type="button" class="btn btn-secondary" data-copy-target="newApiKey">Скопировать</button>
   </div>
   Копирование — initCopyButtons() в assets/js/app.js (атрибут data-copy-target). */
.key-reveal {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 12px 0;
}

/* Голый <code> внутри .key-reveal оформлен так же (pages/settings/api-keys.php
   кладёт ключ в <code id="api-key-value"> без класса). */
.key-reveal-value,
.key-reveal > code {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    background: var(--gray-900);
    color: #f9fafb;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-all;
    overflow-wrap: anywhere;
    user-select: all;
}

.key-reveal .btn {
    flex-shrink: 0;
}

.key-reveal-warning {
    padding: 12px 14px;
    background: var(--warning-bg);
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    color: #92400e;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Кнопка копирования после успеха (initCopyButtons) */
.btn.is-copied {
    color: var(--success);
    border-color: #bbf7d0;
}

/* ─── Профиль ─────────────────────────────────────────────────────────── */
.profile-name-form {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.profile-name-form .form-input {
    flex: 1;
    min-width: 0;
}

.profile-section-gap {
    margin-top: 20px;
}

/* Приглашения в компании: заметная, но спокойная плашка со ссылкой */
.invite-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--primary-bg);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius);
    color: var(--gray-800);
    font-size: 0.9375rem;
}

/* Список компаний (профиль, /companies/): название ссылкой, справа роль */
.company-list {
    display: flex;
    flex-direction: column;
}

.company-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.company-list-item:last-child {
    border-bottom: none;
}

.company-list-name {
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-list-item .badge {
    flex-shrink: 0;
}

/* Справа от названия: значок роли и «Покинуть» (профиль, у компаний, где
   человек не владелец). На узком экране строка переносится целиком
   (.company-list-item — flex-wrap в блоке 480px ниже), кнопка не сжимается. */
.company-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.company-leave-form {
    margin: 0;
}

/* Пустой список заявок новой компании (pages/leads/index.php): вместо
   «измените поиск» — первый шаг и кнопки. Текст ограничен по ширине, чтобы на
   широком экране не растягиваться в одну строку через всю таблицу. */
.empty-state-onboarding p {
    max-width: 520px;
    margin: 0 auto;
}

.empty-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0 12px;
}

/* Уведомления в Telegram: по блоку на компанию */
.notify-company {
    min-width: 0;
    margin: 0 0 16px;
    padding: 12px 16px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.notify-company legend {
    max-width: 100%;
    padding: 0 6px;
    font-weight: 700;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notify-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Подпись галки в две строки (название + пояснение): чекбокс по верхнему краю */
.notify-options .checkbox-label {
    align-items: flex-start;
    font-weight: 500;
}

.notify-options .checkbox-custom {
    margin-top: 1px;
}

.notify-option-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.notify-option-hint {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--gray-500);
}

@media (max-width: 640px) {
    .row-editor-item {
        flex-direction: column;
        align-items: stretch;
    }

    .row-editor-fields {
        flex-direction: column;
    }

    .row-editor-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .settings-tabs a {
        padding: 7px 10px;
        font-size: 0.8125rem;
    }

    .key-reveal,
    .profile-name-form {
        flex-direction: column;
    }

    .company-list-item {
        flex-wrap: wrap;
    }
}

/* Раздел «Чаты» (этап 1, 28.09.2026): то, что видно на ЛЮБОЙ странице
   компании, живёт здесь, а не в chats.css (он грузится только на страницах
   чатов). Числа и видимость ставит assets/js/chats-notify.js атрибутом hidden. */

/* Бейдж пункта «Чаты» в сайдбаре: счётчик прижат вправо (.badge-count выше
   задаёт вид). [hidden] явно: .badge задаёт display и перебил бы атрибут. */
.nav-badge {
    margin-left: auto;
}

.nav-badge[hidden] {
    display: none;
}

/* Точка на кнопке меню до 768 px: сайдбар там спрятан, и без неё о новых
   сообщениях не узнать. Кнопка меню флекс-контейнер без position, поэтому
   точка стоит флекс-элементом после иконки и отрицательным полем садится на
   её правый верхний угол (ширина кнопки не меняется). */
.menu-toggle-dot {
    align-self: flex-start;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    margin-left: -9px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px white;
    pointer-events: none;
}

.menu-toggle-dot[hidden] {
    display: none;
}

/* Подпись кнопки «Чат» карточки заявки: до 768 px в шапке уже меню, заголовок
   и «Назад к заявкам», остаются иконка и счётчик */
@media (max-width: 768px) {
    .lead-chat-btn-text {
        display: none;
    }
}

/* Кнопка «Импорт» списка заявок на узком телефоне (до 400 px): только иконка,
   иначе рядом с «Новая заявка» заголовок страницы сжимался до «За…» */
@media (max-width: 400px) {
    .btn-import-text {
        display: none;
    }
}

/* ===== Адаптивность: планшет и телефон ===== */
/* .main-content: флекс-элемент .app-container; без min-width: 0 он не сжимается
   уже самого широкого содержимого (длинный User-Agent, адрес страницы, строка
   кнопок шапки, широкая таблица), и вся страница получала горизонтальную
   прокрутку. Правило действует на любой ширине: пока содержимое помещается,
   оно ничего не меняет. */
.main-content {
    min-width: 0;
}

/* Длинные значения (адрес страницы, User-Agent, почта, имя файла) переносятся
   в любом месте, а не раздвигают карточку. Короткие значения правило не
   задевает. */
.info-value,
.info-value-highlighted,
.info-row .info-value,
.utm-tag,
.activity-body,
.comment-bubble,
.duplicate-request-content,
.field-change-old,
.field-change-new,
.call-detail,
.card-title,
.alert {
    overflow-wrap: anywhere;
    min-width: 0;
}

/* Дашборд: четыре плитки показателей в ряд не помещались рядом с сайдбаром до
   1100 px (минимум плитки: иконка, поля и подпись) и вылезали за край. До
   1024 px те же две колонки уже задаёт брейкпоинт выше. */
@media (min-width: 1025px) and (max-width: 1100px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Остальные правила блока только дополняют брейкпоинты выше и на широком
   экране (от 1025 px) не действуют. */
@media (max-width: 1024px) {
    /* Шапка: заголовок обрезается многоточием, а кнопки страницы, которым не
       хватило места рядом с ним (карточка заявки: чат, письмо, «Назад к
       заявкам»), уходят во вторую строку. Перенос решает flex-basis заголовка:
       пока рядом с ним помещаются и кнопки, шапка остаётся в одну строку. */
    .top-bar {
        height: auto;
        min-height: var(--topbar-height);
        flex-wrap: wrap;
        row-gap: 8px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .page-title {
        flex: 1 1 140px;
    }

    /* Поиск шапки не сжимается в огрызок (на карточке заявки при 1024 px от
       поля оставалось «Пои»): не уже 200 px, при нехватке места шапка
       переносит кнопки во вторую строку (02.10.2026, проверка адаптивности) */
    .global-search-form {
        flex: 1 1 200px;
        min-width: 200px;
        margin: 0 8px;
    }

    .top-bar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        margin-left: auto;
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    /* Касание: кнопки, поля фильтров и иконки-действия не ниже 40 px */
    .btn,
    .filter-input,
    .filter-select,
    .mobile-search-input {
        min-height: 40px;
    }

    .action-btn,
    .attachment-btn,
    .menu-toggle,
    .modal-close,
    .sidebar-close {
        min-width: 40px;
        min-height: 40px;
        align-items: center;
        justify-content: center;
    }

    /* Корзина комментария: сама иконка прежняя, область касания 40 px, поля
       в минус возвращают строке заголовка события прежнюю высоту */
    .comment-delete-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
        margin-top: -10px;
        margin-bottom: -10px;
        margin-right: -8px;
    }

    /* Лента событий: на телефоне без собственной прокрутки внутри карточки
       (в окне 400 px под формой комментария оставалось полтора события) */
    .activity-card {
        max-height: none;
    }

    .activity-card .card-body {
        overflow-y: visible;
    }

    .activity-content,
    .call-event-content,
    .comment-attachments {
        min-width: 0;
    }

    .call-recording-player {
        max-width: 100%;
    }

    /* Название в шапке открытого сайдбара: в одну строку рядом с крестиком */
    .logo span {
        white-space: nowrap;
    }

    /* «Время звонка» с подписью зоны телефонии: подпись уходит на свою строку */
    .call-detail {
        flex-wrap: wrap;
    }

    .call-detail-hint {
        white-space: normal;
    }

    .call-recording-player audio {
        flex: 1;
        min-width: 0;
        max-width: 100%;
    }

    /* Модальные окна: во всю ширину экрана с полем 10 px, длинное содержимое
       прокручивается внутри окна */
    .modal-overlay {
        padding: 10px;
    }

    .modal {
        width: 100%;
        margin: 0;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    /* Плеер записи: до 480 px .call-recording-player становится колонкой, и
       базовое flex: 1 (основа 0 по высоте) схлопывало <audio> до нуля: на
       телефоне от записи оставалась одна кнопка «Скачать». */
    .call-recording-player audio {
        flex: none;
        height: 40px;
    }

    .call-download-btn {
        min-height: 40px;
    }

    /* Профиль: плашка Telegram в колонку, кнопка под текстом */
    .telegram-status {
        flex-wrap: wrap;
    }

    .telegram-status .btn,
    .telegram-status form {
        width: 100%;
    }
}

/* ===== Сквозной проход по кабинету: телефон, планшет, единый вид ===== */
/* Фокус с клавиатуры виден на любом элементе управления: кольцо рисуется
   только при переходе клавишей (:focus-visible), мышь и касание его не дают. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex="0"]:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Кнопка возврата шапки («Назад к заявкам», «Все сотрудники»): стрелка и
   подпись отдельными элементами, на телефоне остаётся одна стрелка. */
.btn-back-arrow {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    /* Шапка телефона всегда в одну строку: меню, стрелка возврата, заголовок,
       действия страницы. Контейнер действий растворяется (display: contents),
       чтобы стрелка встала слева от заголовка, как в мобильных приложениях. */
    /* Переменная следует за фактической высотой шапки: «Чаты» вычитают её из
       высоты окна, и при прежних 70px под строкой ввода оставалась пустая
       полоса в 14px (02.10.2026, проверка адаптивности). */
    :root {
        --topbar-height: 56px;
    }

    .top-bar {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 0 10px;
        min-height: 56px;
    }

    .top-bar-actions {
        display: contents;
    }

    .top-bar .menu-toggle {
        order: -2;
        flex-shrink: 0;
    }

    .top-bar .btn-back {
        order: -1;
    }

    .top-bar .page-title {
        flex: 1 1 0;
        margin-left: 4px;
    }

    .top-bar > .btn,
    .top-bar-actions > .btn {
        flex-shrink: 0;
    }

    .btn-back-text {
        display: none;
    }

    .top-bar .btn-back {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        border-color: transparent;
        background: transparent;
        color: var(--gray-600);
    }

    .top-bar .btn-back .btn-back-arrow {
        width: 22px;
        height: 22px;
    }

    .top-bar .btn-back:active {
        background: var(--gray-100);
    }

    /* Иконки «Чат» и «Письмо» карточки заявки: квадратные кнопки 40 px */
    .top-bar .lead-chat-btn,
    .top-bar .lead-mail-btn {
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
    }
}

/* Список заявок. Планшет и узкий ноутбук (769-1280 px): колонки не помещались
   рядом с сайдбаром, и «Статус» уезжал за край таблицы. Поля ячеек меньше,
   кнопка-глаз скрыта: строка открывается нажатием целиком, а ссылкой для
   Ctrl+клика, колеса и клавиатуры служит название (a.contact-name). */
@media (min-width: 769px) and (max-width: 1280px) {
    .leads-table th,
    .leads-table td {
        padding: 14px 10px;
    }

    .leads-table th:first-child,
    .leads-table td:first-child {
        padding-left: 18px;
    }

    .leads-table .cell-actions,
    .leads-table th:last-child {
        display: none;
    }

    .leads-table td {
        font-size: 0.875rem;
    }

    .leads-table .cell-contact {
        min-width: 110px;
        overflow-wrap: anywhere;
    }

    .leads-table .cell-date,
    .leads-table .cell-date .local-time {
        white-space: normal;
    }

    .leads-table .cell-manager {
        min-width: 112px;
        overflow-wrap: anywhere;
    }

    .leads-table .cell-phone,
    .leads-table .cell-status {
        white-space: nowrap;
    }

    .leads-table .cell-status,
    .leads-table th:nth-last-child(2) {
        padding-right: 18px;
    }
}

/* Список заявок на телефоне: компактная карточка без подписей полей. Первая
   строка: название и статус, вторая: телефон и дата, третья: ответственный и
   номер заявки. */
@media (max-width: 768px) {
    .leads-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "title title status"
            "phone date date"
            "manager manager id";
        align-items: center;
        gap: 4px 12px;
        padding: 12px 14px;
    }

    .leads-table td::before {
        display: none;
    }

    .leads-table .cell-contact {
        grid-area: title;
    }

    .leads-table .cell-contact .contact-name {
        font-size: 0.9375rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .leads-table .cell-status {
        grid-area: status;
        justify-self: end;
        align-self: start;
    }

    .leads-table .cell-phone {
        grid-area: phone;
        color: var(--gray-700);
        font-size: 0.8125rem;
        overflow-wrap: anywhere;
    }

    .leads-table .cell-date {
        grid-area: date;
        justify-self: end;
    }

    .leads-table .cell-date .date-main {
        font-size: 0.75rem;
        font-weight: 400;
        color: var(--gray-500);
    }

    .leads-table .cell-manager {
        grid-area: manager;
        color: var(--gray-500);
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .leads-table .cell-manager::before {
        content: "Отв.: ";
        display: inline;
        font-size: inherit;
        font-weight: 400;
        text-transform: none;
        letter-spacing: 0;
        margin: 0;
    }

    .leads-table .cell-id {
        grid-area: id;
        justify-self: end;
        order: 0;
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--gray-400);
    }
}

/* Дашборд на телефоне: четыре показателя плиткой 2 x 2 вместо столбца на
   весь первый экран */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .stat-value {
        font-size: 1.375rem;
    }

    .stat-label {
        margin-top: 2px;
        font-size: 0.8125rem;
    }

    .dashboard-grid,
    .dashboard-row {
        gap: 14px;
    }
}

/* Таблицы настроек (сотрудники, приглашения, API-ключи) на телефоне: первая
   ячейка заголовком карточки, остальные строкой «подпись: значение», пустые
   ячейки не занимают места, кнопки действий внизу во всю ширину. */
@media (max-width: 768px) {
    .settings-page .data-table tbody tr {
        gap: 6px;
        padding: 14px;
    }

    .settings-page .data-table td:not(.cell-actions) {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: baseline;
        gap: 2px 12px;
        min-width: 0;
        font-size: 0.8125rem;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .settings-page .data-table td:not(.cell-actions)::before {
        flex-shrink: 0;
        margin: 0;
        font-size: 0.75rem;
        font-weight: 500;
        letter-spacing: 0;
        text-transform: none;
        text-align: left;
    }

    .settings-page .data-table td:not(.cell-actions):not(:first-child) > * {
        grid-column: 2;
        justify-self: end;
    }

    .settings-page .data-table td .badge {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .settings-page .data-table td:first-child {
        display: block;
        padding-bottom: 8px;
        margin-bottom: 2px;
        border-bottom: 1px solid var(--gray-100);
        font-size: 0.9375rem;
        font-weight: 600;
        color: var(--gray-900);
        text-align: left;
    }

    .settings-page .data-table td:first-child::before {
        display: none;
    }

    .settings-page .data-table td:first-child .user-cell {
        flex-wrap: nowrap;
    }

    /* Ячейка без значения (нет отметок у сотрудника) */
    .settings-page .data-table td:has(> .settings-badges):not(:has(.badge)) {
        display: none;
    }

    .settings-page .data-table .settings-badges {
        justify-content: flex-end;
    }

    .settings-page .data-table .cell-actions {
        margin-top: 6px;
    }

    .settings-page .data-table .cell-actions:empty {
        display: none;
    }

    .settings-page .data-table .cell-actions > .btn,
    .settings-page .data-table .cell-actions > form,
    .settings-page .data-table .cell-actions .settings-actions,
    .settings-page .data-table .cell-actions .settings-actions > form {
        flex: 1 1 auto;
    }

    .settings-page .data-table .cell-actions form > .btn {
        width: 100%;
    }
}

/* Опасное действие в строке списка (отозвать приглашение или ключ) спокойнее
   основного: красный контур вместо сплошной заливки. Сплошной красный остаётся
   у кнопок, которые завершают необратимое действие на своей карточке. */
.data-table .btn-danger.btn-sm {
    background: white;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.data-table .btn-danger.btn-sm:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #b91c1c;
}

/* Редактор списков на телефоне: «Добавить» и «Сохранить» делят ширину */
@media (max-width: 640px) {
    .row-editor-footer .btn {
        flex: 1 1 auto;
    }
}

/* Модальные окна на телефоне: во весь экран, содержимое прокручивается между
   шапкой и закреплённой внизу строкой кнопок */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal {
        max-width: none;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        margin: 0;
        border-radius: 0;
    }

    .modal-header {
        flex-shrink: 0;
        padding: 12px 12px 12px 18px;
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: 18px;
    }

    .modal-footer {
        flex-shrink: 0;
        flex-wrap: nowrap;
        padding: 12px 18px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .modal-footer .btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        white-space: normal;
    }

    /* Аудит 12.11.2026: в окне «Причина отказа» (карточка и канбан) «Завершить как «Провал»» не помещалась
       в половину строки и шла в две строки. Кнопки друг под другом во всю ширину, главная сверху */
    #lossReasonModal .modal-footer,
    #kanban-loss-modal .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }

    #lossReasonModal .modal-footer .btn,
    #kanban-loss-modal .modal-footer .btn {
        flex: 0 0 auto;
        width: 100%;
        white-space: nowrap;
    }
}

/* Баннер cookie в кабинете на телефоне: кнопка под палец */
@media (max-width: 640px) {
    body .crm-cookie__btn {
        height: 40px;
    }
}

/* Действия с заявкой под карточкой (объединить, в спам, архив): второстепенные,
   поэтому спокойные контурные кнопки; цвет текста подсказывает смысл. */
.lead-actions .btn-spam {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.lead-actions .btn-spam:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.lead-actions .btn-danger {
    background: white;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.lead-actions .btn-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #b91c1c;
}

@media (max-width: 768px) {
    /* На телефоне три действия в один ряд, а не тремя полосами во всю ширину */
    .lead-actions-mobile {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .lead-actions-mobile > .btn,
    .lead-actions-mobile > form {
        flex: 1 1 auto;
        width: auto;
    }

    .lead-actions-mobile .btn {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Телефон: пункты меню, быстрые ссылки, логотип и крестик поиска не ниже 40 px */
@media (max-width: 768px) {
    .sidebar-external-link,
    .company-menu-item,
    .sidebar-header .logo {
        min-height: 40px;
    }

    .mobile-search-clear {
        right: 2px;
        width: 40px;
        height: 40px;
        padding: 0;
    }
}

/* Сенсорный экран (02.10.2026, проверка адаптивности).
   Поля ввода 16px: при меньшем шрифте iOS приближает страницу при фокусе, и
   после ввода кабинет остаётся увеличенным. :is() поднимает вес правила выше
   классов полей (.form-input, .comment-input, .chats-search-input и др.).
   Вкладки настроек и ссылки карточки заявки под палец (около 44px). */
@media (pointer: coarse) {
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea) {
        font-size: 16px;
    }

    .settings-tabs a {
        min-height: 44px;
    }

    /* Кнопки, бургер, закрытие меню, «Выйти», поля фильтров и мобильный поиск
       под палец не меньше 44px (прогон 31.10.2026: на телефоне были 40px:
       «Новая заявка», «Чат с клиентом», «Назад», «Найти» в админке и т. п.).
       Только высота/ширина-минимум: раскладка строк не меняется. */
    .btn,
    .filter-input,
    .filter-select,
    .mobile-search-input {
        min-height: 44px;
    }

    /* Кнопки-иконки без подписи на телефоне («Назад», «Чат с клиентом»,
       «Новое обращение») были 40px в ширину */
    .btn {
        min-width: 44px;
    }

    /* Квадратные иконки шапки на телефоне заданы 40px селектором .top-bar
       (блок max-width 640px выше), он сильнее .btn: перебиваем тем же весом,
       правило стоит ниже в файле */
    .top-bar .btn-back,
    .top-bar .lead-chat-btn,
    .top-bar .lead-mail-btn {
        min-width: 44px;
    }

    /* display не задаём: бургер и крестик видны только в мобильной раскладке
       (display: flex в @media max-width 1024px), здесь только размер */
    .menu-toggle,
    .sidebar-close,
    .logout-btn {
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }

    /* Телефон, почта и сайт клиента в карточке заявки: зона нажатия была 17px
       в высоту; поля погашены отрицательным отступом, строка не растёт */
    .info-value > a {
        display: inline-block;
        max-width: 100%;
        padding: 12px 0;
        margin: -12px 0;
        overflow-wrap: anywhere;
    }

    /* Аудит 12.11.2026: «Все заявки» на дашборде (22px в высоту) и число открытых заявок на странице
       сотрудника (8x17). Поля погашены отрицательным отступом: строка и вид не меняются */
    .card-header > .card-link {
        display: inline-block;
        padding: 10px 0;
        margin: -10px 0;
    }

    .settings-fact-value > a {
        display: inline-block;
        min-width: 24px;
        padding: 10px 8px;
        margin: -10px -8px;
    }
}

/* Вход за пользователя (админка платформы, inc/platform_admin.php §12.5):
   плашка на каждой странице кабинета, пока оператор работает за клиента. */
.impersonation-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    margin-bottom: 20px; padding: 12px 16px;
    background: var(--warning-bg); border: 1px solid #fcd34d; border-radius: var(--radius);
    color: #92400e; font-size: 14px;
}
.impersonation-text { min-width: 0; overflow-wrap: anywhere; }
.impersonation-form { margin: 0; }
.impersonation-btn { background: var(--warning); color: #fff; border: none; }
.impersonation-btn:hover { background: #d97706; color: #fff; }
