/* Inter лежит у нас, а не на Google Fonts: CSP пускает шрифты только со своего
   домена, да и внешний запрос на каждый вход в дашборд ни к чему. Файлы разбиты
   по алфавитам — браузер скачивает только тот, чьи буквы есть на странице */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;

    /* Тонкая линия для разделения карточек на тёмном фоне: сплошной --border
       на больших плоскостях выглядит как рамка таблицы, а не как край карточки */
    --border-soft: rgba(148, 163, 184, 0.14);

    /* Шкала размеров. До неё заголовки, подписи и текст были почти одного
       кегля, и страница читалась сплошным полотном */
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;
    --text-3xl: 36px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: var(--text-base);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Кнопки и поля сами шрифт не наследуют — остались бы в системном */
button,
input,
select,
textarea {
    font-family: inherit;
}

/* Заголовки набираются плотнее текста: на крупном кегле стандартный трекинг
   выглядит разреженным */
h1, h2, h3, h4, h5 {
    line-height: 1.25;
    letter-spacing: -0.02em;
}

/* Цифры в таблицах и плитках должны стоять в колонку, а не плясать по ширине */
.stat-value,
.plan-price,
.data-table td,
.mono-nums {
    font-variant-numeric: tabular-nums;
}

/* Auth Page */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
}

/* ---------------------------------------------------------------------------
   Логотип — картинка, а не текст: объём и фактура букв нарисованы, CSS так не
   повторить. Ширина задаётся здесь, высота — по пропорциям файла.
   --------------------------------------------------------------------------- */

.brand-logo {
    display: block;
    line-height: 0;
}

.brand-logo img {
    display: block;
    width: 100%;
    height: auto;
}

.auth-card .brand-logo {
    width: 240px;
    margin: 0 auto 12px;
}

.auth-footnote {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
    text-align: center;
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--text-muted);
}

.auth-footnote a {
    color: #a5b4fc;
    font-weight: 600;
    text-decoration: none;
}

.auth-footnote a:hover {
    text-decoration: underline;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg-input);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--bg-card);
    padding: 24px;
    border-right: 1px solid var(--border);
}

/* Логотип по центру колонки меню: у картинки объёмная тень справа, и по левому
   краю она стояла «мимо» пунктов меню */
.sidebar-logo {
    width: 160px;
    margin: 4px auto 28px;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
}

/* Активный пункт — в цвет основной кнопки: серая плашка сливалась с наведением */
.sidebar-nav a.active {
    background: rgba(99, 102, 241, 0.16);
    color: #e0e7ff;
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Кнопки аккаунта — в масштаб пунктов меню, а не во весь кегль основных кнопок */
.sidebar-footer .btn {
    padding: 9px 14px;
    font-size: var(--text-sm);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-weight: 600;
    font-size: var(--text-sm);
}

.user-tier {
    font-size: var(--text-xs);
    line-height: 1.35;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    /* Без этого flex-элемент не ужимается уже своего содержимого, и широкая
       таблица раздвигала страницу вправо за край экрана */
    min-width: 0;
    padding: 32px;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: var(--text-2xl);
    margin-bottom: 6px;
}

.page-header p {
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 650;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 20px 22px;
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.stat-label {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-info h4 {
    margin-bottom: 4px;
}

.toggle-info p {
    color: var(--text-muted);
    font-size: 14px;
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-input);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--success);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* VK Connection */
.vk-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: 8px;
}

.vk-status.connected {
    border-left: 4px solid var(--success);
}

.vk-status.disconnected {
    border-left: 4px solid var(--warning);
}

.vk-status-icon {
    width: 48px;
    height: 48px;
    background: #0077ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.vk-status-info {
    flex: 1;
}

.vk-status-info h4 {
    margin-bottom: 4px;
}

.vk-status-info p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Subscription Badge */
.subscription-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.16);
    color: #a5b4fc;
}

/* Без подписки — приглушённо, это не тревога, а состояние по умолчанию */
.subscription-badge.none {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-muted);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Вкладки */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 16px;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Панель инструментов над таблицей */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.toolbar input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Таблицы */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    /* Длинное слово без пробелов — ответ, ссылка, цепочка эмодзи — иначе растягивало
       колонку, и кнопки действий уезжали за край */
    overflow-wrap: anywhere;
}

