/* Каркас приложения: сайдбар + хедер + контент (стиль KotPlatform) */

.app {
    display: flex;
    /* Под системной полосой (оплата, объявления) — ровно остаток экрана:
       100vh плюс полоса давали лишнюю прокрутку страницы и вторую полосу
       прокрутки рядом со своей у списка. */
    min-height: calc(100vh - var(--sysbar-h, 0px));
}

/* ---------------------------------------------------------------- Сайдбар */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--card);
    border-right: 0.0625rem solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: fixed;
    /* Ниже системной полосы (readonly/объявления), чтобы она шла во всю ширину */
    top: var(--sysbar-h, 0px);
    bottom: 0;
    left: 0;
    z-index: 60;
    transition: transform var(--t-med);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.125rem 1.25rem 0.875rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none !important;
}
.sidebar-brand .brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5625rem;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9063rem;
    flex: none;
}
.sidebar-brand .brand-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.4375rem;
    border-radius: 0.375rem;
    background: var(--accent-soft);
    color: var(--accent);
    letter-spacing: .04em;
}

.sidebar-nav {
    flex: 1;
    /* Без min-height:0 меню растягивалось на всю высоту пунктов и не
       прокручивалось («зависало»); contain — прокрутка не уходит в страницу. */
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0.75rem 1rem;
}
.nav-section {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 1rem 0.625rem 0.375rem;
}

/* Переключатель рабочих пространств (систем) */
.space-switch { margin: 0 0.75rem 0.25rem; position: relative; }
.space-current {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 0.0625rem solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--gray-soft);
    color: var(--text);
    font-weight: 500;
    font-size: 0.9063rem;
    cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.space-current:hover { border-color: var(--accent); }
.space-current .icon:first-child { color: var(--accent); }
.space-switch .dropdown-menu { top: calc(100% + 4px); }
.dropdown-label {
    padding: 0.4rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.dropdown-item.active { color: var(--accent); font-weight: 500; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6875rem;
    /* Пункты чуть крупнее: в них попадают мышью и пальцем, а список стал
       короче — место есть. */
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.1875rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.90625rem;
    font-weight: 400;
    text-decoration: none !important;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--gray-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .icon { color: var(--text-faint); transition: color var(--t-fast); }
.nav-link:hover .icon { color: var(--text-muted); }
.nav-link.active .icon { color: var(--accent); }
.nav-link .counter { margin-left: auto; }

.sidebar-footer {
    padding: 0.75rem;
    border-top: 0.0625rem solid var(--border-soft);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--t-fast);
}
.sidebar-user:hover { background: var(--gray-soft); }
.sidebar-user .u-name { font-size: 0.8125rem; font-weight: 600; line-height: 1.25; }
.sidebar-user .u-role { font-size: 0.75rem; color: var(--text-muted); }

/* ---------------------------------------------------------------- Основная область */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 0.0625rem solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
    position: sticky;
    top: var(--sysbar-h, 0px);
    z-index: 40;
}
.header-titles { min-width: 0; flex: 1; }
.header-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-subtitle { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.625rem; flex: none; }

.burger {
    display: none;
    background: none;
    border: 0;
    padding: 0.5rem;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
}
.burger:hover { background: var(--gray-soft); }

/* Тот же круг 2.25rem, что у подсказки и поиска: раньше колокольчик был
   скруглённым квадратом с другим отступом, и в ряду из трёх значков один
   подсвечивался по-своему. */
