:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --ink: #1c2b33;
    --ink-soft: #5b6b74;
    --accent: #1fa98c;
    --accent-dark: #16806a;
    --accent-soft: #e4f7f2;
    --danger: #d9534f;
    --border: #e4e8eb;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(20, 40, 50, 0.08);
    --stat-telegram: #2a78d6;
    --stat-telegram-direct: #9fc2ec;
    --stat-max: #eb6834;
    --stat-max-direct: #f6bba4;
    --chart-grid: #e1e0d9;
    --chart-axis: #c3c2b7;
    --chart-muted: #898781;
    /* Динамика активности сотрудника (user.html) — переиспользуют палитру тонирования
       фото (TintColor), чтобы не плодить ещё один произвольный набор цветов. */
    --stat-publications: #1fa98c;
    --stat-translate: #f5a623;
    --stat-title: #8b5cf6;
    --stat-shorten: #3aa0e8;
    --stat-photo-process: #ef5b4e;
    --stat-image-generate: #17324f;
    --topbar-h: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* .btn и другие классы задают display: у элементов с одинаковой специфичностью
   [hidden] проигрывает более позднему правилу в каскаде — явно перебиваем. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

/* ------------------------------------------------------------------ */
/*  Каркас приложения: шапка + боковое меню + контент                 */
/* ------------------------------------------------------------------ */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    flex: 1;
}

.topbar-logo {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: block;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
}

.icon-btn:hover { background: var(--accent-soft); }

.hamburger {
    width: 18px;
    height: 13px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger span {
    display: block;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
}

.app-body {
    flex: 1;
    display: flex;
    min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
    width: 264px;
    flex: 0 0 auto;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: space-between;
    /* Как и .panel-result — остаётся на месте при длинном контенте справа/слева,
       чтобы не приходилось прокручивать страницу вверх ради смены функции. */
    position: sticky;
    top: var(--topbar-h);
    max-height: calc(100vh - var(--topbar-h));
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
    padding: 0 10px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 14px;
    border-radius: 12px;
    border: none;
    background: none;
    color: var(--ink);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.nav-item-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    color: var(--ink-soft);
    transition: color .15s ease;
}

.nav-item:hover { background: var(--accent-soft); }
.nav-item:hover .nav-item-icon { color: var(--accent-dark); }

.nav-item--active {
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 700;
}

.nav-item--active .nav-item-icon { color: var(--accent-dark); }

/* Аватарка (см. avatarHtml() в site.js) как первый элемент строки «Профиль» — вместо SVG-иконки. */
.nav-item-avatar {
    flex: 0 0 auto;
    display: flex;
}

/* «Выйти» — единственный деструктивный пункт в сайдбаре, подсвечивается красным при наведении. */
.nav-item--danger {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.nav-item--danger:hover {
    background: #fdecea;
    color: var(--danger);
}

.nav-item--danger:hover .nav-item-icon { color: var(--danger); }

.sidebar-overlay {
    display: none;
}

.content {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(320px, 480px) 1fr;
    gap: 20px;
    align-items: start;
    /* Без этого при нескольких строках в гриде (как на «Работе с текстом» —
       панель + кнопки под ней) лишняя высота растягивается МЕЖДУ строками
       вместо того, чтобы остаться под последней — строки разъезжаются далеко
       друг от друга на высоких экранах. */
    align-content: start;
    padding: 24px;
}

/* «Генерация картинки»: форма с текстом статьи получает столько же места, сколько и
   результат — иначе на длинной статье панель результата (три миниатюры + большое
   превью) неоправданно растягивается на всю оставшуюся ширину экрана. */
.content.content--balanced {
    grid-template-columns: 1fr 1fr;
}

/* Раньше эти правила задавались инлайн-стилем прямо в HTML (style="grid-template-columns: ...")
   на самом <main class="content">  — рабочий способ для десктопа, но инлайн-стиль всегда
   перебивает @media-правила в CSS независимо от специфичности, поэтому дашборд ниже никогда
   не схлопывался в меньше колонок на телефоне/планшете (реальный баг, а не задумка). Перенесено
   сюда именно поэтому — дальше эти же селекторы переопределяются в @media ниже как обычно. */
#dashboardContent.content {
    grid-template-columns: 1fr 1fr 1fr;
}

#orgsContent.content,
#statsContent.content,
#textContent.content {
    grid-template-columns: 1fr;
}

