/* ═══════════════════════════════════════════════════════════
   Nexus Admin Panel v1.13 — full-screen modal
   ═══════════════════════════════════════════════════════════ */

.admin-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(5, 8, 12, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: nx-admin-fade-in 0.25s ease-out;
}
@keyframes nx-admin-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.admin-overlay.hidden { display: none; }

.admin-modal {
    background: var(--bg-primary, #0a0d12);
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 48px);
    max-height: 900px;
    border: 1px solid var(--border, #1f2532);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: nx-admin-slide-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes nx-admin-slide-in {
    from { transform: translateY(20px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ── Topbar ─────────────────────────────────────────────── */
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border, #1f2532);
    background: var(--bg-secondary, #11151c);
    flex-shrink: 0;
}
.admin-brand { display: flex; align-items: center; gap: 14px; }
.admin-brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent, #00d4aa), var(--accent-2, #ff3da3));
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}
.admin-brand h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.admin-topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-env-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    color: var(--accent, #00d4aa);
    padding: 4px 10px;
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 4px;
}
.admin-close-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border, #1f2532);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.admin-close-btn:hover {
    background: var(--bad, #ff5a78);
    border-color: var(--bad, #ff5a78);
    color: white;
}

/* ── Body (sidebar + main) ──────────────────────────────── */
.admin-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar (меню разделов) */
.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-secondary, #11151c);
    border-right: 1px solid var(--border, #1f2532);
    overflow-y: auto;
    padding: 16px 8px;
}
.admin-sidebar::-webkit-scrollbar { width: 6px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.admin-menu-group {
    margin-bottom: 20px;
}
.admin-menu-group-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 12px 4px;
    margin: 0;
}
.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary, #a4adbe);
    font-size: 14px;
    transition: all 0.15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
}
.admin-menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.admin-menu-item.active {
    background: linear-gradient(90deg, rgba(0, 212, 170, 0.15), transparent);
    color: var(--accent, #00d4aa);
    border-left: 2px solid var(--accent, #00d4aa);
    padding-left: 10px;
}
.admin-menu-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.admin-menu-badge {
    margin-left: auto;
    background: var(--accent-2, #ff3da3);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* ── Main content ─────────────────────────────────────── */
.admin-main {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--bg-primary, #0a0d12);
}
.admin-main::-webkit-scrollbar { width: 8px; }
.admin-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.admin-page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.admin-page-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.admin-page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */
.admin-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.admin-stat-card {
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    transition: border-color 0.2s, transform 0.2s;
}
.admin-stat-card:hover {
    border-color: var(--accent, #00d4aa);
    transform: translateY(-2px);
}
.admin-stat-icon {
    font-size: 20px;
    margin-bottom: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 8px;
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent);
}
.admin-stat-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}
.admin-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.admin-stat-trend {
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent, #00d4aa);
    display: flex;
    align-items: center;
    gap: 4px;
}
.admin-stat-trend.down { color: var(--bad, #ff5a78); }

.admin-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}
@media (max-width: 1100px) {
    .admin-section-grid { grid-template-columns: 1fr; }
}

.admin-card {
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
}
.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.admin-card-header h3 {
    font-size: 14px;
    margin: 0;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.admin-card-link {
    color: var(--accent, #00d4aa);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}
.admin-card-link:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════ */
.admin-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.admin-toolbar-search {
    flex: 1;
    min-width: 240px;
    max-width: 400px;
    position: relative;
}
.admin-toolbar-search input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.15s;
}
.admin-toolbar-search input:focus {
    outline: none;
    border-color: var(--accent);
}
.admin-toolbar-search::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
    opacity: 0.6;
}

.admin-btn {
    padding: 10px 16px;
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.admin-btn:hover {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.05);
}
.admin-btn.primary {
    background: var(--accent, #00d4aa);
    color: #0a0d12;
    border-color: var(--accent);
    font-weight: 600;
}
.admin-btn.primary:hover {
    background: transparent;
    color: var(--accent);
}
.admin-btn.danger {
    border-color: var(--bad, #ff5a78);
    color: var(--bad);
}
.admin-btn.danger:hover {
    background: var(--bad);
    color: white;
}
.admin-btn.sm {
    padding: 5px 10px;
    font-size: 12px;
}
.admin-btn.icon-only {
    padding: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.admin-tab {
    padding: 10px 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}
.admin-tab:hover { color: var(--text-primary); }
.admin-tab.active {
    color: var(--accent, #00d4aa);
    border-bottom-color: var(--accent);
}
.admin-tab-count {
    background: var(--border);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    font-size: 11px;
}
.admin-tab.active .admin-tab-count {
    background: var(--accent, #00d4aa);
    color: #0a0d12;
}

/* Table */
.admin-table-wrap {
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.admin-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: var(--bg-elev, #161b25);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.admin-user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.admin-user-cell:hover .admin-user-name { color: var(--accent); }
.admin-user-cell .avatar { width: 32px; height: 32px; flex-shrink: 0; font-size: 12px; }
.admin-user-name { font-weight: 500; }
.admin-user-uname { color: var(--text-muted); font-size: 12px; }

.admin-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.admin-role-badge.super_admin { background: rgba(255, 61, 163, 0.15); color: var(--accent-2, #ff3da3); }
.admin-role-badge.admin       { background: rgba(0, 212, 170, 0.15); color: var(--accent, #00d4aa); }
.admin-role-badge.moderator   { background: rgba(255, 181, 71, 0.15); color: var(--warn, #ffb547); }
.admin-role-badge.user        { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); }
.admin-role-badge.readonly    { background: rgba(255, 255, 255, 0.03); color: var(--text-muted); }
.admin-role-badge.banned      { background: rgba(255, 90, 120, 0.15); color: var(--bad, #ff5a78); }

.admin-status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.admin-status-dot.online  { background: var(--accent, #00d4aa); box-shadow: 0 0 8px var(--accent); }
.admin-status-dot.offline { background: var(--text-muted); }

.admin-actions-cell {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.admin-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}
.admin-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* ═══════════════════════════════════════════════════════════
   INVITES
   ═══════════════════════════════════════════════════════════ */
.admin-invite-form {
    background: var(--bg-secondary, #11151c);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.admin-invite-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.admin-invite-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.admin-form-group label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.admin-form-group input,
.admin-form-group select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary, #0a0d12);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}
.admin-form-group input:focus,
.admin-form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.admin-invite-code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 212, 170, 0.08);
    transition: all 0.15s;
    user-select: all;
}
.admin-invite-code:hover {
    background: rgba(0, 212, 170, 0.15);
}
.admin-invite-code.copied {
    background: var(--accent);
    color: #0a0d12;
}

/* ═══════════════════════════════════════════════════════════
   USER PROFILE MODAL (внутри admin)
   ═══════════════════════════════════════════════════════════ */
.admin-profile-modal {
    position: fixed; inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.admin-profile-card {
    background: var(--bg-primary, #0a0d12);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.admin-profile-header {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.08), rgba(255, 61, 163, 0.04));
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 24px;
}
.admin-profile-header .avatar {
    width: 80px; height: 80px;
    font-size: 28px;
}
.admin-profile-header-info {
    flex: 1;
    min-width: 0;
}
.admin-profile-header-info h2 {
    margin: 0 0 4px;
    font-size: 24px;
    color: var(--text-primary);
}
.admin-profile-username {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    margin-bottom: 12px;
}
.admin-profile-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
}
.admin-profile-close:hover { background: var(--bad); color: white; border-color: var(--bad); }

.admin-profile-section {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
}
.admin-profile-section:last-child { border-bottom: none; }
.admin-profile-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin: 0 0 12px;
    font-weight: 600;
}
.admin-profile-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.admin-profile-row:last-child { border-bottom: none; }
.admin-profile-row-label {
    color: var(--text-muted);
    font-size: 13px;
}
.admin-profile-row-value {
    color: var(--text-primary);
    font-size: 13px;
}

.admin-profile-actions {
    padding: 20px 32px;
    background: var(--bg-secondary);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS sections
   ═══════════════════════════════════════════════════════════ */
.admin-settings-form {
    max-width: 720px;
}
.admin-settings-field {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.admin-settings-field:last-child { border-bottom: none; }
.admin-settings-field-label {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}
.admin-settings-field-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.admin-settings-field input,
.admin-settings-field select,
.admin-settings-field textarea {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

/* ═══════════════════════════════════════════════════════════
   AUDIT LOG
   ═══════════════════════════════════════════════════════════ */
.admin-audit-row {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 140px 140px 1fr 200px;
    gap: 16px;
    align-items: center;
    font-size: 13px;
}
.admin-audit-action {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent);
}
.admin-audit-time {
    color: var(--text-muted);
    font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════
   Responsive — v1.29.6 mobile rewrite (drawer pattern)
   ═══════════════════════════════════════════════════════════ */

/* Hamburger button — показывается только на мобиле */
.admin-mobile-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    /* iOS notch — добавляем padding-top */
    padding-top: max(10px, env(safe-area-inset-top, 0));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.admin-hamburger {
    width: 40px; height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.admin-hamburger:hover { background: var(--bg-hover); }
.admin-mobile-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Drawer backdrop */
.admin-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* v1.29.14 — Мобильная навигация: меню list-view → раздел.
   На мобильных по умолчанию показывается только меню (full-screen),
   при клике на раздел — переходит в контент с кнопкой "← Назад".
   Это намного удобнее работы со смартфона чем drawer. */
@media (max-width: 900px) {
    /* Базовая структура: меню — единственный видимый элемент по умолчанию */
    .admin-modal {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: 0;
    }
    .admin-topbar {
        flex-shrink: 0;
    }
    /* v1.29.14 — mobile bar: показывается только в режиме section */
    .admin-mobile-bar {
        display: none;  /* default: hidden */
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-base);
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    .admin-modal[data-mobile-view="section"] .admin-mobile-bar {
        display: flex;
    }

    /* admin-body — на мобиле flex без перекрытий */
    .admin-body {
        display: flex;
        flex: 1;
        min-height: 0;
        position: relative;
        width: 100%;
        overflow: hidden;
    }

    /* v1.29.14 — Stack-nav: показываем ОДНУ панель за раз */
    /* MENU view: только sidebar full-screen */
    .admin-modal[data-mobile-view="menu"] .admin-sidebar {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        position: relative !important;
        transform: none !important;
        box-shadow: none !important;
        flex: 1 1 auto !important;
        z-index: 1 !important;
    }
    .admin-modal[data-mobile-view="menu"] .admin-main {
        display: none !important;
    }

    /* SECTION view: только main full-screen */
    .admin-modal[data-mobile-view="section"] .admin-sidebar {
        display: none !important;
    }
    .admin-modal[data-mobile-view="section"] .admin-main {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        flex: 1 1 auto !important;
        padding: 16px !important;
    }

    /* Backdrop в новой схеме не нужен */
    .admin-drawer-backdrop { display: none !important; }

    /* Кнопка "‹" в mobile bar */
    .admin-back-to-menu {
        background: transparent;
        border: 0;
        color: var(--text-primary);
        font-size: 22px;
        cursor: pointer;
        padding: 8px 12px;
        flex-shrink: 0;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .admin-back-to-menu:hover { color: var(--accent); }
    .admin-mobile-title {
        flex: 1;
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary);
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0 8px;
    }
    /* Адаптивные размеры для основного контента */
    .admin-main {
        padding: 14px 12px max(20px, env(safe-area-inset-bottom)) !important;
    }
    .admin-page-header h1 { font-size: 18px; }
    .admin-page-subtitle { font-size: 12px; }
    /* Кнопки крупнее на тач-экране */
    .admin-btn { min-height: 36px; padding: 8px 14px; }
    .admin-input, .admin-input-mb { min-height: 38px; }
    .admin-tabs-bar { gap: 4px; padding: 8px 4px 0; overflow-x: auto; }
    .admin-tab-btn { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
    /* Списки и формы — без горизонтальной прокрутки */
    .admin-form-grid {
        grid-template-columns: 1fr !important;
    }
    /* Таблицы — превращаем в карточки */
    .admin-table-wrap {
        overflow-x: auto;
    }
    .admin-list-row {
        flex-wrap: wrap;
    }
    .admin-list-row-actions {
        width: 100%;
        margin-top: 6px;
        justify-content: flex-end;
    }
}

/* v1.29.14 — продолжение мобильных правил для таблиц и кнопок */
@media (max-width: 900px) {
    .admin-table {
        min-width: 640px; /* keeps it usable, table scrolls */
    }
    /* На очень узком — скрываем средние, оставляем первый+последний */
    .admin-table-wrap.admin-table-collapse th:not(:first-child):not(:last-child),
    .admin-table-wrap.admin-table-collapse td:not(:first-child):not(:last-child) { display: none; }

    /* Stat grid — 1 column on narrow screens */
    .admin-section-grid { grid-template-columns: 1fr 1fr !important; }
    .admin-dashboard { grid-template-columns: 1fr 1fr !important; gap: 8px; }

    /* Buttons / inputs touch-friendly */
    .admin-modal button, .admin-modal input, .admin-modal select {
        min-height: 40px;
    }

    /* Section header smaller */
    .admin-page-header h1 { font-size: 20px; }
    .admin-section-head h2 { font-size: 18px; }

    /* Mobile menu items: больше padding для тач-области */
    .admin-menu-item {
        justify-content: flex-start !important;
        gap: 14px !important;
        padding: 14px 18px !important;
        font-size: 15px !important;
        min-height: 52px;
    }
    .admin-menu-item span:not(.admin-menu-icon) {
        display: inline !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .admin-menu-icon {
        font-size: 22px !important;
        flex-shrink: 0;
    }
    .admin-menu-group-title {
        display: block;
        padding: 10px 18px 4px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        color: var(--text-muted);
    }
    /* Стрелка вправо у каждого item — намёк "тапни чтобы открыть раздел" */
    .admin-menu-item::after {
        content: '›';
        margin-left: auto;
        color: var(--text-muted);
        font-size: 22px;
        line-height: 1;
    }
}

@media (max-width: 480px) {
    .admin-section-grid { grid-template-columns: 1fr !important; }
    .admin-dashboard { grid-template-columns: 1fr !important; }
}

/* v1.29.13 — Section header (heading + action) */
.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.admin-section-header h2 {
    font-size: 18px;
    font-weight: 600;
}
@media (max-width: 600px) {
    .admin-section-header {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-section-header h2 { font-size: 16px; }
}

.admin-card {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}
.admin-card:hover { border-color: var(--accent); }


/* v1.29.13 — Sticker upload dialog: per-file emoji picker */
.sup-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--bg-overlay);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.sup-file-preview {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: var(--bg-base);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sup-emoji-btn {
    transition: border-color 0.15s, transform 0.1s;
}
.sup-emoji-btn:hover { border-color: var(--accent) !important; transform: scale(1.05); }

.sup-emoji-popover {
    z-index: 9999;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 32px);
    gap: 2px;
    max-width: 280px;
    max-height: 220px;
    overflow-y: auto;
}
.sup-emoji-opt {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}
.sup-emoji-opt:hover { background: var(--bg-base); transform: scale(1.15); }
.sup-emoji-clear {
    color: var(--red, #f85149);
    font-weight: 700;
    font-size: 18px;
}

/* ════════════════════════════════════════════════════════════════
   v1.29.13 — Comprehensive mobile audit
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Page-header — переносим действия снизу */
    .admin-page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    .admin-page-header > .admin-actions,
    .admin-page-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .admin-page-header h1 {
        font-size: 20px !important;
        line-height: 1.2;
    }

    /* Section-head — heading + action кнопки */
    .admin-section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .admin-section-head h2 { font-size: 16px; }
    .admin-section-head > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .admin-section-head button { font-size: 12px; padding: 8px 12px; }

    /* Все формы в админке — full-width inputs */
    .admin-main .form-group input,
    .admin-main .form-group select,
    .admin-main .form-group textarea,
    .admin-card .form-group input,
    .admin-card .form-group select,
    .admin-card .form-group textarea {
        width: 100%;
        max-width: 100%;
        font-size: 14px; /* Prevent iOS zoom on focus */
        padding: 10px 12px;
    }
    .admin-main .form-group label,
    .admin-card .form-group label {
        font-size: 13px;
        margin-bottom: 4px;
    }

    /* Кнопки в формах — стек на узких */
    .admin-form-actions {
        flex-direction: column;
        gap: 8px;
    }
    .admin-form-actions button { width: 100%; }

    /* Card padding — компактнее на мобиле */
    .admin-card { padding: 16px 14px !important; }

    /* Stat cards — flex 2 в ряд */
    .admin-stats-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .admin-stat-card {
        padding: 12px !important;
        min-width: unset !important;
    }
    .admin-stat-value { font-size: 20px !important; }
    .admin-stat-label { font-size: 11px !important; }

    /* Tabs внутри секций — горизонтальный скролл */
    .admin-tabs,
    .admin-subtabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }
    .admin-tabs::-webkit-scrollbar,
    .admin-subtabs::-webkit-scrollbar { display: none; }
    .admin-tabs > *,
    .admin-subtabs > * {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Search/filter row */
    .admin-search-row {
        flex-direction: column;
        gap: 8px;
    }
    .admin-search-row input,
    .admin-search-row select {
        width: 100%;
    }
}

/* ── Мини-устройства (< 480px) ──────────────────────────── */
@media (max-width: 480px) {
    /* Stat cards в одну колонку */
    .admin-stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* ─── Превращаем "плоские" таблицы в карточки ─── */
    /* Любая таблица с классом admin-table-cards автоматически рендерится как стопка
       карточек где каждая ячейка → блок (заголовок + значение). */
    .admin-table-wrap.admin-table-cards table,
    .admin-table-wrap.admin-table-cards thead,
    .admin-table-wrap.admin-table-cards tbody,
    .admin-table-wrap.admin-table-cards tr,
    .admin-table-wrap.admin-table-cards th,
    .admin-table-wrap.admin-table-cards td {
        display: block;
    }
    .admin-table-wrap.admin-table-cards thead {
        position: absolute;
        clip: rect(0 0 0 0);
        overflow: hidden;
    }
    .admin-table-wrap.admin-table-cards tr {
        background: var(--bg-overlay);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 10px 12px;
        margin-bottom: 8px;
    }
    .admin-table-wrap.admin-table-cards td {
        border: none !important;
        padding: 4px 0 !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
    }
    .admin-table-wrap.admin-table-cards td::before {
        content: attr(data-label);
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
    }
    .admin-table-wrap.admin-table-cards td:not([data-label])::before {
        display: none;
    }

    /* Action кнопки в карточке — внизу полной ширины */
    .admin-table-wrap.admin-table-cards td.action-cell {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin-top: 6px;
        padding-top: 8px !important;
        border-top: 1px solid var(--border) !important;
    }
    .admin-table-wrap.admin-table-cards td.action-cell::before { display: none; }
    .admin-table-wrap.admin-table-cards td.action-cell button {
        width: 100%;
    }

    /* Mobile bar header кнопки чуть меньше */
    .admin-mobile-bar { padding: 10px 12px !important; }
    .admin-mobile-title { font-size: 14px !important; }

    /* Modal внутри админки — full-screen */
    .admin-overlay .modal,
    .admin-overlay .modal-box {
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
}

/* ── Smooth scroll & touch ──────────────────────────── */
@media (max-width: 900px) {
    .admin-main, .admin-modal {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* ════════════════════════════════════════════════════════════════
   v1.29.14 — Inline storage / database panels (без модалок)
   ════════════════════════════════════════════════════════════════ */
.admin-tabs-bar {
    display: flex;
    gap: 4px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.admin-tab-btn {
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    border-bottom: 2px solid transparent;
}
.admin-tab-btn:hover { color: var(--text-primary); background: var(--bg-overlay); }
.admin-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.admin-section-body { padding: 4px 0; }
.admin-loading { padding: 24px; text-align: center; color: var(--text-muted); }
.admin-error { padding: 12px; background: rgba(255,59,48,0.08); color: #ff5f5f; border-radius: 8px; }
.admin-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.admin-empty { padding: 40px; text-align: center; color: var(--text-muted); }
.admin-empty-row { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12px; }
.admin-h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* Storage rows */
.admin-storage-grid { display: flex; flex-direction: column; gap: 8px; }
.admin-storage-row {
    display: grid;
    grid-template-columns: 1.2fr 2fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: var(--bg-overlay);
    border-radius: 10px;
    border: 1px solid var(--border);
}
.admin-storage-head { display: flex; align-items: center; gap: 10px; }
.admin-storage-icon { font-size: 22px; }
.admin-storage-name { font-size: 13px; font-weight: 600; }
.admin-storage-exts { font-size: 11px; color: var(--text-muted); }
.admin-storage-ctl {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.admin-input {
    background: var(--bg-base);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    min-width: 0;             /* v1.29.14 — позволяет ужиматься в grid */
    box-sizing: border-box;
    max-width: 100%;
}
.admin-input-mb { width: 70px; }
.admin-storage-unit { font-size: 11px; color: var(--text-muted); }
.admin-storage-status { font-size: 11px; min-width: 80px; }
.admin-storage-save { font-size: 12px; padding: 5px 10px; }

/* Storage stats */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin: 6px 0 18px;
}
.admin-stat {
    padding: 14px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
}
.admin-stat.warning { border-color: #ffaa00; }
.admin-stat-val { font-size: 20px; font-weight: 700; color: var(--accent); }
.admin-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.admin-stats-tbl { display: flex; flex-direction: column; gap: 4px; }
.admin-stats-tr {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--bg-overlay);
    font-size: 12px;
}

/* Cleanup */
.admin-cleanup-card {
    padding: 18px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-width: 600px;
}
.admin-cleanup-card p { color: var(--text-secondary); font-size: 13px; margin: 8px 0 14px; }
.admin-cleanup-result { margin-top: 12px; font-size: 13px; }

/* List rows (Library admin) */
.admin-toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-overlay);
    border-radius: 8px;
    border: 1px solid var(--border);
    gap: 10px;
}
.admin-list-row-main { flex: 1; min-width: 0; }
.admin-list-row-title { font-size: 13px; font-weight: 500; }
.admin-list-row-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.admin-list-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-btn.danger { color: #ff5f5f; border-color: rgba(255,95,95,0.3); }
.admin-btn.danger:hover { background: rgba(255,59,48,0.1); }

/* ════════════════════════════════════════════════════════════════
   v1.29.14 — расширенные admin-формы (бренд, чаты, audit)
   ════════════════════════════════════════════════════════════════ */
.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.admin-form-section {
    padding: 16px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.admin-form-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.admin-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    min-width: 0;  /* v1.29.14: позволяет шринк в grid-ячейках */
}
.admin-field-label {
    font-size: 12px;
    color: var(--text-secondary);
}
/* .admin-color-* — определены ниже в v1.29.14 секции */
.admin-form-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
}
.admin-form-msg { font-size: 12px; }
.admin-form-msg.ok  { color: var(--green, #3fb950); }
.admin-form-msg.err { color: var(--red, #f85149); }

/* Chat meta */
.admin-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}
.admin-meta-cell {
    padding: 8px 10px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.admin-meta-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-meta-val {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 2px;
    word-break: break-word;
}

/* Health checks */
.health-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-overlay);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    transition: border-color .2s;
}
.health-status { font-size: 16px; }
.health-name { font-weight: 500; font-size: 13px; }
.health-url {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-base);
    padding: 2px 6px;
    border-radius: 4px;
}
.health-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Tab count chip */
.admin-tab-count {
    margin-left: 6px;
    background: rgba(255,255,255,0.12);
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
}
.admin-tab-btn.active .admin-tab-count {
    background: rgba(255,255,255,0.25);
}

/* ════════════════════════════════════════════════════════════════
   v1.29.14 — RBAC: Роли и права
   ════════════════════════════════════════════════════════════════ */
.admin-rbac-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 14px;
    margin-top: 14px;
    min-height: 600px;
}
.admin-rbac-roles {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
}
.admin-rbac-roles-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    background: var(--bg-base);
}
.admin-btn-sm { font-size: 11px; padding: 4px 10px; min-height: 0; }
.admin-rbac-roles-list {
    overflow-y: auto;
    flex: 1;
    padding: 6px;
}
.admin-rbac-role-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    transition: all .15s;
    margin-bottom: 4px;
}
.admin-rbac-role-item:hover { background: var(--bg-base); border-color: var(--border); }
.admin-rbac-role-item.active {
    background: rgba(79, 138, 255, 0.12);
    border-color: var(--accent);
}
.admin-rbac-role-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.admin-rbac-role-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-rbac-role-name { font-weight: 500; font-size: 13px; }
.admin-rbac-role-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.admin-rbac-sys-badge {
    background: rgba(255, 165, 0, 0.18);
    color: #f7a02d;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
}
.admin-rbac-super-badge {
    background: rgba(79, 138, 255, 0.18);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
}

/* Right panel */
.admin-rbac-perms {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    overflow-y: auto;
    max-height: 75vh;
}
.admin-rbac-role-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.admin-rbac-role-header h2 { margin: 0; font-size: 18px; }
.admin-rbac-role-actions { display: flex; gap: 6px; }
.admin-rbac-role-desc {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-base);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}
.admin-rbac-super-notice {
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(79, 138, 255, 0.15), rgba(167, 139, 250, 0.10));
    border: 1px solid rgba(79, 138, 255, 0.3);
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 13px;
}
.admin-rbac-perms-grid { display: flex; flex-direction: column; gap: 10px; }
.admin-rbac-cat {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-base);
}
.admin-rbac-cat-header {
    padding: 10px 12px;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.admin-rbac-cat-title { font-weight: 600; font-size: 13px; flex: 1; }
.admin-rbac-cat-count {
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-base);
    border-radius: 10px;
}
.admin-rbac-toggle-all {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
}
.admin-rbac-cat-perms {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-rbac-perm {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
}
.admin-rbac-perm:hover { background: var(--bg-overlay); }
.admin-rbac-perm input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    width: 18px; height: 18px;
    cursor: pointer;
}
.admin-rbac-perm-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-rbac-perm-label { font-size: 13px; font-weight: 500; }
.admin-rbac-perm-key {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-overlay);
    padding: 1px 5px;
    border-radius: 4px;
    align-self: flex-start;
    font-family: monospace;
}
.admin-rbac-perm-desc { font-size: 11px; color: var(--text-muted); }
.admin-rbac-save-bar {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    bottom: 0;
    background: var(--bg-overlay);
}
.admin-rbac-save-status { font-size: 12px; }
.admin-rbac-save-status.ok  { color: var(--green, #3fb950); }
.admin-rbac-save-status.err { color: var(--red, #f85149); }

@media (max-width: 900px) {
    .admin-rbac-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .admin-rbac-roles { max-height: 200px; }
    .admin-rbac-perms { max-height: none; }
}

/* v1.29.14 — User permissions dialog */
.up-perm-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border-radius: 6px;
}
.up-perm-row:hover { background: var(--bg-overlay); }
.up-perm-row .admin-rbac-perm-info { flex: 1; min-width: 0; }
.up-perm-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.up-state-sel { min-width: 130px; font-size: 12px; }
.up-status { font-size: 12px; min-width: 16px; }
.up-from-role {
    font-size: 10px;
    background: rgba(79, 138, 255, 0.15);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* v1.29.14 — Audit log: красивые карточки */
.admin-audit-card {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color .15s;
}
.admin-audit-card:hover {
    border-color: var(--accent);
}
.admin-audit-card[open] {
    border-color: var(--accent);
}
.admin-audit-summary {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 1.5fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.admin-audit-summary::-webkit-details-marker { display: none; }
.admin-audit-summary::before {
    display: none;
}
.admin-audit-action-wrap {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.admin-audit-info {
    min-width: 0;
}
.admin-audit-actor {
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-audit-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.admin-audit-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.admin-audit-meta-json {
    margin: 0;
    padding: 10px 14px;
    background: var(--bg-base);
    border-top: 1px solid var(--border);
    font-size: 11px;
    overflow: auto;
    color: var(--text-secondary);
    max-height: 280px;
}

@media (max-width: 900px) {
    .admin-audit-summary {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .admin-audit-meta {
        justify-content: space-between;
    }
}

/* ════════════════════════════════════════════════════════════════
   v1.29.14 — Стиль оформления: live preview + новые секции
   ════════════════════════════════════════════════════════════════ */

.admin-preview-card {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 20px;
    overflow: hidden;
    --accent: #4f8aff;
    --logo-clr: #ffffff;
    --sender-clr: #74b9ff;
}
.admin-preview-card .apc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
}
.admin-preview-card .apc-eye { font-size: 14px; }

.apc-preview-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 240px;
    background: #0d1117;  /* dark bg для preview независимо от темы админки */
}
.apc-sidebar {
    padding: 16px 12px;
    border-right: 1px solid var(--border);
    background: #0d1117;
}
.apc-logo {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 4px;
    color: var(--logo-clr);
    margin-bottom: 18px;
    text-align: center;
    transition: color .2s;
}
.apc-chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
}
.apc-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    transition: background .2s;
}
.apc-chat-name { font-size: 13px; color: #e6edf3; font-weight: 500; }
.apc-chat-last { font-size: 11px; color: #7d8590; }

.apc-chat-area {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0d1117;
}
.apc-msg-row { display: flex; flex-direction: column; max-width: 75%; }
.apc-msg-row.apc-msg-own {
    align-self: flex-end;
    align-items: flex-end;
}
.apc-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--sender-clr);
    transition: color .2s;
}
.apc-bubble {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    max-width: 100%;
}
.apc-bubble-them {
    background: #21262d;
    color: #e6edf3;
}
.apc-bubble-mine {
    background: var(--accent);
    color: #fff;
    transition: background .2s;
}

@media (max-width: 700px) {
    .apc-preview-body { grid-template-columns: 1fr; min-height: auto; }
    .apc-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Form sections */
.apc-section {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 14px;
}
.admin-form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.apc-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.apc-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 700px) {
    .apc-grid-2, .apc-grid-3 { grid-template-columns: 1fr; }
}

/* Color picker row */
.admin-color-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;          /* v1.29.14: позволяет шринк в grid-ячейке */
}
.admin-color-input {
    width: 38px;
    height: 36px;
    min-width: 38px;       /* v1.29.14: не сжимать picker до нуля */
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}
.admin-color-text {
    flex: 1 1 auto;
    min-width: 0;          /* v1.29.14: ширина по родителю, не по контенту */
    width: 100%;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    font-size: 12px;
    padding: 8px 6px;      /* было padding наследовался от .admin-input — теперь компактнее */
    text-align: center;
}

/* Skin picker — v1.29.14: 4 скина (Classic / Corporate / Cyberpunk / Hacker) */
.apc-skin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
@media (max-width: 700px) {
    .apc-skin-grid { grid-template-columns: repeat(2, 1fr); }
}
.apc-skin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    background: var(--bg-base);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    position: relative;
    opacity: 0.62;                                 /* v1.29.14: неактивные приглушены */
}
.apc-skin:hover {
    border-color: var(--accent);
    opacity: 0.85;
}
.apc-skin.active {
    border-color: var(--accent);
    background: var(--accent-dim, rgba(79,138,255,0.18));
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 79,138,255), 0.18),
                0 6px 16px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}
/* Чек-иконка в углу активной */
.apc-skin.active::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.apc-skin.active .apc-skin-name {
    color: var(--accent);
    font-weight: 700;
}
.apc-skin-prev {
    width: 100%;
    height: 32px;
    border-radius: 6px;
}
.apc-skin-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color .15s;
}

/* Wallpaper grid */
.apc-wallpaper-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.apc-wall {
    width: 60px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    transition: all .15s;
    background-size: cover !important;
}
.apc-wall:hover { transform: scale(1.05); border-color: var(--accent); }
.apc-wall.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,138,255,0.2); }

/* Save actions */
.apc-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 16px;
    position: sticky;
    bottom: 0;
    backdrop-filter: blur(6px);
    z-index: 5;
}
.admin-form-msg.ok  { color: #3fb950; }
.admin-form-msg.err { color: #f85149; }

/* v1.29.14 — Акцент swatches */
.apc-accent-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.apc-accent-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform .15s, border-color .15s, box-shadow .15s;
    padding: 0;
}
.apc-accent-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.05);
}
.apc-accent-swatch.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.12);
}

/* v1.29.14 — Плотность интерфейса */
.apc-density-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.apc-density {
    background: var(--bg-base);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    transition: all .15s;
}
.apc-density:hover { border-color: var(--accent); }
.apc-density.active {
    border-color: var(--accent);
    background: rgba(79,138,255,0.08);
}
.apc-density-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.apc-density-prev {
    height: 28px;
    background: var(--bg-overlay);
    border-radius: 5px;
    margin-bottom: 6px;
    position: relative;
    overflow: hidden;
}
.apc-density-prev::before,
.apc-density-prev::after {
    content: '';
    position: absolute;
    left: 6px;
    right: 6px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}
.apc-density-prev-compact::before { top: 3px; }
.apc-density-prev-compact::after  { top: 11px; }
.apc-density-prev-regular::before { top: 5px; }
.apc-density-prev-regular::after  { top: 16px; }
.apc-density-prev-comfortable::before { top: 8px; }
.apc-density-prev-comfortable::after  { top: 18px; }
.apc-density-desc {
    line-height: 1.3;
}

/* v1.29.14 — Кнопка загрузки обоев */
.apc-wall-upload {
    cursor: pointer;
    color: var(--accent) !important;
    font-size: 18px;
    border-style: dashed !important;
}
.apc-wall-upload:hover {
    background: rgba(79,138,255,0.1) !important;
}

/* v1.29.14 — Универсальный StyleEditor */
.apc-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.apc-grid-4 > .admin-field {
    min-width: 0;
}
@media (max-width: 900px) {
    .apc-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
    .apc-grid-4 { grid-template-columns: minmax(0, 1fr); }
}
/* v1.29.14 — apc-grid-2 (для админа: Идентификация/Графика) аналогично */
.apc-grid-2 > * { min-width: 0; }
.apc-grid-3 > * { min-width: 0; }

/* Fullscreen modal для пользователя */
.nx-modal-fullscreen {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: none;
    align-items: stretch;
    justify-content: center;
    overflow: auto;
}
.nx-style-modal-content {
    width: 100%;
    max-width: 900px;
    min-height: 100%;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
}
.nx-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-overlay);
    position: sticky; top: 0; z-index: 10;
    backdrop-filter: blur(8px);
}
.nx-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.nx-modal-close {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.nx-modal-close:hover {
    background: var(--bg-base);
    border-color: var(--accent);
}
.nx-modal-body {
    padding: 18px;
    flex: 1;
}


/* v1.29.14 — Style Editor grid 3 columns (6 color fields in 2 rows) */
.apc-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.apc-grid-3 > .admin-field { min-width: 0; }
@media (max-width: 900px) {
    .apc-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
    .apc-grid-3 { grid-template-columns: minmax(0, 1fr); }
}

.apc-auto-contrast-btn {
    background: var(--accent-dim, rgba(79,138,255,0.15));
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.apc-auto-contrast-btn:hover { background: var(--accent); color: #fff; }
.apc-auto-contrast-btn:active { transform: scale(0.96); }

/* v1.29.15 — Voice setup wizard */
.voice-wizard-overlay { display: flex; align-items: center; justify-content: center; z-index: 10000; }
.voice-wizard {
    width: 100%; max-width: 560px; max-height: 90vh;
    background: var(--admin-bg, #15151f); border: 1px solid var(--admin-border, rgba(255,255,255,0.12));
    border-radius: 18px; overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.voice-wizard-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--admin-border, rgba(255,255,255,0.1));
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(79,138,255,0.1));
}
.voice-wizard-head h2 { margin: 0; font-size: 18px; }
.voice-wizard-close {
    width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255,255,255,0.1); color: var(--admin-text, #fff); font-size: 15px;
}
.voice-wizard-close:hover { background: rgba(255,255,255,0.2); }
.voice-wizard-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.vw-section { margin-bottom: 20px; }
.vw-section-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--admin-text, #fff); }
.vw-field { display: block; margin-bottom: 12px; }
.vw-field > span { display: block; font-size: 13px; color: var(--admin-text-muted, #9aa); margin-bottom: 6px; }
.vw-field > span small { color: var(--admin-text-muted, #778); font-weight: 400; }
.vw-field input[type="text"], .vw-field input[type="number"] {
    width: 100%; box-sizing: border-box; padding: 10px 12px;
    background: var(--admin-bg-elev, rgba(255,255,255,0.05));
    border: 1px solid var(--admin-border, rgba(255,255,255,0.12));
    border-radius: 9px; color: var(--admin-text, #fff); font-size: 14px;
}
.vw-field input:focus { outline: none; border-color: #10b981; }
.vw-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--admin-text, #fff); cursor: pointer; margin-bottom: 10px; }
.vw-checkbox input { width: 16px; height: 16px; accent-color: #10b981; }
.vw-log {
    margin-top: 14px; padding: 12px; border-radius: 10px; max-height: 200px; overflow-y: auto;
    background: var(--admin-bg-base, #0a0c12); border: 1px solid var(--admin-border, rgba(255,255,255,0.1));
    font-family: var(--font-mono, monospace); font-size: 12px; line-height: 1.6;
}
.vw-script { margin-top: 16px; }
.voice-wizard-foot {
    display: flex; gap: 10px; padding: 16px 22px; flex-wrap: wrap;
    border-top: 1px solid var(--admin-border, rgba(255,255,255,0.1));
    background: var(--admin-bg-raised, rgba(255,255,255,0.02));
}
.voice-wizard-foot .admin-btn { flex: 1; min-width: 120px; }

/* ═══════════════════════════════════════════════════════════════════════
   v1.31.59 — IT-DENSE РЕСТАЙЛ АДМИНКИ (patch 69)
   Плотное, информационно-насыщенное оформление в инженерном стиле:
   компактные отступы, моноширинные акценты, липкие заголовки групп,
   более узкие пункты меню для большего числа разделов на экране.
   ═══════════════════════════════════════════════════════════════════════ */

/* Сайдбар — компактнее, помещается больше разделов */
.admin-sidebar {
    width: 218px;
    padding: 8px 6px;
}
.admin-menu-group {
    margin-bottom: 8px;
}
.admin-menu-group-title {
    font-size: 9.5px;
    letter-spacing: 0.16em;
    padding: 7px 10px 3px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary, #11151c);
    z-index: 2;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    opacity: 0.75;
}
.admin-menu-item {
    gap: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    border-radius: 5px;
    margin-bottom: 1px;
    line-height: 1.3;
}
.admin-menu-item.active {
    padding-left: 8px;
    font-weight: 600;
}
.admin-menu-icon {
    width: 15px;
    height: 15px;
    font-size: 13px;
}

/* Контент-области плотнее */
.admin-page-header {
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border, #1f2532);
}
.admin-page-header h1 {
    font-size: 18px;
    margin: 0 0 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-page-subtitle {
    font-size: 11.5px;
    color: var(--text-muted);
    margin: 0;
}

/* Плотные карточки-метрики (dashboard) */
.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.admin-stat-card {
    padding: 11px 13px;
    border-radius: 7px;
    border: 1px solid var(--border, #1f2532);
    background: var(--bg-elevated, #161b24);
}
.admin-stat-card .admin-stat-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}
.admin-stat-card .admin-stat-label {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
}

/* Плотные таблицы — инженерный вид */
.admin-table {
    font-size: 12.5px;
    border-collapse: collapse;
    width: 100%;
}
.admin-table th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary, #11151c);
    text-align: left;
}
.admin-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}
.admin-table tr:hover td {
    background: rgba(255,255,255,0.02);
}
/* Моноширинные технические значения (id, ключи, хэши) */
.admin-table td.mono,
.admin-mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    color: var(--text-secondary);
}

/* Компактные секции настроек с группировкой */
.admin-settings-section {
    border: 1px solid var(--border, #1f2532);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.admin-settings-section > .admin-settings-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--accent, #00d4aa);
    padding: 9px 14px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.admin-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.admin-settings-row:last-child { border-bottom: none; }
.admin-settings-row .admin-settings-row-label {
    font-size: 12.5px;
    color: var(--text-primary);
}
.admin-settings-row .admin-settings-row-hint {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* RBAC — плотная сетка прав по категориям */
.admin-rbac-perm-category {
    margin-bottom: 10px;
}
.admin-rbac-perm-category-title {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent, #00d4aa);
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.admin-rbac-perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 4px 14px;
}
.admin-rbac-perm-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 7px;
    border-radius: 5px;
    font-size: 12px;
}
.admin-rbac-perm-item:hover { background: rgba(255,255,255,0.03); }
.admin-rbac-perm-item .admin-rbac-perm-key {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: var(--text-muted);
}

/* Скролл сайдбара — тоньше */
.admin-sidebar::-webkit-scrollbar { width: 4px; }
