/* =============================================================================
   admin.css — единая дизайн-система админ-панели
   =============================================================================

   Структура:
     1. Дизайн-токены (:root — всегда тёмная тема)
     2. Reset и базовая типографика
     3. Layout (sidebar, main-container, hamburger)
     4. Statistics grid (stat-card)
     5. Controls / Filters / Forms
     6. Buttons (.btn-primary, .btn-secondary, .btn-vip, .btn-edit и т.д.)
     7. Lists (универсальные .list, .user-item, .suggestion-item)
     8. Films grid (карточка фильма + overlay)
     9. Film modal (просмотр)
    10. Modals (общие, confirm)
    11. Toasts / Skeletons / Empty states
    12. Pagination
    13. Forms-helpers (form-group, modal-buttons, genres-grid)
    14. Audit-log tab
    15. Quiz tab
    16. Collections tab
    17. Settings tab (toggles)
    18. Kanban
    19. Responsive (768px, 480px)
    20. Utility-classes (для новых шаблонов — без inline-стилей)

   Принципы:
     * Все цвета/отступы/радиусы — через CSS-переменные (--token-*).
       Захардкоженные #hex остаются только в legacy-местах (карточка
       фильма с тёмным фоном, status-badges) и помечены TODO.
     * Файл подгружается из base.html ОДНИМ <link> с версионированием
       через query-string ?v={app_version} → агрессивный кэш и инвалидация
       при деплое.
     * Новые компоненты (новые вкладки, секции) ДОЛЖНЫ использовать токены
       и утилиты, а не inline-стили.

   Общие дизайн-токены админки.
   ============================================================================= */


/* ===== 1. ДИЗАЙН-ТОКЕНЫ ===================================================== */

:root {
    color-scheme: dark;
    /* Цвета — поверхности и контент (тёмная тема по умолчанию) */
    --bg: #000000;
    --surface: #1c1c1e;
    --sidebar-bg: rgba(28,28,30,0.8);
    --text-primary: #f5f5f7;
    --text-secondary: #8e8e93;

    /* Цвета — акценты и состояния */
    --accent: #0a84ff;
    --danger: #ff453a;
    --success: #28a745;
    --warning: #fd7e14;
    --info: #17a2b8;

    /* Бордеры и тени */
    --border: rgba(255,255,255,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --card-shadow: 0 12px 32px rgba(0,0,0,0.5);
    --shadow-elevated: 0 16px 48px rgba(0,0,0,0.6);

    /* Типографика */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-xs: 12px;
    --font-sm: 13px;
    --font-md: 15px;
    --font-lg: 17px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-3xl: 28px;
    --font-4xl: 32px;

    /* Spacing scale (применять в новом коде; legacy-места переходят постепенно) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;

    /* Радиусы */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 20px;
    --radius-pill: 999px;
}


/* ===== 2. RESET И БАЗОВАЯ ТИПОГРАФИКА ====================================== */

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:var(--font-family); background:var(--bg); color:var(--text-primary); min-height:100vh; display:flex; }
h2 { font-size:var(--font-4xl); font-weight:600; text-align:center; margin-bottom:30px; }


/* ===== 3. LAYOUT ============================================================ */

.sidebar { width:280px; background:var(--sidebar-bg); backdrop-filter:blur(20px); border-right:1px solid var(--border); padding:40px 20px; position:fixed; height:100%; overflow-y:auto; box-shadow:var(--shadow); z-index:10; left:0; top:0; display:flex; flex-direction:column; }
.hamburger-btn { display:none; }
.sidebar h1 { font-size:var(--font-3xl); font-weight:700; text-align:center; margin-bottom:60px; }
.sidebar-nav a { display:block; padding:16px 20px; margin-bottom:8px; border-radius:var(--radius-lg); text-decoration:none; color:var(--text-primary); font-size:var(--font-lg); font-weight:500; transition:all .3s ease; }
.sidebar-nav a:hover, .sidebar-nav a.active { background:var(--accent); color:white; }
.sidebar-nav a i { margin-right:10px; opacity:.9; }
.sidebar-footer { margin-top:auto; padding-top:24px; border-top:1px solid var(--border); }
.sidebar-docs { display:flex; flex-direction:column; gap:6px; margin-bottom:12px; }
.sidebar-docs a { font-size:var(--font-sm); color:var(--text-secondary); text-decoration:none; }
.sidebar-docs a:hover { color:var(--accent); text-decoration:underline; }
.sidebar-version { font-size:var(--font-sm); color:var(--text-secondary); text-align:center; display:block; }
.main-container { padding:40px; width:100%; min-height:100vh; box-sizing:border-box; display:flex; flex-direction:column; transition:margin-left .3s ease; }
/* Учёт бокового меню (sidebar 280px + padding 40px + border) */
.main-container {
    margin-left: 280px;
    padding-left: 40px;
    padding-right: 40px;
    width: calc(100% - 280px);
}


/* ===== 4. STATISTICS GRID ================================================== */