.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.panel-result {
    position: sticky;
    top: calc(var(--topbar-h) + 24px);
}

.panel--narrow {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.panel-header h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.link-btn {
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.link-btn:hover { color: var(--accent-dark); }

/* ------------------------------------------------------------------ */
/*  Профиль (в сайдбаре — см. .nav-item-avatar/.nav-item--danger выше)  */
/* ------------------------------------------------------------------ */

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/*  Форма карточки                                                     */
/* ------------------------------------------------------------------ */

.field-group {
    margin-bottom: 22px;
}

.field-group-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 10px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.choice-btn {
    display: block;
    width: 100%;
    padding: 12px 10px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: #fbfcfc;
    color: var(--ink);
    font-size: 13.5px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.choice-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.choice-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* ------------------------------------------------------------------ */
/*  Работа с текстом (ИИ-перевод)                                      */
/* ------------------------------------------------------------------ */

.text-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.text-toolbar-group {
    display: flex;
    gap: 8px;
}

.text-toolbar-select {
    width: 150px;
}

.autogrow {
    overflow: hidden;
    resize: none;
    min-height: 64px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-row .field {
    flex: 1;
    margin-bottom: 0;
}

.input-row .btn {
    flex: 0 0 auto;
    height: 46px;
}

.image-gallery-wrap {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.image-gallery-item {
    display: block;
    padding: 3px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    line-height: 0;
    transition: border-color .15s ease, background .15s ease;
}

.image-gallery-item img {
    display: block;
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 7px;
}

.image-gallery-item:hover {
    border-color: var(--accent);
}

.image-gallery-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.image-candidates {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* Фиксированный размер миниатюры — не растягиваем на всю ширину панели. */
.image-candidate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 150px;
    padding: 8px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.image-candidate--pending,
.image-candidate--failed {
    cursor: default;
}

.image-candidate-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
}

.image-candidate img {
    display: block;
    width: 134px;
    height: 134px;
    object-fit: cover;
    border-radius: 8px;
}

.image-candidate:hover {
    border-color: var(--accent);
}

.image-candidate.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.image-candidate.active .image-candidate-label {
    color: var(--accent-dark);
}

/* Крутилка, пока конкретная модель ещё не отдала картинку. */
.image-candidate-spinner {
    width: 134px;
    height: 134px;
    border-radius: 8px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-candidate-spinner::after {
    content: '';
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
}

@keyframes image-candidate-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: no-preference) {
    .image-candidate-spinner::after {
        animation: image-candidate-spin 0.8s linear infinite;
    }
}

.image-candidate-error {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 134px;
    height: 134px;
    border-radius: 8px;
    background: #fdecea;
    color: var(--danger);
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.gen-preview-frame {
    /* Никакого фона/рамки под фото — просто сама картинка под тремя миниатюрами,
       без "коробки" вокруг. */
    position: relative;
    width: 100%;
    max-width: 480px;
    line-height: 0;
}

.gen-preview-frame img#previewImg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    /* Без object-fit/обрезки — картинка от GigaChat не масштабируется под чужие пропорции,
       показывается в точности такой, какой пришла (см. NewsImageComposer.toJpeg). Перебиваем
       max-width/max-height у общего #previewImg ниже по файлу (id один и тот же на разных
       страницах) — это отдельное свойство, не перекрывается через width/height, и без явного
       none картинка обрезалась по высоте 520px. */
    max-width: none;
    max-height: none;
}

.headline-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.headline-option {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: #fbfcfc;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

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

/* Острота заголовка — 1/3 у официальных вариантов, 2/3 у интригующего, 3/3 у кликбейтного
   (порядок жёстко задан промптом в ArticleTranslationService.suggestTitles). Бейдж в
   верхнем правом углу рамки, чуть наезжая на неё сверху — как ярлычок. */
.headline-option-peppers {
    position: absolute;
    top: -7px;
    right: 20px;
    display: inline-flex;
    gap: 1px;
    align-items: center;
    background: var(--card-bg);
    padding: 1px 4px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(20, 40, 50, 0.12);
    font-size: 9px;
    line-height: 1;
}

.pepper--muted {
    filter: grayscale(1);
    opacity: 0.28;
}

.headline-option:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.headline-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 600;
}

@keyframes field-fill-flash {
    from { background: var(--accent-soft); }
    to { background: #fff; }
}

@media (prefers-reduced-motion: no-preference) {
    .field-flash {
        animation: field-fill-flash 1s ease;
    }
}

.file-field {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.file-field input[type="file"] {
    display: none;
}

.file-field-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: #fbfcfc;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    transition: border-color .15s ease, background .15s ease;
}

.file-field:hover .file-field-btn {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-field-name {
    font-size: 13px;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: #9aa7ac;
}

.color-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid transparent;
    background: var(--swatch-color, #ccc);
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
    transition: transform .1s ease, border-color .15s ease;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.08);
}

.color-swatch.active {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px rgba(0,0,0,0.08);
}

.color-swatch--none {
    background: #f5f7f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-swatch--none svg {
    width: 20px;
    height: 20px;
    color: var(--ink);
    stroke: var(--ink);
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
}

.counter {
    font-weight: 400;
    color: #98a5ab;
}

.counter.over {
    color: var(--danger);
    font-weight: 700;
}

input[type="text"], input[type="url"], input[type="password"], textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    resize: vertical;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="password"] {
    padding-right: 92px;
    letter-spacing: 2px;
    font-size: 17px;
}

select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ------------------------------------------------------------------ */
/*  Страницы входа / смены пароля                                      */
/* ------------------------------------------------------------------ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 36px 32px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 18px;
}

.auth-logo img {
    width: 100%;
    height: 100%;
    display: block;
}

.auth-title {
    text-align: center;
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    text-align: center;
    margin: 0 0 28px;
    color: var(--ink-soft);
    font-size: 14px;
}

.password-field {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 6px;
    top: 30px;
    min-width: 74px;
    height: 34px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: 8px;
    white-space: nowrap;
}

.password-toggle:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.auth-hint {
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
    color: #9aa7ac;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-bottom: 14px;
    cursor: pointer;
    color: var(--ink);
}

.checkbox-field input { width: 17px; height: 17px; }

.error-box {
    background: #fdecea;
    color: #a83a36;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.success-box {
    background: #e8f6ef;
    color: #1d7a53;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, opacity .15s ease, transform .1s ease;
}

.btn:active { transform: scale(0.98); }

.btn-block { width: 100%; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-primary:disabled {
    background: #b7c2c6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.btn-secondary:hover { background: #d4f0ea; }

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1.5px solid var(--border);
}

.btn-ghost:hover { border-color: #c9d1d5; }

/* ------------------------------------------------------------------ */
/*  Результат                                                          */
/* ------------------------------------------------------------------ */

.result-empty {
    color: var(--ink-soft);
    font-size: 14px;
    padding: 40px 10px;
    text-align: center;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
}

.preview-wrap {
    display: flex;
    justify-content: center;
    background: #101820;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

#previewImg {
    max-width: 100%;
    max-height: 520px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

/* Обёртка вокруг превью фото — точно по размеру картинки, чтобы слои
   тонирования/текста легли ровно поверх неё (используется в photo.html
   для мгновенного предпросмотра до отправки на сервер). */
.preview-frame {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.tint-overlay {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    pointer-events: none;
}

.logo-overlay {
    /* top/bottom и width выставляются в photo.js по выбранной позиции/размеру логотипа
       (в пикселях, от natural-размера фото — см. updateLivePreview), чтобы превью точно
       совпадало с тем, что нарисует сервер (PhotoProcessorService.drawLogo). */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: auto;
    pointer-events: none;
}

/* Флаг всегда угол-в-угол с фото (0,0), без масштабирования на сервере — ширина
   в превью выставляется JS-ом по натуральному размеру файла flag.png (см. photo.js). */
.flag-overlay {
    position: absolute;
    left: 0;
    top: 0;
    height: auto;
    opacity: 0.4;
    pointer-events: none;
}

.text-overlay {
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 4%;
    text-align: center;
    color: #fff;
    font-weight: 700;
    font-size: clamp(12px, 3.4vw, 22px);
    line-height: 1.25;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    word-break: break-word;
}

.preview-title {
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    margin: 0 0 20px;
}

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

/* Главные действия «Работы с текстом» — вынесены из белой панели под неё, той же
   ширины (совпадает с .panel--narrow), крупнее обычных кнопок, с иконкой. */
.text-primary-actions {
    max-width: 760px;
    width: 100%;
    margin: 16px auto 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.text-primary-actions .btn {
    flex: 1 1 240px;
}

.btn-large {
    padding: 18px 24px;
    font-size: 16px;
    gap: 10px;
}

.btn-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    color: currentColor;
}

.publish-panel {
    margin-top: 18px;
    padding: 18px;
    background: #f7f9fa;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.publish-hint {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-soft);
}

.platform-choices {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.platform-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.platform-group-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
}

.platform-group .platform-chip {
    width: fit-content;
}

.platform-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.platform-chip.checked {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.platform-chip input { display: none; }

.publish-result {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #f7f9fa;
    font-size: 14px;
    line-height: 1.6;
}

.publish-result .ok { color: var(--accent-dark); font-weight: 700; }
.publish-result .warn { color: #b5842a; font-weight: 700; }

.page-footer {
    text-align: center;
    padding: 8px 0 22px;
    font-size: 12px;
    color: #9aa7ac;
    min-height: 18px;
}

.details-list {
    margin: 0;
}

.details-list dt {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    margin-top: 16px;
}

.details-list dt:first-child {
    margin-top: 0;
}

.details-list dd {
    margin: 4px 0 0;
    font-size: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    text-decoration: none;
    color: var(--ink);
    transition: border-color .15s ease, background .15s ease;
}

.user-row:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.user-row[draggable="true"] { cursor: grab; }

.user-row--dragging {
    opacity: 0.4;
}

.user-row-name {
    font-weight: 600;
    font-size: 15px;
}

.user-row-meta {
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 2px;
}

.user-status {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.user-status.ok { color: var(--accent-dark); }
.user-status.warn { color: #b5842a; }
.user-status.pending { color: #9aa7ac; }
.user-status.direct { color: #4a3aa7; }

.channel-edit-group {
    margin-bottom: 14px;
}

.channel-edit-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 8px;
}

.channel-edit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.channel-edit-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.channel-edit-list input { width: 16px; height: 16px; }

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.channel-empty {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0 0 12px;
}

.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
}

.channel-row-name {
    font-weight: 600;
    font-size: 14px;
}

.channel-row-id {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 2px;
}

.channel-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.channel-add-form input {
    flex: 1 1 180px;
}

.channel-add-form .btn {
    flex: 0 0 auto;
}

.channel-card {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.channel-card:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.channel-card .channel-edit-group {
    margin-top: 10px;
    margin-bottom: 0;
}

/* Карточка канала на дашборде — сама рамка + всё, что относится к каналу, внутри неё. */
.channel-box {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    transition: border-color .15s ease, background .15s ease;
}

/* Перетаскиваем сотрудника из «Сотрудники» сюда, чтобы назначить его на канал. */
.channel-box--drop-target {
    border-color: var(--accent);
    border-style: dashed;
    background: var(--accent-soft);
}

.channel-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.channel-access-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.channel-access-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    cursor: pointer;
}

.channel-access-toggle:hover { color: var(--ink); }

.channel-access-toggle-chevron {
    flex: 0 0 auto;
    transition: transform .15s ease;
}

.channel-access-toggle--open .channel-access-toggle-chevron {
    transform: rotate(180deg);
}

.channel-access-panel {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.channel-access-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 8px;
}

.channel-access-row:hover { background: var(--bg); }

.channel-access-name {
    min-width: 0;
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-access-username {
    color: var(--ink-soft);
    font-size: 12px;
}

.channel-access-remove,
.channel-access-add-btn {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 7px;
    cursor: pointer;
}

.channel-access-remove {
    background: none;
    color: var(--ink-soft);
}

.channel-access-remove:hover { background: #fdecea; color: var(--danger); }

.channel-access-add-btn {
    background: var(--accent);
    color: #fff;
}

.channel-access-add-btn:hover { background: var(--accent-dark); }

.channel-access-add-btn:disabled {
    background: var(--border);
    color: var(--ink-soft);
    cursor: not-allowed;
}

.channel-access-empty {
    font-size: 13px;
    color: var(--ink-soft);
    padding: 5px 6px;
}

.channel-access-add-select {
    width: 100%;
    font-size: 13px;
    padding: 6px 8px;
    margin-bottom: 4px;
}

/* ------------------------------------------------------------------ */
/*  Статистика                                                         */
/* ------------------------------------------------------------------ */

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.stat-tile {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
}

.stat-tile-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 4px;
}

.stat-tile-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

/* Раздел статистики компактнее обычных панелей — данных много, воздуха нужно меньше. */
#statsContent.content { gap: 14px; }
#statsContent .panel { padding: 16px 18px; }
#statsContent .panel-header { margin-bottom: 12px; }

.chart-legend {
    display: flex;
    gap: 18px;
    margin-bottom: 14px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--ink-soft);
}

.chart-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: 0 0 auto;
}

.chart-container {
    width: 100%;
    overflow-x: auto;
}

.chart-container svg {
    width: 100%;
    height: auto;
    min-width: 480px;
}

/* Страница сотрудника (user.html) — график крупнее обычного, на всю правую колонку. */
.chart-container--large svg {
    min-width: 560px;
}

.chart-hit-band {
    cursor: pointer;
}

.chart-hit-band:hover {
    fill: var(--accent-soft);
    opacity: 0.5;
}

.chart-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Страница сотрудника — данные слева, статистика (крупнее, с графиком) справа. */
.user-page-grid {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 20px;
    align-items: start;
}

.user-page-left, .user-page-right {
    margin: 0;
}

@media (max-width: 860px) {
    .user-page-grid {
        grid-template-columns: 1fr;
    }
}

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

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.stats-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}

.stats-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tbody tr {
    transition: background .1s ease;
}

.stats-table tbody tr:hover {
    background: var(--bg);
}

.stats-table .stats-title-cell {
    white-space: normal;
    max-width: 320px;
}

.avatar-wrap {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
}

.avatar-wrap .avatar {
    width: 100%;
    height: 100%;
}

.avatar-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: none;
}

/* ------------------------------------------------------------------ */
/*  Простые страницы вне app-shell (сотрудники / аккаунт)             */
/* ------------------------------------------------------------------ */

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.subtitle {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

/* Планшет — начиная отсюда и до самого маленького телефона. Десктоп (>980px) не трогаем вообще. */
@media (max-width: 980px) {
    .content,
    .content.content--balanced {
        grid-template-columns: 1fr;
    }

    /* На планшете, в отличие от телефона, ширины ещё хватает на 2 колонки —
       полностью в одну (как на телефоне) схлопываем только ниже, см. 600px. */
    #dashboardContent.content {
        grid-template-columns: 1fr 1fr;
    }

    .panel-result {
        position: static;
    }

    /* Боковое меню — раньше сворачивалось в выезжающую панель только с 720px, из-за чего
       на планшете (обычно 768-834px по CSS-пикселям в портретной ориентации) оно продолжало
       занимать фиксированные 264px и вместе с 2-колоночным дашбордом получалось тесно.
       Теперь сворачивается сразу с этого же брейкпоинта — единая точка перехода "десктоп/
       не-десктоп" для всего каркаса приложения, а не три рассинхронизированных. */
    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 25;
    }

    .sidebar--open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    .sidebar-overlay:not([hidden]) {
        display: block;
        position: fixed;
        inset: var(--topbar-h) 0 0 0;
        background: rgba(15, 25, 30, 0.35);
        z-index: 24;
    }

    .content {
        padding: 16px;
    }

    .topbar-title {
        font-size: 15px;
    }
}

/* Телефон — тут уже даже 2 колонки тесно, всё в один столбец. */
@media (max-width: 600px) {
    #dashboardContent.content {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 12px;
        gap: 14px;
    }

    #statsContent .panel,
    #dashboardContent .panel {
        padding: 14px;
    }

    .stats-table th,
    .stats-table td {
        padding: 7px 8px;
        font-size: 12.5px;
    }
}

/* ------------------------------------------------------------------ */
/*  Модалы                                                             */
/* ------------------------------------------------------------------ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 25, 30, 0.5);
    animation: fadeIn 0.15s ease;
}

.modal-dialog {
    position: relative;
    z-index: 1001;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}

.modal-dialog--small {
    max-width: 360px;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink-soft);
    border-radius: 8px;
    transition: background .15s ease, color .15s ease;
}

.modal-close:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.modal-close::before,
.modal-close::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 2px;
    background: currentColor;
}

.modal-close::before {
    transform: rotate(45deg);
}

.modal-close::after {
    transform: rotate(-45deg);
}

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

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

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

.btn-primary--danger:hover {
    background: #d84036;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .card { padding: 20px; }
    .panel { padding: 18px; }

    .modal-dialog {
        width: 95%;
    }
}