/* Колонки задаются шириной заголовков, а не содержимым: предложение любой длины
   переносится внутри своей ячейки */
.data-table.fixed-layout {
    table-layout: fixed;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .cell-actions {
    white-space: nowrap;
    text-align: right;
}

/* btn-primary растягивается на всю ширину — в ячейке действий это выталкивало
   соседнюю кнопку за край таблицы */
.data-table .cell-actions .btn {
    width: auto;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
    margin-left: 6px;
}

.empty-state {
    padding: 40px 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
    border: 1px dashed var(--border-soft);
    border-radius: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Поля настроек */
.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.field-row:last-child {
    border-bottom: none;
}

.field-row label {
    color: var(--text);
    font-size: 14px;
}

.field-row input {
    width: 120px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

.field-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: var(--text-xs);
    line-height: 1.45;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.modal textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* Всплывающее уведомление */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    z-index: 200;
    max-width: 380px;
}

.toast.error {
    border-left-color: var(--danger);
}

/* Поля вне модалок: форма предложения и выбор тарифа */
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Счётчик непроверенных предложений в меню */
.nav-badge {
    display: inline-block;
    min-width: 20px;
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--danger);
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

/* Публичная страница отправки вопроса */
.public-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 20px;
}

.public-page h1 {
    margin-bottom: 8px;
}

.public-page .public-logo {
    width: 160px;
    margin-bottom: 24px;
}

.public-page .subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Выбор игр флажками — вместо прежнего выпадающего списка тарифов */
.games-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.games-picker label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 400;
}

.games-picker input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* Поле с кнопкой в одной строке: «сгенерировать пароль» рядом с самим паролем */
.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

.input-row .btn {
    white-space: nowrap;
}

/* Учётные данные нового профиля. Пароль показывается один раз, поэтому
   не тост на три секунды, а карточка, которая висит до перезагрузки списка */
.credentials {
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
}

.credentials code {
    font-size: var(--text-base);
    color: var(--text);
    word-break: break-all;
}

/* ---------------------------------------------------------------------------
   Тарифы карточками. Таблицей их читать неудобно: цена — главное на странице,
   а в ячейке она весит столько же, сколько срок и перечисление игр.
   --------------------------------------------------------------------------- */

.section-head {
    margin-bottom: 16px;
}

.section-note {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: 4px;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    align-items: stretch;
}

.plan {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 22px 20px;
}

/* Рекомендованный набор выделен рамкой и подсветкой: без опоры взгляд
   одинаково скользит по всем карточкам и выбор откладывается */
.plan.plan--featured {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), 0 12px 32px -18px var(--primary);
}

.plan-badge {
    position: absolute;
    top: -10px;
    left: 20px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
}

.plan-name {
    font-size: var(--text-lg);
    font-weight: 650;
}

.plan-desc {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: 4px;
    min-height: 2.6em;
}

.plan-price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 16px 0 4px;
}

.plan-price {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
}

.plan-period {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* Зачёркнутая сумма показывает выгоду набора: без неё скидка невидима */
.plan-strike {
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-decoration: line-through;
    margin-bottom: 4px;
}

.plan-games {
    list-style: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    display: grid;
    gap: 8px;
}

.plan-games li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
}

/* Галочку рисуем символом, а не картинкой: иконочный набор ради четырёх
   строк тянуть незачем */
.plan-games li::before {
    content: "✓";
    color: var(--success);
    font-weight: 700;
    flex: none;
}

/* Карточка подписки на «Обзоре»: три строки подряд одинаковым кеглем читались
   сплошным абзацем. Разводим по весу и цвету */
#sub-info {
    font-size: var(--text-base);
    font-weight: 550;
}

#sub-games,
#sub-expires {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* --- Buddy13 --------------------------------------------------------------- */

/* Пока своего логотипа нет — название текстом */
.brand-text {
    display: block;
    line-height: 1.1;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sidebar-logo .brand-text {
    font-size: 28px;
    text-align: left;
}

/* Текстовые поля и имя бота в настройках шире числовых */
.field-row input[type="text"],
.field-row textarea {
    width: 100%;
    max-width: 640px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
}

#page-bot > .btn {
    margin-top: 8px;
}