.stats-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:16px; max-width:1280px; margin:0 auto 40px; width:100%; }
.stat-card { background:var(--surface); border-radius:var(--radius-xl); padding:24px; text-align:center; box-shadow:var(--card-shadow); border:1px solid var(--border); }
.stat-card--clickable { cursor:pointer; transition:transform .15s ease, box-shadow .15s ease; }
.stat-card--clickable:hover { box-shadow:0 8px 28px rgba(0,0,0,.12); transform:translateY(-2px); }
.stat-card--clickable:focus { outline:2px solid var(--accent); outline-offset:2px; }
.stat-value { font-size:42px; font-weight:700; color:var(--accent); margin:12px 0; }
.stat-label { font-size:var(--font-lg); color:var(--text-secondary); }


/* ===== 5. CONTROLS / FILTERS / INPUTS ====================================== */

.controls { display:flex; justify-content:space-between; align-items:flex-end; max-width:1200px; margin:0 auto 30px; width:100%; flex-wrap:wrap; gap:20px; }
.filters { display:flex; gap:20px; flex-wrap:wrap; align-items:flex-end; flex:1; min-width:320px; }
.filter-group { flex:1; min-width:200px; }
label { display:block; margin-bottom:8px; font-weight:600; color:var(--text-secondary); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width:100%; padding:14px 16px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface); color:var(--text-primary); font-size:var(--font-lg); font-family:inherit; }
input[type="checkbox"], input[type="radio"] { width:auto; height:auto; padding:0; margin:0; border:none; border-radius:0; background:transparent; min-height:auto; cursor:pointer; }
.tab-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; flex-wrap:wrap; gap:15px; }
.tab-header h2 { text-align: center; flex: 1; margin: 0; }
.tab-title i { margin-right:10px; }
.tab { display:none; width:100%; flex:1; flex-direction:column; }
.tab.active { display:flex; }


/* ===== 6. BUTTONS =========================================================== */

