/* ============================================================
   WGAdminAPI — строгая однотонная тема
   Базовый цвет: графитово-синий (#37474F). Без градиентов.
   ============================================================ */

:root {
    --accent: #37474F;
    --accent-hover: #455A64;
    --accent-dark: #263238;
    --accent-light: #546E7A;
    --accent-ghost: rgba(55, 71, 79, 0.08);
    --bg: #f5f6f7;
    --surface: #ffffff;
    --border: #d7dbdd;
    --text: #263238;
    --text-muted: #6a7580;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    margin: 0;
    padding: 0;
    color: var(--text);
}

/* ==================== О программе (документация) ==================== */

/* Кнопки выбора документа и оглавление на вкладке «О программе». */
.doc-tabs { gap: .25rem; }
.doc-tabs .btn { white-space: nowrap; }

.docs-toc-card {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    overflow: auto;
}

.doc-toc-link {
    display: block;
    padding: .2rem .5rem;
    border-radius: .35rem;
    color: var(--text);
    font-size: .875rem;
    text-decoration: none;
}

.doc-toc-link:hover { background: var(--accent-ghost); }
.doc-toc-link.toc-2 { padding-left: 1.1rem; }
.doc-toc-link.toc-3 { padding-left: 1.7rem; font-size: .82rem; }

.docs-body h2.doc-title { margin-bottom: 1rem; }
.docs-body h2, .docs-body h3, .docs-body h4 {
    scroll-margin-top: 5rem;
    margin-top: 1.5rem;
}
.docs-body h2:first-of-type { margin-top: 0; }
.docs-body pre {
    background: #263238;
    color: #eceff1;
    border-radius: .5rem;
    padding: 1rem;
    overflow-x: auto;
    font-size: .86rem;
}
.docs-body pre code { color: inherit; }
.docs-body code { word-break: break-word; }

/* Картинки в документации и справке: не выходят за ширину карточки,
   сохраняют пропорции и подстраиваются под мобильный экран. */
.docs-body img.doc-img,
.help-body img.doc-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: .75rem 0;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: .5rem;
    background: #fff;
}

@media (max-width: 576px) {
    .docs-body img.doc-img,
    .help-body img.doc-img {
        margin: .5rem 0;
        border-radius: .35rem;
    }
}
/* Видео в справке: занимает ширину карточки, сохраняет пропорции и не
   разъезжается на мобильном экране. */
.docs-body video.doc-video,
.help-body video.doc-video {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: .75rem 0 .25rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: .5rem;
    background: #000;
}
.docs-body .doc-media-caption,
.help-body .doc-media-caption {
    margin: 0 0 1rem;
}

.docs-body blockquote {
    border-left: 4px solid var(--accent-light);
    margin: 0 0 1rem;
    padding: .25rem 1rem;
    background: var(--accent-ghost);
    border-radius: 0 .5rem .5rem 0;
}
.docs-body img { max-width: 100%; }
.docs-body .table { margin-bottom: 1rem; }

/* ==================== Sidebar ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    /* dvh, а не vh: на телефоне vh учитывает и скрытую часть адресной строки,
       из-за чего низ панели (футер) уходил за пределы экрана. vh оставлен
       запасным вариантом для браузеров без dvh. */
    height: 100vh;
    height: 100dvh;
    background: var(--accent-dark);
    color: #fff;
    z-index: 100;
    /* Flex-колонка: меню сверху, футер прижат к низу */
    display: flex;
    flex-direction: column;
    /* Меню не поддаётся «оттягиванию» всей страницы на iOS. */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.sidebar-brand {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h4 {
    margin: 0;
    font-weight: 600;
    color: #fff;
}

.sidebar-brand small {
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-nav {
    padding: 1rem 0;
    /* Меню занимает всё пространство между шапкой и футером */
    flex: 1 1 auto;
    overflow-y: auto;
}

/* Футер сайдбара: приглушённая подпись, прижата к низу панели.
   Отображается только обычным пользователям («Личный кабинет»). */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.18);
}

.sidebar-footer small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-footer small i {
    font-size: 0.9rem;
}

