        :root {
            --color-primary: #011566;
            --color-primary-hover: #020e4a;
            --color-primary-soft: #e7ebfa;
            --color-accent: #2563eb;
            --color-accent-soft: rgba(37, 99, 235, 0.14);
            --color-accent-ring: rgba(37, 99, 235, 0.22);

            --color-text: #0f172a;
            --color-text-muted: #475569;
            --color-text-faint: #94a3b8;

            --color-border: #e2e8f0;
            --color-border-strong: #cbd5e1;

            --color-surface: #ffffff;
            --color-surface-2: #f8fafc;
            --color-surface-app: #f4f4f4;
            --color-weekend: #eef2f6;

            --color-sidebar-bg: #1c1c1e;
            --color-sidebar-border: #2a2a2c;
            --color-sidebar-text: #f5f5f5;
            --color-sidebar-muted: #9a9a9c;

            --color-success: #16a34a;
            --color-success-soft: #f0fdf4;
            --color-danger: #dc2626;
            --color-danger-soft: #fee2e2;
            --color-warning: #d97706;
            --color-warning-soft: #fffbeb;
            --color-violet: #7c3aed;
            --color-violet-soft: #f5f3ff;
            --color-slate-soft: #f1f5f9;

            --radius-sm: 6px;
            --radius-md: 8px;
            --radius-lg: 10px;
            --radius-xl: 16px;
            --radius-pill: 9999px;

            --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
            --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
            --shadow-lg: 0 20px 60px rgba(2, 14, 74, 0.45);
            --shadow-toast: 0 8px 24px rgba(15, 23, 42, 0.18);

            --skeleton-1: #eef2f6;
            --skeleton-2: #f6f9fc;

            --row-hover: #f4f7ff;
            --row-hover-we: #e7edf6;
            --row-hover-name: #e7ebfa;
            --row-hover-total: #d4ddef;

            --topbar-height: 72px;          /* высота .topbar — используется sticky thead */
            --topbar-height-mobile: 56px;   /* высота .topbar на мобильных */
        }

        /* ── Тёмная тема ───────────────────────────────────────── */
        :root[data-theme="dark"] {
            --color-primary: #4f6ad6;
            --color-primary-hover: #5e7be0;
            --color-primary-soft: #1a2240;
            --color-accent: #60a5fa;
            --color-accent-soft: rgba(96, 165, 250, 0.18);
            --color-accent-ring: rgba(96, 165, 250, 0.32);
            --color-text: #e5e7eb;
            --color-text-muted: #9ca3af;
            --color-text-faint: #6b7280;
            --color-border: #2d333d;
            --color-border-strong: #404856;
            --color-surface: #161a21;
            --color-surface-2: #1d222c;
            --color-surface-app: #0e1117;
            --color-weekend: #1a1f29;
            --color-success: #34d399;
            --color-success-soft: #0c2c20;
            --color-danger: #f87171;
            --color-danger-soft: #3b1419;
            --color-warning: #fbbf24;
            --color-warning-soft: #3a2a08;
            --color-violet: #a78bfa;
            --color-violet-soft: #2a1d4a;
            --color-slate-soft: #1f242e;
            --skeleton-1: #1d222c;
            --skeleton-2: #262c38;
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
            --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
            --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
            --shadow-toast: 0 8px 24px rgba(0, 0, 0, 0.5);

            --row-hover: #1f2530;
            --row-hover-we: #232a36;
            --row-hover-name: #1f263a;
            --row-hover-total: #1d243a;
        }

        /* Auto-detect, если пользователь не выбрал явную тему */
        @media (prefers-color-scheme: dark) {
            :root:not([data-theme="light"]) {
                --color-primary: #4f6ad6;
                --color-primary-hover: #5e7be0;
                --color-primary-soft: #1a2240;
                --color-accent: #60a5fa;
                --color-accent-soft: rgba(96, 165, 250, 0.18);
                --color-accent-ring: rgba(96, 165, 250, 0.32);
                --color-text: #e5e7eb;
                --color-text-muted: #9ca3af;
                --color-text-faint: #6b7280;
                --color-border: #2d333d;
                --color-border-strong: #404856;
                --color-surface: #161a21;
                --color-surface-2: #1d222c;
                --color-surface-app: #0e1117;
                --color-weekend: #1a1f29;
                --color-success: #34d399;
                --color-success-soft: #0c2c20;
                --color-danger: #f87171;
                --color-danger-soft: #3b1419;
                --color-warning: #fbbf24;
                --color-warning-soft: #3a2a08;
                --color-violet: #a78bfa;
                --color-violet-soft: #2a1d4a;
                --color-slate-soft: #1f242e;
                --skeleton-1: #1d222c;
                --skeleton-2: #262c38;
                --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
                --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
                --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
                --shadow-toast: 0 8px 24px rgba(0, 0, 0, 0.5);
                --row-hover: #1f2530;
                --row-hover-we: #232a36;
                --row-hover-name: #1f263a;
                --row-hover-total: #1d243a;
            }
        }

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
            background: var(--color-surface-app);
            color: var(--color-text);
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
        }

        :focus-visible {
            outline: 2px solid var(--color-accent);
            outline-offset: 2px;
            border-radius: inherit;
        }
        input:focus-visible, select:focus-visible { outline: none; }

        /* ── Login ─────────────────────────────────────────────── */
        #login-screen, #force-change-screen {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            height: 100dvh;
            padding: 24px;
            background: #011566;
            background-image:
                radial-gradient(circle at 20% 0%, rgba(255,255,255,0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 100%, rgba(255,255,255,0.06) 0%, transparent 55%),
                linear-gradient(135deg, #011566 0%, #020e4a 100%);
        }
        #force-change-screen { display: none; }
        .login-theme-toggle {
            position: absolute; top: 16px; right: 16px;
            width: 40px; height: 40px; border-radius: 50%;
            background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.22);
            color: #ffffff; cursor: pointer;
            display: inline-flex; align-items: center; justify-content: center;
            transition: background 0.12s, border-color 0.12s;
            z-index: 2;
            -webkit-tap-highlight-color: transparent;  /* убираем квадрат-подсветку при тапе по круглой кнопке */
            -webkit-appearance: none; appearance: none;
        }
        /* Фокус-рамку показываем только при навигации с клавиатуры, не при тапе/клике */
        .login-theme-toggle:focus:not(:focus-visible),
        .theme-toggle:focus:not(:focus-visible) { outline: none; }
        .theme-toggle { -webkit-tap-highlight-color: transparent; }
        .login-theme-toggle:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.36); }
        .login-theme-toggle > .ic { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
        .login-theme-toggle > .ic svg { width: 20px; height: 20px; display: block; }
        /* В light режиме на тёмном фоне логина показываем sun (предлагаем уйти на light? нет, на самом деле логин ВСЕГДА на тёмном фоне).
           Поэтому показываем иконку, которая отражает целевую тему — moon в light, sun в dark. */
        .login-theme-toggle .theme-ic-sun { display: none; }
        :root[data-theme="dark"] .login-theme-toggle .theme-ic-sun { display: inline-flex; }
        :root[data-theme="dark"] .login-theme-toggle .theme-ic-moon { display: none; }
        @media (prefers-color-scheme: dark) {
            :root:not([data-theme="light"]) .login-theme-toggle .theme-ic-sun { display: inline-flex; }
            :root:not([data-theme="light"]) .login-theme-toggle .theme-ic-moon { display: none; }
        }
        .login-card {
            background: var(--color-surface);
            border-radius: var(--radius-xl);
            padding: 36px 40px 32px;
            width: 360px;
            box-shadow: var(--shadow-lg);
            text-align: center;
        }
        .login-logo {
            width: 96px; height: 96px; display: block;
            margin: 0 auto 18px; border-radius: 50%;
            background: white;
            box-shadow: 0 6px 20px rgba(1,21,102,0.18);
        }
        .login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: #ffffff; letter-spacing: -0.01em; }
        .login-card .subtitle { font-size: 13px; color: var(--color-text-muted); margin-bottom: 24px; }
        .login-card .form-group { text-align: left; }
        .login-card .form-group input { width: 100%; box-sizing: border-box; }
        .login-card .pwd-wrap input { width: 100%; box-sizing: border-box; padding-right: 36px; }
        /* .has-clear (декоратор поисковых инпутов) по умолчанию inline-block;
           внутри login-card он схлопывал ширину Логина — форсируем block. */
        .login-card .has-clear { display: block; width: 100%; }
        .login-card .has-clear > input { width: 100%; }

        /* ── Password show/hide toggle ─────────────────────────── */
        .pwd-wrap { position: relative; }
        .pwd-wrap input { padding-right: 38px; }
        .pwd-toggle {
            position: absolute; right: 6px; top: 50%;
            transform: translateY(-50%);
            background: transparent; border: 0; cursor: pointer;
            line-height: 0; padding: 4px 6px;
            color: #64748b;
            display: inline-flex; align-items: center; justify-content: center;
        }
        .pwd-toggle svg { display: block; }
        .pwd-toggle:hover { color: #0f172a; }

        /* ── Layout ────────────────────────────────────────────── */
        #app { display: none; height: 100vh; height: 100dvh; flex-direction: row; }

        .sidebar {
            width: var(--sidebar-w, 280px);
            background: #1c1c1e;
            color: #f5f5f5;
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            border-right: 1px solid #2a2a2c;
            transition: width 0.18s ease;
            position: relative;
        }
        .sidebar-resize-handle {
            position: absolute;
            top: 0; right: -3px; bottom: 0;
            width: 6px;
            cursor: col-resize;
            z-index: 50;
            background: transparent;
        }
        .sidebar-resize-handle:hover, .sidebar-resize-handle.dragging { background: var(--color-accent-soft); }
        .sidebar.collapsed .sidebar-resize-handle { display: none; }
        @media (max-width: 768px) { .sidebar-resize-handle { display: none; } }
        body.is-resizing { cursor: col-resize; user-select: none; }
        body.is-resizing .sidebar { transition: none; }
        .sidebar-header {
            position: relative;
            padding: 22px 14px 18px;
            display: flex; flex-direction: column; align-items: center;
            gap: 12px; text-align: center;
            border-bottom: 1px solid var(--color-sidebar-border);
        }
        .sidebar-header .logo {
            width: 72px; height: 72px;
            object-fit: contain;
        }
        .sidebar-header .titles { min-width: 0; width: 100%; }
        .sidebar-header h2 { font-size: 14px; font-weight: 700; color: var(--color-sidebar-text); line-height: 1.25; letter-spacing: -0.01em; }
        .sidebar-header p { display: none; }
        .sidebar-collapse-btn {
            position: absolute; top: 8px; right: 8px;
            width: 28px; height: 28px; border-radius: 8px;
            display: inline-flex; align-items: center; justify-content: center;
            background: transparent; border: none; cursor: pointer;
            color: var(--color-sidebar-muted); transition: background 0.12s, color 0.12s;
        }
        .sidebar-collapse-btn:hover { background: rgba(255,255,255,0.08); color: #f5f5f5; }
        .sidebar-collapse-btn svg { width: 18px; height: 18px; display: block; transition: transform 0.18s ease; }
        .sidebar-nav { flex: 1; padding: 6px 10px; overflow-y: auto; overflow-x: hidden; }
        .nav-item {
            display: flex; align-items: center; gap: 12px;
            padding: 9px 14px; border-radius: 999px; cursor: pointer;
            font-size: 14px; font-weight: 500; color: #e5e5e7;
            transition: background 0.12s, color 0.12s;
            margin-bottom: 2px; user-select: none;
            line-height: 1.2; white-space: nowrap;
        }
        .nav-item > .ic {
            display: inline-flex; align-items: center; justify-content: center;
            width: 20px; height: 20px; flex-shrink: 0; color: #b8b8ba;
        }
        .nav-item > .ic svg { width: 20px; height: 20px; display: block; }
        .nav-item > span:not(.ic) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
        .nav-item:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
        .nav-item:hover > .ic { color: #ffffff; }
        .nav-item.active { background: var(--color-accent); color: #ffffff; font-weight: 600; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35); }
        .nav-item.active > .ic { color: #ffffff; }

        .nav-group { margin-bottom: 10px; }
        .nav-group:last-child { margin-bottom: 0; }
        .nav-group-label {
            font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
            text-transform: uppercase; color: var(--color-sidebar-muted);
            padding: 10px 16px 6px; user-select: none;
        }
        .sidebar.collapsed .nav-group-label { display: none; }
        .sidebar.collapsed .nav-group { margin-bottom: 4px; padding-top: 4px; border-top: 1px solid var(--color-sidebar-border); }
        .sidebar.collapsed .nav-group:first-child { border-top: none; }
        .sidebar-footer { padding: 10px 12px; border-top: 1px solid #2a2a2c; background: #1c1c1e; display: flex; flex-direction: column; gap: 8px; }
        .user-info { padding: 8px 12px; margin-bottom: 6px; overflow: hidden; }
        .user-info .name { font-size: 13px; font-weight: 600; color: #f5f5f5; line-height: 1.25; overflow: hidden; word-break: break-word; }
        .user-info .role { font-size: 11px; color: #9a9a9c; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .btn-logout, .theme-toggle {
            width: 100%; padding: 8px 14px; background: transparent;
            border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; color: #e5e5e7;
            font-size: 13px; font-weight: 500; cursor: pointer; text-align: left;
            transition: background 0.12s, border-color 0.12s, color 0.12s;
            display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden;
        }
        .btn-logout:hover, .theme-toggle:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.32); color: #ffffff; }
        .btn-logout > .ic, .theme-toggle > .ic { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; }
        .btn-logout > .ic svg, .theme-toggle > .ic svg { width: 18px; height: 18px; display: block; }
        .theme-toggle { margin-bottom: 8px; }
        /* В light режиме показываем moon (предлагает dark) и подпись "Тёмная тема".
           В dark — sun и "Светлая тема". */
        .theme-toggle .theme-ic-sun { display: none; }
        .theme-toggle .theme-toggle-label-alt { display: none; }
        :root[data-theme="dark"] .theme-toggle .theme-ic-sun { display: inline-flex; }
        :root[data-theme="dark"] .theme-toggle .theme-ic-moon { display: none; }
        :root[data-theme="dark"] .theme-toggle .theme-toggle-label { display: none; }
        :root[data-theme="dark"] .theme-toggle .theme-toggle-label-alt { display: inline; }
        @media (prefers-color-scheme: dark) {
            :root:not([data-theme="light"]) .theme-toggle .theme-ic-sun { display: inline-flex; }
            :root:not([data-theme="light"]) .theme-toggle .theme-ic-moon { display: none; }
            :root:not([data-theme="light"]) .theme-toggle .theme-toggle-label { display: none; }
            :root:not([data-theme="light"]) .theme-toggle .theme-toggle-label-alt { display: inline; }
        }
        .sidebar.collapsed .theme-toggle { justify-content: center; padding: 8px 0; gap: 0; }
        .sidebar.collapsed .theme-toggle .theme-toggle-label { display: none; }

        /* Collapsed sidebar (desktop only) */
        .sidebar.collapsed { width: 64px; }
        .sidebar.collapsed .sidebar-header {
            padding: 8px 8px;
            border-bottom: 1px solid var(--color-sidebar-border);
            min-height: 44px;
            justify-content: center;
        }
        .sidebar.collapsed .sidebar-header .logo { display: none; }
        .sidebar.collapsed .sidebar-header .titles { display: none; }
        .sidebar.collapsed .sidebar-collapse-btn { position: static; }
        .sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
        .sidebar.collapsed .sidebar-nav { padding: 6px 8px; }
        .sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; gap: 0; position: relative; }
        .sidebar.collapsed .nav-item > span:not(.ic) { display: none; }
        /* Счётчики (новые сотрудники / командировки) JS показывает inline-стилем —
           перебиваем !important, иначе число вылезает за узкую колонку. */
        .sidebar.collapsed .nav-item .badge-count { display: none !important; }
        .sidebar.collapsed .sidebar-footer { padding: 10px 8px; }
        .sidebar.collapsed .user-info { display: none !important; }  /* !important — перебить inline display:flex на .user-info */
        .sidebar.collapsed .btn-logout { justify-content: center; padding: 8px 0; gap: 0; }
        .sidebar.collapsed .btn-logout > span:not(.ic) { display: none; }

        /* ── Main ──────────────────────────────────────────────── */
        .main { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column;
            -webkit-overflow-scrolling: touch; }
        .topbar {
            position: sticky; top: 0; z-index: 20;
            padding: 16px 24px;
            padding-top: calc(16px + env(safe-area-inset-top));
            background: var(--color-surface);
            transition: transform 0.18s ease, opacity 0.18s ease;
            will-change: transform;
            border-bottom: 1px solid var(--color-border);
            display: flex; align-items: center; justify-content: space-between;
            flex-shrink: 0;
        }
        .topbar.topbar-hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }
        /* Telegram Mini App перекрывает верхушку панелью «Закрыть × ↓ ⋮» —
           добавляем отступ сверху, чтобы гамбургер и заголовок не уходили под чрому. */
        body.is-telegram-webapp .topbar {
            padding-top: calc(56px + env(safe-area-inset-top));
        }
        .topbar h1 { font-size: 18px; font-weight: 700; color: var(--color-text); letter-spacing: -0.01em; }
        .topbar p { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
        .topbar-head { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
        .topbar-title { flex: 1 1 auto; min-width: 0; }
        .content { padding: 24px; flex: 1; }
        .content.view-enter { animation: viewEnter 0.18s ease-out; }
        @keyframes viewEnter {
            from { opacity: 0; transform: translateY(6px); }
            to { opacity: 1; transform: none; }
        }
        @media (prefers-reduced-motion: reduce) {
            .content.view-enter { animation: none; }
        }

        /* ── Cards ─────────────────────────────────────────────── */
        .card { background: var(--color-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
        .card-header {
            padding: 16px 20px; border-bottom: 1px solid var(--color-border);
            display: flex; align-items: center; justify-content: space-between;
        }
        .card-header h3 { font-size: 15px; font-weight: 600; color: var(--color-text); }
        .card-body { padding: 20px; }

        /* ── Form ──────────────────────────────────────────────── */
        input[type=text], input[type=password], input[type=number],
        input[type=date], input[type=time], input[type=tel], input[type=email], select, textarea {
            width: 100%; padding: 9px 12px;
            border: 1px solid var(--color-border); border-radius: var(--radius-md);
            font-size: 14px; color: var(--color-text); background: var(--color-surface);
            outline: none; transition: border-color 0.15s, box-shadow 0.15s;
            box-sizing: border-box;
            line-height: 1.2;
        }
        /* iOS Safari: пустой input[type=date]/[type=time] не получает высоту
           строки → выходит ниже select'ов/текстовых полей и выглядит «тоньше».
           Задаём min-height = высота обычного поля (line-height 1.2em + паддинги
           9+9 + границы 2). box-sizing:border-box уже стоит. Компактные time-инпуты
           в карточках (.mm-tf/.mm-tt, height:32px) исключаем. */
        input[type="date"]:not(.mm-tf):not(.mm-tt),
        input[type="time"]:not(.mm-tf):not(.mm-tt) {
            min-height: calc(1.2em + 20px);
        }
        /* Тёмное оформление ТОЛЬКО для полей времени в модалке «Согласие РВ»
           (#cr-tf/#cr-tt). Компактные time-инпуты в карточках сотрудников
           (.mm-tf/.mm-tt, height:32px) НЕ трогаем — они остаются нативными. */
        #cr-tf, #cr-tt {
            border: 1px solid var(--color-border); border-radius: var(--radius-md);
            font-size: 14px; color: var(--color-text); background: var(--color-surface);
            box-sizing: border-box; padding: 9px 12px; min-height: 40px; width: 100%;
        }
        :root[data-theme="dark"] #cr-tf::-webkit-calendar-picker-indicator,
        :root[data-theme="dark"] #cr-tt::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.6); }
        select {
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 14px;
            padding-right: 32px;
        }
        input:focus, select:focus, textarea:focus {
            border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-ring);
        }
        /* Date-input в навигаторе «Главной» — стрелка как у select выше:
           прячем нативный индикатор, рисуем тот же SVG-chevron с отступом 10px. */
        input[type="date"].home-date-nav-input,
        input[type="time"].home-date-nav-input {
            -webkit-appearance: none; appearance: none;
            position: relative;
            background-color: var(--color-surface);
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 14px;
            padding-right: 32px !important;
        }
        input[type="date"].home-date-nav-input::-webkit-calendar-picker-indicator,
        input[type="time"].home-date-nav-input::-webkit-calendar-picker-indicator {
            opacity: 0;
            position: absolute;
            right: 0; top: 0;
            width: 32px; height: 100%;
            margin: 0; padding: 0;
            cursor: pointer;
        }
        /* iOS Safari: input[type=date] не растягивается на всю flex-ячейку
           (остаётся по контенту → тоньше select'ов). min-width:100% форсирует
           заполнение. Применяем к датам в ячейках-фильтрах. */
        .jfilter-cell input[type="date"], .jfilter-cell input[type="time"] {
            box-sizing: border-box;
            width: 100%;
            /* iOS Safari игнорирует width:100% для date-инпута (остаётся по
               контенту → тоньше). -webkit-fill-available надёжно растягивает;
               !important перебивает инлайн width:100%, на неподдерживающих —
               невалидно и откатывается на инлайн. */
            width: -webkit-fill-available !important;
            min-width: 0;
        }
        input.invalid, select.invalid { border-color: var(--color-danger); }
        input.invalid:focus, select.invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
        .form-group { margin-bottom: 16px; }
        .form-group label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }

        /* ── Buttons ───────────────────────────────────────────── */
        .btn {
            padding: 9px 16px; border-radius: var(--radius-md); font-size: 14px;
            font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
            display: inline-flex; align-items: center; justify-content: center; gap: 6px;
        }
        .btn:active { transform: translateY(1px); }
        .btn-primary { background: var(--color-primary); color: white; }
        .btn-primary:hover { background: var(--color-primary-hover); }
        .btn-secondary { background: var(--color-surface); color: var(--color-text-muted); border-color: var(--color-border); }
        .btn-secondary:hover { background: var(--color-surface-2); border-color: var(--color-border-strong); color: var(--color-text); }
        .btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
        .btn-danger:hover { background: #fecaca; }
        /* Кнопка «Изменить» в табличных списках — янтарная подсветка для заметности. */
        .btn-edit { background: #fef3c7; color: #92400e; border-color: #fcd34d; font-weight: 600; }
        .btn-edit:hover { background: #fde68a; border-color: #f59e0b; color: #78350f; }
        /* Баннер «бригада уже отмечена» — theme-aware фон (раньше был хардкод
           #eef0fa, на тёмной теме светлый bg + светлый текст не читался). */
        .brig-marked-banner { background: var(--color-primary-soft); color: var(--color-text); }
        .btn-sm { padding: 5px 10px; font-size: 12px; }
        .btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
        .btn-icon svg { width: 16px; height: 16px; }
        .row-actions .btn-icon + .btn-icon { margin-left: 6px; }
        /* Документы — ряд действий (Скачать/Сканы/Изменить/Удалить): кнопки
           равной ширины. Обёртка-flex внутри обычного <td>, чтобы ячейка
           оставалась табличной (иначе display:flex на <td> ломает подсветку
           строки при наведении). */
        .doc-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
        .doc-actions .btn { min-width: 96px; justify-content: center; }
        /* Кнопки «+ Создать …» в Документах — одинакового размера и справа. */
        .doc-create { display: flex; justify-content: flex-end; }
        .doc-create .btn { min-width: 240px; max-width: 100%; justify-content: center; }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn svg { width: 16px; height: 16px; }

        /* ── Messages ──────────────────────────────────────────── */
        .error-msg {
            color: var(--color-danger); font-size: 13px; margin-top: 6px;
            padding: 8px 12px; background: var(--color-danger-soft); border-radius: var(--radius-sm);
            border: 1px solid rgba(220, 38, 38, 0.18);
        }

        /* ── Table ─────────────────────────────────────────────── */
        table { width: 100%; border-collapse: collapse; font-size: 14px; }
        th {
            text-align: left; padding: 10px 14px; font-size: 13px;
            font-weight: 600; color: var(--color-text-muted);
            background: var(--color-surface-2); border-bottom: 1px solid var(--color-border);
        }
        td { padding: 12px 14px; border-bottom: 1px solid var(--color-slate-soft); color: var(--color-text); }
        tr:last-child td { border-bottom: none; }
        tr:hover td { background: var(--color-surface-2); }

        /* Sticky thead в списках. Высота topbar динамическая (h1+p+actions
           + safe-area + переносы) — JS пишет в --topbar-real-h. fallback'и
           на старые --topbar-height(-mobile) для случаев без JS. */
        table.list-table thead th {
            position: sticky;
            top: var(--topbar-real-h, var(--topbar-height));
            z-index: 3;
            box-shadow: inset 0 -1px 0 var(--color-border);
            background: var(--color-surface);
            transition: top 0.18s ease;
        }
        /* Когда topbar спрятан (transform translateY(-100%) по скроллу вниз),
           sticky thead перекрывает реально пустую область сверху. Подтягиваем
           thead к 0, чтобы данные не «сползали» под фантомный topbar. */
        body.topbar-is-hidden table.list-table thead th { top: 0; }
        /* Таблица внутри .scroll-x: overflow-x:auto делает контейнер scroll-боксом
           и по обеим осям (спека: visible→auto), из-за чего sticky thead с
           top:var(--topbar-real-h) отсчитывается от .scroll-x и опускается на ~88px,
           накрывая первые строки. Для таких таблиц прижимаем шапку к верху контейнера. */
        .scroll-x table.list-table thead th { top: 0; }
        /* ── Impersonation banner (fixed сверху, отжимает topbar/main) ─
           padding-top и top для .topbar выставляются в renderImpersonationBanner()
           через JS — высота баннера переменная (1-3 строки на mobile). */

        /* ── Кнопка очистки для поисковых полей ────────────────────── */
        .has-clear { position: relative; display: inline-block; vertical-align: middle; max-width: 100%; }
        .has-clear > input { padding-right: 28px !important; }
        .has-clear > .input-clear-btn {
            position: absolute; right: 6px; top: 50%;
            transform: translateY(-50%);
            background: transparent; border: none; cursor: pointer;
            padding: 2px 6px; line-height: 1; font-size: 14px;
            color: var(--color-text-muted); display: none;
            border-radius: 4px;
        }
        .has-clear > .input-clear-btn:hover { background: rgba(0,0,0,0.08); color: var(--color-text); }
        .has-clear.has-value > .input-clear-btn { display: inline-flex; align-items: center; justify-content: center; }

        @media (max-width: 768px) {
            table.list-table thead th { top: var(--topbar-real-h, 88px); }
            /* Журнал за месяц: на мобильном выравниваем фильтры в две колонки —
               label фиксированной ширины справа + контрол растягивается. */
            .jm-frow { width: 100%; }
            .jm-frow > label:first-child {
                min-width: 110px; flex-shrink: 0; text-align: right;
            }
            .jm-frow > select,
            .jm-frow > input[type="text"],
            .jm-frow > input[type="date"] {
                flex: 1; min-width: 0; max-width: 100%;
            }
        }
        th.sort-th { transition: background 0.12s; }
        th.sort-th:hover { background: var(--color-surface); }
        th.sort-th.active { color: var(--color-accent); }
        .sort-arrow { font-size: 11px; margin-left: 4px; }

        /* Bulk-action bar */
        .bulk-bar {
            position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
            background: var(--color-text);
            color: var(--color-surface);
            border-radius: var(--radius-pill);
            padding: 8px 16px;
            display: flex; align-items: center; gap: 12px;
            box-shadow: var(--shadow-md);
            z-index: 150;
            animation: slideUp 0.2s ease;
        }
        .bulk-bar .btn-secondary { background: transparent; color: inherit; border-color: rgba(255,255,255,0.25); }
        .bulk-bar .btn-secondary:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.5); color: inherit; }
        .bulk-count { font-size: 13px; }

        /* Chip-фильтры */
        .filter-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
        .filter-chip {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 4px 4px 4px 10px; border-radius: var(--radius-pill);
            background: var(--color-accent-soft); color: var(--color-accent);
            font-size: 12px; font-weight: 500;
        }
        .filter-chip-label { color: var(--color-text-muted); font-weight: 600; }
        .filter-chip-value { color: var(--color-text); }
        .filter-chip-x {
            background: transparent; border: none; cursor: pointer;
            color: var(--color-text-muted); font-size: 16px; line-height: 1;
            width: 22px; height: 22px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
        }
        .filter-chip-x:hover { background: rgba(220, 38, 38, 0.15); color: var(--color-danger); }

        /* ── Search results ────────────────────────────────────── */
        .search-results {
            border: 1px solid var(--color-border); border-top: none;
            border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--color-surface);
            max-height: 250px; overflow-y: auto;
            position: absolute; width: 100%; z-index: 10;
            box-shadow: var(--shadow-md);
        }
        .search-result-item {
            padding: 10px 14px; display: flex; align-items: center;
            justify-content: space-between; cursor: pointer;
            border-bottom: 1px solid var(--color-slate-soft); transition: background 0.1s;
        }
        .search-result-item:last-child { border-bottom: none; }
        .search-result-item:hover { background: var(--color-surface-2); }
        .search-result-item .emp-name { font-size: 14px; font-weight: 500; color: var(--color-text); }
        .search-result-item .emp-meta { font-size: 12px; color: var(--color-text-muted); }

        /* ── Tabs ──────────────────────────────────────────────── */
        /* вкладки — в одну строку с горизонтальной прокруткой (свайп), без переноса */
        .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; align-items: flex-end; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
        .tabs::-webkit-scrollbar { display: none; }
        .tab-btn {
            background: transparent; border: none; cursor: pointer;
            flex: 0 0 auto;
            padding: 10px 18px; font-size: 14px; font-weight: 500; color: var(--color-text-muted);
            border-bottom: 2px solid transparent; margin-bottom: -1px;
            transition: color 0.15s, border-color 0.15s;
            border-radius: 6px 6px 0 0;
            white-space: nowrap;
            display: inline-flex; align-items: center;
            min-height: 42px; line-height: 1.2;
        }
        .tab-btn .badge { min-height: 20px; padding: 0 8px; font-size: 11px; }
        .tab-btn:hover { color: var(--color-text); }
        .tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
        .tab-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
        .tab-pane { display: none; }
        .tab-pane.active { display: block; }

        .nav-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
        .btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

        /* ── Timesheet grid ────────────────────────────────────── */
        :root { --ts-day-min: 38px; }
        .timesheet-wrapper { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); }
        .ts-table { border-collapse: separate; border-spacing: 0; font-size: 12px; }
        .ts-table th {
            padding: 6px 4px; text-align: center; font-size: 12px;
            background: var(--color-surface-2); border-bottom: 1px solid var(--color-border);
            border-right: 1px solid var(--color-border);
            min-width: var(--ts-day-min); white-space: nowrap; font-weight: 600; color: var(--color-text-muted);
        }
        .ts-table th.col-name { min-width: 200px; text-align: left; padding-left: 14px; }
        .ts-table th.col-total { min-width: 56px; background: var(--color-primary-soft); color: var(--color-primary); }
        .ts-table td { padding: 0; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); text-align: center; background: var(--color-surface); }
        .ts-table td.col-name {
            padding: 9px 14px; text-align: left; font-size: 13px;
            white-space: nowrap; background: var(--color-surface-2); font-weight: 500;
        }
        .ts-table td.col-total { padding: 6px 4px; font-weight: 600; font-size: 12px; background: var(--color-primary-soft); color: var(--color-primary-hover); }

        /* Sticky pinned columns */
        .ts-table th.col-name, .ts-table td.col-name { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--color-border); }
        .ts-table thead th.col-name { z-index: 4; }
        .ts-table th.col-total, .ts-table td.col-total { position: sticky; z-index: 2; box-shadow: -1px 0 0 var(--color-border); }
        .ts-table thead th.col-total { z-index: 4; }
        .ts-table th.col-total:nth-last-child(2), .ts-table td.col-total:nth-last-child(2) { right: 56px; }
        .ts-table th.col-total:last-child, .ts-table td.col-total:last-child { right: 0; }

        .ts-table th.we-day, .ts-table td.we-day { background: var(--color-weekend); }
        .ts-table td.sched-off { background: #eef2f6; color: var(--color-text-faint); }
        .ts-table td.sched-missed { background: var(--color-danger-soft); color: #b91c1c; }
        .ts-table td.status-rv { background: #dcfce7; color: #15803d; font-weight: 600; }
        .ts-table td.status-do { background: #dbeafe; color: #1e40af; font-weight: 600; }

        /* Разделители недель: воскресенье — толстая правая граница */
        .ts-table th.week-end, .ts-table td.week-end { border-right: 2px solid var(--color-border-strong); }

        /* Подсветка «сегодня» в табеле */
        .ts-table th.today { background: var(--color-accent-soft); color: var(--color-accent); border-bottom: 2px solid var(--color-accent); }
        .ts-table td.today { box-shadow: inset 0 0 0 2px var(--color-accent); }
        .dirty-dot {
            display: inline-block; width: 8px; height: 8px; border-radius: 50%;
            background: #fbbf24; margin-right: 6px;
            box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
            animation: pulse 1.4s ease-in-out infinite;
        }
        @keyframes pulse {
            0%, 100% { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35); }
            50% { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0); }
        }
        .ts-zoom { display: inline-flex; gap: 2px; align-items: center; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 2px; }
        .ts-zoom .btn { border: none; background: transparent; padding: 2px 8px; font-size: 14px; min-width: 28px; }
        .ts-zoom .btn:hover { background: var(--color-surface-2); }
        /* «Сегодня» в мини-календаре сотрудника */
        .ec-cell.ec-today { box-shadow: 0 0 0 2px var(--color-accent); position: relative; z-index: 1; }

        /* Hover подсветка всей строки */
        .ts-table tbody tr:hover td { background: var(--row-hover); }
        .ts-table tbody tr:hover td.we-day { background: var(--row-hover-we); }
        .ts-table tbody tr:hover td.col-name { background: var(--row-hover-name); }
        .ts-table tbody tr:hover td.col-total { background: var(--row-hover-total); }
        .sched-off-mark { color: #94a3b8; font-size: 10px; }
        .sched-legend-box { display: inline-block; width: 14px; height: 14px; vertical-align: middle; border: 1px solid #cbd5e1; margin-right: 4px; }
        .sched-legend-box.sched-off { background: #e9ecef; }
        .sched-legend-box.sched-missed { background: #fee2e2; }
        .sched-legend-box.we-day { background: #f0f4f8; }
        .sched-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 11px; color: #64748b; text-align: center; margin-bottom: 4px; }
        .sched-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
        .sched-cell { border: 1px solid #e2e8f0; border-radius: 6px; padding: 6px 4px; text-align: center; font-size: 12px; min-height: 50px; }
        .sched-cell.sched-empty { border: none; }
        .sched-cell-work { background: var(--color-success-soft); border-color: #a7f3d0; }
        .sched-cell-off { background: var(--color-slate-soft); color: var(--color-text-faint); }
        .sched-cell-unknown { background: var(--color-surface); }
        .sched-day-num { font-weight: 600; font-size: 13px; }
        .sched-day-h { font-size: 11px; margin-top: 2px; }

        .cell-input {
            width: 100%; height: 34px; border: none; outline: none;
            text-align: center; font-size: 13px; font-family: inherit;
            background: transparent; cursor: cell; padding: 0 2px;
            color: var(--color-text);
        }
        .cell-input:focus { background: var(--color-accent-soft); box-shadow: inset 0 0 0 2px var(--color-accent); }
        .cell-input.cv { color: var(--color-text-faint); }
        .cell-input.co { color: var(--color-warning); background: var(--color-warning-soft); }
        .cell-input.cb { color: var(--color-danger); background: var(--color-danger-soft); }
        .cell-input.cn { color: var(--color-violet); background: var(--color-violet-soft); }
        .cell-input.ch { color: var(--color-primary); font-weight: 600; }

        /* ── Badge ─────────────────────────────────────────────── */
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 0 10px;
            min-height: 22px;
            border-radius: var(--radius-pill);
            font-size: 12px; font-weight: 600;
            letter-spacing: 0.01em;
            line-height: 1;
            white-space: nowrap;
        }
        .badge-blue { background: #dde4f6; color: var(--color-primary); }
        .badge-green { background: var(--color-success-soft); color: var(--color-success); border: 1px solid rgba(22, 163, 74, 0.18); }
        .badge-rv { background: #dcfce7; color: #15803d; border: 1px solid #86efac; font-weight: 600; }
        .badge-do { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; font-weight: 600; }
        .badge-yellow { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
        .badge-red { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
        .badge-gray { background: var(--color-slate-soft); color: var(--color-text-muted); border: 1px solid var(--color-border); }
        .badge-count {
            min-width: 72px;
            justify-content: center;
            font-variant-numeric: tabular-nums;
        }

        /* ── Utils ─────────────────────────────────────────────── */
        .flex { display: flex; }
        .gap-2 { gap: 8px; }
        .gap-3 { gap: 12px; }
        .items-center { align-items: center; }
        .justify-between { justify-content: space-between; }
        .mt-4 { margin-top: 16px; }
        .mb-4 { margin-bottom: 16px; }
        .text-sm { font-size: 13px; }
        .text-gray { color: #64748b; }
        .hidden { display: none !important; }

        .spinner {
            display: inline-block; width: 14px; height: 14px;
            border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
            border-radius: 50%; animation: spin 0.6s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* ── Контекстное меню ─────────────────────────────────── */
        .ctx-menu {
            position: fixed; z-index: 200;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-md);
            min-width: 200px;
            padding: 4px;
            font-size: 13px;
        }
        .ctx-menu button {
            display: block; width: 100%;
            text-align: left;
            padding: 8px 12px;
            background: transparent; border: none;
            border-radius: var(--radius-sm);
            color: var(--color-text);
            cursor: pointer;
        }
        .ctx-menu button:hover { background: var(--color-surface-2); }
        .ctx-menu hr { border: none; border-top: 1px solid var(--color-border); margin: 4px 0; }
        .ctx-menu .ctx-meta { padding: 6px 12px; font-size: 11px; color: var(--color-text-muted); }

        /* ── Command palette (Cmd+K) ──────────────────────────── */
        .cmdk-overlay {
            position: fixed; inset: 0;
            background: rgba(15, 23, 42, 0.55);
            backdrop-filter: blur(3px);
            display: flex; align-items: flex-start; justify-content: center;
            padding-top: 12vh; z-index: 200;
            animation: fadeIn 0.15s ease;
        }
        .cmdk {
            width: 600px; max-width: calc(100vw - 32px);
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
            overflow: hidden;
        }
        .cmdk-input {
            width: 100%; padding: 16px 20px;
            border: none; border-bottom: 1px solid var(--color-border) !important;
            font-size: 16px; color: var(--color-text); background: var(--color-surface);
            outline: none; border-radius: 0;
        }
        .cmdk-input:focus { border-color: var(--color-border) !important; box-shadow: none !important; }
        .cmdk-results { max-height: 60vh; overflow-y: auto; padding: 6px 0; }
        .cmdk-section { padding: 10px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); font-weight: 700; }
        .cmdk-item {
            padding: 10px 20px; display: flex; align-items: center; justify-content: space-between;
            cursor: pointer; gap: 12px; user-select: none;
        }
        .cmdk-item:hover, .cmdk-item.selected { background: var(--color-surface-2); }
        .cmdk-item.selected { box-shadow: inset 3px 0 0 var(--color-accent); }
        .cmdk-item-label { font-size: 14px; color: var(--color-text); font-weight: 500; }
        .cmdk-item-meta { font-size: 12px; color: var(--color-text-muted); }
        .cmdk-empty { padding: 24px 20px; text-align: center; color: var(--color-text-muted); font-size: 13px; }
        .cmdk-hint {
            padding: 8px 20px; border-top: 1px solid var(--color-border);
            background: var(--color-surface-2);
            font-size: 11px; color: var(--color-text-muted);
            display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
        }
        .cmdk-hint kbd { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 11px; }

        /* Highlight совпадений поиска */
        mark.hl { background: rgba(250, 204, 21, 0.45); color: inherit; padding: 0 1px; border-radius: 2px; }
        :root[data-theme="dark"] mark.hl { background: rgba(250, 204, 21, 0.3); color: #fde68a; }

        /* ── Charts ────────────────────────────────────────────── */
        .chart-legend { display: inline-flex; gap: 14px; align-items: center; }
        .chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-muted); font-weight: 500; }
        .chart-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
        /* Легенда круговой диаграммы: подпись слева, число с процентом —
           по правому краю (выравнены в колонку). */
        /* контейнер: элементы тянем на всю ширину (перебиваем inline align-items:flex-start),
           иначе flex:1 у подписи не выталкивает число к правому краю. */
        .chart-legend.pie-legend { align-items: stretch !important; }
        .pie-legend .chart-legend-item { display: flex; width: 100%; align-items: flex-start; gap: 8px; line-height: 1.5; }
        /* квадраты одинакового размера, выровнены по левому краю и по верхней строке подписи */
        .pie-legend .chart-legend-item .chart-swatch { flex: 0 0 12px; width: 12px; height: 12px; margin-top: 4px; }
        .pie-legend .cli-label { flex: 1 1 auto; min-width: 0; }
        .pie-legend .cli-val { flex: 0 0 auto; margin-left: auto; padding-left: 12px; white-space: nowrap; text-align: right; }
        .bar-chart .bar-g rect { transition: opacity 0.12s; }
        .bar-chart .bar-g:hover rect { opacity: 0.75; }
        .chart-wrap { padding: 4px 0; }

        /* ── Timeline истории отметок ─────────────────────────── */
        .emp-timeline { padding: 14px 20px; }
        .tl-item { display: grid; grid-template-columns: 70px 16px 1fr; gap: 12px; align-items: stretch; min-height: 60px; }
        .tl-item:last-child .tl-line::after { display: none; }
        .tl-date { text-align: right; padding-top: 2px; }
        .tl-date-d { font-size: 13px; font-weight: 600; color: var(--color-text); }
        .tl-date-t { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
        .tl-line { position: relative; display: flex; justify-content: center; }
        .tl-line::after { content: ""; position: absolute; left: 50%; top: 18px; bottom: -8px; width: 2px; background: var(--color-border); transform: translateX(-50%); }
        .tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--color-text-faint); border: 2px solid var(--color-surface); box-shadow: 0 0 0 1px var(--color-border); flex-shrink: 0; margin-top: 4px; position: relative; z-index: 1; }
        .tl-dot.tl-dot-work { background: var(--color-accent); }
        .tl-dot.tl-dot-off { background: var(--color-text-muted); }
        .tl-dot.tl-dot-vac { background: var(--color-warning); }
        .tl-dot.tl-dot-sick { background: var(--color-danger); }
        .tl-dot.tl-dot-nn { background: var(--color-violet); }
        .tl-body { padding: 2px 0 16px; }
        .tl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

        /* ── Мини-график отметок в карточке сотрудника ──────────── */
        .mc-wrap { padding: 14px 20px 6px; border-bottom: 1px solid var(--color-slate-soft); }
        .mc-row { display: flex; gap: 2px; flex-wrap: wrap; }
        .mc-cell {
            width: 18px; height: 26px; border-radius: 3px;
            display: flex; align-items: center; justify-content: center;
            font-size: 9px; font-weight: 700; color: #fff;
            cursor: default;
        }
        .mc-cell.mc-empty { background: var(--color-slate-soft); color: var(--color-text-faint); }
        .mc-cell.mc-work  { background: var(--color-accent); }
        .mc-cell.mc-ot    { background: var(--color-info, #2563eb); }
        .mc-cell.mc-off   { background: var(--color-text-muted); }
        .mc-cell.mc-vac   { background: var(--color-warning); }
        .mc-cell.mc-sick  { background: var(--color-danger); }
        .mc-cell.mc-nn    { background: var(--color-violet); }
        .mc-cell.mc-pv    { background: #eab308; }
        .mc-cell.mc-other { background: var(--color-text-faint); }
        .mc-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--color-text-muted); }
        .mc-legend > span { display: inline-flex; align-items: center; gap: 5px; }
        .mc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
        .mc-title { font-size: 12px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }

        /* Селекты и поиск в раскрытой бригаде — одного размера */
        .card-body table.list-table select,
        .card-body table.list-table input[type=text].off-brig-obj {
            font-size: 13px;
            padding: 7px 10px;
            height: 36px;
            line-height: 1.2;
            box-sizing: border-box;
            width: 100%;
        }
        .card-body table.list-table select { padding-right: 32px; }
        .card-body table.list-table .off-obj-wrap { width: 100%; min-width: 200px; }
        .card-body table.list-table td[data-label="Объект"],
        .card-body table.list-table td[data-label="Отметка"],
        .card-body table.list-table td[data-label="Статус"] { min-width: 200px; }

        /* Специальности в карточке сотрудника — вертикальный список */
        .spec-list { list-style: none; padding: 0; margin: 0; }
        .spec-item {
            display: flex; align-items: center; justify-content: space-between;
            padding: 10px 12px;
            border-bottom: 1px solid var(--color-slate-soft);
            gap: 10px;
        }
        .spec-item:last-child { border-bottom: none; }
        .spec-name { font-size: 14px; font-weight: 500; color: var(--color-text); }
        .spec-item-x {
            background: transparent; border: none; cursor: pointer;
            color: var(--color-text-muted); font-size: 18px; line-height: 1;
            width: 28px; height: 28px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
            flex-shrink: 0;
        }
        .spec-item-x:hover { background: var(--color-danger-soft); color: var(--color-danger); }

        /* Плавающий footer бригадира */
        .brigade-footer {
            position: sticky; bottom: env(safe-area-inset-bottom, 0);
            padding: 14px 16px;
            margin-top: 16px;
            display: flex; flex-direction: column; gap: 12px;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.12);
            z-index: 20;
        }
        .brigade-footer .brig-footer-top {
            display: flex; align-items: center; justify-content: space-between; gap: 12px;
        }
        .brigade-footer .brig-submit-btn {
            display: block; margin: 0 auto;
            min-width: 220px;
            justify-content: center;
        }

        /* Блок «Применить ко всем» — те же размеры что и в строках */
        .apply-all-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
        .apply-all-row .off-obj-wrap.apply-all-obj { flex: 1 1 220px; min-width: 0; }
        .apply-all-row .off-obj-wrap.apply-all-obj input[type=text] {
            width: 100%; height: 36px; font-size: 13px; padding: 7px 10px; line-height: 1.2; box-sizing: border-box;
        }
        .apply-all-row select.apply-all-st {
            flex: 0 0 160px; height: 36px; font-size: 13px; padding: 7px 32px 7px 10px; line-height: 1.2; box-sizing: border-box;
        }
        .apply-all-row .apply-all-btn { height: 36px; padding: 0 16px; }
        @media (max-width: 768px) {
            .apply-all-row .off-obj-wrap.apply-all-obj { flex: 1 1 100%; }
            .apply-all-row .off-obj-wrap.apply-all-obj input[type=text],
            .apply-all-row select.apply-all-st {
                height: 44px !important; font-size: 16px !important; padding: 8px 12px !important;
                width: 100% !important;
            }
            .apply-all-row select.apply-all-st { padding-right: 36px !important; flex: 1 1 100% !important; }
            .apply-all-row .apply-all-btn { height: 44px; flex: 1 1 100%; }
        }
        @media (max-width: 768px) {
            /* На мобиле iOS зумит при <16px — оставляем 16 */
            .card-body table.list-table select,
            .card-body table.list-table input[type=text].off-brig-obj,
            .card-body table.list-table input[type=text].brig-obj,
            .card-body table.list-table select.brig-st {
                font-size: 16px !important;
                padding: 8px 12px !important;
                height: 44px !important;
                width: 100% !important;
                min-width: 0 !important;
            }
            .card-body table.list-table select { padding-right: 36px !important; }
            /* Ячейки формы (объект/отметка/статус) — растягиваем на всю ширину карточки */
            .list-table td[data-label="Объект"],
            .list-table td[data-label="Отметка"],
            .list-table td[data-label="Статус"] {
                display: block !important;
                width: 100% !important;
                min-width: 0 !important;
                padding: 0 !important;
                align-self: stretch !important;
                flex: 0 0 auto !important;
            }
            .list-table td[data-label="Объект"] .off-obj-wrap,
            .list-table td[data-label="Объект"] > div {
                display: block !important;
                width: 100% !important;
                min-width: 0 !important;
                flex: 1 1 auto !important;
            }
            .list-table td[data-label="Объект"] input,
            .list-table td[data-label="Объект"] .off-obj-wrap input,
            .list-table td[data-label="Отметка"] select,
            .list-table td[data-label="Статус"] select {
                display: block !important;
                width: 100% !important;
                min-width: 0 !important;
                box-sizing: border-box !important;
            }
        }

        /* ── Сотрудник внутри раскрытой бригады ────────────────── */
        .brig-emp { display: flex; flex-direction: column; gap: 8px; min-width: 0; width: 100%; }
        .brig-emp-fio {
            font-size: 15px; font-weight: 700; color: var(--color-text);
            letter-spacing: -0.01em;
            word-break: break-word; overflow-wrap: anywhere;
            line-height: 1.25;
        }
        .brig-emp-fio .badge { vertical-align: middle; margin-left: 4px; }
        .brig-emp-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; justify-content: space-between; }
        .plan-tag {
            display: inline-block; padding: 2px 8px;
            border-radius: var(--radius-pill);
            font-size: 11px; font-weight: 600;
        }
        .plan-tag.plan-work { background: var(--color-success-soft); color: var(--color-success); border: 1px solid rgba(22,163,74,0.25); }
        .plan-tag.plan-off { background: var(--color-danger-soft); color: var(--color-danger); border: 1px solid rgba(220,38,38,0.25); }

        /* ── Карточка бригадира в Моя бригада (office) ────────── */
        .brig-card-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
        .brig-card-toggle { flex: 0 0 22px; font-size: 18px; line-height: 1; color: var(--color-text-muted); text-align: center; }
        .brig-card-name { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
        .brig-card-name h3 {
            margin: 0; font-size: 15px; font-weight: 600;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
            max-width: 100%;
        }
        /* Кол-во человек — отдельная выровненная колонка фикс. ширины. */
        .brig-card-count { flex: 0 0 84px; justify-content: center; }
        .brig-card-badges { display: flex; align-items: center; gap: 6px; flex: 0 0 300px; flex-wrap: wrap; justify-content: flex-end; }
        @media (max-width: 768px) {
            /* На узких — снимаем фикс-ширины, бейджи переносятся. */
            .brig-card-count { flex: 0 0 auto; }
            .brig-card-badges { flex: 1 1 auto; margin-left: auto; }
        }
        @media (max-width: 480px) {
            .brig-card-name h3 { font-size: 14px; white-space: normal; }
        }

        /* ── Employee calendar cards ──────────────────────────── */
        .emp-cal-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 14px;
        }
        .emp-cal-card {
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 14px;
            box-shadow: var(--shadow-sm);
            display: flex; flex-direction: column; gap: 10px;
            /* Не отрисовываем карточки за пределами вьюпорта — убирает лаги
               скролла при сотнях календарей. intrinsic-size резервирует место,
               чтобы скроллбар не прыгал. */
            content-visibility: auto;
            contain-intrinsic-size: auto 300px;
        }
        .emp-cal-head {
            display: flex; align-items: center; gap: 10px;
            min-height: 56px;  /* резерв на 2-строчное ФИО, чтобы карточки выравнивались */
        }
        .emp-cal-fio {
            font-weight: 600; font-size: 14px; color: var(--color-text);
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .ec-weekdays {
            display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
            font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
            color: var(--color-text-muted); text-align: center; font-weight: 600;
        }
        .ec-weekdays span.ec-we { color: var(--color-text-faint); }
        .ec-grid {
            display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
        }
        .ec-cell {
            aspect-ratio: 1 / 1;
            border: 1px solid var(--color-border);
            border-radius: 5px;
            background: var(--color-surface);
            display: flex; flex-direction: column;
            align-items: center; justify-content: center;
            position: relative;
            font-size: 10px;
            color: var(--color-text);
            user-select: none;
            overflow: hidden;
        }
        .ec-cell .ec-d { font-size: 10px; color: var(--color-text-muted); position: absolute; top: 2px; left: 4px; line-height: 1; }
        .ec-cell .ec-l { font-size: 12px; font-weight: 700; margin-top: 6px; }
        .ec-cell.ec-empty { background: transparent; border-color: transparent; }
        .ec-cell.ec-we { background: var(--color-weekend); }
        .ec-cell.ec-cell-work { background: rgba(22, 163, 74, 0.15); border-color: rgba(22, 163, 74, 0.45); color: #15803d; }
        .ec-cell.ec-cell-off { background: var(--color-slate-soft); color: var(--color-text-muted); }
        .ec-cell.ec-cell-off-plan { background: var(--color-slate-soft); color: var(--color-text-faint); }
        .ec-cell.ec-cell-vac { background: var(--color-warning-soft); border-color: var(--color-warning); color: var(--color-warning); }
        .ec-cell.ec-cell-sick { background: var(--color-danger-soft); border-color: var(--color-danger); color: var(--color-danger); }
        .ec-cell.ec-cell-nn { background: #dc2626; border-color: #991b1b; color: #fff; font-weight: 700; }
        .ec-cell.ec-cell-n { background: rgba(22, 163, 74, 0.25); border-color: #16a34a; color: #15803d; font-weight: 700; }
        .ec-cell.ec-cell-rv { background: rgba(22, 163, 74, 0.20); border-color: #16a34a; color: #15803d; font-weight: 600; }
        .ec-cell.ec-cell-do { background: #dbeafe; border-color: #93c5fd; color: #1e40af; font-weight: 600; }
        .ec-cell.ec-cell-other { background: var(--color-surface-2); border-color: var(--color-border-strong); }
        .ec-cell.ec-cell-miss { background: rgba(220, 38, 38, 0.08); border-style: dashed; border-color: rgba(220, 38, 38, 0.4); }

        .emp-cal-stats { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 4px; border-top: 1px dashed var(--color-border); }
        .ec-stat {
            font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill);
            background: var(--color-surface-2); color: var(--color-text-muted);
            font-weight: 600;
        }
        .ec-stat-work { background: rgba(22, 163, 74, 0.15); color: #15803d; }
        .ec-stat-off { background: var(--color-slate-soft); }
        .ec-stat-vac { background: var(--color-warning-soft); color: var(--color-warning); }
        .ec-stat-sick { background: var(--color-danger-soft); color: var(--color-danger); }
        .ec-stat-nn { background: #dc2626; color: #fff; }
        .ec-stat-n { background: rgba(22, 163, 74, 0.25); color: #15803d; }

        /* ── Avatar ────────────────────────────────────────────── */
        .avatar {
            display: inline-flex; align-items: center; justify-content: center;
            background: var(--color-surface-2);
            color: var(--color-text-muted);
            border-radius: 50%;
            font-weight: 600;
            font-size: 12px;
            flex-shrink: 0;
            overflow: hidden;
            border: 1px solid var(--color-border);
            user-select: none;
            background-size: cover;
            background-position: center;
        }
        .avatar.sm { width: 28px; height: 28px; font-size: 11px; }
        .avatar.md { width: 36px; height: 36px; font-size: 12px; }
        .avatar.lg { width: 56px; height: 56px; font-size: 16px; }
        .avatar.loaded { color: transparent; }

        /* ── Skeleton loading ─────────────────────────────────── */
        .skeleton {
            display: block;
            background: linear-gradient(90deg, var(--skeleton-1) 0%, var(--skeleton-2) 50%, var(--skeleton-1) 100%);
            background-size: 200% 100%;
            animation: skeleton-shimmer 1.3s ease-in-out infinite;
            border-radius: var(--radius-sm);
        }
        .skeleton-card {
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 18px 20px;
            box-shadow: var(--shadow-sm);
        }
        .skeleton-row { height: 14px; margin-bottom: 12px; }
        .skeleton-row:last-child { margin-bottom: 0; }
        .skeleton-row.w-30 { width: 30%; }
        .skeleton-row.w-50 { width: 50%; }
        .skeleton-row.w-70 { width: 70%; }
        .skeleton-row.lg { height: 18px; }
        @keyframes skeleton-shimmer {
            0% { background-position: 100% 0; }
            100% { background-position: -100% 0; }
        }

        .empty-state { padding: 40px 20px; text-align: center; color: var(--color-text-faint); }
        .empty-state .icon { font-size: 36px; margin-bottom: 14px; display: inline-flex; align-items: center; justify-content: center; }
        .empty-state .icon svg { width: 44px; height: 44px; color: var(--color-border-strong); }
        .empty-state p { font-size: 14px; }

        .toast {
            position: fixed; bottom: 24px; right: 24px;
            padding: 12px 18px; border-radius: var(--radius-lg); font-size: 14px;
            font-weight: 500; z-index: 1000;
            box-shadow: var(--shadow-toast);
            animation: slideUp 0.2s ease;
            display: inline-flex; align-items: center; gap: 8px;
        }
        .toast-success { background: var(--color-success); color: white; }
        .toast-error { background: var(--color-danger); color: white; }
        @keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

        .legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
        .legend span { font-size: 12px; color: var(--color-text-muted); }

        /* Цветная закреплённая легенда табеля */
        .ts-legend {
            position: sticky; bottom: 12px;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 8px 14px;
            margin-top: 14px;
            display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
            box-shadow: var(--shadow-md);
            z-index: 5;
        }
        .ts-legend-title { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-text-muted); padding-right: 4px; }
        .ts-legend-chip {
            display: inline-flex; align-items: center; gap: 6px;
            font-size: 12px; color: var(--color-text);
            padding: 3px 10px 3px 6px; border-radius: var(--radius-pill);
            background: var(--color-surface-2);
        }
        .ts-legend-chip .swatch {
            width: 14px; height: 14px; border-radius: 4px;
            border: 1px solid var(--color-border);
            display: inline-block;
        }

        /* ── Modal ─────────────────────────────────────────────── */
        .modal-overlay {
            position: fixed; inset: 0; background: rgba(15,23,42,0.5);
            display: flex; align-items: center; justify-content: center;
            z-index: 100; animation: fadeIn 0.15s ease;
            backdrop-filter: blur(2px);
        }
        .modal {
            background: var(--color-surface); border-radius: 12px; width: 480px;
            max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px);
            overflow: auto; box-shadow: 0 20px 60px rgba(2, 14, 74, 0.3);
        }
        .modal-header { padding: 18px 20px; border-bottom: 1px solid var(--color-border);
            display: flex; align-items: center; justify-content: space-between; }
        .modal-header h3 { font-size: 16px; font-weight: 700; color: var(--color-text); }
        .modal-close { background: transparent; border: none; cursor: pointer;
            font-size: 22px; color: var(--color-text-muted); line-height: 1; padding: 4px 8px; border-radius: var(--radius-sm); transition: background 0.12s, color 0.12s; }
        .modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }
        .modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
        .modal-footer { padding: 14px 20px; border-top: 1px solid var(--color-border);
            display: flex; gap: 8px; justify-content: flex-end; }
        .modal label { font-size: 13px; color: var(--color-text-muted); font-weight: 500; display: block; margin-bottom: 6px; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        .emp-pick { display: flex; align-items: center; justify-content: space-between;
            padding: 10px 12px; background: var(--color-primary-soft); border: 1px solid #cdd2e4;
            border-radius: var(--radius-md); gap: 10px; }
        .emp-pick .emp-name { font-weight: 500; font-size: 14px; color: var(--color-text); }
        .emp-pick .emp-meta { font-size: 12px; color: var(--color-text-muted); }

        /* ── Mobile menu toggle ───────────────────────────────── */
        .menu-toggle {
            display: none; background: transparent; border: none; cursor: pointer;
            padding: 6px 10px; color: var(--color-text); line-height: 1;
            border-radius: var(--radius-sm);
        }
        .menu-toggle:hover { background: var(--color-surface-2); }
        .sidebar-backdrop {
            display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5);
            z-index: 90; animation: fadeIn 0.15s ease;
        }

        /* ── Responsive ───────────────────────────────────────── */
        @media (max-width: 768px) {
            /* На мобиле скролл переезжает на body — это даёт нативный pull-to-refresh
               и схлопывание адресной строки Safari */
            html, body { height: auto; overflow: visible; overflow-x: hidden; }
            body { min-height: 100dvh; }
            /* iOS Safari делает auto-zoom при фокусе на input если font-size < 16px */
            input[type=text], input[type=password], input[type=number],
            input[type=date], input[type=email], input[type=tel],
            select, textarea, .cell-input { font-size: 16px; }
            #app { flex-direction: column; height: auto; min-height: 100dvh; }
            .main { flex: 1 1 auto; min-height: 0; overflow: visible; }

            .sidebar {
                position: fixed; top: 0; left: 0; bottom: 0;
                width: 240px; z-index: 100;
                padding-top: env(safe-area-inset-top);
                padding-bottom: env(safe-area-inset-bottom);
                transform: translateX(-100%);
                transition: transform 0.2s ease;
            }
            .sidebar.open { transform: translateX(0); }
            .sidebar-backdrop.open { display: block; }
            .menu-toggle { display: inline-flex; align-items: center; }
            /* На мобильном collapse-кнопка не нужна — есть гамбургер и backdrop */
            .sidebar.collapsed { width: 240px; }
            .sidebar-collapse-btn { display: none; }
            .sidebar.collapsed .sidebar-header { padding: 14px 14px; justify-content: flex-start; }
            .sidebar.collapsed .sidebar-header .logo,
            .sidebar.collapsed .sidebar-header .titles { display: revert; }
            .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 9px 14px; gap: 12px; }
            .sidebar.collapsed .nav-item > span:not(.ic),
            .sidebar.collapsed .btn-logout > span:not(.ic),
            .sidebar.collapsed .user-info { display: revert; }
            .sidebar.collapsed .btn-logout { justify-content: flex-start; padding: 8px 14px; gap: 10px; }

            /* На мобильном делаем topbar fixed (sticky+transform ломается на iOS
               WebKit). Высоту бара измеряет JS и проставляет padding-top на .main
               через CSS-переменную --topbar-real-h, чтобы контент не уезжал под бар. */
            .topbar { position: fixed; top: 0; left: 0; right: 0;
                padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
                gap: 8px; flex-wrap: wrap; align-items: flex-start; }
            .main { padding-top: var(--topbar-real-h, 88px); }
            .topbar h1 { font-size: 16px; word-break: break-word; }
            .topbar p { font-size: 12px; word-break: break-word; }
            .topbar > div:nth-child(2) { min-width: 0; flex: 1 1 auto; }
            #topbar-actions {
                flex: 1 1 100%;
                display: flex; gap: 6px; flex-wrap: wrap;
                margin-top: 4px;
            }
            #topbar-actions:empty { display: none; margin: 0; }
            .topbar .btn-sm { padding: 6px 10px; font-size: 12px; }

            .content { padding: 14px; }

            /* карточки на всю ширину */
            .card[style*="max-width"] { max-width: 100% !important; }

            .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
            .card-body { padding: 14px; }

            /* поле "label : value" — в столбик */
            .card-body > div[style*="flex:0 0 200px"],
            .card-body > div > span[style*="flex:0 0 200px"] { flex: 1 1 100% !important; }
            .card-body > div[style*="display:flex; justify-content:space-between"] {
                flex-direction: column; align-items: flex-start !important; gap: 4px !important;
                text-align: left !important;
            }
            .card-body > div[style*="display:flex; justify-content:space-between"] > span:last-child {
                text-align: left !important; width: 100%;
            }

            /* таблицы — горизонтальный скролл */
            .card-body table, #emp-marks-body table { display: block; overflow-x: auto; white-space: nowrap; }
            th, td { padding: 8px 10px; font-size: 13px; }

            /* Тач-таргеты в табеле: 44px минимум */
            .ts-table th, .ts-table td { min-width: 44px; }
            .ts-table th.col-name, .ts-table td.col-name { min-width: 140px; }
            .ts-table th.col-total, .ts-table td.col-total { min-width: 56px; }
            .cell-input { height: 44px; font-size: 16px; }
            /* На мобиле sticky-колонки убираем — иначе они блокируют прокрутку */
            .ts-table th.col-name, .ts-table td.col-name,
            .ts-table th.col-total, .ts-table td.col-total {
                position: static !important;
                box-shadow: none !important;
            }
            /* timesheet-wrapper сохраняет горизонтальный скролл */
            .timesheet-wrapper { -webkit-overflow-scrolling: touch; }
            /* На мобиле ts-table не должна превращаться в block через общее правило card-body table */
            .card-body table.ts-table, .timesheet-wrapper table.ts-table { display: table; white-space: normal; }

            /* списки → карточки на мобильных */
            .card-body table.list-table, #emp-marks-body table.list-table,
            .scroll-x table.list-table {
                display: block; overflow: visible; white-space: normal;
            }
            /* .scroll-x на мобиле не нужен (карточки и так влезают) — гасим скролл */
            .scroll-x { overflow-x: visible; }
            .list-table thead { display: none; }
            .list-table tbody, .list-table tr { display: block; }
            .list-table {
                background: transparent;
            }
            .list-table tbody {
                display: flex;
                flex-direction: column;
                gap: 10px;
            }
            .list-table tr {
                padding: 14px;
                display: flex;
                flex-direction: column;
                gap: 10px;
                background: var(--color-surface-2);
                border: 1px solid var(--color-border);
                border-radius: var(--radius-md);
            }
            .list-table tr:last-child { border-bottom: 1px solid var(--color-border); }
            .list-table td {
                display: flex;
                justify-content: space-between;
                align-items: flex-start;
                gap: 12px;
                padding: 4px 0;
                border: none;
                white-space: normal;
                word-break: break-word;
                font-size: 13px;
                text-align: left;
            }
            /* На мобиле показываем data-label перед значением — иначе пустые «—»
               без контекста (Объект? Время?). */
            .list-table td[data-label]::before {
                content: attr(data-label) ":";
                color: var(--color-text-muted);
                font-size: 12px;
                font-weight: 500;
                margin-right: 8px;
                flex-shrink: 0;
                min-width: 60px;
                display: inline;
            }
            /* Список табелей: все строки — flex с подписью фикс. ширины, чтобы
               значения встали в одну колонку. Статус/Объект иначе попадают под
               глобальное display:block (для редактируемых таблиц) и ломают ряд. */
            .ts-list-table td[data-label],
            .aligned-list td[data-label] {
                display: flex !important;
                width: auto !important;
                flex: 0 0 auto !important;
                padding: 4px 0 !important;
                align-self: auto !important;
                align-items: baseline;
            }
            .ts-list-table td[data-label]::before,
            .aligned-list td[data-label]::before { min-width: 124px; }
            /* Пустой data-label (напр. ячейка чекбокса) — без подписи-двоеточия */
            .list-table td[data-label=""]::before { display: none !important; }
            .aligned-list td.emp-check-cell { width: auto !important; }
            /* Объекты(день): ячейки с селектами (Статус/Перенести) — подпись над
               полем, селект во всю ширину (а ФИО/Должность выровнены по aligned-list). */
            .wo-aligned td[data-label="Статус"],
            .wo-aligned td[data-label="Перенести"] {
                flex-direction: column !important;
                align-items: stretch !important;
                gap: 4px;
            }
            .wo-aligned td[data-label="Статус"]::before,
            .wo-aligned td[data-label="Перенести"]::before { min-width: 0 !important; }
            .wo-aligned td[data-label="Статус"] select,
            .wo-aligned td[data-label="Перенести"] select { width: 100%; }
            .list-table td { justify-content: flex-start; }
            .list-table td > * { text-align: left; }
            /* Ячейки с маркером «нет данных» — на мобиле скрываем целиком,
               иначе строка засоряется бесполезными прочерками. */
            .list-table td.empty-cell { display: none; }
            /* Чекбокс в углу карточки на мобиле */
            .list-table tr { position: relative; }
            .list-table td.emp-check-cell {
                position: absolute; top: 12px; right: 14px;
                width: auto !important; padding: 0 !important;
            }
            .list-table td.emp-check-cell input { transform: scale(1.2); }
            .list-table td.row-actions {
                justify-content: flex-end;
                padding-top: 8px;
                gap: 6px;
                flex-wrap: wrap;
            }
            .list-table td.row-actions::before { display: none; }
            .list-table td.row-actions > * { text-align: center; }
            .list-table td.row-actions .flex { flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
            /* Список табелей: кнопки действий — ровная сетка равной ширины */
            .ts-list-table td.row-actions .flex {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
                gap: 6px;
                width: 100%;
            }
            .ts-list-table td.row-actions .btn {
                width: 100%; white-space: nowrap;
                min-height: 46px; padding: 10px 14px; font-size: 15px;
            }

            /* На мобиле модалки выезжают как bottom sheet */
            .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
            .modal {
                width: 100vw !important;
                max-width: 100vw !important;
                max-height: 92dvh !important;
                border-radius: 18px 18px 0 0 !important;
                animation: sheetUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
                padding-top: 6px;
                padding-bottom: env(safe-area-inset-bottom);
            }
            .modal::before {
                content: "";
                display: block;
                width: 44px; height: 4px;
                background: var(--color-border-strong);
                border-radius: 999px;
                margin: 4px auto 6px;
            }
            .modal-header { padding: 14px 20px; }
            .modal-body { padding: 14px 16px; gap: 10px; }
            .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
            @keyframes sheetUp {
                from { transform: translateY(100%); }
                to { transform: none; }
            }

            /* фильтры в строку — переносим */
            .card-body > div[style*="flex:1; min-width:240px"],
            .card-body > div[style*="flex:1;min-width:180px"] { flex: 1 1 100% !important; min-width: 0 !important; }

            /* кнопки в шапке — мельче и переносятся */
            .topbar h1, .topbar p { width: 100%; }
        }

        @media (max-width: 480px) {
            .login-card { width: 100%; max-width: 360px; padding: 28px 24px 24px;
                border-radius: 16px; }
            .toast { left: 12px; right: 12px; bottom: 12px; }
        }

        /* ── FAB ──────────────────────────────────────────────── */
        .fab {
            position: fixed;
            right: 18px;
            bottom: calc(20px + env(safe-area-inset-bottom));
            width: 56px; height: 56px;
            border-radius: 50%;
            background: var(--color-accent);
            color: white;
            border: none;
            box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
            cursor: pointer;
            font-size: 26px; line-height: 1; font-weight: 400;
            display: flex; align-items: center; justify-content: center;
            z-index: 105;
            transition: transform 0.12s, background 0.12s;
        }
        .fab:hover { background: var(--color-primary); }
        .fab:active { transform: scale(0.95); }
        .fab.hidden { display: none; }
        body.has-bottom-nav .fab { bottom: calc(80px + env(safe-area-inset-bottom)); }
        @media (min-width: 769px) { .fab { display: none; } }

        /* ── Bottom navigation (мобиль для бригадира) ─────────── */
        .bottom-nav { display: none; }
        body.has-bottom-nav .bottom-nav {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            position: fixed;
            left: 0; right: 0; bottom: 0;
            background: var(--color-surface);
            border-top: 1px solid var(--color-border);
            padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
            z-index: 110;
            box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
        }
        body.has-bottom-nav .menu-toggle { display: none !important; }
        body.has-bottom-nav .sidebar { display: none !important; }
        body.has-bottom-nav #sidebar-backdrop { display: none !important; }
        body.has-bottom-nav .main { padding-bottom: 72px; }
        .bn-item {
            background: transparent; border: none; cursor: pointer;
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            gap: 2px;
            padding: 6px 4px;
            color: var(--color-text-muted);
            font-size: 11px; font-weight: 500;
            border-radius: var(--radius-md);
            min-height: 52px;
        }
        .bn-item svg { width: 22px; height: 22px; }
        .bn-item.active { color: var(--color-accent); }
        .bn-item:active { background: var(--color-surface-2); }

        /* ── Дополнительная мобильная полировка ──────────────── */
        @media (max-width: 768px) {
            /* Скрываем гамбургер, когда сайдбар открыт */
            .sidebar.open ~ .main .menu-toggle { visibility: hidden; }
            /* Sticky-плашка с кнопкой Сохранить в редакторе табеля */
            .ts-save-bottom {
                position: sticky;
                bottom: env(safe-area-inset-bottom, 0);
                background: var(--color-surface);
                border-top: 1px solid var(--color-border);
                padding: 10px 12px;
                margin: 16px -14px 0;
                text-align: center !important;
                z-index: 30;
                box-shadow: 0 -4px 10px rgba(0,0,0,0.08);
            }
            .ts-save-bottom .btn { width: 100%; justify-content: center; }
            /* Компактные шапки эмп-календарей */
            .emp-cal-grid { grid-template-columns: 1fr; gap: 10px; }
            .emp-cal-fio { font-size: 13px; }
            .emp-cal-head .avatar { width: 32px; height: 32px; }
            .ec-cell .ec-l { font-size: 11px; margin-top: 4px; }
            /* Закреплённая легенда табеля — на мобиле выше, чтоб не зажимало под FAB */
            .ts-legend { bottom: 76px; }
        }

        /* ── Print ─────────────────────────────────────────────── */
        @media print {
            html, body { background: white !important; color: black !important; overflow: visible !important; height: auto !important; }
            #login-screen, #force-change-screen, .sidebar, .sidebar-backdrop, .topbar, .toast, .modal-overlay, .cmdk-overlay, #topbar-actions, .menu-toggle, .theme-toggle, .btn-logout { display: none !important; }
            #app { display: block !important; height: auto !important; }
            .main { overflow: visible !important; height: auto !important; display: block !important; }
            .content { padding: 0 !important; }
            .card { border: 1px solid #999 !important; box-shadow: none !important; page-break-inside: avoid; }
            .card-header { background: #f0f0f0 !important; }
            a { color: inherit !important; text-decoration: none !important; }
            .timesheet-wrapper { overflow: visible !important; border: 1px solid #999 !important; box-shadow: none !important; }
            .ts-table { font-size: 9pt !important; }
            .ts-table th, .ts-table td { border: 1px solid #aaa !important; }
            .ts-table th.col-name, .ts-table td.col-name, .ts-table th.col-total, .ts-table td.col-total { position: static !important; box-shadow: none !important; background: #f5f5f5 !important; color: black !important; }
            .ts-table tbody tr:hover td { background: white !important; }
            .cell-input { color: black !important; background: white !important; }
            .badge { border: 1px solid #999 !important; background: white !important; color: black !important; }
            .btn { display: none !important; }
            .row-actions { display: none !important; }
            .skeleton, .skeleton-card { display: none !important; }
            @page { margin: 12mm; }
        }


/* ── Распределение 2/2 (shift_dist.js) ──────────────────────────────── */
.sd-toolbar { display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.sd-obj-tabs { margin-top:8px; display:flex; gap:6px; overflow-x:auto;
               padding-bottom:6px; border-bottom:1px solid var(--color-border); }
.sd-obj-tab { flex:0 0 auto; max-width:240px; overflow:hidden;
              text-overflow:ellipsis; white-space:nowrap; }
.sd-row { padding:8px 12px; display:grid;
          grid-template-columns: auto 1fr; grid-template-rows: auto auto;
          gap:6px 10px; align-items:start; margin-bottom:6px; }
.sd-row > .sd-sel { width:18px; height:18px; flex:0 0 auto;
                    grid-column:1; grid-row: 1 / span 2; margin-top:4px; }
.sd-row .sd-fio { min-width:0; grid-column:2; grid-row:1; }
.sd-row .sd-fio .sd-name { font-weight:600; font-size:15px; line-height:1.2; }
.sd-row .sd-fio .sd-pos  { font-size:13px; opacity:.85; margin-top:2px; }
.sd-row .sd-fio .sd-meta { color: var(--color-text-muted); font-size:11px; margin-top:2px; }
.sd-row .sd-fio .sd-brig { color: #2563eb; font-size:11px; margin-top:2px; }
.sd-row .sd-move { grid-column:2; grid-row:2; width:100%; min-width:0; max-width:none; }
.sd-bulk-panel { display:none; position:sticky; bottom:0;
                 background:var(--color-bg); border-top:1px solid var(--color-border);
                 padding:10px; margin-top:10px; z-index:5; }
.sd-bulk-panel.is-open { display:block; }
.sd-bulk-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.sd-info { padding-top:10px; }

/* ── Утилиты для отчётов (reports.js) и виджетов ─────────────────────── */
.t-right { text-align: right; }
.t-inherit { color: inherit; }
.p-2-0 { padding: 2px 0; }
.p-8-14 { padding: 8px 14px; }
.p-12 { padding: 12px; }
.scroll-x { overflow-x: auto; }
.rep-bullets { margin: 6px 0 6px 14px; padding: 0; list-style: disc; font-size: 13px; }
.rep-big-num { font-size: 24px; font-weight: 600; }
.rep-warn-pill { background: #fee2e2; color: #b91c1c; }

/* ── Доп. util-классы (общие для нескольких js-файлов) ───────────────── */
.p-8 { padding: 8px; }
.rel { position: relative; }
.f-1 { flex: 1; }
.cur-pointer { cursor: pointer; }
.mb-1 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-14 { margin-bottom: 14px; }
.mt-14 { margin-top: 14px; }
.m-0 { margin: 0; }
.w-auto { width: auto; }
.block { display: block; }
.flex-gap-8 { display: flex; gap: 8px; }
.flex-gap-8-wrap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Карточка события в журнале за месяц (вкладка «События») ─────────── */
/* Простой div-карточный рендер вместо table.list-table — DOM в разы легче,
   content-visibility:auto отрезает off-screen карточки при скролле 1000+ */
#jm-events-list { display: flex; flex-direction: column; gap: 8px; }
.jm-ev-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border, #e8ecf3);
    border-radius: 10px;
    padding: 12px 14px;
    content-visibility: auto;
    contain-intrinsic-size: auto 130px;
}
.jm-ev-head { display: flex; align-items: center; gap: 10px; }
.jm-ev-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.jm-ev-fio { font-size: 14px; font-weight: 600; line-height: 1.2; }
.jm-ev-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.jm-ev-dt { font-size: 11px; color: var(--color-text-muted, #5a6890); font-variant-numeric: tabular-nums; }
.jm-ev-line { font-size: 12px; color: var(--color-text-muted, #5a6890); margin-top: 6px; line-height: 1.35; }
.jm-ev-lbl { color: var(--color-text-faint, #7280a3); margin-right: 4px; }
.jm-ev-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.jm-ev-actions .btn { min-width: 96px; justify-content: center; }

/* ── Фильтры в journal-day/month: одинаковая ширина всех полей ──────── */
/* select по умолчанию имеет width:auto и сжимается до ширины контента
   («Май», «Все»), а после загрузки списков отделов растягивается до
   ширины самого длинного option. Это даёт неровную сетку. Фиксируем
   100% явно — все поля одинаковой ширины с момента первого рендера. */
.jfilter-cell { width: 100%; min-width: 0; }
.jfilter-cell select,
.jfilter-cell input[type="text"],
.jfilter-cell input[type="date"],
.jfilter-cell input[type="number"],
.jfilter-cell input[type="search"] {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Ряд фильтров journal-day/month — class вместо inline-style, чтобы
   media-селектор .card-body > div[style*="display:grid"] из styles-redesign.css
   его не цеплял. minmax(0, 1fr) гарантирует равные треки независимо от
   min-content контента (длинных опций select). */
.jfilter-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 14px !important;
    align-items: flex-end !important;
}
.jfilter-row > .jfilter-cell {
    flex: 1 1 calc(50% - 7px) !important;
    min-width: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════════════
 *  LOGIN «как в редизайне, но системный шрифт» — только для 155 (prod).
 *  Порт login-секции styles-redesign.css. --rd-* цвета/радиусы/тени взяты
 *  из редизайна, но --rd-font-* заменены на системный стек.
 *  На 91 поверх грузится styles-redesign.css (отдельным файлом, позже) —
 *  он переобъявляет те же :root --rd-* (Manrope/Serif/Mono) и те же
 *  селекторы .login-card, поэтому 91 остаётся на полном редизайне.
 * ═══════════════════════════════════════════════════════════════════════ */
:root {
  --rd-primary: #011566;
  --rd-primary-hover: #020e4a;
  --rd-primary-soft: #eef2ff;
  --rd-accent: #60a5fa;
  --rd-accent-glow: rgba(96, 165, 250, 0.13);

  --rd-text: #0f1530;
  --rd-text-muted: #5a6890;
  --rd-text-faint: #7280a3;
  --rd-text-meta: #9aa5c2;

  --rd-surface: #ffffff;
  --rd-surface-2: #f4f6fb;
  --rd-border: #e8ecf3;
  --rd-border-strong: #cbd5e1;

  --rd-success: #16a34a;
  --rd-danger: #dc2626;

  --rd-radius-sm: 6px;
  --rd-radius-md: 10px;
  --rd-radius-lg: 14px;
  --rd-radius-xl: 20px;

  --rd-shadow-card: 0 1px 2px rgba(15, 21, 48, 0.04);
  --rd-shadow-md: 0 4px 14px rgba(15, 21, 48, 0.06);
  --rd-shadow-lg: 0 24px 64px rgba(15, 21, 48, 0.14);
  --rd-shadow-primary: 0 8px 22px rgba(1, 21, 102, 0.28);

  /* Системный шрифт вместо редизайновых Source Serif / Manrope / IBM Plex Mono */
  --rd-font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --rd-font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --rd-font-mono: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

#login-screen,
#force-change-screen {
  background: linear-gradient(180deg, #fcfcfd 0%, #f4f6fb 100%);
  background-image:
    radial-gradient(ellipse 540px 380px at 14% 8%, rgba(96, 165, 250, 0.13), transparent 60%),
    radial-gradient(ellipse 640px 460px at 86% 92%, rgba(1, 21, 102, 0.06), transparent 60%),
    linear-gradient(180deg, #fcfcfd 0%, #f4f6fb 100%);
  font-family: var(--rd-font-ui);
}

.login-card {
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius-xl);
  padding: 40px 44px 36px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--rd-shadow-lg);
  text-align: center;
  position: relative;
  z-index: 2;
}

.login-card .login-logo {
  width: auto;
  max-width: 280px;
  height: auto;
  margin: 0 auto 18px;
  display: block;
  object-fit: contain;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.login-card h1 {
  font-family: var(--rd-font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--rd-text);
  margin: 0 0 6px;
  text-align: center;
}

.login-card .subtitle {
  font-family: var(--rd-font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--rd-primary);
  margin: 0 0 28px;
  text-align: center;
  line-height: 1.4;
  white-space: nowrap;
}

.login-card .form-group {
  margin-bottom: 14px;
  text-align: left;
}
.login-card .form-group label {
  display: block;
  font-family: var(--rd-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rd-text-faint);
  margin-bottom: 6px;
}
.login-card .form-group input {
  width: 100%;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius-md);
  padding: 12px 14px;
  font-family: var(--rd-font-ui);
  font-size: 14px;
  color: var(--rd-text);
  transition: border-color 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 0 rgba(15, 21, 48, 0.02);
}
.login-card .form-group input:focus {
  outline: none;
  border-color: var(--rd-primary);
  box-shadow: 0 0 0 4px rgba(1, 21, 102, 0.10);
}
.login-card .form-group input::placeholder {
  color: var(--rd-text-meta);
}

.login-card .pwd-wrap input { padding-right: 42px; }
.login-card .pwd-toggle {
  right: 10px;
  color: var(--rd-text-faint);
}
.login-card .pwd-toggle:hover { color: var(--rd-primary); }

.login-card #login-btn,
.login-card #fcp-btn,
.login-card #login-2fa-btn {
  width: 100%;
  background: var(--rd-primary);
  color: #fff;
  border: none;
  border-radius: var(--rd-radius-md);
  padding: 14px 18px;
  font-family: var(--rd-font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--rd-shadow-primary);
  transition: background 0.12s, transform 0.06s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.login-card #login-btn:hover,
.login-card #fcp-btn:hover,
.login-card #login-2fa-btn:hover {
  background: var(--rd-primary-hover);
  box-shadow: 0 12px 28px rgba(1, 21, 102, 0.32);
}
.login-card #login-btn:active,
.login-card #fcp-btn:active,
.login-card #login-2fa-btn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(1, 21, 102, 0.22);
}

.login-card > div[style*="text-align:center;margin-top:14px"],
.login-card > div[style*="text-align: center; margin-top: 14px"] {
  font-family: var(--rd-font-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--rd-text-meta) !important;
  margin: 20px 0 6px !important;
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 12px;
}
.login-card > div[style*="text-align:center;margin-top:14px"]::before,
.login-card > div[style*="text-align:center;margin-top:14px"]::after,
.login-card > div[style*="text-align: center; margin-top: 14px"]::before,
.login-card > div[style*="text-align: center; margin-top: 14px"]::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rd-border);
}

.login-card #login-tg-btn,
.login-card #login-max-btn,
.login-card #login-code-btn {
  width: 100%;
  background: var(--rd-surface);
  color: var(--rd-text);
  border: 1px solid var(--rd-border-strong);
  border-radius: var(--rd-radius-md);
  padding: 12px 14px;
  font-family: var(--rd-font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  transition: border-color 0.12s, background 0.12s, transform 0.06s;
}
.login-card #login-tg-btn:hover,
.login-card #login-max-btn:hover,
.login-card #login-code-btn:hover {
  border-color: var(--rd-primary);
  background: var(--rd-primary-soft);
}
.login-card #login-tg-btn svg,
.login-card #login-max-btn svg {
  color: var(--rd-primary);
}

.login-card .error-msg {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.18);
  color: var(--rd-danger);
  border-radius: var(--rd-radius-sm);
  padding: 10px 12px;
  font-family: var(--rd-font-ui);
  font-size: 13px;
  margin: 8px 0;
}

#login-2fa {
  background: var(--rd-surface-2) !important;
  border: 1px solid var(--rd-border) !important;
  border-radius: var(--rd-radius-lg) !important;
  padding: 16px !important;
  margin-top: 16px !important;
}
#login-2fa > div:first-child {
  font-family: var(--rd-font-mono) !important;
  font-size: 12px !important;
  letter-spacing: 0.01em !important;
  color: var(--rd-text-muted) !important;
  margin-bottom: 10px !important;
  line-height: 1.45 !important;
}
#login-2fa-code {
  width: 100%;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius-md);
  padding: 14px 16px;
  font-family: var(--rd-font-mono);
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.5em;
  color: var(--rd-text);
}
#login-2fa-code:focus {
  outline: none;
  border-color: var(--rd-primary);
  box-shadow: 0 0 0 4px rgba(1, 21, 102, 0.10);
}
.login-card .btn-link {
  background: transparent !important;
  color: var(--rd-text-faint) !important;
  border: none !important;
  box-shadow: none !important;
  font-family: var(--rd-font-ui) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 8px !important;
  margin-top: 6px !important;
  cursor: pointer;
}
.login-card .btn-link:hover {
  color: var(--rd-primary) !important;
}

#force-change-screen .login-card h1 {
  font-family: var(--rd-font-display);
  font-size: 26px;
  font-weight: 600;
}
#force-change-screen .login-card .subtitle {
  margin-bottom: 20px;
}
#force-change-screen .login-card .btn:not(#fcp-btn) {
  width: 100%;
  background: transparent;
  color: var(--rd-text-faint);
  border: 1px solid var(--rd-border-strong);
  border-radius: var(--rd-radius-md);
  padding: 12px;
  font-family: var(--rd-font-ui);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  cursor: pointer;
  transition: all 0.12s;
}
#force-change-screen .login-card .btn:not(#fcp-btn):hover {
  border-color: var(--rd-danger);
  color: var(--rd-danger);
}

/* Тёмный фон под кнопкой темы больше не нужен — логин теперь светлый */
#login-screen .login-theme-toggle,
#force-change-screen .login-theme-toggle {
  background: rgba(1, 21, 102, 0.06);
  border: 1px solid var(--rd-border-strong);
  color: var(--rd-text-faint);
}
#login-screen .login-theme-toggle:hover,
#force-change-screen .login-theme-toggle:hover {
  background: var(--rd-primary-soft);
  border-color: var(--rd-primary);
  color: var(--rd-primary);
}

@media (max-width: 480px) {
  .login-card {
    width: 100%;
    padding: 32px 24px 28px;
  }
  .login-card h1 { font-size: 26px; }
}

/* ─── Тёмная тема для редизайн-логина ──────────────────────────────────────
   Переключатель темы на странице входа меняет data-theme на <html>, но порт
   логина использует фиксированные светлые --rd-*, из-за чего вид не менялся.
   Даём логину тёмный вариант тех же --rd-* (палитра — из dark-блока выше). */
:root[data-theme="dark"],
:root[data-theme="dark"] #login-screen,
:root[data-theme="dark"] #force-change-screen {
  --rd-surface: #161a21;
  --rd-surface-2: #1d222c;
  --rd-border: #2d333d;
  --rd-border-strong: #404856;
  --rd-text: #e5e7eb;
  --rd-text-muted: #9ca3af;
  --rd-text-faint: #9aa5b8;
  --rd-text-meta: #6b7280;
  --rd-primary: #4f6ad6;
  --rd-primary-hover: #5e7be0;
  --rd-primary-soft: #1a2240;
  --rd-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  --rd-shadow-primary: 0 8px 22px rgba(0, 0, 0, 0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rd-surface: #161a21;
    --rd-surface-2: #1d222c;
    --rd-border: #2d333d;
    --rd-border-strong: #404856;
    --rd-text: #e5e7eb;
    --rd-text-muted: #9ca3af;
    --rd-text-faint: #9aa5b8;
    --rd-text-meta: #6b7280;
    --rd-primary: #4f6ad6;
    --rd-primary-hover: #5e7be0;
    --rd-primary-soft: #1a2240;
    --rd-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
    --rd-shadow-primary: 0 8px 22px rgba(0, 0, 0, 0.5);
  }
}
/* Тёмный фон экрана входа + видимая кнопка темы на тёмном */
:root[data-theme="dark"] #login-screen,
:root[data-theme="dark"] #force-change-screen,
.login-dark-bg {
  background: linear-gradient(180deg, #0e1117 0%, #161a21 100%);
  background-image:
    radial-gradient(ellipse 540px 380px at 14% 8%, rgba(96, 165, 250, 0.10), transparent 60%),
    radial-gradient(ellipse 640px 460px at 86% 92%, rgba(79, 106, 214, 0.12), transparent 60%),
    linear-gradient(180deg, #0e1117 0%, #161a21 100%);
}
:root[data-theme="dark"] #login-screen .login-theme-toggle,
:root[data-theme="dark"] #force-change-screen .login-theme-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--rd-border-strong);
  color: var(--rd-text-faint);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #login-screen,
  :root:not([data-theme="light"]) #force-change-screen {
    background: linear-gradient(180deg, #0e1117 0%, #161a21 100%);
    background-image:
      radial-gradient(ellipse 540px 380px at 14% 8%, rgba(96, 165, 250, 0.10), transparent 60%),
      radial-gradient(ellipse 640px 460px at 86% 92%, rgba(79, 106, 214, 0.12), transparent 60%),
      linear-gradient(180deg, #0e1117 0%, #161a21 100%);
  }
  :root:not([data-theme="light"]) #login-screen .login-theme-toggle,
  :root:not([data-theme="light"]) #force-change-screen .login-theme-toggle {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--rd-border-strong);
    color: var(--rd-text-faint);
  }
}

/* ── Карточка сотрудника: hero-шапка (fallback для базовой темы) ──── */
.ec-hero { display:flex; gap:20px; align-items:center; flex-wrap:wrap; background:var(--color-surface); border:1px solid var(--color-border); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); padding:20px 22px; }
.ec-hero-photo { flex:0 0 128px; width:128px; height:128px; border-radius:12px; overflow:hidden; display:flex; align-items:center; justify-content:center; background:var(--color-surface-2); border:1px solid var(--color-border); }
.ec-hero-photo img { width:100%; height:100%; object-fit:cover; cursor:zoom-in; }
.ec-hero-initials { font-size:38px; font-weight:700; color:var(--color-text-muted); }
.ec-hero-main { flex:1 1 280px; min-width:0; }
.ec-hero-toprow { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.ec-hero-name { margin:0; font-size:22px; font-weight:700; letter-spacing:-0.01em; line-height:1.15; color:var(--color-text); }
.ec-hero-sub { color:var(--color-text-muted); margin-top:5px; font-size:14px; }
.ec-hero-chips { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.ec-chip { display:inline-flex; align-items:center; gap:6px; padding:5px 12px; border-radius:999px; background:var(--color-surface-2); border:1px solid var(--color-border); font-size:12.5px; color:var(--color-text); max-width:100%; }
.ec-chip b { font-weight:600; }
.ec-chip a { color:inherit; text-decoration:none; }
.ec-hero-actions { margin-top:16px; display:flex; gap:8px; flex-wrap:wrap; }
@media (max-width:768px){ .ec-hero{padding:16px;gap:14px} .ec-hero-photo{flex-basis:92px;width:92px;height:92px} .ec-hero-name{font-size:19px} }

/* Карточка сотрудника: строки-поля (fallback базовой темы) */
.ec-field { display:flex; justify-content:space-between; gap:16px; padding:13px 2px; border-bottom:1px solid var(--color-border); align-items:center; }
.ec-field:last-child { border-bottom:none; }
.ec-field-label { flex:0 0 200px; color:var(--color-text-muted); font-size:13px; }
.ec-field-val { flex:1; min-width:0; text-align:right; font-weight:600; color:var(--color-text); display:inline-flex; justify-content:flex-end; align-items:center; gap:8px; flex-wrap:wrap; }
@media (max-width:768px){ .ec-field{flex-direction:column;align-items:flex-start;gap:4px} .ec-field-label{flex:none} .ec-field-val{text-align:left;justify-content:flex-start;width:100%} }