.bell-btn {
    position: relative;
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.bell-btn:hover { background: var(--gray-soft); color: var(--text); }
/* Сам значок внутри — одного размера у всех трёх кнопок шапки. */
.help-btn .icon, .srch-btn .icon, .bell-btn .icon { width: 1.25rem; height: 1.25rem; }
/* Значок на колокольчике сидит в углу и наполовину снаружи, а не поверх него.
   Внутри кнопки он места не находит: круг под «99+» шире самого колокольчика и
   закрывал его целиком — оставалось красное пятно без понятного смысла.
   Кольцо в цвет шапки отделяет число от значка, на который оно наезжает. */
.bell-btn .counter {
    position: absolute;
    top: 0.125rem;
    right: 0.125rem;
    transform: translate(40%, -40%);
    box-shadow: 0 0 0 0.125rem var(--card);
}
/* Кнопке нужен запас справа и сверху: иначе выехавший значок обрежется краем
   шапки или наедет на соседнюю кнопку. */
.bell-btn { margin-right: 0.375rem; }

/* Часы в шапке */
.header-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.9063rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
}
.header-date { font-size: 0.75rem; font-weight: 500; color: var(--text-faint); }
@media (max-width: 30rem) { .header-clock { display: none; } }

/* Подсказка по разделу — значком справа, рядом с поиском и колокольчиком.
   Своя строка над содержимым обходилась в целую полосу ради одной кнопки и
   опускала карточки вниз, а у названия раздела кнопка отвлекала от него. */