.nav-section {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: background 0.15s;
}

/* ==================== Основной контент ==================== */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    min-height: 100dvh;
}

.header {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content {
    padding: 1.5rem;
}

/* ==================== Cards ==================== */
.card {
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
}

/* Разделитель сохраняет обычную ширину содержимого панели. */
.dashboard-section-divider {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    border-top: 1px solid var(--border);
    opacity: 1;
}

/* ==================== Login ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dark);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 6px;
    padding: 2rem;
    border-top: 3px solid var(--accent);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.captcha-block {
    margin-top: .5rem;
}

.captcha-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.captcha-image {
    width: 190px;
    height: 64px;
    flex: 0 0 190px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
    user-select: none;
}

.captcha-image:focus {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

.captcha-image.captcha-loading {
    opacity: .45;
}

.captcha-row .form-control {
    min-width: 0;
}

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

    .captcha-image {
        width: 100%;
        flex-basis: auto;
    }
}

/* ==================== Tables ==================== */
.table {
    margin: 0;
    width: 100%;
}

.table thead th {
    border-top: none;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.table tbody td {
    vertical-align: middle;
}

/* Таблицы данных: ширину колонок подбирает браузер — у таблиц разное число
   колонок и разный контент. Жёсткая сетка (table-layout: fixed + 25%/20%/15%)
   растягивала первые колонки и сжимала остальные («Интерфейсы», «Ключи»), а
   колонка действий не вмещала кнопки, и они вылезали за пределы карточки
   («Тарифы»). */
.app-table {
    width: 100%;
}

/* Колонка действий (помечается классом .text-end) занимает ровно столько
   места, сколько нужно кнопкам: width: 1% + nowrap — кнопки не переносятся
   на вторую строку и не растягивают таблицу. */
.app-table th.text-end,
.app-table td.text-end {
    width: 1%;
    white-space: nowrap;
}

/* Компактные кнопки в таблицах */
.app-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.app-table .btn-group .btn-sm {
    padding: 0.25rem 0.4rem;
}

/* ==================== Badges / статусы ==================== */
.badge {
    padding: 0.5em 0.75em;
    border-radius: 4px;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.status-dot.online {
    background: #2e7d32;
}

.status-dot.offline {
    background: #b0bec5;
}

.status-dot.blink {
    animation: status-blink 1.2s infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ==================== Элементы управления ==================== */
.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-primary:disabled {
    background-color: var(--accent-light);
    border-color: var(--accent-light);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 0.2rem var(--accent-ghost);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.nav-tabs .nav-link.active {
    color: var(--accent);
}

a {
    color: var(--accent);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.data-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

/* Моно-шрифт для ключей и конфигов */
.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

/* ==================== Adaptive ==================== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        /* На узком экране фиксированные 250px съедали бы большую часть
           ширины, поэтому панель ограничена долей экрана. */
        width: min(250px, 82vw);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    /* Подложка под открытым меню. Без неё контент под панелью оставался
       видимым и кликабельным: нажатие на кнопку в контенте одновременно
       срабатывало и закрывало меню, и выполняло действие. */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* Пока меню открыто, страница за ним не прокручивается. */
    body.sidebar-open {
        overflow: hidden;
    }
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--accent);
}

/* ==================== Системный монитор ==================== */
.sys-chart {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.25rem;
    position: relative;
}
.sys-chart-canvas {
    position: relative;
    flex: 1 1 auto;
    min-width: 60px;
    height: 70px;
    display: block;
}
.sys-chart-box {
    display: flex;
    align-items: stretch;
}
.sys-chart-y {
    position: relative;
    flex: 0 0 auto;
    display: block;
}
/* Скрытый sizer задаёт ширину колонки = ширине самого широкого значения шкалы */
.sys-chart-y-sizer {
    display: block;
    visibility: hidden;
    white-space: nowrap;
    font-size: 0.65rem;
    padding-right: 4px;
}
.sys-chart-max {
    position: absolute;
    top: -0.1rem;
    right: 0.25rem;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
}
.sys-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
    align-items: center;
}
.sys-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.sys-legend-dot {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}

/* Шкала оси Y — колонка слева от графика (HTML overlay, не растягивается).
   Ширина колонки динамическая (от sizer); отступ линии графика от шкалы —
   ширина колонки + зазор sizer-элемента. */
.sys-y-label {
    position: absolute;
    top: auto;
    right: 0;
    left: auto;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--muted);
    text-align: right;
    white-space: nowrap;
    pointer-events: none;
    width: fit-content;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar {
    background-color: var(--accent);
}

.toast-container {
    z-index: 1060;
}

/* ==================== Key cards ==================== */
.key-card {
    transition: box-shadow 0.15s, transform 0.15s;
    border-left: 3px solid transparent;
}
.key-card.active {
    border-left-color: #2e7d32;
}
.key-card.inactive {
    border-left-color: #b0bec5;
}
.key-card.admin-disabled {
    border-left-color: #ef6c00;
    opacity: 0.85;
}
.key-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.key-card .badge {
    font-size: 0.75rem;
}
.key-address {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

/* ==================== QR-код ==================== */
/* PNG генерируется 800x800 и раньше ужимался инлайновым max-width: 400px.
   Инлайновый стиль перебивал max-width: 100% из .img-fluid, поэтому на
   телефоне QR не сжимался под ширину модалки и выходил за экран. Здесь
   картинка остаётся адаптивной, но не раздувается шире 320px. */
.qr-image {
    max-width: 100%;
    width: 320px;
    height: auto;
    background: #fff;
    border-radius: 4px;
    image-rendering: pixelated;
}

/* ==================== Новости ==================== */
/* Лента живёт в узкой колонке справа от ключей: прилипает при прокрутке,
   не вытесняет карточки ключей и ограничена по высоте. На узких экранах
   колонки складываются (Bootstrap), лента уходит под ключи. */
.news-feed {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    background: #fff;
    overflow: hidden;
}
@media (min-width: 992px) {
    .news-feed {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        display: flex;
        flex-direction: column;
    }
    /* Длинная лента прокручивается внутри колонки, а не растягивает страницу. */
    .news-feed .news-list {
        overflow-y: auto;
    }
}
.news-feed-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: rgba(102, 126, 234, 0.08);
    font-size: 0.8rem;
    font-weight: 600;
}
.news-feed-title {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.news-item-more {
    margin-left: auto;
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--bs-secondary-color, #6c757d);
}
.news-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.news-item + .news-item {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.news-item-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.15rem 0.4rem;
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: none;
    border: 0;
    text-align: left;
    color: inherit;
}
.news-item-head:hover {
    background: rgba(102, 126, 234, 0.06);
}
.news-item-title {
    grid-column: 1;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.news-item-meta {
    grid-column: 1;
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--bs-secondary-color, #6c757d);
    /* Длинные имена и даты обрезаются, а не рвут сетку ленты. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.news-item-chevron {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
}
.news-item-body {
    padding: 0 0.7rem 0.6rem 0.7rem;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.news-admin-title {
    max-width: 240px;
    font-weight: 600;
}
.news-admin-body {
    max-width: 420px;
    overflow-wrap: anywhere;
}
.key-traffic {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}
.btn-key-action {
    min-width: 32px;
    padding: 0.25rem 0.5rem;
}
.modal .mono {
    font-size: 0.78em;
    line-height: 1.4;
    word-break: break-all;
}

/* ==================== Config Categories ==================== */
.config-category {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.config-category-header {
    background: var(--surface);
    cursor: pointer;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s;
}

.config-category-header:hover {
    background: var(--bg);
}

.config-category-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.config-category-title {
    font-weight: 600;
    color: var(--text);
}

.config-collapse-icon {
    transition: transform 0.2s;
    color: var(--text-muted);
}

.config-category-header[aria-expanded="false"] .config-collapse-icon {
    transform: rotate(-90deg);
}

.config-table {
    /* Единая ширина колонок во всех разделах «Конфигурация» */
    table-layout: fixed;
    width: 100%;
}

.config-table thead th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.config-table th:first-child,
.config-table td:first-child {
    width: 45%;
}

.config-table th:nth-child(2),
.config-table td:nth-child(2) {
    width: calc(55% - 50px);
}

.config-option-label {
    font-weight: 500;
    color: var(--text);
}

.config-option-hint {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.config-option-value {
    font-size: 0.9rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.config-edit-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.config-sections {
    animation: fadeIn 0.3s ease-out;
}

/* Индикатор выполнения действий создания/изменения/сохранения.
   Отдельный элемент в body с position: fixed — не влияет на вёрстку страницы
   и открытой модалки и не встраивается в кнопку. z-index выше модалок
   Bootstrap (1055), чтобы индикатор был виден поверх открытой формы. */
.action-progress {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
}

.action-progress.show {
    display: flex;
}

.action-progress-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: 0.5rem;
    background: var(--bg, #fff);
    color: var(--text, #111);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
    font-size: 0.95rem;
}

.action-progress .spinner-border {
    width: 1.1rem;
    height: 1.1rem;
    border-width: 0.15em;
}


/* ==================== Поддержка: чат ==================== */
.support-chat {
    max-height: 52vh;
    overflow-y: auto;
    padding: .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: .4rem;
}
.support-message {
    max-width: 82%;
    padding: .55rem .7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .65rem;
    white-space: normal;
    overflow-wrap: anywhere;
}
.support-message-staff {
    background: var(--accent-ghost);
    border-color: var(--accent-light);
}
/* Вложения внутри реплики: длинное имя переносится, а не растягивает чат. */
.support-attachments {
    margin-top: .4rem;
    padding-left: 0;
    list-style: none;
}
.support-attachment {
    font-size: .9rem;
    overflow-wrap: anywhere;
}
.support-attachment a {
    text-decoration: none;
}
.support-attachment a:hover {
    text-decoration: underline;
}

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

.btn-group .btn-sm {
    font-size: 0.8rem;
}


/* ==================== Модалка аудита: ограничение ширины блока Детали ==================== */
#audit-details-modal .modal-body pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    max-height: 60vh;
    max-width: 100%;
}


/* ==================== Центр уведомлений ==================== */
.notification-center-trigger {
    position: relative;
}
.notification-center-trigger.has-unread {
    color: var(--accent);
}
.notification-center-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: #c62828;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}
.notification-center-badge.d-none {
    display: none !important;
}
body.notification-center-open {
    overflow: hidden;
}
.notification-center-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(38, 50, 56, .34);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.notification-center-backdrop.show {
    opacity: 1;
    visibility: visible;
}
.notification-center-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1100;
    width: min(420px, 100vw);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 30px rgba(38, 50, 56, .18);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .22s ease, visibility .22s ease;
}
.notification-center-panel.show {
    transform: translateX(0);
    visibility: visible;
}
.notification-center-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.notification-center-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 1.1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.notification-center-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex: 0 0 auto;
}
/* Переключатель браузерных уведомлений: подпись слева, тумблер справа. */
.notification-center-push-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem 1.1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
/* Подсказка о том, что уведомления приходят при закрытой вкладке, на узком
   экране переносится под переключатель, а не сжимает его. */
@media (max-width: 576px) {
    .notification-center-push-row {
        flex-wrap: wrap;
    }
}
/* Включённый переключатель уведомлений — зелёный: «включено» должно читаться
   как действие, а --accent того же серо-синего цвета, что и остальные
   чекбоксы панели, и сливается с ними.

   Правило локальное по id намеренно: глобальный .form-check-input:checked
   задаёт --accent всем чекбоксам, и его правка перекрасила бы всю панель,
   чего не просили. */
#push-notifications-toggle:checked {
    background-color: #198754;
    border-color: #198754;
}
/* Кольцо фокуса — тем же зелёным, иначе при навигации с клавиатуры
   переключатель «мигает» другим цветом. */
#push-notifications-toggle:focus-visible {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}
.notification-center-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.notification-center-item {
    position: relative;
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .9rem 1rem;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-align: left;
}
.notification-center-item:hover,
.notification-center-item:focus-visible {
    background: var(--accent-ghost);
}
.notification-center-item.unread {
    background: #f3f7f8;
}
.notification-center-item-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-ghost);
    color: var(--accent);
}
.notification-center-item-content {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.notification-center-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
}
.notification-center-item-top strong {
    font-size: .9rem;
}
.notification-center-item-top time {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .7rem;
}
.notification-center-item-message {
    color: var(--text);
    font-size: .82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.notification-center-item-type {
    color: var(--text-muted);
    font-size: .7rem;
}
.notification-center-unread-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    margin-top: .35rem;
    border-radius: 50%;
    background: #c62828;
}
.notification-center-empty {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    color: var(--text-muted);
    text-align: center;
}
.notification-center-empty i {
    font-size: 2rem;
}
@media (max-width: 575px) {
    .notification-center-panel {
        width: 100vw;
        border-left: 0;
    }
    .header {
        padding: 0 .75rem;
    }
    .header-user {
        gap: .45rem;
    }
}

/* ==================== Оплата счёта ЮKassa ==================== */

/* Платёжная страница ЮKassa отдаёт `X-Frame-Options: SAMEORIGIN` и
   `frame-ancestors 'self'`, поэтому встроить её в iframe стороннего сайта
   невозможно (браузер: ERR_BLOCKED_BY_RESPONSE). Ссылка открывается в новой
   вкладке, поэтому стили для встроенной формы не нужны. */

/* ==================== Пополнение баланса ==================== */

/* Поле количества vCoin: суммы небольшие (5-6 цифр), поэтому ввод компактный
   и не растягивается на всю ширину карточки. */
.topup-amount {
    width: 100%;
    max-width: 12.5rem;
}

/* Сумма к оплате — одной строкой справа от кнопки «Купить» (margin-left:auto
   прижимает её вправо на широких экранах, на узких flex-wrap переносит вниз).
   Раньше это был отдельный блок под полем, из-за чего карточка покупки была
   заметно выше соседней карточки промокода. */
.topup-total {
    margin-left: auto;
    padding: .25rem .5rem;
    display: flex;
    align-items: baseline;
    gap: .4rem;
    border-radius: .4rem;
    background: var(--accent-ghost, rgba(13, 110, 253, .08));
}

.topup-total-label {
    color: var(--text-muted);
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.topup-total-value {
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

/* ============================================================
   Мобильная вёрстка
   ============================================================
   Ниже — то, что на телефоне ломалось: тесные отступы, неудобные
   для пальца кнопки, таблицы без подсказки о прокрутке, модалки
   почти во всю высоту экрана и шапка, не помещавшаяся на 360px.
   Отдельный блок в конце файла, чтобы переопределения не разрывали
   смысловые секции выше и к ним было легко вернуться. */

/* Базовый уровень: телефон и узкий планшет. */
@media (max-width: 767px) {

    /* --- Отступы --- */
    /* 1.5rem на 360px экране съедали 48px ширины — оставалось 312px
       на контент. */
    .content {
        padding: 1rem .75rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .main-content {
        min-height: 100dvh;
    }

    /* Низ сайдбара не должен уходить под «домашний» индикатор iPhone. */
    .sidebar-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .dashboard-section-divider {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    /* --- Шапка ---
       Имя и роль уступают место иконкам: на 360px строка с логином,
       ролью, колокольчиком и меню не помещалась. */
    .header {
        height: 56px;
        padding: 0 .75rem;
    }

    .header-user .data-value,
    .header-user small {
        display: none;
    }

    .header-user {
        gap: .4rem;
    }

    .avatar {
        width: 34px;
        height: 34px;
        font-size: .9rem;
    }

    /* --- Тач-таргеты ---
       .btn-sm в таблицах был 0.25rem по вертикали (~24px) — ниже
       рекомендуемых 44px, в такие кнопки промахивались. */
    .btn-sm {
        padding: .4rem .65rem;
        font-size: .8rem;
    }

    .app-table .btn-sm {
        padding: .4rem .6rem;
    }

    /* Крупные кнопки не должны ниже 40px по высоте. */
    .btn:not(.w-100) {
        min-height: 40px;
    }

    /* Иконка-кнопка (бургер, колокольчик, меню профиля). */
    .btn-icon {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Пункты меню — крупнее: палец должен попадать в строку. */
    .sidebar .nav-link {
        padding: .85rem 1.25rem;
    }

    /* --- Таблицы ---
       .table-responsive прокручивает таблицу вбок, но на телефоне не
       видно, что она шире экрана: край просто обрезался. Ниже —
       затенение правого края, подсказывающее о продолжении. */
    .table-responsive {
        position: relative;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Тень у края — только когда таблица правда прокручивается.
       Классы can-scroll-left/right ставит updateTableShadows() по факту
       scrollWidth/clientWidth; без них тень бы показывалась даже на
       коротких таблицах, где прокручивать нечего. */
    .table-responsive::after,
    .table-responsive::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        width: 28px;
        /* Подсказка не должна перехватывать прокрутку и нажатия. */
        pointer-events: none;
        opacity: 0;
        transition: opacity .15s;
    }

    .table-responsive::after {
        right: 0;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(15, 23, 42, .14));
        border-radius: 0 6px 6px 0;
    }

    .table-responsive::before {
        left: 0;
        background: linear-gradient(to right, rgba(15, 23, 42, .14), rgba(255, 255, 255, 0));
        border-radius: 6px 0 0 6px;
    }

    .table-responsive.can-scroll-right::after,
    .table-responsive.can-scroll-left::before {
        opacity: 1;
    }

    /* Меньше колонок — больше полезной ширины. */
    .app-table th,
    .app-table td {
        padding: .6rem .7rem;
        font-size: .875rem;
    }

    /* --- Формы ---
       Поля ввода меньше 16px заставляют iOS Safari зумить страницу
       при фокусе, поэтому размер сохраняется. */
    .form-control,
    .form-select {
        font-size: 16px;
        min-height: 44px;
    }

    .input-group-text {
        font-size: .9rem;
    }

    /* --- Модалки ---
       Панель снизу во всю ширину вместо почти квадратного окна:
       на 360px диалог с формой иначе не помещался по высоте. */
    .modal-dialog {
        margin: 0;
        min-height: 100%;
        align-items: flex-end;
    }

    .modal-content {
        border-radius: 12px 12px 0 0;
        border-bottom: none;
        max-height: 92dvh;
        display: flex;
        flex-direction: column;
    }

    .modal-header,
    .modal-footer {
        padding: .85rem 1rem;
        flex-shrink: 0;
    }

    /* Тело модалки прокручивается, кнопки в подвале остаются на виду. */
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Уведомления (toast) ---
       position-fixed сверху справа перекрывали шапку на телефоне. */
    .toast-container {
        left: .5rem;
        right: .5rem;
        top: auto !important;
        bottom: calc(.5rem + env(safe-area-inset-bottom));
        width: auto;
        z-index: 1090;
    }

    .toast {
        width: 100%;
    }

    /* --- Карточки ключей и QR --- */
    .key-card {
        margin-bottom: .75rem;
    }

    .qr-image {
        width: 100%;
        max-width: 280px;
    }

    /* Длинные адреса и ключи переносились только по словам и
       разъезжались — принудительный перенос по любому символу. */
    .key-address {
        font-size: .75rem;
    }

    .data-value {
        font-size: 1.1rem;
    }
}

/* Очень узкие экраны (iPhone SE, 320px) */
@media (max-width: 360px) {

    .content {
        padding: .75rem .5rem;
    }

    .header {
        padding: 0 .5rem;
    }

    .app-table th,
    .app-table td {
        padding: .5rem .5rem;
        font-size: .8rem;
    }

    .modal-body {
        padding: .75rem;
    }
}

/* Ландшафтная ориентация телефона: панель меню не должна занимать
   половину короткого экрана. */
@media (max-width: 991px) and (orientation: landscape) and (max-height: 500px) {
    .sidebar {
        width: 220px;
    }
}