.btn-primary, .btn-danger, .btn-edit, .btn-save, .btn-cancel { cursor:pointer; padding:12px 20px; border:none; border-radius:var(--radius-md); font-size:var(--font-md); font-weight:600; }
.btn-primary { background:var(--accent); color:white; }
.btn-danger { background:var(--danger); color:white; }
.btn-edit { background:#ffc107; color:black; font-size:14px; padding:8px 14px; }
.btn-edit:hover { background:#e0a800; }
.btn-view { background:#0d6efd; color: white; }
.btn-view:hover { background:#0b5ed7; }
.btn-secondary { background:#6c757d; color:white; cursor:pointer; padding:12px 20px; border:none; border-radius:var(--radius-md); font-size:var(--font-md); font-weight:600; }
.btn-secondary:hover { background:#5a6268; }
.btn-small { padding:8px 14px; font-size:14px; }
.btn-vip { background:var(--accent, #007aff); color:white; cursor:pointer; padding:12px 20px; border:none; border-radius:var(--radius-md); font-size:var(--font-md); font-weight:600; }
.btn-vip:hover { opacity:0.9; filter:brightness(1.1); }
.btn-toggle {
    padding: 10px 20px;
    border: 1px solid #444;
    border-radius: var(--radius-sm);
    background: #2a2a2a;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}
.file-label {
    background: #0066ff;
    color: white;
    border-radius: var(--radius-sm);
    text-align: center;
}
.file-label:hover { background: #0052cc; }


/* ===== 7. LISTS ============================================================= */

.list { list-style:none; max-width:900px; margin:0 auto; width:100%; }
.list li { padding:20px; background:var(--surface); border-radius:var(--radius-lg); margin-bottom:16px; display:flex; justify-content:space-between; align-items:center; box-shadow:var(--shadow); flex-wrap:wrap; gap:15px; }
.list li strong { transition:opacity .2s; }
.list li strong:hover { opacity:.8; }
.suggestion-item .suggestion-header { display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
.suggestion-deleted-badge { font-size:12px; font-weight:500; color:var(--text-secondary); background:var(--border); padding:4px 10px; border-radius:var(--radius-sm); }
.suggestion-deleted-by-user { opacity:0.85; }
.user-item .user-sections { margin-top:8px; font-size:13px; color:var(--text-secondary); }
.user-item .user-meta { margin-top:10px; font-size:14px; color:var(--text-secondary); display:flex; flex-wrap:wrap; gap:16px 24px; }
.user-item .user-meta span { white-space:nowrap; }
.user-item .user-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }


/* ===== 8. FILMS GRID ======================================================== */

.films-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 20px;
}

@media (min-width: 769px) {
    .films-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Карточка = весь постер; оверлей (статус, название, кнопка) по наведению.
 * NB: дублируется в Layout-секции выше — эту версию (с aspect-ratio и
 * box-shadow более тёмным) используем для UI карточек с постером. */
.film-card {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #1e1e1e;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.25s ease;
    cursor: pointer;
}
.film-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.card-poster-wrapper { position: absolute; inset: 0; background: #111; }
.card-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-poster-no-poster {
    position: absolute;
    inset: 0;
    background: #1e1e1e;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.85rem;
    font-weight: 500;
}
.card-poster-no-poster::after { content: 'Нет постера'; }
.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 14px;
}
.film-card:hover .card-overlay { opacity: 1; }
.film-card.no-poster .card-overlay { opacity: 1; }
@media (max-width: 768px) {
    .film-card:not(.no-poster):hover .card-overlay { opacity: 0; }
    .film-card.card-tap-revealed .card-overlay { opacity: 1; }
    .film-card.no-poster .card-overlay { opacity: 1; }
}
.card-status-badge {
    align-self: flex-start;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}
/* Status colors — оставляем хардкод (бизнес-семантика, не в токены) */
.card-status-badge.published     { background: var(--success); }
.card-status-badge.ready         { background: var(--info); }
.card-status-badge.requires_work { background: var(--danger); }
.card-status-badge.need_watch    { background: var(--warning); }
.card-status-badge.draft         { background: #6c757d; }
.card-rating {
    align-self: flex-end;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.9rem;
}
.card-overlay .card-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    text-align: center;
    align-self: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    max-width: 100%;
}
.card-overlay-btn {
    align-self: center;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
/* Legacy fallback film-card (без aspect-ratio): используется в старых местах */
.film-poster { width:100%; height:380px; background-size:cover; background-position:center; background-repeat:no-repeat; display:flex; align-items:center; justify-content:center; color:#999; font-size:64px; background-color:#e5e5e5; }
.film-title { padding:20px; text-align:center; font-weight:600; font-size:18px; flex-grow:1; display:flex; align-items:center; justify-content:center; }


/* ===== 9. FILM MODAL (просмотр) ============================================= */

.film-modal-content {
    background: #121212;
    color: #e0e0e0;
    max-width: 1100px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px;
    border-radius: 16px;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) var(--border);
}
#filmModal .film-modal-content::-webkit-scrollbar { width: 10px; }
#filmModal .film-modal-content::-webkit-scrollbar-track { background: var(--border); border-radius: 10px; margin: 8px 0; }
#filmModal .film-modal-content::-webkit-scrollbar-thumb { background: var(--text-secondary); border-radius: 10px; }
#filmModal .film-modal-content::-webkit-scrollbar-thumb:hover { background: var(--text-primary); }
.modal-film-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.2rem;
    color: #fff;
}
@media (min-width: 769px) {
    .film-details-grid {
        display: grid;
        grid-template-columns: 1fr 1.4fr;
        gap: 40px;
    }
    .film-poster-column {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        min-width: 0;
    }
    .film-poster-carousel {
        position: relative;
        overflow: hidden;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.6);
        max-width: 100%;
        width: fit-content;
        height: 800px;
        max-height: min(70vh, 800px);
    }
    .film-poster-carousel img {
        width: 100%;
        height: auto;
        max-height: min(70vh, 800px);
        object-fit: contain;
        display: block;
        border-radius: 12px;
    }
    .film-poster-carousel > div { min-height: 200px; }
}
/* Заглушка «Нет постера» в модалке просмотра */
.film-poster-placeholder {
    width: 100%;
    height: 100%;
    min-height: 200px;
    aspect-ratio: 2 / 3;
    background: #1e1e1e;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1rem;
    font-weight: 500;
    box-sizing: border-box;
}
.btn-publish-film {
    padding: 12px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s;
}
.btn-publish-film:hover { opacity: 0.9; }
.btn-publish-film:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-edit-modal {
    padding: 12px 20px;
    background: #3d8bff;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s;
}
.btn-edit-modal:hover { opacity: 0.85; }
.btn-random-film {
    padding: 0;
    width: 48px;
    height: 48px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-random-film:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-random-film.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.film-info-column p { margin: 12px 0; font-size: 1.1rem; line-height: 1.5; }
.film-info-column strong { color: #bbb; }
.film-synopsis, .film-opinion, .film-audience { font-size: 1.05rem; line-height: 1.7; color: #ddd; }
.film-synopsis, .film-opinion { white-space: pre-wrap; }


/* ===== 10. MODALS (общие, confirm) ========================================== */

.modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.7); justify-content:center; align-items:center; z-index:1000; padding:20px; }
.modal.active { display:flex; }
.modal-content { background:var(--surface); border-radius:var(--radius-2xl); width:90%; max-width:900px; padding:30px; box-shadow:var(--card-shadow); position:relative; }
.modal-content.modal-no-scroll { max-height:90vh; overflow:visible; }
/* Параметры публикации — поверх модалки карточки фильма (#filmModal.z-index 1000) */
#publish-modal.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,.72);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
/* Модалки «Добавить/Редактировать фильм» — влезают в экран, красивый скролл */
#add-film-modal .modal-content,
#edit-film-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) var(--border);
}
#add-film-modal .modal-content::-webkit-scrollbar,
#edit-film-modal .modal-content::-webkit-scrollbar { width: 10px; }
#add-film-modal .modal-content::-webkit-scrollbar-track,
#edit-film-modal .modal-content::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 10px;
    margin: 8px 0;
}
#add-film-modal .modal-content::-webkit-scrollbar-thumb,
#edit-film-modal .modal-content::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 10px;
}
#add-film-modal .modal-content::-webkit-scrollbar-thumb:hover,
#edit-film-modal .modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}
.close { position:absolute; top:15px; right:20px; font-size:32px; cursor:pointer; color:var(--text-secondary); transition:opacity .2s; }
.close:hover { opacity:.6; }
#filmModal img#modalPoster { max-width:800px; max-height:80vh; width:100%; height:auto; object-fit:contain; margin:25px auto; border-radius:16px; box-shadow:0 12px 40px rgba(0,0,0,.35); }
@media (max-width:768px) { #filmModal img#modalPoster { max-width:95vw; max-height:70vh; } }
.confirm-modal { position:fixed; inset:0; background:rgba(0,0,0,.5); display:flex; align-items:center; justify-content:center; z-index:9999; }
.confirm-content { background:var(--surface); padding:24px; border-radius:12px; width:90%; max-width:400px; box-shadow:0 10px 30px rgba(0,0,0,.3); color:var(--text-primary); }
.confirm-buttons { display:flex; gap:12px; margin-top:20px; justify-content:flex-end; }
.btn-confirm, .btn-cancel { padding:10px 20px; border:none; border-radius:8px; cursor:pointer; font-weight:500; }
.btn-confirm { background:var(--danger); color:white; }
.btn-cancel { background:#6c757d; color:white; }


/* ===== 11. TOASTS / SKELETONS / EMPTY STATES ================================ */

.toast { position:fixed; bottom:max(24px, calc(env(safe-area-inset-bottom) + 16px)); right:max(24px, env(safe-area-inset-right)); padding:14px 24px; border-radius:8px; color:white; font-weight:500; z-index:10000; transform:translateY(120px); opacity:0; transition:all .35s cubic-bezier(.25,.8,.25,1); box-shadow:0 6px 20px rgba(0,0,0,.18); max-width:400px; }
.toast.show { transform:translateY(0); opacity:1; }
.toast-success { background:#28a745; }
.toast-error { background:#dc3545; }
.toast-info { background:#17a2b8; }
.loading { text-align:center; padding:80px; font-size:20px; color:var(--text-secondary); }
.empty-state { text-align:center; padding:60px 20px; color:var(--text-secondary); font-size:15px; }
@keyframes skeletonShimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, color-mix(in srgb, var(--border) 60%, var(--surface)) 50%, var(--border) 75%);
    background-size: 800px 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
}
.skeleton-card { background:var(--surface); border-radius:18px; padding:24px; box-shadow:var(--card-shadow); border:1px solid var(--border); display:flex; flex-direction:column; gap:12px; }
.skeleton-line { height:14px; }
.skeleton-line--sm { height:10px; width:60%; }
.skeleton-line--lg { height:20px; width:80%; }
.skeleton-img { height:180px; border-radius:12px; }


/* ===== 12. PAGINATION ======================================================= */

.pagination { display:flex; gap:12px; align-items:center; white-space:nowrap; }
.pagination button { padding:12px 20px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface); color:var(--text-primary); font-size:16px; cursor:pointer; }
.pagination button:hover:not(:disabled) { background:var(--accent); color:white; }
.pagination button:disabled { opacity:.5; cursor:not-allowed; }
.pagination .active { background:var(--accent); color:white; }


/* ===== 13. FORMS-HELPERS ==================================================== */

.form-group { margin-bottom:18px; }
.form-group label { display:block; margin-bottom:6px; font-weight:500; }
.form-group input:not([type="checkbox"]):not([type="radio"]), .form-group select, .form-group textarea { width:100%; padding:10px; border:1px solid var(--border); border-radius:6px; font-size:15px; font-family:inherit; }
.genres-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(140px,100%),1fr)); gap:8px; max-height:140px; overflow-y:auto; padding:8px; border:1px solid var(--border); border-radius:6px; }
.genre-checkbox { display:flex; align-items:center; gap:6px; cursor:pointer; }
.genre-checkbox label { display:inline; margin-bottom:0; font-weight:400; color:var(--text-primary); cursor:pointer; }
.modal-buttons { display:flex; gap:12px; justify-content:flex-end; margin-top:24px; }
.btn-save { background:#007aff; color:white; padding:10px 20px; border:none; border-radius:8px; cursor:pointer; }
.btn-cancel { background:#6c757d; color:white; padding:10px 20px; border:none; border-radius:8px; cursor:pointer; }


/* ===== 14. AUDIT-LOG TAB =================================================== */

.audit-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; align-items: end; }
.audit-filter { display: flex; flex-direction: column; gap: 4px; }
.audit-filter-label { font-size: 12px; color: var(--text-secondary); }
.audit-filter-actions { flex-direction: row; align-items: stretch; gap: 8px; }
.audit-filter-actions .btn { padding: 10px 16px; font-size: 14px; }
.audit-input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--bg); color: var(--text-primary); }
.audit-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.audit-summary { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; min-height: 18px; }
.audit-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto; box-shadow: var(--shadow); }
.audit-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 980px; }
.audit-table thead { background: color-mix(in srgb, var(--border) 60%, var(--surface)); }
.audit-table th, .audit-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.audit-table th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.audit-table tbody tr { cursor: pointer; transition: background 0.15s; }
.audit-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.audit-col-time { width: 160px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-th-sortable { cursor: pointer; user-select: none; }
.audit-th-sortable:hover { color: var(--text-primary); }
.audit-col-group { width: 150px; }
.audit-col-sev { width: 100px; }
.audit-col-action { width: 180px; }
.audit-col-user { width: 160px; }
.audit-col-target { width: 160px; }
.audit-col-details { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-empty { text-align: center; padding: 40px 12px; color: var(--text-secondary); }
.sev-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.sev-info { background: rgba(0,122,255,0.12); color: #0a84ff; }
.sev-warning { background: rgba(255,149,0,0.18); color: #b25600; }
.sev-error, .sev-critical { background: rgba(255,69,58,0.18); color: #c5251a; }
.sev-debug { background: rgba(120,120,128,0.18); color: var(--text-secondary); }
.audit-pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }
.audit-pagination .btn { padding: 8px 14px; font-size: 14px; min-height: auto; }
.audit-pagination-info { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.audit-modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.audit-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.audit-modal-content { position: relative; background: var(--surface); color: var(--text-primary); max-width: 720px; width: 100%; max-height: 86vh; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); display: flex; flex-direction: column; overflow: hidden; }
.audit-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.audit-modal-title { margin: 0; font-size: 18px; }
.audit-modal-close { background: transparent; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text-secondary); }
.audit-modal-close:hover { color: var(--text-primary); }
.audit-modal-body { padding: 18px 20px; overflow-y: auto; }
.audit-modal-body dt { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 12px; }
.audit-modal-body dt:first-child { margin-top: 0; }
.audit-modal-body dd { margin: 4px 0 0; font-size: 14px; word-break: break-word; }
.audit-modal-body pre.audit-details-pre { margin: 6px 0 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; font-size: 12.5px; line-height: 1.5; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 768px) {
    .audit-table { min-width: 760px; }
    .audit-col-details { max-width: 220px; }
}


/* ===== 15. QUIZ TAB ========================================================= */

.quiz-add-section { max-width: 700px; margin: 0 auto 32px; }
.quiz-add-title { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; text-align: left; }
.quiz-add-form { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 24px; box-shadow: var(--shadow); }
.quiz-film-search-wrap { margin-bottom: 12px; }
.quiz-film-results { margin-top: 12px; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.quiz-film-results-placeholder { padding: 16px; text-align: center; color: var(--text-secondary); font-size: 15px; }
.selected-film-info { margin-top: 14px; padding: 12px 16px; background: rgba(0,122,255,0.08); border-radius: 12px; font-size: 15px; }
.quiz-add-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.quiz-file-label { cursor: pointer; padding: 12px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; margin: 0; display: inline-block; }
.quiz-file-label:hover { opacity: 0.92; }
.quiz-file-input { position: absolute; width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; z-index: -1; }
.frame-preview-container { margin-top: 16px; text-align: center; }
.frame-preview-img { max-width: 100%; max-height: 260px; border-radius: 12px; box-shadow: var(--shadow); }
.quiz-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); width: 100%; max-width: 100%; }
.quiz-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.quiz-table th { text-align: left; padding: 12px 16px; background: var(--bg); color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border); }
.quiz-table th.col-actions { text-align: center; }
.quiz-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
.quiz-table td:first-child { font-variant-numeric: tabular-nums; }
.quiz-table tbody tr:last-child td { border-bottom: none; }
.quiz-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.quiz-table td:nth-child(4) { text-align: center; white-space: nowrap; }
.quiz-table td:nth-child(4) button { margin: 0 4px; }
.quiz-table-empty { text-align: center; padding: 24px 16px !important; }
.quiz-table-empty-muted { color: var(--text-secondary); }
/* Модальное окно «Добавить кадр» */
.quiz-add-modal-content { max-width: 480px; max-height: 90vh; overflow: visible; }
.quiz-add-modal-content h3 { margin-bottom: 20px; }
.quiz-add-modal-form .form-group { margin-bottom: 16px; }
.quiz-modal-results { max-height: 200px; margin-top: 8px; }


/* ===== 16. COLLECTIONS TAB ================================================= */

.collection-card { background:var(--surface); border-radius:14px; box-shadow:var(--shadow); padding:20px; border:1px solid var(--border); transition:box-shadow .2s; }
.collection-card:hover { box-shadow:var(--card-shadow); }
.collection-card-inner { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.collection-info { flex:1; min-width:0; }
.collection-title { margin:0; cursor:pointer; color:var(--accent); font-size:17px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }
.collection-title:hover { text-decoration:underline; }
.collection-count { color:var(--text-secondary); margin-top:4px; font-size:13px; }
.collection-side { display:flex; flex-direction:column; align-items:stretch; gap:8px; flex-shrink:0; min-width:min(180px, 38vw); }
.collection-toggle-wrap { flex-shrink:0; }
.collection-btn-row { display:flex; flex-direction:column; gap:8px; width:100%; }
.collection-btn-row .btn-small { width:100%; box-sizing:border-box; text-align:center; }
.coll-visibility-toggle { display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none; margin-bottom:0; justify-content:flex-end; }
.coll-visibility-toggle input { display:none; }
.coll-toggle-slider { position:relative; width:40px; height:22px; background:rgba(255,255,255,0.2); border-radius:11px; transition:background .2s; flex-shrink:0; }
.coll-toggle-slider::after { content:''; position:absolute; left:3px; top:3px; width:16px; height:16px; background:#fff; border-radius:50%; transition:transform .2s; }
.coll-visibility-toggle input:checked + .coll-toggle-slider { background:var(--accent); }
.coll-visibility-toggle input:checked + .coll-toggle-slider::after { transform:translateX(18px); }
.coll-toggle-label { font-size:13px; color:var(--text-secondary); min-width:42px; }
.coll-preview { margin-top:12px; font-size:13px; color:var(--text-secondary); line-height:1.6; }
.coll-preview-empty { margin-top:12px; font-size:13px; color:var(--text-secondary); font-style:italic; }
@media (max-width:600px) {
    .collection-card { padding:14px 12px; }
    .collection-card-inner {
        display:grid;
        grid-template-columns:minmax(0,1fr) auto;
        grid-template-areas:
            "info toggle"
            "buttons buttons";
        gap:10px 10px;
        align-items:start;
    }
    .collection-side { display:contents; }
    .collection-info { grid-area:info; min-width:0; padding-right:4px; }
    .collection-toggle-wrap {
        grid-area:toggle;
        justify-self:end;
        align-self:start;
    }
    .collection-btn-row {
        grid-area:buttons;
        display:grid;
        grid-template-columns:1fr 1fr 1fr;
        gap:8px;
        margin-top:2px;
    }
    .collection-btn-row .btn-small {
        width:100%;
        padding:10px 6px;
        font-size:11px;
        line-height:1.2;
        white-space:normal;
    }
    .collection-title {
        font-size:15px;
        white-space:normal;
        line-height:1.25;
    }
    .collection-count { font-size:12px; }
    .coll-preview, .coll-preview-empty { margin-top:8px; font-size:12px; }
    .coll-toggle-label { display:none; }
    .coll-visibility-toggle { justify-content:flex-end; }
}
.collection-film-row { display:flex; justify-content:space-between; align-items:center; padding:12px 16px; background:var(--surface); border-radius:10px; margin-bottom:8px; border:1px solid var(--border); }
.search-hint { padding:30px; text-align:center; color:var(--text-secondary); font-size:14px; }
.search-loading { padding:40px; text-align:center; color:var(--accent); font-size:14px; }
.search-result-item { padding:12px 16px; border-bottom:1px solid var(--border); cursor:pointer; }
.search-result-item:hover { background:rgba(0,122,255,0.08); }
.search-result-title { font-weight:500; }


/* ===== 17. SETTINGS TAB (toggles) ========================================== */

.settings-section { max-width: 560px; margin: 0 auto; }
.settings-block { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.settings-block h3 { font-size: 1.1rem; margin-bottom: 16px; color: var(--text-primary); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.settings-row label { margin: 0; font-weight: 500; color: var(--text-primary); }
.toggle-switch { position: relative; width: 52px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 28px; cursor: pointer; transition: background 0.25s; }
.toggle-slider::before { content: ''; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px; background: var(--surface); border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.25s; }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 0 2px var(--accent); }
.settings-hint { font-size: 0.9rem; color: var(--text-secondary); margin-top: 8px; }


/* ===== 18. KANBAN ========================================================== */

.kanban-board { display: flex; gap: 20px; padding: 20px 0; min-height: 400px; overflow-x: auto; justify-content: center; flex-wrap: wrap; }
.kanban-column { flex: 0 0 320px; min-width: 280px; background: var(--surface); border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--card-shadow); display: flex; flex-direction: column; max-height: calc(100vh - 220px); transition: background 0.2s, box-shadow 0.2s; }
.kanban-column-drag-over { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); box-shadow: 0 0 0 2px var(--accent); }
.kanban-column-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.kanban-column-title { font-weight: 600; font-size: 15px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.kanban-column-count { background: var(--border); color: var(--text-secondary); font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.kanban-column-cards { flex: 1; padding: 10px; overflow-y: auto; min-height: 120px; }
.kanban-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; cursor: grab; transition: box-shadow 0.2s, opacity 0.2s; }
.kanban-card:hover { cursor: grab; }
.kanban-card:last-child { margin-bottom: 0; }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card:active { cursor: grabbing; }
.kanban-card-dragging { opacity: 0.6; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.kanban-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.kanban-card-title { font-weight: 600; font-size: 14px; color: var(--text-primary); line-height: 1.3; word-break: break-word; }
.kanban-card-badge { font-size: 11px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.kanban-card-badge-deleted { background: var(--danger); color: #fff; }
.kanban-card-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.kanban-card-notes { margin-top: 8px; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border); padding-top: 8px; }
.kanban-card-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.priority-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; }
.priority-badge.priority-low { background: #6c757d; color: #fff; }
.priority-badge.priority-medium { background: #fd7e14; color: #fff; }
.priority-badge.priority-high { background: #dc3545; color: #fff; }
.kanban-page { max-width: 1400px; margin: 0 auto; padding: 0 20px; text-align: center; }
.kanban-header { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 20px; margin-bottom: 20px; }
.kanban-header-text { text-align: center; }
.kanban-header .tab-title { margin-bottom: 6px; }
.kanban-header .tab-subtitle { color: var(--text-secondary); font-size: 14px; margin: 0; }
.kanban-toolbar { display: flex; gap: 10px; flex-shrink: 0; align-items: center; flex-wrap: wrap; justify-content: center; }
.kanban-toggle-wrap { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; color: var(--text-secondary); }
.kanban-toggle-label { white-space: nowrap; }
.kanban-toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; border-radius: 13px; background: var(--text-secondary); opacity: 0.7; border: 2px solid var(--border); cursor: pointer; transition: background 0.2s, border-color 0.2s, opacity 0.2s; }
.kanban-toggle-switch:hover { opacity: 1; }
.kanban-toggle-switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); opacity: 1; }
.toggle-switch-slider { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.35); transition: transform 0.2s; }
.kanban-toggle-switch[aria-checked="true"] .toggle-switch-slider { transform: translateX(22px); }
.kanban-toggle-switch:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.kanban-modal-content { max-width: 520px; }
.kanban-modal-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.kanban-columns-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.kanban-column-row { display: flex; gap: 10px; align-items: center; }
.kanban-column-row .kanban-column-name { flex: 2; min-width: 0; }
.kanban-column-row .kanban-column-id { flex: 1; min-width: 0; font-size: 13px; }
.kanban-column-remove { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); cursor: pointer; font-size: 20px; line-height: 1; flex-shrink: 0; }
.kanban-column-remove:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.kanban-modal-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: flex-end; }
.kanban-ticket-modal-content { max-width: 560px; }
.kanban-ticket-meta { font-size: 13px; color: var(--text-secondary); margin: 12px 0; padding: 10px; background: var(--bg); border-radius: 8px; }
.kanban-ticket-meta-p { margin: 0; }


/* ===== 19. RESPONSIVE ====================================================== */

@media (max-width: 768px) {
    .main-container {
        margin-left: 0;
        width: 100%;
        padding: 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        padding-top: max(72px, calc(env(safe-area-inset-top) + 52px));
    }
    .sidebar {
        width: 280px;
        max-width: 85vw;
        left: -280px;
        transition: left 0.25s ease, box-shadow 0.25s ease;
        z-index: 1001;
        padding: 20px 16px;
        padding-top: max(60px, calc(12px + 44px + env(safe-area-inset-top)));
    }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar { left: 0; box-shadow: 8px 0 24px rgba(0,0,0,0.25); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.25s ease;
    }
    body.sidebar-open .sidebar-overlay { display: block; opacity: 1; }
    .sidebar h1 { font-size: 22px; margin-bottom: 24px; }
    .sidebar-nav a { padding: 14px 16px; font-size: 16px; margin-bottom: 4px; min-height: 44px; display: flex; align-items: center; }
    .hamburger-btn {
        display: flex;
        position: fixed;
        top: max(12px, env(safe-area-inset-top));
        left: max(12px, env(safe-area-inset-left));
        z-index: 1002;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: var(--shadow);
    }
    .hamburger-btn:active { opacity: 0.9; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 28px; }
    .stat-label { font-size: 14px; }
    .films-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px 0; }
    .controls { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 20px; }
    .films-controls { flex-direction: column; align-items: stretch; }
    .films-controls .filters { flex-direction: column; display: flex; gap: 12px; min-width: 0; width: 100%; }
    .films-controls .filter-group { min-width: 0; width: 100%; }
    .filters { min-width: 0; }
    .filter-group { min-width: 0; }
    .tab-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .tab-header h2 { font-size: 1.5rem; text-align: left; }
    .list li { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
    .list li .list-actions { justify-content: flex-start; flex-wrap: wrap; }
    /* Модальные окна → bottom sheet на мобильных */
    .modal { align-items: flex-end; padding: 0; }
    .modal-content {
        width: 100%;
        max-width: 100%;
        padding: 20px 20px max(20px, env(safe-area-inset-bottom));
        margin: 0;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: -8px auto 16px;
    }
    @keyframes modalSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .modal.active .modal-content { animation: modalSlideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1) forwards; }
    .close { top: 12px; right: 12px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 50%; }
    .confirm-modal { align-items: flex-end; }
    .confirm-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 20px 20px 0 0;
        padding: 24px 24px max(24px, env(safe-area-inset-bottom));
    }
    .film-modal-content { padding: 16px; width: 100%; max-height: 95vh; }
    .modal-film-title { font-size: 1.5rem; margin-bottom: 16px; }
    .film-details-grid { grid-template-columns: 1fr; gap: 24px; }
    .film-poster-carousel { max-height: 45vh; height: auto; width: 100%; }
    .film-poster-column { max-width: 260px; margin: 0 auto; width: 100%; }
    .btn-publish-film, .btn-edit-modal { padding: 10px 16px; font-size: 14px; }
    .pagination { flex-wrap: wrap; justify-content: center; gap: 8px; }
    .btn-primary, .btn-edit, .btn-danger, .btn-secondary { min-height: 44px; }
    .btn-confirm, .btn-cancel { min-height: 44px; }
    .card-overlay-btn { min-height: 44px; }
    .quiz-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
    .quiz-table { min-width: 480px; font-size: 13px; }
    .quiz-table th, .quiz-table td { padding: 10px 12px; }
    .settings-section { padding: 0 4px; }
    #collections-list { grid-template-columns: 1fr; padding: 0 8px; }
    /* Канбан — горизонтальный скролл без переноса строк */
    .kanban-board { flex-wrap: nowrap; justify-content: flex-start; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
    .kanban-column { flex: 0 0 280px; scroll-snap-align: start; max-height: calc(100vh - 180px); }
    /* ── Формы в модалках: схлопываем в один столбец ── */
    .form-row { grid-template-columns: 1fr !important; gap: 12px !important; }
    /* ── Блок загрузки файла: стек сверху вниз ── */
    .file-actions { flex-direction: column !important; align-items: stretch !important; flex-wrap: nowrap !important; gap: 8px !important; }
    /* ── Кнопки «Кому можно / нельзя»: равная ширина ── */
    #add-audience-yes, #add-audience-no,
    #edit-audience-yes, #edit-audience-no { flex: 1; min-width: 0; }
    /* ── Кнопки редактирования фильма: сохранить → отмена → удалить ── */
    #edit-film-modal .modal-buttons { flex-direction: column-reverse !important; justify-content: flex-start !important; gap: 8px; }
    #edit-film-modal .modal-buttons > div { flex-direction: column-reverse !important; gap: 8px !important; width: 100% !important; }
    #edit-film-modal .modal-buttons button { width: 100%; }
    /* ── Кнопки добавления фильма: растянуть ── */
    #add-film-modal .modal-buttons > button { flex: 1; min-width: 0; }
    /* ── Канбан-модалки: стек кнопок ── */
    .kanban-modal-actions { flex-direction: column-reverse; }
    .kanban-modal-actions > button { width: 100%; }
    /* ── Превью постера в формах: на всю ширину ── */
    #edit-poster-preview-img, #add-poster-preview { max-width: 100% !important; width: auto; }
    /* ── Бейдж статуса на карточке: меньше padding/шрифт ── */
    .card-status-badge { padding: 4px 8px; font-size: 0.75rem; max-width: calc(100% - 2px); }
    .card-overlay { overflow: hidden; }
    .film-card { -webkit-transform: translateZ(0); transform: translateZ(0); }
    /* ── Жанровая сетка: две равные колонки, не меньше ── */
    .genres-grid { grid-template-columns: repeat(2, 1fr); }
    .genres-grid .genre-checkbox { min-width: 0; }
    .genres-grid .genre-checkbox label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .genres-grid input[type="checkbox"] {
        -webkit-appearance: checkbox; appearance: auto;
        accent-color: var(--accent, #007aff);
        flex-shrink: 0;
        width: 16px !important; height: 16px !important; min-height: 16px !important;
        border: unset !important; background: unset !important; border-radius: unset !important;
    }
    /* ── Пользователи: панель массовых действий ── */
    #users-bulk-bar { flex-direction: column !important; align-items: stretch !important; flex-wrap: nowrap !important; }
    #users-bulk-bar > button { width: 100%; }
    #users-bulk-bar > span[style] { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .films-grid { grid-template-columns: 1fr; }
    .main-container { padding: 12px; padding-top: max(72px, calc(env(safe-area-inset-top) + 52px)); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .hamburger-btn { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
}


/* ===== 19a. LOGIN MODAL (вынесено из base.html inline-стилей) ============== */

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-lg);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}
.login-card {
    background: var(--surface);
    padding: 28px 24px;
    border-radius: var(--radius-2xl);
    width: 380px;
    max-width: 100%;
    box-shadow: var(--card-shadow);
    text-align: center;
}
.login-card h2 {
    margin-bottom: 30px;
    font-size: 28px;
}
.login-card .login-input {
    width: 100%;
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 18px;
}
.login-card .login-input--last { margin-bottom: 30px; }
.login-card .login-submit {
    width: 100%;
    padding: var(--space-lg);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
}
.login-card .login-error {
    color: var(--danger);
    margin-top: var(--space-xl);
    display: none;
}


/* ===== 20. UTILITY-CLASSES ================================================== */
/* Маленькие helper'ы, чтобы новые шаблоны не плодили inline-стили.
 * Префикс ``.u-`` зарезервирован под utilities. */

.u-text-secondary { color: var(--text-secondary); }
.u-text-danger { color: var(--danger); }
.u-text-center { text-align: center; }
.u-text-right { text-align: right; }
.u-flex { display: flex; }
.u-flex-col { display: flex; flex-direction: column; }
.u-flex-wrap { flex-wrap: wrap; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-justify-end { justify-content: flex-end; }
.u-gap-xs { gap: var(--space-xs); }
.u-gap-sm { gap: var(--space-sm); }
.u-gap-md { gap: var(--space-md); }
.u-gap-lg { gap: var(--space-lg); }
.u-gap-xl { gap: var(--space-xl); }
.u-mt-sm { margin-top: var(--space-sm); }
.u-mt-md { margin-top: var(--space-md); }
.u-mt-lg { margin-top: var(--space-lg); }
.u-mb-sm { margin-bottom: var(--space-sm); }
.u-mb-md { margin-bottom: var(--space-md); }
.u-mb-lg { margin-bottom: var(--space-lg); }
.u-w-full { width: 100%; }
.u-hidden { display: none !important; }