.help-btn {
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem;
    border: 0; border-radius: 50%;
    background: none; color: var(--text-muted); cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.help-btn:hover { background: var(--gray-soft); color: var(--text); }
@media (max-width: 40rem) {
    /* На телефоне в шапке тесно: подсказка уступает место поиску и часам. */
    .help-btn { display: none; }
}
/* Выше левого меню (60, открытое на телефоне — 95) и нижней навигации (70):
   справка накрывает весь экран, иначе меню оставалось светлым пятном. */
.help-panel { position: fixed; inset: 0; z-index: 110; }
body.help-open { overflow: hidden; }
.help-panel[hidden] { display: none !important; }
.help-back { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.35); animation: mig-fade 0.2s ease; }
.help-card {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(30rem, 100%);
    display: flex;
    flex-direction: column;
    background: var(--card);
    box-shadow: -1rem 0 3rem rgba(15, 23, 42, 0.18);
    animation: help-in 0.22s ease;
}
@keyframes help-in { from { transform: translateX(1.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mig-fade { from { opacity: 0; } to { opacity: 1; } }
.help-head,
.help-foot { flex: none; display: flex; align-items: center; gap: 0.6rem; padding: 0.9rem 1.1rem; }
.help-head { justify-content: space-between; border-bottom: 0.0625rem solid var(--border-soft); }
.help-foot { border-top: 0.0625rem solid var(--border-soft); background: var(--gray-soft); }
.help-foot .btn:last-child { margin-left: auto; }
/* min-height:0 — иначе длинная справка не скроллится, а выдавит футер */
.help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 1.1rem; line-height: 1.65; }
.help-body p { margin: 0 0 0.75rem; }
.help-body ul, .help-body ol { margin: 0 0 0.75rem; padding-left: 1.15rem; }
.help-body li { margin-bottom: 0.35rem; }
.help-body h4 { margin: 1rem 0 0.4rem; font-size: 0.9063rem; }
.help-shot { display: block; margin-top: 0.75rem; border-radius: 0.75rem; overflow: hidden; border: 0.0625rem solid var(--border); }
.help-shot img { display: block; width: 100%; height: auto; }
.help-toc { display: flex; flex-direction: column; gap: 0.35rem; }
.help-toc a { color: var(--text-muted); text-decoration: none; padding: 0.3rem 0; }
.help-toc a:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .help-card, .help-back { animation: none; } }

/* Напоминание о ближайшем перезвоне — круглая иконка перед зарплатой.
   Текст (кому и через сколько) — в подсказке: в шапке он занимал полстроки. */
.header-remind {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    background: var(--warning-soft, #fff7ed);
    color: var(--warning, #b45309);
    text-decoration: none;
    transition: filter var(--t-fast);
}
/* Цвет закреплён и при наведении: общее правило ссылок красило её в синий. */
.header-remind:hover { text-decoration: none; color: var(--warning, #b45309);
    background: color-mix(in srgb, var(--warning, #b45309) 22%, var(--warning-soft, #fff7ed)); }
.header-remind:focus-visible { outline: 0.125rem solid var(--accent); outline-offset: 0.125rem; }
.header-remind[hidden] { display: none; }
.header-remind .icon { width: 1.05rem; height: 1.05rem; }
/* Просрочен — тревожно; оператор на звонке — спокойно, штрафа за это не будет */
.header-remind.is-late { background: var(--danger-soft, #fef2f2); color: var(--danger); }
.header-remind.is-busy { background: var(--gray-soft); color: var(--text-muted); }
.header-remind.is-late:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--danger-soft, #fef2f2)); }
.header-remind.is-busy:hover { color: var(--text-muted); background: color-mix(in srgb, var(--text-muted) 14%, var(--gray-soft)); }
.header-remind .dot {
    position: absolute; top: 0.2rem; right: 0.2rem;
    width: 0.5rem; height: 0.5rem; border-radius: 50%;
    background: currentColor; box-shadow: 0 0 0 0.125rem var(--card);
    animation: remind-pulse 1.6s ease-in-out infinite;
}
.header-remind.is-busy .dot { animation: none; }
@keyframes remind-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .header-remind .dot { animation: none; } }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Чип зарплаты оператора в шапке */
.salary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--t-fast), color var(--t-fast);
}
/* При наведении — свой зелёный, а не общий синий для ссылок: чип про деньги,
   и цвет у него должен оставаться денежным. */
.salary-chip:hover,
.salary-chip:focus-visible { background: var(--success); color: #fff; text-decoration: none; }

/* Раздача заявок — строка в левом меню над профилем: значок со счётчиком
   очереди, подпись, состояние словом и бегунок. Выключенная раздача —
   предупреждающим цветом: заявки копятся, это не норма. */
.side-distrib {
    display: flex; align-items: center; gap: 0.625rem;
    width: 100%; margin: 0 0 0.375rem;
    padding: 0.45rem 0.625rem;
    border: 0; border-radius: var(--radius-sm);
    background: var(--warning-soft, #fff7ed); color: var(--text);
    font: inherit; text-align: left; cursor: pointer;
    transition: background var(--t-fast), filter var(--t-fast);
}
.side-distrib:hover { filter: brightness(0.97); }
.side-distrib:focus-visible { outline: 0.125rem solid var(--accent); outline-offset: 0.125rem; }
.side-distrib:disabled { cursor: progress; opacity: 0.7; }
.side-distrib.is-on { background: var(--success-soft); }
.sd-ic {
    position: relative; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem; border-radius: 50%;
    background: var(--card); color: var(--warning);
}
.side-distrib.is-on .sd-ic { color: var(--success); }
.sd-queue {
    position: absolute; top: -0.35rem; right: -0.45rem;
    min-width: 1.05rem; padding: 0 0.25rem;
    border-radius: 999px; background: var(--warning); color: #fff;
    font-size: 0.625rem; font-weight: 600; line-height: 1.05rem; text-align: center;
    box-shadow: 0 0 0 0.125rem var(--card);
}
.sd-queue[hidden] { display: none; }
.sd-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sd-title { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-distrib .dt-value { font-size: 0.75rem; font-weight: 600; color: var(--warning); }
.side-distrib.is-on .dt-value { color: var(--success); }
.dt-switch {
    position: relative; flex: none; width: 2rem; height: 1.125rem;
    border-radius: 999px; background: var(--gray); opacity: 0.45;
    transition: background var(--t-fast), opacity var(--t-fast);
}
.side-distrib.is-on .dt-switch { background: var(--success); opacity: 1; }
.dt-knob {
    position: absolute; top: 0.125rem; left: 0.125rem;
    width: 0.875rem; height: 0.875rem; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .25);
    transition: transform var(--t-fast);
}
.side-distrib.is-on .dt-knob { transform: translateX(0.875rem); }
/* Вспышка при нажатии: подтверждает, что переключение приняли. */
.side-distrib.is-flash { animation: dtflash .45s ease; }
@keyframes dtflash {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, .35); }
    100% { box-shadow: 0 0 0 0.5rem rgba(37, 99, 235, 0); }
}
@media (prefers-reduced-motion: reduce) { .side-distrib.is-flash { animation: none; } }
.salary-chip .icon { width: 1.1rem; height: 1.1rem; }
@media (max-width: 480px) {
    .salary-chip-sum { display: none; }
}

.content {
    flex: 1;
    padding: 1.5rem 1.75rem 3rem;
    width: 100%;
    max-width: var(--content-max);
}

/* Полноэкранные чаты (мессенджер и чаты с клиентами): без отступов и
   ограничения ширины — интерфейс занимает всю область справа от меню,
   во всю высоту, как в Telegram. */
.content:has(.msgr),
.content:has(.wc-inbox) {
    padding: 0;
    max-width: none;
    overflow: hidden;
    --chat-gap: 0rem;   /* отступов больше нет — чат занимает всю область */
}
/* Высоту задаём самому чату, а не только контейнеру: если браузер не понимает
   :has(), отступы .content остаются, но чат всё равно ограничен по высоте и
   поле ввода не уезжает под экран (--chat-gap подставит запас на отступы). */
.msgr,
.wc-inbox {
    height: calc(100dvh - var(--header-h) - var(--sysbar-h, 0px) - var(--chat-gap, 4.5rem));
}
@media (max-width: 48rem) {
    /* На телефоне вычитаем нижнюю навигацию — её высоту меряет app.js. */
    .msgr,
    .wc-inbox {
        height: calc(100dvh - var(--header-h) - var(--sysbar-h, 0px)
                     - var(--bottomnav-h, 4.75rem) - var(--chat-gap, 4.5rem));
    }
}

/* Мобильная нижняя навигация */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    border-top: 0.0625rem solid var(--border-soft);
    z-index: 70;
    padding: 0.375rem 0.5rem calc(0.375rem + env(safe-area-inset-bottom));
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.3125rem 0.125rem;
    color: var(--text-muted);
    font-size: 0.6563rem;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: var(--radius-xs);
}
.bottom-nav a.active { color: var(--accent); }
/* Кнопка «Ещё» — такая же цель, как и раздел: её жмут не реже остальных. */
.bottom-nav .bn-more {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.3125rem 0.125rem;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.6563rem;
    font-weight: 600;
    cursor: pointer;
}
body.sidebar-open .bottom-nav .bn-more { color: var(--accent); }
/* Значок раздела и счётчик над ним. */
.bottom-nav .bn-ic { position: relative; display: inline-flex; min-height: 1.5rem; align-items: center; }
.bottom-nav .bn-ic .icon { width: 1.375rem; height: 1.375rem; }
/* Круг, а не таблетка: значок не должен менять форму от числа — на узком
   экране растянутый значок налезает на соседний пункт. */
.bottom-nav .bn-dot {
    position: absolute; top: -0.25rem; left: 60%;
    width: 1rem; min-width: 1rem; height: 1rem; padding: 0;
    border-radius: 50%; background: var(--danger, #dc2626); color: #fff;
    font-size: 0.625rem; line-height: 1rem; font-weight: 600; text-align: center;
}
/* Три знака — круг крупнее, а не шрифт мельче: нечитаемый значок не нужен. */
.bottom-nav .bn-dot.is-wide {
    width: 1.25rem; min-width: 1.25rem; height: 1.25rem;
    font-size: 0.5625rem; line-height: 1.25rem; letter-spacing: -0.01em;
}
/* Тревожная точка (ИИ позвал оператора) — слева от значка, с кольцом. */
.bottom-nav .bn-dot.is-alert { left: auto; right: 60%; }
.bottom-nav .bn-dot.is-alert::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 0.125rem var(--danger, #dc2626);
    animation: crmAlertRing 1.6s ease-out infinite; will-change: transform, opacity; }
@media (prefers-reduced-motion: reduce) { .bottom-nav .bn-dot.is-alert::after { animation: none; opacity: 0; } }
/* Текущий раздел отмечаем и полоской: цветом одного значка его на ходу не видно. */
.bottom-nav a.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 2rem;
    height: 0.1875rem;
    border-radius: 0 0 999px 999px;
    background: var(--accent);
}
.bottom-nav a { position: relative; min-height: 3rem; justify-content: center; }
.bottom-nav .bn-more { min-height: 3rem; justify-content: center; }

/* Затемнение при открытом мобильном сайдбаре */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .4);
    z-index: 90;
}

/* Открытое меню — всегда поверх содержимого страницы.
   Чат с клиентами на телефоне разворачивается на весь экран с тем же
   z-index, и, будучи ниже в разметке, накрывал собой меню: пункты были
   видны, но нажать на них было нельзя. */
body.sidebar-open .sidebar { z-index: 95; }
body.sidebar-open .wc-inbox,
body.sidebar-open .msgr { z-index: 10 !important; }

/* ---------------------------------------------------------------- Страница входа */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 25rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
/* Разделитель между входом по паролю и по PIN */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 0.0625rem;
    background: var(--border-soft);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

/* ---- Системная полоса сообщений: поверх всего, во всю ширину ----
   Каждое сообщение — яркая карточка, залитая цветом сообщения: белый текст,
   значок в полупрозрачной плашке, светлые кнопки. Бледную её не замечали
   («работаете под чужой учётной записью», «нет оплаты»). Полоса закрывает
   содержимое под собой фоном страницы, высота уходит в --sysbar-h (app.js). */
.sysbar {
    position: sticky;
    top: 0;
    z-index: 100; /* поверх сайдбара и шапки — полоса всегда сверху во всю ширину */
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    background: var(--bg);
}
.sysbar:empty { display: none; }
/* Отступы — у сообщений, не у полосы: без сообщений полоса нулевой высоты. */
.sysbar-msg { margin: 0 0.75rem; }
.sysbar-msg:first-child { margin-top: 0.5rem; }
.sysbar-msg:last-child { margin-bottom: 0.5rem; }
.sysbar-msg {
    --tone: var(--accent);
    --tone-soft: var(--accent-soft);
    --tone-line: var(--accent-soft-2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.375rem 0.5rem 0.375rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #fff;
    background: var(--tone);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    box-shadow: 0 0.25rem 0.75rem color-mix(in srgb, var(--tone) 30%, transparent);
}
.sysbar-msg.is-warning { --tone: #c2410c; }
.sysbar-msg.is-danger { --tone: #b91c1c; }
.sysbar-msg .grow { flex: 1; min-width: 0; }
.sysbar-msg .grow b { color: #fff; font-weight: 700; }
/* Напоминание о подписке и балансе ИИ: строка-пояснение под заголовком. */
.sysbar-msg .grow small { display: block; font-size: 0.8125rem; opacity: 0.88; }
.sysbar-acts { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.sysbar-msg a:not(.btn) { color: #fff; text-decoration: underline; }
/* Значок — в полупрозрачной светлой плашке */
.sysbar-msg > .icon {
    flex-shrink: 0;
    box-sizing: border-box;
    width: 2rem;
    height: 2rem;
    padding: 0.4375rem;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}
.sysbar-msg .btn,
.sysbar-msg > form { flex-shrink: 0; margin: 0; }
.sysbar-msg .btn { white-space: nowrap; }
/* Кнопки на цветной полосе — белые, текст в цвет сообщения */
.sysbar-msg .btn-primary,
.sysbar-msg .btn-secondary {
    background: #fff;
    color: var(--tone);
    border-color: transparent;
    font-weight: 600;
}
.sysbar-msg .btn-primary:hover,
.sysbar-msg .btn-secondary:hover { background: rgba(255, 255, 255, 0.9); color: var(--tone); filter: none; }
.sysbar-msg .btn-ghost { color: #fff; }
.sysbar-msg .btn-ghost:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
/* «Оплатить» — главное действие полосы: чуть заметнее. */
.sysbar-msg .sysbar-pay { font-weight: 600; padding-left: 0.875rem; padding-right: 0.875rem; }
/* Новость или предложение платформы: цвет владельца (или акцент темы)
   мягким переливом, белая кнопка в тон и заголовок с текстом в две строки. */
.sysbar-msg.is-promo {
    background: linear-gradient(115deg, var(--tone) 0%, color-mix(in srgb, var(--tone) 72%, #7c3aed) 100%);
    padding-top: 0.5rem; padding-bottom: 0.5rem;
}
.sysbar-msg.is-promo .grow { display: flex; flex-direction: column; gap: 0.1rem; }
.sysbar-promo-t { opacity: 0.92; font-size: 0.8125rem; }
.sysbar-msg .sysbar-promo-btn { background: #fff; color: var(--tone); border: 0; font-weight: 600; border-radius: 0.65rem; }
.sysbar-msg .sysbar-promo-btn:hover { background: rgba(255, 255, 255, 0.9); color: var(--tone); }
.sysbar-x {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-xs);
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.375rem;
    line-height: 1;
    cursor: pointer;
}
.sysbar-x:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
/* Телефон: в одну строку не помещается. Значок — слева, текст и крестик —
   первой строкой, кнопки — переносятся под текст в ряд, ровно по его краю. */
@media (max-width: 640px) {
    .sysbar-msg { margin: 0 0.5rem; }
    .sysbar-msg:first-child { margin-top: 0.375rem; }
    .sysbar-msg:last-child { margin-bottom: 0.375rem; }
    .sysbar-msg {
        position: relative;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.5rem 0.5rem 3.125rem;
        font-size: 0.8125rem;
    }
    .sysbar-msg > .icon { position: absolute; left: 0.5rem; top: 0.5rem; }
    .sysbar-msg > .grow { flex: 1 1 calc(100% - 2.75rem); align-self: center; }
    .sysbar-msg > .sysbar-x { order: 1; width: 2rem; height: 2rem; align-self: flex-start; }
    .sysbar-msg > .btn, .sysbar-msg > form, .sysbar-msg > a { order: 2; }
    .sysbar-msg .btn { white-space: normal; text-align: left; }
}

/* ---- Блокировка: размытая система + карточка с оплатой ---- */
.lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}
.lock-overlay-card {
    width: 100%;
    max-width: 27rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.3);
    padding: 2.25rem 2rem;
    text-align: center;
}
.lock-overlay-ico {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warning-soft);
    color: var(--warning-text, #b45309);
}
.lock-overlay-ico .icon { width: 1.75rem; height: 1.75rem; }
.lock-overlay-card h2 { font-size: 1.375rem; margin-bottom: 0.5rem; }
.lock-overlay-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ---- Режим «только чтение»: гасим средства ввода ---- */
body[data-readonly] [data-ro-hide] { display: none !important; }
body[data-readonly] .ro-disabled {
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
}


/* ---------------------------------------------------------------- Меню до иконок
   Кнопка в шапке сворачивает сайдбар в узкую полосу: остаются иконки и
   счётчики, названия всплывают подсказкой. Контент получает всю ширину. */
.rail-btn {
    flex: none;
    width: 2.25rem; height: 2.25rem;
    display: none;                      /* только на широких экранах */
    align-items: center; justify-content: center;
    border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--text-muted); cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.rail-btn:hover { background: var(--gray-soft); color: var(--text); }
.rail-btn.is-on { color: var(--accent); background: var(--accent-soft); }
@media (min-width: 64rem) { .rail-btn { display: inline-flex; } }

@media (min-width: 64rem) {
    body.rail .sidebar { width: 4.25rem; }
    body.rail .main { margin-left: 4.25rem; }
    body.rail .sidebar-brand span:not(.brand-mark),
    body.rail .nav-link span:not(.counter),
    body.rail .nav-section,
    body.rail .space-current .grow,
    body.rail .space-current .icon:last-child,
    /* Блок пользователя: в узком меню остаётся только кружок с буквой.
       Имя, должность и стрелка не помещаются — от них оставалась пустая
       белая плашка рядом с аватаром. */
    body.rail .sidebar-user .grow,
    body.rail .sidebar-user > .icon,
    /* Раздача: остаётся цветной кружок со счётчиком очереди, состояние — в подсказке */
    body.rail .side-distrib .sd-text,
    body.rail .side-distrib .dt-switch,
    body.rail .nav-group-toggle .grow { display: none; }
    body.rail .sidebar-footer { padding: 0.5rem 0.4rem; }
    body.rail .sidebar-user { padding: 0.35rem; gap: 0; }
    /* Меню профиля само по себе шире полосы — выводим его вбок, а не внутрь */
    body.rail .sidebar-footer .dropdown-menu {
        left: calc(100% + 0.4rem); right: auto; min-width: 13rem;
    }
    body.rail .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
    body.rail .nav-link { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
    body.rail .nav-link .counter {
        position: absolute; transform: translate(0.9rem, -0.7rem); margin: 0;
    }
    /* Тревожный значок — в другом углу значка раздела, не поверх счётчика. */
    body.rail .nav-link .counter.is-alert { transform: translate(-0.9rem, -0.7rem); }
    body.rail .nav-link { position: relative; }
    body.rail .space-switch { margin-left: 0.4rem; margin-right: 0.4rem; }
    body.rail .space-current { justify-content: center; padding-left: 0.4rem; padding-right: 0.4rem; }
    body.rail .sidebar-user { justify-content: center; }
    body.rail .side-distrib { justify-content: center; padding: 0.35rem; }
}


/* Экран запуска (телефон) — стили в самой странице (layouts/_splash-css.php):
   он должен появиться раньше, чем загрузятся файлы стилей. */

/* Логотипы системы (Настройки → Система → Логотипы).
   Развёрнутое меню — полный логотип; свёрнутое — квадратный знак. */
.sidebar-brand .brand-mark.has-img { background: transparent; overflow: hidden; }
.sidebar-brand .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand.has-logo .brand-mark { display: none; }
.brand-logo { display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; height: 2.25rem; }
.brand-logo img { max-height: 100%; max-width: 10rem; object-fit: contain; object-position: center; }
.brand-logo .brand-logo-dark { display: none; }
:is([data-theme="dark"], [data-theme="black"]) .brand-logo:has(.brand-logo-dark) .brand-logo-light { display: none; }
:is([data-theme="dark"], [data-theme="black"]) .brand-logo .brand-logo-dark { display: block; }
@media (min-width: 64rem) {
    body.rail .sidebar-brand.has-logo .brand-mark { display: flex; }
    body.rail .sidebar-brand.has-logo .brand-logo { display: none; }
}
.auth-logo-img { max-height: 3rem; max-width: 14rem; object-fit: contain; }

/* Поддержка и инструкции в подвале меню: туда идут, когда что-то не
   получилось, — место им рядом с именем и выходом, а не в ряду с заявками. */
.sidebar-help {
    display: flex; flex-direction: column; gap: 0.125rem;
    padding-bottom: 0.5rem; margin-bottom: 0.5rem;
    border-bottom: 0.0625rem solid var(--border-soft);
}
.sidebar-help .nav-link { font-weight: 500; }

/* Подпункт группы в меню (простой режим): строкой под группой, с отступом —
   «Разборы разговоров» под «Звонками и СМС». */
.sidebar-nav .nav-link.is-sub { padding-left: 2.75rem; min-height: 2.125rem; font-size: 0.8125rem; color: var(--text-muted); }
.sidebar-nav .nav-link.is-sub .icon { width: 0.9375rem; height: 0.9375rem; }
.sidebar-nav .nav-link.is-sub.active { color: var(--accent); }

body.rail .sidebar-nav .nav-link.is-sub { display: none; }

/* Поддержка и инструкции на телефоне и планшете — обычными пунктами в конце
   списка (sidebar.php), подвал с ними не показываем. */
.sidebar-nav .nav-link.is-help-m { display: none; }
@media (max-width: 1024px) {
    .sidebar-nav .nav-link.is-help-m { display: flex; }
    .sidebar-help { display: none; }
}

/* Знак, нарисованный по названию (Core\BrandIcon): SVG во всю плашку. */
.sidebar-brand .brand-mark.is-gen { background: transparent; padding: 0; overflow: hidden; }
.sidebar-brand .brand-mark.is-gen svg { width: 100%; height: 100%; display: block; }
