        /* ===== ОРИГИНАЛЬНЫЕ СТИЛИ (без изменений) ===== */
        .btn-status-all { background: #6b7280; color: white; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
        .btn-status-active { background: #10b981; color: white; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
        .btn-status-suspended { background: #f59e0b; color: white; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
        .btn-status-expired { background: #ef4444; color: white; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
        .btn-status-all:hover, .btn-status-active:hover, .btn-status-suspended:hover, .btn-status-expired:hover { transform: translateY(-2px); filter: brightness(1.05); }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Inter', sans-serif; background: #f0f2f8; color: #1e293b; margin: 0; padding: 0; min-height: 100vh; }
        .container { width: 100%; margin: 0 auto; padding: 0 20px; }
        .main-menu { background: #1b4a6e; border-radius: 60px; padding: 8px 24px; margin-bottom: 32px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; border: 1px solid #eef2f8; box-shadow: 0 2px 8px rgba(0,0,0,0.03); position: relative;}
        .logo-area { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
        .logo-text h2 { font-size: 1rem; color: white; margin: 0; line-height: 1.2; }
        .logo-text p { font-size: 0.65rem; color: rgba(255,255,255,0.7); margin: 0; }
        .logo-icon {
    width: 90px;
    height: 90px;
    background: rgba(255,255,255,0.2);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 700;
    color: #ffb347;
}
        .menu-items { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
        .menu-item { background: transparent; border: none; padding: 10px 18px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; color: rgba(255,255,255,0.7) !important; display: flex; align-items: center; gap: 6px; transition: all 0.2s; position: relative; }
        .menu-item:not(:last-child)::after { content: '│'; position: absolute; right: -12px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.2); font-size: 0.8rem; }
        .menu-item:hover { background: rgba(255,255,255,0.15) !important; color: white !important; }
        .menu-item.active { background: #ffb347; color: #1e293b !important; }
        .menu-item.active::after { display: none; }
        .stats-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; margin-top: 10px; }
        .stat-card { background: white; border-radius: 16px; padding: 16px 14px; text-align: center; border: 1px solid #eef2f8; box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: all 0.2s; }
        .stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .stat-card .stat-icon { font-size: 1.4rem; margin-bottom: 6px; display: block; color: #1b4a6e; }
        .stat-card .stat-number { font-size: 1.5rem; font-weight: 700; color: #1b4a6e; line-height: 1.2; }
        .stat-card .stat-label { font-size: 0.65rem; color: #5b6e8c; font-weight: 500; margin-top: 4px; }
        .stat-card.card-total { border-top: 3px solid #1b4a6e; }
        .stat-card.card-pending { border-top: 3px solid #f59e0b; }
        .stat-card.card-amount { border-top: 3px solid #10b981; }
        .stat-card.card-paid { border-top: 3px solid #3b82f6; }
        .stat-card.card-unpaid { border-top: 3px solid #ef4444; }
        .stat-card.card-all { border-top: 3px solid #8b5cf6; }
        .stat-divider { border-top: 1px dashed #cbd5e1; margin: 6px auto; width: 40px; }
        .stat-count { font-size: 1rem; color: #5b6e8c; font-weight: 600; }
        
        .user-menu-wrapper {
        position: relative;
        z-index: 9999;
        flex-shrink: 0;
}
        .user-menu-btn { background: rgba(255,255,255,0.15); border: none; padding: 8px 16px 8px 12px; border-radius: 40px; color: white; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 0.8rem; font-weight: 500; transition: all 0.2s; font-family: 'Inter', sans-serif; }
        .user-menu-btn:hover { background: rgba(255,255,255,0.25); }
        .user-menu-btn i { font-size: 1rem; }
        .user-menu-btn .user-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
        .user-menu-btn .user-arrow { font-size: 0.6rem; margin-left: 4px; transition: transform 0.2s; }
        .user-menu-btn.open .user-arrow { transform: rotate(180deg); }
        .user-dropdown {
            display: none;
            position: absolute;
            right: 0;
            top: calc(100% + 8px);
            background: white;
            border-radius: 16px;
            min-width: 140px;
            box-shadow: 0 8px 30px rgba(0,0,0,0.15);
            border: 1px solid #eef2f8;
            padding: 8px 0;
            z-index: 1000;
        }
        .user-dropdown.open { display: block; }
        .user-dropdown .dropdown-item { padding: 10px 16px; cursor: pointer; font-size: 0.8rem; color: #1e293b; display: flex; align-items: center; gap: 10px; transition: all 0.15s; border: none; background: none; width: 100%; text-align: left; font-family: 'Inter', sans-serif; }
        .user-dropdown .dropdown-item:hover { background: #f1f5f9; }
        .user-dropdown .dropdown-item i { width: 18px; color: #94a3b8; font-size: 0.8rem; }
        .user-dropdown .dropdown-divider { height: 1px; background: #f0f4f9; margin: 4px 0; }
        .user-dropdown .dropdown-item.logout-item { color: #dc2626; border-top: 1px solid #f0f4f9; margin-top: 4px; padding-top: 12px; }
        .user-dropdown .dropdown-item.logout-item i { color: #dc2626; }
        .user-dropdown .dropdown-item .year-badge { background: #e0e7ff; padding: 2px 10px; border-radius: 20px; font-size: 0.7rem; color: #3730a3; margin-left: auto; }
        
        .stats-header {
            background: #1b4a6e;
            border-radius: 28px;
            padding: 12px 28px;
            margin-bottom: 0;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
            min-height: 20px;
            position: relative;
        }
        .filter-panel {
    background: white;
    border-radius: 20px;
    padding: 20px 24px;
    margin-bottom: 25px;
    border: 1px solid #eef2f8;
    border-top: 3px solid #ffb347 !important;

    /* ===== ФИКСАЦИЯ ФИЛЬТРОВ ПОД ГЛАВНЫМ МЕНЮ ===== */
    position: sticky !important;
    top: calc(var(--main-menu-height, 100px) - 16px) !important;
    z-index: 900 !important;
}
/* =========================================================
   ФИКСИРОВАННЫЕ БЛОКИ ПОИСКА И ФИЛЬТРОВ
   Всегда останавливаются непосредственно под главным меню.
   Работает также для будущих вкладок.
   ========================================================= */

.sticky-search-filter {
    position: sticky !important;
    top: calc(var(--main-menu-height, 100px) - 16px) !important;
    z-index: 900 !important;
}
        .contract-table th { background: #1b4a6e !important; color: white !important; }
        .modal-header { background: #1b4a6e !important; border-radius: 32px 32px 0 0 !important; padding: 20px 28px !important; margin: -28px -30px 0 -30px !important; }
        .modal-header h2 { color: white !important; margin: 0; }
        .close-modal { color: white !important; font-size: 28px; background: none; border: none; cursor: pointer; }
        .btn-search { background: #1b4a6e !important; color: white !important; }
        .btn-add { background: #ffb347 !important; color: #1e293b !important; }
        input:focus, select:focus, textarea:focus { border-color: #ffb347 !important; box-shadow: 0 0 0 2px rgba(255, 179, 71, 0.2) !important; outline: none !important; }
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 10px; }
        ::-webkit-scrollbar-thumb { background: #1b4a6e; border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: #ffb347; }
        button { transition: all 0.2s ease !important; }
        button:hover { transform: translateY(-1px); filter: brightness(1.05); }
        .filter-row { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 15px; }
        .filter-group { flex: 1; min-width: 180px; }
        .filter-group label { display: block; font-size: 0.7rem; font-weight: 600; color: #5b6e8c; margin-bottom: 6px; }
        .filter-group label i { margin-right: 4px; }
        .filter-group input, .filter-group select { width: 100%; padding: 10px 12px; border: 1px solid #dce3ec; border-radius: 12px; font-size: 0.85rem; font-family: inherit; }
        .filter-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; margin-top: 5px; }
        .filter-buttons button { padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; border: none; }
        .btn-search { background: #1b4a6e; color: white; }
        .btn-clear { background: #e2e8f0; color: #334155; }
        .btn-deleted { background: #fef3c7; color: #b45309; }
        .btn-export-filter { background: #10b981; color: white; }
        .btn-add { background: #ffb347; color: #1e293b; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
        .btn-add:hover { background: #ff9f1a; }
        .table-wrapper { overflow-x: auto; border-radius: 20px; background: white; border: 1px solid #eef2f8; }
        .contract-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; min-width: 1300px; }
        .contract-table th { background: #f8fafd; padding: 14px 12px; font-weight: 600; border-bottom: 1px solid #e2e8f0; text-align: center; cursor: pointer; }
        .contract-table th:hover { background: #eef2ff; }
        .contract-table td { padding: 12px 10px; border-bottom: 1px solid #f0f4f9; text-align: center; cursor: pointer; }
        .contract-table tr:hover td { background-color: #e6f0fa; }
        .status-badge { display: inline-block; padding: 4px 10px; border-radius: 40px; font-size: 0.7rem; font-weight: 600; }
        .status-active { background: #dcfce7; color: #15803d; }
        .status-expired { background: #fee2e2; color: #b91c1c; }
        .status-pending { background: #fef3c7; color: #b45309; }
        .status-suspended { background: #e0e7ff; color: #3730a3; }
        .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
        .modal-content { background: white; border-radius: 32px; width: 95%; max-width: 1400px; max-height: 90vh; overflow-y: auto; padding: 28px 30px; margin: auto; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #eef2f8; }
        .modal-header h2 { font-size: 1.3rem; color: #1f3a4b; }
        .close-modal { background: none; border: none; font-size: 28px; cursor: pointer; color: #94a3b8; }
        .form-group { margin-bottom: 20px; }
        .form-group label { display: block; font-size: 0.75rem; font-weight: 600; color: #5b6e8c; margin-bottom: 6px; }
        .form-group input, .form-group select, .settings-input { width: 100%; padding: 10px 12px; border: 1px solid #dce3ec; border-radius: 12px; font-size: 0.9rem; font-family: inherit; }
        .login-password-wrap { position: relative; }
        .login-password-wrap input { height: 48px; box-sizing: border-box; }
        .login-password-eye { position: absolute; right: 8px; top: 9px; transform: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; background: transparent; color: #64748b; font-size: 0.85rem; cursor: pointer; }
        .login-password-eye:hover { background: #eef5fb; color: #1b4a6e; }
        .login-password-eye.is-visible { color: #1b4a6e; }
        .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
        .total-card { background: #f1f5f9; border-radius: 16px; padding: 20px; margin: 25px 0; text-align: center; border: 1px solid #e2e8f0; }
        .total-label { font-size: 0.75rem; color: #5b6e8c; text-transform: uppercase; letter-spacing: 1px; }
        .total-amount { font-size: 1.8rem; font-weight: 700; color: #1b4a6e; margin-top: 8px; }
        .form-hint { font-size: 0.65rem; color: #94a3b8; margin-top: 5px; display: block; }
        .required { color: #dc2626; margin-left: 4px; }
        .btn-primary { background: #1b4a6e; color: white; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .btn-secondary { background: #e2e8f0; color: #334155; border: none; padding: 10px 20px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .btn-danger { background: #dc2626; color: white; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .btn-warning { background: #f59e0b; color: white; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .btn-sm { padding: 5px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; cursor: pointer; border: none; margin: 2px; }
        .btn-edit { background: #fef3c7; color: #b45309; }
        .btn-delete { background: #fee2e2; color: #dc2626; }
        .modal-buttons { display: flex; gap: 15px; justify-content: flex-end; margin-top: 25px; }
        .detail-container { display: none; background: white; border-radius: 24px; padding: 6px 28px; border: 1px solid #eef2f8; margin-top: 0; }
        .detail-container.active { display: block; }
        .tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; background: #f8fafd; padding: 6px 12px; border-radius: 60px; border: 1px solid #eef2f8; }
        .tab-btn { background: transparent; border: none; padding: 10px 24px; border-radius: 40px; font-weight: 600; font-size: 0.85rem; cursor: pointer; color: #5b6e8c; position: relative; transition: all 0.2s; }
        .tab-btn:not(:first-child)::before { content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%); height: 20px; width: 1px; background: #cbd5e1; }
        .tab-btn:hover:not(.active) { background: #f1f5f9; }
        .tab-btn.active { background: #ffb347 !important; color: #1e293b !important; }
        .tab-btn.active::before { background: transparent; }
        .tab-content { display: none; background: white; border-radius: 20px; padding: 10px 20px; border: 1px solid #eef2f8; }
        .tab-content.active { display: block; }
        .detail-row { display: flex; padding: 12px 0; border-bottom: 1px solid #f0f4f9; }
        .detail-label { width: 35%; font-weight: 600; color: #5b6e8c; }
        .detail-value { width: 65%; color: #1e293b; font-weight: 500; }
        .flex-buttons { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-start; flex-wrap: wrap; }
        .stats-mini-card { background: #f8fafd; padding: 15px; border-radius: 16px; text-align: center; border-top: 3px solid #ffb347 !important; }
        .stat-mini-label { font-size: 0.7rem; color: #5b6e8c; }
        .stat-mini-value { font-size: 1.3rem; font-weight: 700; color: #1b4a6e; }
        .payment-form { background: #f8fafd; padding: 15px; border-radius: 16px; margin-bottom: 20px; }
        .comment-item { background: #f8fafd; padding: 12px; border-radius: 16px; margin-bottom: 10px; border-left: 4px solid #ffb347; }
        .comment-date { font-size: 0.65rem; color: #94a3b8; margin-bottom: 5px; }
        .comment-text { font-size: 0.85rem; }
        .invoices-table-wrapper { overflow-x: auto; margin-top: 20px; border-radius: 20px; border: 1px solid #eef2f8; background: white; }
        .invoices-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; min-width: 1300px; }
        .invoices-table th { background: #1b4a6e !important; color: white !important; padding: 14px 10px; font-weight: 600; border-bottom: 1px solid #e2e8f0; text-align: center; }
        .invoices-table td { padding: 12px 10px; border-bottom: 1px solid #f0f4f9; text-align: center; vertical-align: middle; cursor: pointer; }
        .invoices-table tr:hover td { background-color: #fafcff; }
        .create-btn { background: #1b4a6e !important; color: white !important; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .create-btn:hover { background: #0f3a57 !important; }
        .status-published { background: #d1fae5; color: #065f46; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .status-rejected { background: #fee2e2; color: #b91c1c; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .status-pending-faktura { background: #fef3c7; color: #b45309; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .branch-badge { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 0.65rem; background: #e0e7ff; color: #3730a3; }
        .faktura-id-badge { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 0.65rem; font-family: monospace; background: #f1f5f9; }
        .faktura-id-linked { background: #dcfce7; color: #15803d; }
        .faktura-id-missing { background: #fef3c7; color: #b45309; }
        .invoice-actions-cell { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
        .btn-table { padding: 6px 10px; border-radius: 20px; font-size: 0.65rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
        .btn-edit-table { background: #fef3c7; color: #b45309; }
        .btn-delete-table { background: #fee2e2; color: #dc2626; }
        .btn-send-table { background: #dbeafe; color: #1d4ed8; }
        .btn-id-table { background: #fef3c7; color: #b45309; }
        .btn-id-linked-table { background: #dbeafe; color: #1d4ed8; }
        .btn-table:hover { opacity: 0.8; transform: scale(1.02); }
        .faktura-status-select { padding: 6px 10px; border-radius: 20px; border: 1px solid #dce3ec; background: white; font-size: 0.7rem; font-weight: 600; cursor: pointer; font-family: inherit; }
        .pagination-controls { display: flex; justify-content: center; gap: 10px; margin-top: 20px; align-items: center; }
        .invoice-horizontal-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 2000; justify-content: center; align-items: center; }
        .invoice-horizontal-content { background: white; border-radius: 24px; width: 95%; max-width: 1600px; height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
        .invoice-horizontal-header { padding: 20px 28px; background: #1b4a6e; color: white; display: flex; justify-content: space-between; align-items: center; border-radius: 24px 24px 0 0; }
        .invoice-horizontal-body { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 24px; }
        .invoice-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
        .invoice-info-card { background: white; border: 1px solid #e2e8f0; border-radius: 20px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); margin-bottom: 20px; }
        .invoice-info-card h3 { background: #f8fafc; margin: -20px -20px 20px -20px; padding: 15px 20px; border-bottom: 2px solid #ffb347; border-radius: 20px 20px 0 0; color: #1b4a6e; font-size: 1rem; }
        .invoice-detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f0f4f9; }
        .invoice-detail-label { width: 35%; font-weight: 600; color: #5b6e8c; font-size: 0.8rem; }
        .invoice-detail-value { width: 65%; color: #1e293b; font-weight: 500; font-size: 0.85rem; }
        .invoice-items-table-wrapper { overflow-x: auto; border-radius: 16px; border: 1px solid #e2e8f0; background: white; }
        .invoice-items-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
        .invoice-items-table th { background: #f1f5f9; padding: 12px 10px; text-align: center; font-weight: 600; }
        .invoice-items-table td { padding: 10px; text-align: center; border-bottom: 1px solid #e9edf2; }
        .invoice-items-table input { width: 100%; padding: 6px 8px; border: 1px solid #dce3ec; border-radius: 8px; font-size: 0.7rem; text-align: center; }
        .invoice-footer-buttons { display: flex; gap: 16px; justify-content: flex-end; margin-top: 20px; padding-top: 20px; border-top: 1px solid #e2e8f0; }
        .btn-send-faktura { background: #10b981; color: white; border: none; padding: 12px 28px; border-radius: 40px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; }
        .btn-send-faktura:hover { background: #059669; transform: translateY(-2px); }
        .invoice-footer-buttons .btn-secondary { background: #e2e8f0; color: #334155; border: none; padding: 12px 28px; border-radius: 40px; font-weight: 600; cursor: pointer; }
        .invoice-footer-buttons .btn-secondary:hover { background: #cbd5e1; transform: translateY(-2px); }
        .invoice-footer-buttons .btn-danger { background: #dc2626; color: white; border: none; padding: 12px 28px; border-radius: 40px; font-weight: 700; cursor: pointer; }
        .invoice-footer-buttons .btn-danger:hover { background: #b91c1c; transform: translateY(-2px); }
        .id-modal-content { max-width: 500px; }
        .info-card { background: #f8fafc; padding: 15px; border-radius: 16px; margin-bottom: 20px; }
        .info-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
        .info-label { color: #5b6e8c; }
        .info-value { font-weight: 600; color: #1e293b; }
        .invoice-form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
        .full-width-textarea { grid-column: span 4; }
        .modal-buttons-row { display: flex; gap: 15px; justify-content: flex-end; margin-top: 25px; }
        .btn-ecp { background: #f59e0b; color: white; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; margin-right: auto; }
        .btn-ecp:hover { background: #d97706; }
        .readonly-field { background: #f1f5f9; color: #334155; }
        .act-container { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
        .act-part { background: white; border: 1px solid #e2e8f0; border-radius: 20px; overflow: hidden; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
        .act-part h3 { background: #f8fafd; padding: 14px 20px; margin: 0; font-size: 0.95rem; font-weight: 600; color: #1b4a6e; border-bottom: 2px solid #ffb347; }
        .act-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; background: white; }
        .act-table th { background: #1b4a6e; color: white; padding: 10px 8px; font-weight: 600; text-align: center; border: 1px solid #2d5a7c; }
        .act-table td { padding: 8px 6px; text-align: center; border: 1px solid #e2e8f0; }
        .act-table tr:hover td { background: #f8fafc; }
        .act-total { background: #f1f5f9 !important; font-weight: 700; }
        .act-total td { background: #f1f5f9; }
        .print-btn button { background: #1b4a6e !important; color: white !important; border: none; padding: 10px 24px; border-radius: 40px; font-weight: 600; cursor: pointer; transition: all 0.2s; margin-top: 20px; }
        .print-btn button:hover { background: #0f3a57 !important; transform: translateY(-2px); }
        hr { margin: 20px 0; border-color: #e2e8f0; }
        .admin-user-list { margin-top: 20px; }
        .admin-user-item { background: #f8fafd; padding: 15px; border-radius: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
        .admin-role-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; }
        .role-admin { background: #dcfce7; color: #15803d; }
        .role-user { background: #e0e7ff; color: #3730a3; }
        .admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px; }
        .admin-stat-card { background: #f8fafc; padding: 15px; border-radius: 16px; text-align: center; }
        .btn-reset { background: #ef4444; color: white; border: none; padding: 8px 16px; border-radius: 40px; font-weight: 600; cursor: pointer; margin-left: 10px; }
        .btn-reset:hover { background: #dc2626; }
        .print-header { text-align: center; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid #1b4a6e; }
        .print-header h2 { color: #1b4a6e; font-size: 1.5rem; margin-bottom: 8px; }
        .print-header p { color: #5b6e8c; font-size: 0.85rem; }
        .signatures { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 20px; border-top: 1px solid #e2e8f0; }
        .signature-line { width: 45%; }
        .signature-line p { margin: 5px 0; color: #1e293b; }
        .signature-line p:first-child { font-weight: 600; color: #1b4a6e; }
        .print-footer { margin-top: 30px; text-align: center; font-size: 0.7rem; color: #94a3b8; border-top: 1px solid #e2e8f0; padding-top: 15px; }
        @media (max-width: 1024px) {
    .new-contract-page .top-fields {
        grid-template-columns: auto auto auto;
    }
}
        @media (max-width: 768px) { .invoice-two-columns { grid-template-columns: 1fr !important; gap: 20px !important; } .signatures { flex-direction: column; gap: 20px; } .signature-line { width: 100%; } .act-container { grid-template-columns: 1fr !important; } .form-row { grid-template-columns: 1fr; } .invoice-form-row { grid-template-columns: 1fr 1fr; } .full-width-textarea { grid-column: span 2; } .main-menu { border-radius: 20px; padding: 12px 16px; } .menu-item { padding: 6px 12px; font-size: 0.7rem; } .menu-item:not(:last-child)::after { display: none; } .filter-row { flex-direction: column; } .filter-group { min-width: 100%; } .filter-buttons { justify-content: center; } .detail-container { padding: 16px; } .stats-cards { grid-template-columns: repeat(2, 1fr); } }
        @media (max-width: 480px) { .invoice-form-row { grid-template-columns: 1fr; } .full-width-textarea { grid-column: span 1; } .tabs { overflow-x: auto; flex-wrap: nowrap; padding: 4px 8px; } .tab-btn { padding: 8px 14px; font-size: 0.7rem; white-space: nowrap; } .stats-cards { grid-template-columns: 1fr 1fr; gap: 8px; } .stat-card .stat-number { font-size: 1.2rem; } .stat-card { padding: 12px 10px; } }
        .admin-layout { display: flex; gap: 24px; background: white; border-radius: 24px; padding: 0; overflow: hidden; border: 1px solid #eef2f8; }
        .admin-sidebar { width: 240px; background: #f8fafc; padding: 20px 0; flex-shrink: 0; border-right: 1px solid #eef2f8; display: flex; flex-direction: column; gap: 4px; }
        .admin-sidebar-btn { background: transparent; border: none; padding: 12px 24px; text-align: left; font-weight: 500; font-size: 0.85rem; color: #5b6e8c; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 12px; border-left: 3px solid transparent; width: 100%; }
        .admin-sidebar-btn i { width: 20px; text-align: center; font-size: 1rem; color: #94a3b8; }
        .admin-sidebar-btn:hover { background: #f1f5f9; color: #1e293b; }
        .admin-sidebar-btn:hover i { color: #1b4a6e; }
        .admin-sidebar-btn.active { background: #f1f5f9; color: #1b4a6e; font-weight: 600; border-left-color: #ffb347; }
        .admin-sidebar-btn.active i { color: #ffb347; }
        .admin-content-area { flex: 1; padding: 24px 28px; min-height: 500px; background: white; }
        .admin-content-area h3 { color: #1b4a6e; margin-bottom: 20px; font-size: 1.1rem; }
        .admin-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px; }
        .admin-section { display: none; }
        .admin-section.active { display: block; }
        @media (max-width: 768px) { .admin-layout { flex-direction: column; } .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid #eef2f8; flex-direction: row; flex-wrap: wrap; padding: 10px; gap: 4px; } .admin-sidebar-btn { padding: 8px 14px; border-left: none; border-bottom: 3px solid transparent; width: auto; flex: 1 0 auto; justify-content: center; font-size: 0.75rem; } .admin-sidebar-btn.active { border-left: none; border-bottom-color: #ffb347; } .admin-content-area { padding: 16px; } .admin-stats-grid { grid-template-columns: 1fr 1fr; } }
        @media (max-width: 480px) { .admin-stats-grid { grid-template-columns: 1fr; } }
        .filter-panel.hidden { display: none !important; }
        #autoSaveIndicator { display: none !important; }

        .detail-right-panel { background: #f8fafd; border-radius: 16px; padding: 20px; margin-top: 20px; border: 1px solid #eef2f8; }
        .detail-right-panel h4 { color: #1b4a6e; margin-bottom: 15px; font-size: 0.9rem; }
        .detail-right-panel .detail-row { padding: 8px 0; }
        .detail-right-panel .detail-label { width: 40%; }
        .detail-right-panel .detail-value { width: 60%; }
        .contract-detail-layout { display: flex; flex-direction: column; gap: 20px; }
        .contract-detail-main { flex: 1; }
        .contract-detail-side { flex: 1; }
        @media (min-width: 992px) { .contract-detail-layout { flex-direction: row; } .contract-detail-main { flex: 2; } .contract-detail-side { flex: 1.2; } }
        
        .detail-action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0; padding-top: 0; }
        .detail-action-buttons .btn-sm { padding: 8px 16px; font-size: 0.7rem; border-radius: 30px; }
        .detail-action-buttons .btn-edit { background: #fef3c7; color: #b45309; border: none; }
        .detail-action-buttons .btn-suspend { background: #e0e7ff; color: #3730a3; border: none; }
        .detail-action-buttons .btn-delete { background: #fee2e2; color: #dc2626; border: none; }
        .detail-action-buttons .btn-pdf { background: #dbeafe; color: #1d4ed8; border: none; }
        .detail-action-buttons .btn-word { background: #fce7f3; color: #be185d; border: none; }
        .detail-action-buttons .btn-sm:hover { opacity: 0.85; transform: translateY(-1px); }
        
        .input-stir { letter-spacing: 1px; font-family: monospace; }
        .input-mfo { letter-spacing: 1px; font-family: monospace; }
        .btn-disabled { opacity: 0.5; pointer-events: none; cursor: not-allowed; }
        
        #contractModal .modal-content { max-width: 900px; }
        #contractModal .modal-header { border-radius: 32px 32px 0 0 !important; margin: -28px -30px 24px -30px !important; padding: 20px 28px !important; }
        #invoiceModal .modal-header { border-radius: 32px 32px 0 0 !important; margin: -28px -30px 24px -30px !important; padding: 20px 28px !important; }

        .stat-icon .fa-money-bill-wave,
        .stat-icon .fa-check-circle,
        .stat-icon .fa-exclamation-circle {
            margin: 0 2px;
        }
        .stat-icon .fa-money-bill-wave + .fa-check-circle,
        .stat-icon .fa-money-bill-wave + .fa-exclamation-circle {
            margin-left: 4px;
        }

        .invoice-stats-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; margin-top: 10px; }
        .invoice-stat-card { background: white; border-radius: 16px; padding: 16px 14px; text-align: center; border: 1px solid #eef2f8; box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: all 0.2s; }
        .invoice-stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .invoice-stat-card .stat-icon { font-size: 1.4rem; margin-bottom: 6px; display: block; color: #1b4a6e; }
        .invoice-stat-card .stat-number { font-size: 1.5rem; font-weight: 700; color: #1b4a6e; line-height: 1.2; }
        .invoice-stat-card .stat-label { font-size: 0.65rem; color: #5b6e8c; font-weight: 500; margin-top: 4px; }
        .invoice-stat-card.card-sent { border-top: 3px solid #3b82f6; }
        .invoice-stat-card.card-saved { border-top: 3px solid #8b5cf6 !important; }
        .invoice-stat-card.card-signed { border-top: 3px solid #10b981; }
        .invoice-stat-card.card-waiting { border-top: 3px solid #f59e0b; }
        .invoice-stat-card.card-rejected { border-top: 3px solid #ef4444; }

        .btn-sync-faktura { background: #8b5cf6; color: white; border: none; padding: 10px 24px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s; }
        .btn-sync-faktura:hover { background: #7c3aed; transform: translateY(-2px); }
        .btn-download-invoice { background: #10b981; color: white; border: none; padding: 10px 24px; border-radius: 40px; font-weight: 600; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s; }
        .btn-download-invoice:hover { background: #059669; transform: translateY(-2px); }

        .faktura-status-sent { background: #dbeafe; color: #1d4ed8; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .faktura-status-signed-supplier { background: #d1fae5; color: #065f46; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .faktura-status-signed-buyer { background: #dcfce7; color: #15803d; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .faktura-status-rejected { background: #fee2e2; color: #b91c1c; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }
        .faktura-status-draft { background: #f1f5f9; color: #5b6e8c; padding: 4px 10px; border-radius: 40px; display: inline-block; font-size: 0.7rem; font-weight: 600; }

        /* ===== НОВЫЕ СТИЛИ ДЛЯ КАРТОЧЕК ДОГОВОРОВ ===== */
        .contract-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 16px;
            padding: 4px 0;
        }
        .contract-card {
            background: white;
            border-radius: 16px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            border: 1px solid #eef2f8;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
        }
        .contract-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        }
        .contract-card .card-indicator {
            height: 4px;
            width: 100%;
            border-radius: 4px 4px 0 0;
            flex-shrink: 0;
        }
        .contract-card .card-indicator.blue { background: #3b82f6; }
        .contract-card .card-indicator.red { background: #ef4444; }
        .contract-card .card-indicator.purple { background: #8b5cf6; }
        .contract-card .card-indicator.yellow { background: #f59e0b; }
        .contract-card .card-indicator.gray { background: #94a3b8; }

        .contract-card .card-body {
            padding: 14px 16px 16px 16px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .contract-card .card-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 3px 0;
            border-bottom: 1px solid #f1f5f9;
        }
        .contract-card .card-row:last-child {
            border-bottom: none;
        }
        .contract-card .card-label {
            font-size: 0.65rem;
            font-weight: 600;
            color: #5b6e8c;
            text-transform: uppercase;
            letter-spacing: 0.3px;
            min-width: 80px;
            flex-shrink: 0;
        }
        .contract-card .card-value {
            font-size: 0.8rem;
            font-weight: 500;
            color: #1e293b;
            text-align: right;
            word-break: break-word;
        }
        .contract-card .card-value strong {
            font-weight: 700;
            color: #1b4a6e;
        }
        .contract-card .card-operator {
            font-size: 0.7rem;
            font-weight: 500;
            color: #1e293b;
            text-align: right;
            line-height: 1.3;
        }
        .contract-card .card-operator .fio-surname { font-weight: 600; }
        .contract-card .card-operator .fio-name { font-weight: 400; }
        .contract-card .card-operator .fio-patronymic { font-weight: 400; }

        .contract-card .card-date-block {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            font-size: 0.7rem;
            line-height: 1.4;
        }
        .contract-card .card-date-block .date-start { color: #1b4a6e; font-weight: 500; }
        .contract-card .card-date-block .date-end { color: #5b6e8c; }
        .contract-card .card-date-block .date-label { font-size: 0.55rem; color: #94a3b8; font-weight: 400; }

        .contract-card .card-status-badge {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 30px;
            font-size: 0.6rem;
            font-weight: 600;
            white-space: nowrap;
        }
        .contract-card .card-status-badge.status-active { background: #dcfce7; color: #15803d; }
        .contract-card .card-status-badge.status-expired { background: #fee2e2; color: #b91c1c; }
        .contract-card .card-status-badge.status-pending { background: #fef3c7; color: #b45309; }
        .contract-card .card-status-badge.status-suspended { background: #e0e7ff; color: #3730a3; }

        .contract-card .card-number {
            font-weight: 700;
            font-size: 0.85rem;
            color: #1b4a6e;
        }
        .contract-card .card-customer {
            font-weight: 500;
            font-size: 0.8rem;
            color: #1e293b;
        }
        .contract-card .card-stir {
            font-size: 0.7rem;
            color: #5b6e8c;
            font-family: monospace;
        }
        .contract-card .card-branch {
            font-size: 0.65rem;
            background: #e0e7ff;
            padding: 2px 8px;
            border-radius: 12px;
            color: #3730a3;
            display: inline-block;
        }
        .contract-card .card-amount {
            font-weight: 700;
            font-size: 0.9rem;
            color: #1b4a6e;
        }
        .contract-card .card-debt {
            font-size: 0.7rem;
            font-weight: 500;
        }

        /* ===== СТИЛИ ДЛЯ НОВОЙ СТРАНИЦЫ СОЗДАНИЯ ДОГОВОРА ===== */
        .new-contract-page {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f0f2f8;
            z-index: 99999;
            overflow-y: auto;
            padding: 24px;
        }
        .new-contract-page.active {
            display: block;
        }
        .new-contract-page .top-bar {
            background: white;
            border-radius: 20px;
            padding: 16px 28px;
            margin-bottom: 24px;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid #eef2f8;
            box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        }
        .new-contract-page .top-bar-title {
            font-size: 1.2rem;
            font-weight: 700;
            color: #1b4a6e;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .new-contract-page .top-bar-title i {
            color: #ffb347;
        }
        .new-contract-page .main-card {
            background: white;
            border-radius: 24px;
            padding: 32px 36px;
            border: 1px solid #eef2f8;
            box-shadow: 0 4px 16px rgba(0,0,0,0.04);
            max-width: 1400px;
            margin: 0 auto;
        }
        /* ===== ИЗМЕНЕНО: 5 полей в ряд (добавлен НОМЕР ДОГОВОРА) ===== */
        .new-contract-page .top-fields {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
            gap: 16px;
            margin-bottom: 16px;
        }
        .new-contract-page .field-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .new-contract-page .field-group label {
            font-size: 0.65rem;
            font-weight: 600;
            color: #5b6e8c;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .new-contract-page .field-group label i {
            font-size: 0.7rem;
            color: #94a3b8;
        }
        .new-contract-page .field-group select,
        .new-contract-page .field-group input {
            padding: 10px 14px;
            border: 1px solid #dce3ec;
            border-radius: 12px;
            font-size: 0.85rem;
            font-family: 'Inter', sans-serif;
            background: white;
            width: 100%;
            transition: all 0.2s;
        }
        .new-contract-page .field-group select:focus,
        .new-contract-page .field-group input:focus {
            border-color: #ffb347;
            box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
            outline: none;
        }
        .new-contract-page .divider-line {
            border: none;
            border-top: 2px dashed #dce3ec;
            margin: 16px 0;
        }
        .new-contract-page .total-block {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 14px 20px;
            background: #f8fafc;
            border-radius: 16px;
            border: 2px solid #ffb347;
            margin-bottom: 28px;
        }
        .new-contract-page .total-label {
            font-size: 0.9rem;
            font-weight: 700;
            color: #1b4a6e;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .new-contract-page .total-label i {
            color: #f59e0b;
            font-size: 1.2rem;
        }
        .new-contract-page .total-amount {
            font-size: 1.4rem;
            font-weight: 700;
            color: #1b4a6e;
        }
        .new-contract-page .two-columns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 40px;
            margin-top: 8px;
        }
        .new-contract-page .column-title {
            font-size: 0.85rem;
            font-weight: 700;
            color: #1b4a6e;
            margin-bottom: 16px;
            padding-bottom: 10px;
            border-bottom: 2px solid #f0f4f9;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .new-contract-page .column-title i {
            font-size: 1rem;
        }
        .new-contract-page .form-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
            margin-bottom: 14px;
        }
        .new-contract-page .form-row-three {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 16px;
            margin-bottom: 14px;
        }
        .new-contract-page .form-group {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .new-contract-page .form-group label {
            font-size: 0.7rem;
            font-weight: 600;
            color: #5b6e8c;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .new-contract-page .form-group label i {
            font-size: 0.7rem;
            color: #94a3b8;
        }
        .new-contract-page .form-group input,
        .new-contract-page .form-group select {
            padding: 10px 14px;
            border: 1px solid #dce3ec;
            border-radius: 12px;
            font-size: 0.85rem;
            font-family: 'Inter', sans-serif;
            background: white;
            width: 100%;
            transition: all 0.2s;
        }
        .new-contract-page .form-group input:focus,
        .new-contract-page .form-group select:focus {
            border-color: #ffb347;
            box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
            outline: none;
        }
        .new-contract-page .form-group input:disabled {
            background: #f1f5f9;
            color: #5b6e8c;
        }
        .new-contract-page .input-stir {
            letter-spacing: 1px;
            font-family: monospace;
        }
        .new-contract-page .input-mfo {
            letter-spacing: 1px;
            font-family: monospace;
        }
        .new-contract-page .required {
            color: #dc2626;
            margin-left: 2px;
        }
        .new-contract-page .bottom-buttons {
            display: flex;
            justify-content: flex-end;
            gap: 16px;
            margin-top: 28px;
            padding-top: 18px;
            border-top: 2px solid #f0f4f9;
        }
        .new-contract-page .btn-cancel {
            background: #e2e8f0;
            color: #334155;
            border: none;
            padding: 12px 32px;
            border-radius: 40px;
            font-weight: 600;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .new-contract-page .btn-cancel:hover {
            background: #cbd5e1;
            transform: translateY(-2px);
        }
        .new-contract-page .btn-save {
            background: #10b981;
            color: white;
            border: none;
            padding: 12px 32px;
            border-radius: 40px;
            font-weight: 600;
            font-size: 0.85rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.2s;
        }
        .new-contract-page .btn-save:hover {
            background: #059669;
            transform: translateY(-2px);
            box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
        }
        @media (max-width: 1024px) {
            .new-contract-page .top-fields {
                grid-template-columns: 1fr 1fr 1fr;
            }
            .new-contract-page .two-columns {
                grid-template-columns: 1fr;
            }
        }
        @media (max-width: 768px) {
    .new-contract-page .top-fields {
        grid-template-columns: auto auto;
    }
            .new-contract-page .form-row {
                grid-template-columns: 1fr;
            }
            .new-contract-page .form-row-three {
                grid-template-columns: 1fr;
            }
            .new-contract-page .main-card {
                padding: 20px;
            }
            .new-contract-page .total-block {
                flex-direction: column;
                gap: 8px;
                text-align: center;
            }
            .new-contract-page .bottom-buttons {
                flex-direction: column-reverse;
            }
            .new-contract-page .bottom-buttons button {
                width: 100%;
                justify-content: center;
            }
        }
        @media (max-width: 480px) {
    .new-contract-page .top-fields {
        grid-template-columns: auto;
    }
        }

        .sticky-header {
    background: #f0f2f8 !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}
        .sticky-header .stats-cards {
            margin-bottom: 4px;
            margin-top: 4px;
        }
        .sticky-header .stats-header {
            margin-bottom: 0;
        }
        .sticky-header .stat-card {
            padding: 12px 12px;
        }
        .sticky-header .stat-card .stat-number {
            font-size: 1.3rem;
        }
        @media (max-width: 768px) {
            .sticky-header {
                position: sticky;
                top: 0;
                padding-top: 2px;
                padding-bottom: 2px;
            }
            .sticky-header .stats-cards {
                gap: 6px;
            }
            .sticky-header .stat-card {
                padding: 8px 6px;
            }
            .sticky-header .stat-card .stat-number {
                font-size: 1rem;
            }
            .sticky-header .stat-card .stat-label {
                font-size: 0.55rem;
            }
        }

        .main-menu {
    position: fixed !important;
    top: 0 !important;
    left: 20px !important;
    right: 20px !important;
    z-index: 1000 !important;
    background: #1b4a6e !important;
    border-radius: 60px !important;
    padding: 8px 24px !important;
    margin-bottom: 16px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 20px !important;
    border: 1px solid #eef2f8 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
}

#mainPage > .container {
    padding-top: var(--main-menu-height, 100px) !important;
}
        
        .sticky-header .stats-cards {
            margin-bottom: 4px !important;
            margin-top: 4px !important;
        }
        .sticky-header .stats-header {
            margin-bottom: 0 !important;
        }
        .sticky-header .stat-card {
            padding: 12px 12px !important;
        }
        .sticky-header .stat-card .stat-number {
            font-size: 1.3rem !important;
        }
        @media (max-width: 768px) {
            .main-menu {
                position: sticky !important;
                top: 0 !important;
                border-radius: 20px !important;
                padding: 12px 16px !important;
                margin-bottom: 10px !important;
            }
            .sticky-header {
                top: 70px !important;
                padding-top: 2px !important;
                padding-bottom: 2px !important;
            }
            .sticky-header .stats-cards {
                gap: 6px !important;
            }
            .sticky-header .stat-card {
                padding: 8px 6px !important;
            }
            .sticky-header .stat-card .stat-number {
                font-size: 1rem !important;
            }
            .sticky-header .stat-card .stat-label {
                font-size: 0.55rem !important;
            }
        }

        /* ===== НОВЫЕ СТИЛИ ДЛЯ ПРАВ ДОСТУПА ===== */
        .permission-group {
            background: #f8fafc;
            border-radius: 12px;
            padding: 15px;
            margin-bottom: 12px;
            border: 1px solid #eef2f8;
        }
        .permission-group h4 {
            color: #1b4a6e;
            margin-bottom: 10px;
            font-size: 0.85rem;
        }
        .permission-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 8px;
        }
        .permission-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.75rem;
            color: #1e293b;
        }
        .permission-item input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: #1b4a6e;
            cursor: pointer;
        }
        .permission-item label {
            cursor: pointer;
            font-weight: 400;
        }
        .permission-item.disabled {
            opacity: 0.5;
        }
        .permission-item.disabled input {
            pointer-events: none;
        }
        .permission-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 0.6rem;
            font-weight: 600;
            margin: 1px;
        }
        .permission-badge.green { background: #dcfce7; color: #15803d; }
        .permission-badge.red { background: #fee2e2; color: #dc2626; }
        .permission-badge.gray { background: #f1f5f9; color: #5b6e8c; }

        .permissions-popup {
            position: relative;
            display: inline-block;
            cursor: pointer;
        }
        .permissions-popup .permissions-tooltip {
            visibility: hidden;
            width: 300px;
            background: white;
            color: #1e293b;
            text-align: left;
            border-radius: 12px;
            padding: 12px 16px;
            border: 1px solid #eef2f8;
            box-shadow: 0 8px 30px rgba(0,0,0,0.15);
            position: absolute;
            z-index: 1000;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 0.7rem;
            line-height: 1.6;
        }
        .permissions-popup:hover .permissions-tooltip {
            visibility: visible;
            opacity: 1;
        }
        .permissions-tooltip .perm-item {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 12px;
            margin: 2px;
            font-size: 0.6rem;
            background: #f1f5f9;
            color: #1e293b;
        }
        .permissions-tooltip .perm-item.granted {
            background: #dcfce7;
            color: #15803d;
        }
        .permissions-tooltip .perm-item.denied {
            background: #fee2e2;
            color: #dc2626;
            opacity: 0.5;
        }

        /* ===== ДОБАВЛЕН СТИЛЬ ДЛЯ МОДАЛЬНОГО ОКНА КАРТОЧКИ ===== */
        .contract-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.6);
            z-index: 10000;
            justify-content: center;
            align-items: center;
            padding: 20px;
            box-sizing: border-box;
            overflow-y: auto;
        }
        .contract-modal-overlay.active {
            display: flex;
        }
        .contract-modal-box {
            background: white;
            border-radius: 24px;
            width: 100%;
            max-width: 1400px;
            max-height: 90vh;
            overflow-y: auto;
            padding: 30px 32px;
            box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
            position: relative;
        }
        .contract-modal-box .close-modal-btn {
            position: sticky;
            top: 0;
            float: right;
            background: none;
            border: none;
            font-size: 28px;
            cursor: pointer;
            color: #94a3b8;
            z-index: 10;
            padding: 0 0 0 20px;
            line-height: 1;
        }
        .contract-modal-box .close-modal-btn:hover {
            color: #1e293b;
        }
        .contract-modal-box .modal-two-columns {
            display: flex;
            gap: 30px;
            flex-wrap: wrap;
            margin-top: 10px;
        }
        .contract-modal-box .modal-left {
            flex: 35;
            min-width: 300px;
        }
        .contract-modal-box .modal-right {
            flex: 65;
            min-width: 280px;
        }
        /* Стили для содержимого внутри модального окна — такие же как в оригинале */
        .contract-modal-box .contract-info-block {
            background: #f8fafd;
            border-radius: 16px;
            padding: 20px;
            border: 1px solid #eef2f8;
        }
        .contract-modal-box .contract-side-block {
            background: #f8fafd;
            border-radius: 16px;
            padding: 20px;
            border: 1px solid #eef2f8;
        }
        /* Адаптация */
        @media (max-width: 768px) {
            .contract-modal-box .modal-two-columns {
                flex-direction: column;
            }
            .contract-modal-box .modal-left,
            .contract-modal-box .modal-right {
                flex: 1 1 100%;
                min-width: 0;
            }
            .contract-modal-box {
                padding: 20px 16px;
            }
        }
                                /* ===== НОВЫЕ СТИЛИ ДЛЯ ПОЛЕЙ ПОСТАВЩИКА ===== */
        /* ===== КАЖДОЕ ПОЛЕ ПОДСТРАИВАЕТСЯ ПОД СОДЕРЖИМОЕ ===== */
        .new-contract-page .supplier-field-group {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
            flex: 1 1 auto;
        }
        .new-contract-page .supplier-field-group label {
            font-size: 0.65rem;
            font-weight: 600;
            color: #5b6e8c;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .new-contract-page .supplier-field-group input {
            padding: 10px 14px;
            border: 1px solid #dce3ec;
            border-radius: 12px;
            font-size: 0.85rem;
            font-family: 'Inter', sans-serif;
            background: #f1f5f9;
            width: auto;
            min-width: 60px;
            max-width: 100%;
            box-sizing: border-box;
            transition: all 0.2s;
            height: auto;
            min-height: 44px;
            max-height: none;
            line-height: 1.4;
            word-wrap: break-word;
            word-break: break-word;
            overflow-wrap: break-word;
            white-space: normal;
            display: inline-block;
            flex: 0 1 auto;
        }
        .new-contract-page .supplier-field-group input:focus {
            border-color: #ffb347;
            box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15);
            outline: none;
        }
                /* ===== ДЛЯ DISABLED ПОЛЕЙ (НЕ МЕНЯЕМ) ===== */
        .new-contract-page .supplier-field-group input[disabled] {
            background: #f1f5f9;
            color: #1e293b;
            cursor: default;
            opacity: 1;
            -webkit-text-fill-color: #1e293b;
        }

        /* ===== НОВЫЕ ПРАВИЛА ДЛЯ ПОЛЕЙ, ЧТОБЫ ОНИ ПОДСТРАИВАЛИСЬ ПОД ТЕКСТ ===== */

/* 1. САМИ ПОЛЯ ВВОДА */
.new-contract-page .supplier-field-group input {
    width: auto;
    min-width: 80px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border: 1px solid #dce3ec;
    border-radius: 12px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    background: #f1f5f9;
    height: auto;
    min-height: 44px;
    line-height: 1.4;
    transition: all 0.2s;
    white-space: normal;
    word-wrap: break-word;
}

/* 2. КОНТЕЙНЕР ДЛЯ ПОЛЯ */
.new-contract-page .supplier-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

/* 3. ПОДПИСИ К ПОЛЯМ */
.new-contract-page .supplier-field-group label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #5b6e8c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ===== СЕТКА ДЛЯ ПОЛЕЙ ===== */
.new-contract-page .supplier-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 14px;
    width: 100%;
}

/* ===== 3 КОЛОНКИ ===== */
.new-contract-page .supplier-grid-3 {
    grid-template-columns: auto auto auto;
}

/* ===== 4 КОЛОНКИ ===== */
.new-contract-page .supplier-grid-4 {
    grid-template-columns: auto auto auto auto;
}

/* ===== ИНДИВИДУАЛЬНЫЕ РАЗМЕРЫ ДЛЯ КАЖДОГО ПОЛЯ ===== */

/* 1. Поле "Наименование организации" */
.new-contract-page .supplier-field-group input#newSupplierName {
    min-width: 200px;
    max-width: 600px;
}

/* 2. Поле "Директор" */
.new-contract-page .supplier-field-group input#newSupplierDirector {
    min-width: 200px;
    max-width: 600px;
}

/* 3. Поле "На основание" */
.new-contract-page .supplier-field-group input#newSupplierBasis {
    min-width: 60px;
    max-width: 80px;
}

/* 4. Поле "ИНН" */
.new-contract-page .supplier-field-group input#newSupplierInn {
    min-width: 70px;
    max-width: 105px;
}

/* 5. Поле "Юридический адрес" */
.new-contract-page .supplier-field-group input#newSupplierAddress {
    min-width: 250px;
    max-width: 800px;
}

/* 6. Поле "Телефон" */
.new-contract-page .supplier-field-group input#newSupplierPhone {
    min-width: 100px;
    max-width: 130px;
}

/* 7. Поле "Банковский счёт" */
.new-contract-page .supplier-field-group input#newSupplierBankAccount {
    min-width: 200px;
    max-width: 500px;
}

/* 8. Поле "Рег. номер НДС" */
.new-contract-page .supplier-field-group input#newSupplierVatNumber {
    min-width: 130px;
    max-width: 130px;
}

/* 9. Поле "ОКЭД" */
.new-contract-page .supplier-field-group input#newSupplierOked {
    min-width: 100px;
    max-width: 100px;
}

/* 10. Поле "МФО банка" */
.new-contract-page .supplier-field-group input#newSupplierMfo {
    min-width: 100px;
    max-width: 100px;
}

/* ===== АДАПТАЦИЯ ДЛЯ МАЛЕНЬКИХ ЭКРАНОВ ===== */
@media (max-width: 768px) {
    .new-contract-page .supplier-grid-3 {
        grid-template-columns: minmax(60px, auto) minmax(60px, auto);
    }
    .new-contract-page .supplier-grid-4 {
        grid-template-columns: minmax(60px, auto) minmax(60px, auto);
    }
    
    /* ===== АДАПТИВНЫЙ ЛОГОТИП ===== */
    .logo-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.5rem !important;
        border-radius: 10px !important;
    }
    .logo-icon img {
        width: 40px !important;
        height: 40px !important;
        border-radius: 10px !important;
    }
    .logo-text h2 {
        font-size: 0.8rem !important;
    }
    .logo-text p {
        font-size: 0.5rem !important;
    }
    .logo-area {
        gap: 6px !important;
    }
    .main-menu {
        padding: 6px 12px !important;
        gap: 10px !important;
    }
}

@media (max-width: 480px) {
    .new-contract-page .supplier-grid-3 {
        grid-template-columns: minmax(60px, auto);
    }
    .new-contract-page .supplier-grid-4 {
        grid-template-columns: minmax(60px, auto);
    }
    
    /* ===== АДАПТИВНЫЙ ЛОГОТИП (ТЕЛЕФОНЫ) ===== */
    .logo-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.2rem !important;
        border-radius: 8px !important;
    }
    .logo-icon img {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
    }
    .logo-text h2 {
        font-size: 0.7rem !important;
    }
    .logo-text p {
        font-size: 0.45rem !important;
    }
    .logo-area {
        gap: 4px !important;
    }
    .main-menu {
        padding: 4px 8px !important;
        gap: 6px !important;
    }
}

        /* ===== СКРЫВАЕМ КОНТЕНТ ДО ЗАГРУЗКИ ===== */
        #mainPage {
            opacity: 0;
            transition: opacity 0.1s ease;
        }
        #mainPage.visible {
            opacity: 1;
        }


/* ===== ЛИЧНЫЙ ПРОФИЛЬ ===== */
.profile-modal-overlay{position:fixed;inset:0;z-index:10000;background:rgba(15,23,42,.55);backdrop-filter:blur(5px);display:flex;align-items:center;justify-content:center;padding:20px;overflow:auto}
.profile-modal{width:min(620px,100%);max-height:calc(100vh - 40px);overflow:auto;background:#fff;border:1px solid #e7edf5;border-radius:28px;box-shadow:0 24px 80px rgba(15,23,42,.28);padding:28px;color:#1e293b;position:relative}
.profile-modal-close{position:absolute;right:18px;top:16px;width:38px;height:38px;border:0;border-radius:50%;background:#f1f5f9;color:#475569;font-size:25px;line-height:1;cursor:pointer}
.profile-modal-close:hover{background:#e2e8f0}
.profile-modal-header{display:flex;align-items:center;gap:18px;padding:4px 45px 24px 4px}
.profile-modal-header h2{margin:0 0 5px;font-size:1.25rem;color:#1b4a6e}
.profile-role{font-size:.82rem;color:#64748b;font-weight:600}
.profile-avatar-large{width:82px;height:82px;flex:none;border-radius:50%;overflow:hidden;background:linear-gradient(145deg,#eaf0f7,#dce5ef);display:flex;align-items:center;justify-content:center;color:#64748b;font-size:38px;border:4px solid #fff;box-shadow:0 6px 18px rgba(27,74,110,.12)}
.profile-avatar-large img{width:100%;height:100%;object-fit:cover;display:block}
.profile-section{border-top:1px solid #edf1f6;padding:20px 0 2px;margin-top:4px}
.profile-section-title{display:flex;align-items:center;gap:9px;color:#1b4a6e;font-weight:800;font-size:.92rem;margin-bottom:14px}
.profile-section-title i{color:#ffb347;width:18px;text-align:center}
.profile-avatar-actions{display:flex;gap:10px;flex-wrap:wrap}
.profile-action-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:42px;padding:10px 14px;border-radius:12px;border:1px solid #dce3ec;background:#f8fafc;color:#334155;font:600 .78rem Inter,sans-serif;cursor:pointer;transition:.2s}
.profile-upload-btn{background:#eef2ff;color:#3730a3;border-color:#dbe2ff}
.profile-delete-btn{background:#fff1f2;color:#dc2626;border-color:#fecdd3}
.profile-action-btn:disabled{opacity:.45;cursor:not-allowed;transform:none!important;filter:none!important}
.profile-hint{font-size:.72rem;color:#94a3b8;margin-top:9px}
.profile-field{margin-bottom:12px}
.profile-field label{display:block;font-size:.72rem;font-weight:700;color:#64748b;margin:0 0 6px}
.profile-field input{width:100%;padding:11px 13px;border:1px solid #dce3ec;border-radius:12px;background:#fff;color:#1e293b;font:500 .84rem Inter,sans-serif}
.profile-fields-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.profile-save-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:42px;padding:10px 17px;border:0;border-radius:12px;background:#1b4a6e;color:#fff;font:700 .8rem Inter,sans-serif;cursor:pointer;margin-top:2px}
.profile-save-btn:hover{background:#153b59}
.profile-save-btn:disabled{opacity:.6;cursor:wait;transform:none!important;filter:none!important}
.profile-save-btn.is-loading{cursor:wait}
@media(max-width:600px){
 .profile-modal-overlay{padding:10px;align-items:flex-start}
 .profile-modal{max-height:calc(100vh - 20px);border-radius:20px;padding:20px 16px}
 .profile-modal-header{gap:12px;padding-right:42px}
 .profile-avatar-large{width:68px;height:68px;font-size:30px}
 .profile-modal-header h2{font-size:1rem}
 .profile-fields-grid{grid-template-columns:1fr}
 .profile-avatar-actions{flex-direction:column}
 .profile-action-btn,.profile-save-btn{width:100%}
}

/* ===== PROFILE / USER MENU PREMIUM OVERRIDES ===== */
.user-menu-wrapper{position:relative}
.user-menu-btn{display:flex!important;align-items:center;gap:10px!important;min-height:46px!important;padding:5px 12px 5px 7px!important;border:1px solid rgba(255,255,255,.22)!important;border-radius:16px!important;background:rgba(255,255,255,.10)!important;box-shadow:0 8px 24px rgba(15,23,42,.12)!important;backdrop-filter:blur(10px)!important;transition:transform .2s,background .2s,box-shadow .2s!important}
.user-menu-btn:hover,.user-menu-btn.open{transform:translateY(-1px);background:rgba(255,255,255,.17)!important;box-shadow:0 10px 28px rgba(15,23,42,.18)!important}
#userAvatarWrap{width:36px!important;height:36px!important;border:2px solid #FFC928!important;box-shadow:0 3px 12px rgba(0,0,0,.14)}
#userAvatarWrap i{font-size:29px!important;color:#fff}
#userAvatarWrap img{width:100%;height:100%;object-fit:cover}
.user-name{font-weight:800!important;letter-spacing:.1px}
.user-dropdown{min-width:280px!important;padding:9px!important;border-radius:20px!important;border:1px solid #e8edf4!important;box-shadow:0 20px 55px rgba(15,23,42,.20)!important;background:rgba(255,255,255,.98)!important}
.user-dropdown.open{animation:profileDropIn .16s ease-out}
.user-dropdown .dropdown-item{border-radius:13px!important;margin:3px 0!important;min-height:44px!important;font-weight:700!important}
.user-dropdown .dropdown-item:hover{background:#f4f7fb!important;transform:translateX(2px)}
.user-dropdown .logout-item{color:#dc2626!important}
.user-dropdown .dropdown-divider{margin:8px 4px!important}
@keyframes profileDropIn{from{opacity:0;transform:translateY(-5px) scale(.985)}to{opacity:1;transform:none}}
.profile-modal-overlay{padding:14px!important;background:rgba(15,23,42,.62)!important;backdrop-filter:blur(9px)!important}
.profile-modal{width:min(680px,100%)!important;border-radius:30px!important;padding:30px!important;background:linear-gradient(180deg,#fff 0%,#fbfdff 100%)!important;box-shadow:0 30px 100px rgba(15,23,42,.32)!important}
/* жёлтая полоска сверху — как у поискового блока на главной */
.profile-modal{border-top:4px solid #ffb347!important}
.profile-modal-header{padding:3px 48px 24px 3px!important}
.profile-avatar-large{width:96px!important;height:96px!important;border-radius:28px!important;border:2px solid #FFC928!important;box-shadow:0 12px 30px rgba(27,74,110,.16)!important;background:linear-gradient(145deg,#edf4fb,#dfe9f4)!important}
.profile-modal-header h2{font-size:1.45rem!important;font-weight:850!important}
.profile-role{display:inline-flex!important;padding:5px 9px!important;border-radius:999px!important;background:#f1f5f9!important}
.profile-section{padding:22px 0 5px!important}
.profile-field input{min-height:46px!important;border-radius:14px!important;background:#f8fafc!important}
.profile-field input:focus{outline:none!important;background:#fff!important;border-color:#8aa9c2!important;box-shadow:0 0 0 4px rgba(27,74,110,.08)!important}
.profile-action-btn{min-height:44px!important;border-radius:13px!important;font-weight:800!important;box-shadow:0 4px 12px rgba(15,23,42,.05)!important}
.profile-action-btn:hover:not(:disabled){transform:translateY(-1px)!important;box-shadow:0 7px 18px rgba(15,23,42,.10)!important}
.profile-upload-btn{background:#eef6ff!important;color:#1b4a6e!important}
.profile-delete-btn{background:#fff5f5!important}
.profile-modal-close{width:42px!important;height:42px!important;right:15px!important;top:14px!important;background:#f4f7fb!important}
@media(max-width:600px){
 .user-name{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 .user-dropdown{position:fixed!important;top:70px!important;right:10px!important;left:10px!important;min-width:0!important;width:auto!important}
 .profile-modal-overlay{align-items:flex-end!important;padding:0!important}
 .profile-modal{width:100%!important;max-height:92vh!important;border-radius:28px 28px 0 0!important;padding:22px 18px calc(22px + env(safe-area-inset-bottom))!important}
 .profile-modal-header{gap:14px!important;padding-right:44px!important}
 .profile-avatar-large{width:76px!important;height:76px!important;border-radius:22px!important}
 .profile-modal-header h2{font-size:1.18rem!important}
 .profile-avatar-actions{display:grid!important;grid-template-columns:1fr 1fr!important}
 .profile-action-btn{width:100%!important}
}

/* =========================================================
   ПОИСК ФАКТУР — СТИЛЬ ГЛАВНОГО ОКНА
   ========================================================= */

.invoice-search-panel {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-top: 3px solid #ffb347 !important;
    border-radius: 18px;
    padding: 18px 20px;
    margin: 0 0 20px 0;
    box-shadow: 0 3px 12px rgba(27, 74, 110, 0.05);

    position: sticky !important;
    top: calc(var(--main-menu-height, 100px) - 35px) !important;
    z-index: 900 !important;
}

.invoice-search-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf1f7;
}

.invoice-search-title > div {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1b4a6e;
    font-size: 0.88rem;
    font-weight: 700;
}

.invoice-search-title > div i {
    font-size: 0.9rem;
}

.invoice-search-hint {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 500;
}

/* ===== ВСЕ 6 ПОЛЕЙ В ОДИН РЯД ===== */

.invoice-search-grid {
    display: grid;
    grid-template-columns:
        1fr
        1fr
        1fr
        1fr
        1fr
        1fr;
    gap: 10px;
}

.invoice-search-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.invoice-search-field label {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
    color: #52657d;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.invoice-search-field label i {
    color: #1b4a6e;
    font-size: 0.68rem;
}

/* ===== ПОЛЯ ===== */

.invoice-search-field input,
.invoice-search-field select {
    width: 100%;
    height: 38px;
    box-sizing: border-box;
    border: 1px solid #dfe6ef;
    border-radius: 10px;
    background: #fafdff;
    color: #26384d;
    padding: 0 10px;
    font-size: 0.70rem;
    font-family: inherit;
    outline: none;
    transition: all 0.18s ease;
}

.invoice-search-field select {
    cursor: pointer;
}

.invoice-search-field input::placeholder {
    color: #a6b2c1;
}

.invoice-search-field input:hover,
.invoice-search-field select:hover {
    border-color: #c5d2e0;
    background: #ffffff;
}

.invoice-search-field input:focus,
.invoice-search-field select:focus {
    border-color: #1b4a6e;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(27, 74, 110, 0.07);
}

/* ===== ВЫПАДАЮЩИЙ ПОИСК «ТИП ПРОДУКТА» (АНАЛИТИКА) ===== */

.analytics-producttype {
    position: relative;
    display: flex;
    align-items: center;
}

.analytics-producttype input {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 34px;
}

.analytics-producttype-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #52657d;
    font-size: 0.66rem;
    cursor: pointer;
}

.analytics-producttype-toggle:hover {
    background: #eef4fb;
    color: #1b4a6e;
}

.analytics-producttype-list {
    position: absolute;
    z-index: 60;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    background: #ffffff;
    border: 1px solid #dfe6ef;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(27, 74, 110, 0.16);
}

.analytics-producttype-list[hidden] {
    display: none;
}

.analytics-producttype-option {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.70rem;
    color: #26384d;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-producttype-option:hover,
.analytics-producttype-option.is-active {
    background: #eef4fb;
    color: #1b4a6e;
    font-weight: 700;
}

.analytics-producttype-option.is-selected {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 700;
}

.analytics-producttype-option.is-message {
    color: #94a3b8;
    font-style: italic;
    cursor: default;
}

.analytics-producttype-option.is-message:hover {
    background: transparent;
    color: #94a3b8;
    font-weight: 400;
}

/* ===== КНОПКИ ===== */

.invoice-search-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #edf1f7;
}

.invoice-search-btn,
.invoice-clear-btn {
    height: 38px;
    padding: 0 18px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 0.18s ease;
}

.invoice-search-btn {
    background: #1b4a6e;
    color: #ffffff;
    border: 1px solid #1b4a6e;
    box-shadow: 0 3px 8px rgba(27, 74, 110, 0.14);
}

.invoice-search-btn:hover {
    background: #163e5d;
    border-color: #163e5d;
    transform: translateY(-1px);
}

.invoice-clear-btn {
    background: #f5f7fa;
    color: #52657d;
    border: 1px solid #dfe6ef;
}

.invoice-clear-btn:hover {
    background: #edf2f7;
    color: #1b4a6e;
}

/* ===== ИНФОРМАЦИЯ О РЕЗУЛЬТАТАХ ===== */

.invoice-search-result-info {
    display: none;
    margin-top: 10px;
    padding: 8px 11px;
    border-radius: 9px;
    background: #f5f8fb;
    color: #5b6e8c;
    font-size: 0.68rem;
    font-weight: 600;
}

.invoice-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding: 12px;
    border-top: 1px solid #edf1f7;
    color: #52657d;
    font-size: 0.72rem;
    font-weight: 600;
}

.invoice-pagination button {
    min-width: 100px;
    height: 36px;
}

.invoice-pagination button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .invoice-pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* =========================================================
   АДАПТИВНОСТЬ
   ========================================================= */

@media (max-width: 1250px) {
    .invoice-search-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {
    .invoice-search-panel {
        padding: 15px;
        border-radius: 16px;
    }

    .invoice-search-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .invoice-search-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .invoice-search-grid {
        grid-template-columns: 1fr;
    }

    .invoice-search-actions {
        flex-direction: column;
    }

    .invoice-search-btn,
    .invoice-clear-btn {
        width: 100%;
    }
}

/* ===== ЕДИНАЯ ШИРИНА ОСНОВНЫХ ВКЛАДОК ===== */
/* Вкладки находятся вне .container, поэтому
   выравниваем их по ширине рабочей области договоров. */

#invoiceContent,
#reportsContent,
#analyticsContent,
#adminContent,
#aboutContent,
#debtContent {
    width: calc(100% - 40px);
    margin-left: 20px;
    margin-right: 20px;
    box-sizing: border-box;
}

/* =========================================================
   РАЗДЕЛ УДАЛЕНО — только собственные классы с префиксом deleted-
   (глобальные styles других разделов не переопределяются)
   ========================================================= */
.deleted-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
}
.deleted-row-actions .btn-sm {
    padding: 4px 10px;
    font-size: 0.62rem;
    border-radius: 20px;
    white-space: nowrap;
}
.deleted-reason-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.66rem;
    text-decoration: none;
    max-width: 180px;
}
.deleted-reason-link:hover { text-decoration: underline; }
.deleted-action-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #b45309;
    border-radius: 14px;
    padding: 12px 15px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.deleted-action-contract {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #f8fafd;
    border: 1px solid #eef2f8;
    border-radius: 14px;
    padding: 12px 15px;
    margin-bottom: 14px;
}
.deleted-action-cell span {
    display: block;
    color: #94a3b8;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.deleted-action-cell strong {
    display: block;
    margin-top: 2px;
    color: #26384d;
    font-size: 0.78rem;
    font-weight: 700;
    word-break: break-word;
}
.deleted-action-note {
    grid-column: 1 / -1;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    color: #1e40af;
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 0.68rem;
    font-weight: 600;
}
.deleted-action-error {
    margin: 4px 0 12px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.72rem;
    font-weight: 600;
}
.deleted-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}
.deleted-history-item {
    background: #f8fafd;
    border: 1px solid #eef2f8;
    border-left: 3px solid #1b4a6e;
    border-radius: 12px;
    padding: 12px 14px;
}
.deleted-history-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.deleted-history-action {
    font-weight: 800;
    color: #1b4a6e;
    font-size: 0.78rem;
}
.deleted-history-state {
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.64rem;
    font-weight: 700;
}
.deleted-history-date {
    margin-left: auto;
    color: #94a3b8;
    font-size: 0.66rem;
    font-weight: 600;
}
.deleted-history-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #475569;
    font-size: 0.72rem;
}
.deleted-history-body span { color: #94a3b8; font-weight: 600; }
.deleted-history-pdf a { color: #dc2626; font-weight: 700; text-decoration: none; }
.deleted-history-pdf a:hover { text-decoration: underline; }
@media (max-width: 600px) {
    .deleted-action-contract { grid-template-columns: 1fr; }
    .deleted-history-date { margin-left: 0; }
}
#deletedActionModal .modal-content { max-width: 640px; }
#contractHistoryModal .modal-content { max-width: 820px; }

/* =========================================================
   БУХГАЛТЕРИЯ — локальные правки (только #reportsContent)
   Форма добавления платежа использует стиль
   .invoice-search-panel, но не должна «прилипать» к меню.
   ========================================================= */
#reportsContent #paymentFormContainer {
    position: static !important;
    margin-bottom: 20px;
}

/* =========================================================
   АНАЛИТИКА — дополнительная визуальная подача ВНУТРИ
   существующего дизайна. Все правила scoped под #analyticsContent
   и не влияют на ГЛАВНУЮ, СЧЕТ-ФАКТУРУ, ЗАДОЛЖЕННОСТЬ и БУХГАЛТЕРИЮ.
   Базовые блоки (карточки, поиск, таблицы, кнопки) берутся из
   уже существующих классов .invoice-* / .filter-buttons / .stats-header.
   ========================================================= */
/* ===== ФОН РАЗДЕЛА «АНАЛИТИКА» ===== */
/* Очень светлый голубовато-серый фон рабочей области: белые карточки
   читаются на нём как на образце. Только этот раздел, другие вкладки не трогаем. */
#analyticsContent {
    background: #f5f8fc;
    border-radius: 18px;
    padding: 16px;
}
#analyticsContent .analytics-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
#analyticsContent .analytics-level-badge {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border-radius: 40px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
#analyticsContent .analytics-generated {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.64rem;
}
#analyticsContent .analytics-kpi-grid {
    grid-template-columns: repeat(6, 1fr);
    margin-top: 18px;
}
#analyticsContent .analytics-kpi-change {
    margin-top: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #94a3b8;
    min-height: 13px;
}
#analyticsContent .analytics-kpi-change.up,
#analyticsContent .analytics-kpi-change .up { color: #15803d; }
#analyticsContent .analytics-kpi-change.down,
#analyticsContent .analytics-kpi-change .down { color: #b91c1c; }
#analyticsContent .analytics-kpi-change.same,
#analyticsContent .analytics-kpi-change .same { color: #94a3b8; }
#analyticsContent .analytics-kpi-change i { margin-right: 3px; }
#analyticsContent .analytics-card {
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid #eef2f8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 20px 22px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#analyticsContent .analytics-card-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #1b4a6e;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid #edf1f7;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
#analyticsContent .analytics-card-title i { font-size: 0.9rem; }
#analyticsContent .analytics-card-hint {
    margin-left: auto;
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.66rem;
}

#analyticsContent .analytics-two-col > * { min-width: 0; }
/* Внутренний контейнер графика: оставь над собой верхнюю часть карточки,
   график оказывается внизу, а заголовок остаётся вверху. */
#analyticsContent .analytics-card > .analytics-chart { margin-top: auto; }

/* ===== ШАПКА «ДИНАМИКА ПО ГОДАМ»: легенда + выбор периода =====
   Оба элемента перенесены сюда из тела графика: порядок в строке —
   заголовок → легенда → подсказка «организации · договоры · пользователи» →
   селектор. Цвета маркеров и связь серий сохранены. */
#analyticsContent .analytics-card-yearly {
    padding-top: 14px;
    padding-bottom: 14px;
}
#analyticsContent .analytics-card-yearly .analytics-card-title {
    flex-wrap: wrap;
    row-gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
}
#analyticsContent .analytics-yearly-legend {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.7rem;
    color: #475569;
    font-weight: 600;
}
#analyticsContent .analytics-yearly-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
#analyticsContent .analytics-yearly-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
#analyticsContent .analytics-yearly-period {
    padding: 6px 26px 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    min-width: 150px;
    appearance: auto;
}
#analyticsContent .analytics-yearly-period:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}
#analyticsContent .analytics-counter {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 40px;
    padding: 2px 12px;
    font-size: 0.66rem;
    font-weight: 700;
}
#analyticsContent .analytics-reset-btn {
    margin-left: auto;
    background: #f1f5f9;
    border: none;
    border-radius: 40px;
    padding: 5px 12px;
    font-size: 0.64rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
/* Нижний ряд: «ДИНАМИКА ТЕКУЩЕГО ГОДА» и «РЕГИОНЫ» — одинаковая ширина,
   одинаковая высота (align-items: stretch) и одинаковый промежуток.
   minmax(0, …) — чтобы широкое содержимое не вызывало горизонтальное
   переполнение; на узких экранах карточки встают друг под другом. */
#analyticsContent .analytics-two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}
#analyticsContent .analytics-two-col > * { min-width: 0; }
#analyticsContent .analytics-chart { display: flex; flex-direction: column; gap: 12px; }
#analyticsContent .analytics-empty {
    text-align: center;
    color: #94a3b8;
    padding: 26px 10px;
    font-size: 0.75rem;
}
#analyticsContent .analytics-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 160px;
    padding-top: 8px;
    overflow-x: auto;
}
#analyticsContent .analytics-bar-col {
    flex: 1;
    min-width: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}
#analyticsContent .analytics-bar-stack {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 118px;
    justify-content: center;
}
#analyticsContent .analytics-bar {
    width: 11px;
    border-radius: 5px 5px 0 0;
    background: #1b4a6e;
    min-height: 3px;
    transition: height 0.3s ease;
}
#analyticsContent .analytics-bar.org { background: #3b82f6; }
#analyticsContent .analytics-bar.contract { background: #1b4a6e; }
#analyticsContent .analytics-bar.user { background: #10b981; }
/* Серии «ДИНАМИКА ТЕКУЩЕГО ГОДА»: новые — синий, завершённые — зелёный,
   будущие месяцы приглушены через .future (светло-серый). */
#analyticsContent .analytics-bar.newc { background: #3b82f6; }
#analyticsContent .analytics-bar.ended { background: #10b981; }
#analyticsContent .analytics-bar-label {
    font-size: 0.6rem;
    color: #94a3b8;
    font-weight: 700;
    white-space: nowrap;
}
#analyticsContent .analytics-bar-value { font-size: 0.6rem; color: #334155; font-weight: 700; }
#analyticsContent .analytics-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.66rem;
    color: #52657d;
}
#analyticsContent .analytics-legend span { display: inline-flex; align-items: center; gap: 6px; }
#analyticsContent .analytics-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}
#analyticsContent .analytics-months {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
    align-items: end;
    min-height: 150px;
    /* тонкая осевая линия сетки */
    border-bottom: 1px solid #dbe3ec;
    padding-bottom: 4px;
}
#analyticsContent .analytics-month {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    min-width: 0;
}
#analyticsContent .analytics-month .pair {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 104px;
}
#analyticsContent .analytics-month .analytics-bar { width: 8px; }
/* Будущие месяцы — светло-серая серия (цвет совпадает с легендой). */
#analyticsContent .analytics-month.future .analytics-bar { background: #cbd5e1; }
#analyticsContent .analytics-month.future .analytics-bar-label { color: #94a3b8; }
#analyticsContent .analytics-month.now .analytics-bar-label { color: #1b4a6e; font-weight: 800; }
#analyticsContent .analytics-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}
/* Строка «РЕГИОНЫ»: название, отдельный ряд организаций, остальные метрики. */
#analyticsContent .analytics-breakdown-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    background: #f8fafd;
    border: 1px solid #eef2f8;
    border-radius: 12px;
    padding: 9px 12px;
    cursor: pointer;
    transition: background 0.15s;
}
#analyticsContent .analytics-breakdown-row:hover { background: #eef4fb; }
#analyticsContent .analytics-breakdown-name {
    font-weight: 700;
    color: #26384d;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#analyticsContent .analytics-breakdown-org {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    color: #52657d;
    font-weight: 600;
    white-space: nowrap;
}
#analyticsContent .analytics-breakdown-metrics {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
#analyticsContent .analytics-breakdown-name {
    min-width: 0;
    flex: 1 1 auto;
}
#analyticsContent .analytics-breakdown-metric { font-size: 0.66rem; color: #52657d; white-space: nowrap; }
#analyticsContent .analytics-breakdown-metric strong { color: #1b4a6e; }
#analyticsContent .analytics-deadline-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
#analyticsContent .analytics-deadline-card {
    border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid #eef2f8;
    background: #f8fafd;
    cursor: pointer;
    transition: all 0.2s;
}
#analyticsContent .analytics-deadline-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.07); }
#analyticsContent .analytics-deadline-card .num { font-size: 1.4rem; font-weight: 800; color: #1b4a6e; line-height: 1.1; }
#analyticsContent .analytics-deadline-card .lbl { font-size: 0.64rem; color: #5b6e8c; margin-top: 5px; font-weight: 600; }
#analyticsContent .analytics-deadline-card.d30 { border-top: 3px solid #f59e0b; }
#analyticsContent .analytics-deadline-card.d60 { border-top: 3px solid #fbbf24; }
#analyticsContent .analytics-deadline-card.d90 { border-top: 3px solid #facc15; }
#analyticsContent .analytics-deadline-card.ended { border-top: 3px solid #ef4444; }
#analyticsContent .analytics-deadline-card.needs_new { border-top: 3px solid #dc2626; }
#analyticsContent .analytics-deadline-card.covers_year { border-top: 3px solid #10b981; }
#analyticsContent .analytics-coverage-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
#analyticsContent .analytics-coverage-card {
    border-radius: 14px;
    padding: 16px;
    border: 1px solid #eef2f8;
    cursor: pointer;
    transition: all 0.2s;
}
#analyticsContent .analytics-coverage-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.07); }
#analyticsContent .analytics-coverage-card .num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
#analyticsContent .analytics-coverage-card .lbl { font-size: 0.66rem; margin-top: 6px; font-weight: 600; color: #52657d; }
#analyticsContent .analytics-coverage-card.covered { background: #f0fdf4; }
#analyticsContent .analytics-coverage-card.covered .num { color: #15803d; }
#analyticsContent .analytics-coverage-card.endingBeforeYearEnd { background: #fffbeb; }
#analyticsContent .analytics-coverage-card.endingBeforeYearEnd .num { color: #b45309; }
#analyticsContent .analytics-coverage-card.needsNew { background: #fef2f2; }
#analyticsContent .analytics-coverage-card.needsNew .num { color: #b91c1c; }
#analyticsContent .analytics-coverage-card.gap { background: #fff1f2; }
#analyticsContent .analytics-coverage-card.gap .num { color: #be123c; }
#analyticsContent .analytics-table-empty {
    text-align: center;
    padding: 30px 20px;
    color: #94a3b8;
    font-size: 0.75rem;
}
@media (max-width: 1100px) {
    #analyticsContent .analytics-kpi-grid { grid-template-columns: repeat(3, 1fr); }
    #analyticsContent .analytics-two-col { grid-template-columns: 1fr; }
    #analyticsContent .analytics-deadline-grid { grid-template-columns: repeat(2, 1fr); }
    #analyticsContent .analytics-coverage-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    #analyticsContent .analytics-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    #analyticsContent .analytics-months { grid-template-columns: repeat(6, 1fr); }
    #analyticsContent .analytics-deadline-grid,
    #analyticsContent .analytics-coverage-grid { grid-template-columns: 1fr; }
}


/* ===== PROFILE PANEL v2 — язык + аватар + ФИО (стиль сайта: navy #1b4a6e, радиусы 16–20, мягкие тени) ===== */
.profile-panel{display:flex;align-items:center;gap:10px;flex-shrink:0}
.profile-panel .lang-menu{position:relative;z-index:10000}
.profile-panel .lang-btn{display:flex;align-items:center;gap:8px;min-height:46px;padding:0 14px;border:1px solid rgba(255,255,255,.22);border-radius:16px;background:rgba(255,255,255,.10);color:#fff;font-family:'Inter',sans-serif;font-size:.8rem;font-weight:800;letter-spacing:.4px;cursor:pointer;box-shadow:0 8px 24px rgba(15,23,42,.12);backdrop-filter:blur(10px);transition:transform .2s,background .2s,box-shadow .2s}
.profile-panel .lang-btn:hover,.profile-panel .lang-btn[aria-expanded="true"]{transform:translateY(-1px);background:rgba(255,255,255,.17);box-shadow:0 10px 28px rgba(15,23,42,.18)}
.profile-panel .lang-btn .lang-arrow{font-size:.6rem;transition:transform .2s}
.profile-panel .lang-btn[aria-expanded="true"] .lang-arrow{transform:rotate(180deg)}
.lang-dropdown{display:none;position:absolute;right:0;top:calc(100% + 10px);min-width:230px;padding:8px;background:#fff;border:1px solid #e8edf4;border-radius:20px;box-shadow:0 20px 55px rgba(15,23,42,.20);z-index:10001}
.lang-dropdown.open{display:block;animation:profileDropIn .16s ease-out}
.lang-dropdown .lang-item{display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:6px 12px 6px 8px;margin:3px 0;border:0;border-radius:13px;background:transparent;color:#0f172a;font-family:'Inter',sans-serif;font-size:.85rem;font-weight:700;text-align:left;cursor:pointer;transition:background .15s,transform .15s}
.lang-dropdown .lang-item:hover{background:#f4f7fb;transform:translateX(2px)}
.lang-dropdown .lang-item.active{background:#eef5fb}
.lang-dropdown .lang-item .lc{display:inline-flex;align-items:center;justify-content:center;width:34px;height:30px;border-radius:10px;background:#1b4a6e;color:#fff;font-size:.68rem;font-weight:800;letter-spacing:.3px;flex:none}
.lang-dropdown .lang-item .ln{flex:1;color:#0f172a}


/* кнопка профиля */
.profile-panel .user-menu-btn{padding:5px 14px 5px 6px!important;gap:10px!important}
.profile-panel #userAvatarWrap{width:38px!important;height:38px!important;border:2px solid rgba(255,255,255,.55);background:rgba(255,255,255,.18)!important;box-shadow:0 4px 12px rgba(0,0,0,.18);font-size:1.25rem;color:#fff}
.user-menu-btn .user-text{display:flex;flex-direction:column;align-items:flex-start;line-height:1.15;min-width:0}
.user-menu-btn .user-name{font-size:.82rem}
.user-menu-btn .user-role{font-size:.62rem;font-weight:600;letter-spacing:.3px;color:rgba(255,255,255,.72);text-transform:uppercase;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.user-menu-btn .user-role:empty{display:none}

/* выпадающая карточка профиля */
.profile-panel .user-dropdown{min-width:300px!important;padding:0 0 9px!important;overflow:hidden}
.ud-head{display:flex;align-items:center;gap:14px;padding:18px 18px 16px;background:linear-gradient(135deg,#1b4a6e 0%,#0f3a57 100%);color:#fff}
.ud-avatar{display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:50%;overflow:hidden;border:3px solid #FFC928;background:rgba(255,255,255,.16);box-shadow:0 6px 18px rgba(0,0,0,.25);font-size:2rem;flex:none}
.ud-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.ud-meta{min-width:0;flex:1}
.ud-name{font-size:1rem;font-weight:800;line-height:1.25;word-break:break-word}
.ud-sub{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:6px}
.ud-role{display:inline-block;padding:2px 10px;border-radius:20px;background:rgba(255,255,255,.18);font-size:.65rem;font-weight:700;letter-spacing:.3px;text-transform:uppercase}
.ud-role:empty{display:none}
.ud-login{font-size:.72rem;color:rgba(255,255,255,.75)}
.ud-section{padding:12px 18px 4px;font-size:.62rem;font-weight:800;letter-spacing:.8px;text-transform:uppercase;color:#94a3b8}
.profile-panel .user-dropdown #yearDropdownItems,.profile-panel .user-dropdown>.dropdown-item,.profile-panel .user-dropdown>.dropdown-divider{margin-left:9px!important;margin-right:9px!important}
.profile-panel .user-dropdown .dropdown-item{color:#1e293b!important}
.profile-panel .user-dropdown .dropdown-item.logout-item{color:#dc2626!important}

/* список выбора языка на экране входа: чёрный текст на белом фоне */
select.lang-switcher option{color:#0f172a!important;background:#fff!important}
select.lang-switcher{color-scheme:light}

@media (max-width:768px){
  .profile-panel{gap:6px}
  .profile-panel .lang-btn{min-height:42px;padding:0 10px}
  .profile-panel .user-menu-btn .user-role{display:none}
  .profile-panel .user-menu-btn .user-name{max-width:90px}
  .profile-panel .user-menu-btn .user-arrow{margin-left:0}
  .lang-dropdown{position:fixed;top:70px;right:10px;left:10px;min-width:0}
  .profile-panel .user-dropdown{min-width:0!important}
}


/* ===== MODALS v2 — единый компактный стиль окон (как на сайте: navy #1b4a6e, радиус 16–22, мягкие тени) ===== */
.modal, .invoice-horizontal-modal, .contract-modal-overlay, .profile-modal-overlay {
  background: rgba(15,23,42,.55) !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
  box-sizing: border-box;
}
.modal { padding: 14px; }
.contract-modal-overlay { padding: 14px !important; }

/* обычные окна (.modal) */
.modal-content {
  width: min(540px, 94vw) !important; max-width: 540px !important; max-height: 86vh !important;
  padding: 0 18px 16px !important; border-radius: 20px !important; border: 1px solid #e8edf4;
  box-shadow: 0 24px 60px rgba(15,23,42,.35) !important; overflow-x: hidden;
  font-size: .88rem;
}
#invoiceModal .modal-content { width: min(760px, 95vw) !important; max-width: 760px !important; }
#contractModal .modal-content { width: min(640px, 95vw) !important; max-width: 640px !important; }
#contractHistoryModal .modal-content { width: min(620px, 95vw) !important; max-width: 620px !important; }
#deletedActionModal .modal-content { width: min(480px, 95vw) !important; max-width: 480px !important; }
.modal-content.id-modal-content { width: min(440px, 94vw) !important; max-width: 440px !important; }

.modal-header {
  display: flex !important; align-items: center !important; justify-content: space-between !important;
  margin: 0 -18px 14px -18px !important; padding: 12px 16px 12px 18px !important;
  background: linear-gradient(135deg, #1b4a6e 0%, #0f3a57 100%) !important;
  border-radius: 0 !important; border-bottom: 0 !important;
  border-top: 4px solid #ffb347 !important;
}
#invoiceModal .modal-header { margin: 0 -18px 14px -18px !important; padding: 12px 16px 12px 18px !important; border-radius: 0 !important; }
.modal-header h2 { margin: 0 !important; font-size: 1rem !important; font-weight: 800 !important; color: #fff !important; letter-spacing: .1px; display: flex; align-items: center; gap: 8px; }
.close-modal, .invoice-horizontal-header .close-modal {
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0 !important; border: 0 !important; border-radius: 50% !important;
  background: rgba(255,255,255,.15) !important; color: #fff !important; font-size: 20px !important; line-height: 1;
  cursor: pointer; transition: background .15s;
}
.close-modal:hover { background: rgba(255,255,255,.28) !important; }

.modal-content label { font-size: .7rem !important; font-weight: 700; color: #64748b; margin-bottom: 4px; }
.modal-content input:not([type="checkbox"]):not([type="radio"]),
.modal-content select, .modal-content textarea {
  padding: 8px 11px !important; font-size: .85rem !important; border-radius: 10px !important; border: 1px solid #dbe3ec;
  box-sizing: border-box; max-width: 100%;
}
.modal-content input:focus, .modal-content select:focus, .modal-content textarea:focus {
  outline: none; border-color: #1b4a6e; box-shadow: 0 0 0 3px rgba(27,74,110,.12);
}
.modal-content .form-group { margin-bottom: 10px !important; }
.modal-content .invoice-form-row { gap: 10px !important; }
.modal-buttons, .modal-buttons-row { gap: 8px !important; margin-top: 14px !important; }
.modal-buttons button, .modal-buttons-row button, .modal-content .btn-primary, .modal-content .btn-secondary {
  padding: 8px 16px !important; font-size: .8rem !important; border-radius: 10px !important;
}
.modal-content table { font-size: .8rem; }
.modal-content th, .modal-content td { padding: 6px 8px !important; }

/* карточка договора (быстрый просмотр) */
.contract-modal-box {
  max-width: 980px !important; max-height: 88vh !important; padding: 18px 20px !important;
  border-radius: 20px !important; border: 1px solid #e8edf4; box-shadow: 0 24px 60px rgba(15,23,42,.35) !important;
  border-top: 4px solid #ffb347 !important;
}
.contract-modal-box .close-modal-btn {
  position: sticky; float: right; top: 0; z-index: 5; width: 30px; height: 30px; margin: 0 0 6px 8px;
  display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%;
  background: #f1f5f9; color: #475569; font-size: 20px; line-height: 1; cursor: pointer;
}
.contract-modal-box .close-modal-btn:hover { background: #e2e8f0; color: #1e293b; }
.contract-modal-box .contract-in { padding: 14px !important; border-radius: 14px !important; }
.contract-modal-box .modal-two-columns { gap: 14px !important; }

/* горизонтальная фактура */
.invoice-horizontal-modal { padding: 14px; }
.invoice-horizontal-content { width: min(980px, 96vw) !important; max-width: 980px !important; height: auto !important; max-height: 88vh !important; border-radius: 20px !important; }
.invoice-horizontal-header { padding: 12px 16px 12px 18px !important; background: linear-gradient(135deg, #1b4a6e 0%, #0f3a57 100%) !important; border-radius: 0 !important; }
.invoice-horizontal-header h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.invoice-horizontal-body { padding: 14px 18px !important; gap: 14px !important; }

/* личный профиль */
.profile-modal-overlay { padding: 14px !important; align-items: center !important; }
.profile-modal-overlay .profile-modal {
  position: relative; width: min(430px, 100%) !important; max-width: 430px; max-height: calc(100vh - 28px) !important;
  overflow-y: auto; padding: 0 !important; border-radius: 22px !important; background: #fff;
  border: 1px solid #e8edf4; box-shadow: 0 28px 70px rgba(15,23,42,.38);
}
.profile-modal-overlay .profile-modal-header {
  display: flex; align-items: center; gap: 14px; margin: 0 !important; padding: 18px 54px 16px 20px !important;
  background: linear-gradient(135deg, #1b4a6e 0%, #0f3a57 100%); color: #fff;
}
.profile-modal-overlay .profile-avatar-large {
  width: 54px !important; height: 54px !important; flex: none; border-radius: 50% !important; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem;
  border: 3px solid rgba(255,255,255,.6); background: rgba(255,255,255,.16); box-shadow: 0 6px 18px rgba(0,0,0,.25); color: #fff;
}
.profile-modal-overlay .profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.profile-modal-overlay .profile-modal-header h2 { margin: 0 !important; font-size: 1.02rem !important; font-weight: 800 !important; color: #fff !important; line-height: 1.25; }
.profile-modal-overlay .profile-role {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 20px; background: rgba(255,255,255,.18);
  color: #94a3b8; font-size: .64rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.profile-modal-overlay .profile-modal-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-modal-overlay .profile-role-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.profile-modal-overlay .profile-role-line .profile-role { margin-top: 0 !important; }
.profile-modal-overlay .profile-avatar-toolbar { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.profile-modal-overlay .profile-avatar-toolbar .profile-avatar-icon-btn {
  width: 22px !important; height: 22px !important; min-height: 0 !important; padding: 0 !important;
  box-sizing: border-box !important; gap: 0 !important; border-radius: 7px !important;
  line-height: 1; box-shadow: none !important;
}
.profile-modal-overlay .profile-avatar-toolbar .profile-avatar-icon-btn i { font-size: .62rem !important; line-height: 1; }
.profile-modal-overlay .profile-modal-close {
  position: absolute !important; right: 12px !important; top: 12px !important; width: 30px !important; height: 30px !important;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.16) !important; color: #fff !important; font-size: 20px !important;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; cursor: pointer; z-index: 3;
}
.profile-modal-overlay .profile-modal-close:hover { background: rgba(255,255,255,.3) !important; }
.profile-modal-overlay .profile-section { margin: 0 !important; padding: 12px 20px 14px !important; border: 0 !important; border-bottom: 1px solid #eef2f8 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; }
.profile-modal-overlay .profile-section:last-child { border-bottom: 0 !important; }
.profile-modal-overlay .profile-section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 9px !important; font-size: .7rem !important; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #1b4a6e; }
.profile-modal-overlay .profile-section-title i { width: 22px; height: 22px; border-radius: 7px; background: #eef5fb; display: inline-flex; align-items: center; justify-content: center; font-size: .68rem; }
.profile-modal-overlay .profile-field { margin: 0 0 8px !important; }
.profile-modal-overlay .profile-field label { display: block; margin: 0 0 3px; font-size: .66rem; font-weight: 700; color: #64748b; }
.profile-modal-overlay .profile-field input {
  width: 100%; box-sizing: border-box; padding: 8px 11px !important; font-size: .84rem !important; border: 1px solid #dbe3ec !important;
  border-radius: 10px !important; background: #fff; color: #1e293b; height: auto !important;
}
.profile-modal-overlay .profile-field input:focus { outline: none; border-color: #1b4a6e !important; box-shadow: 0 0 0 3px rgba(27,74,110,.12); }
.profile-modal-overlay .profile-fields-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px !important; }
.profile-modal-overlay .profile-tab-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.profile-modal-overlay .profile-tab-btn {
  padding: 9px 10px; border: 1px solid #dbe3ec; border-radius: 10px; background: #f4f7fb; color: #1b4a6e;
  font: 800 .68rem Inter, sans-serif; letter-spacing: .5px; text-transform: uppercase; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.profile-modal-overlay .profile-tab-btn:hover { background: #e9f1f8; }
.profile-modal-overlay .profile-tab-btn.active { background: #1b4a6e; border-color: #1b4a6e; color: #fff; }
.profile-modal-overlay .profile-tab-pane { display: none; }
.profile-modal-overlay .profile-tab-pane.active { display: block; }
.profile-modal-overlay .profile-login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.profile-modal-overlay .profile-password-wrap { position: relative; }
.profile-modal-overlay .profile-password-wrap input { padding-right: 34px !important; }
.profile-modal-overlay .profile-eye-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 25px; height: 25px;
  display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 7px;
  background: transparent; color: #64748b; font-size: .72rem; cursor: pointer;
}
.profile-modal-overlay .profile-eye-btn:hover { background: #eef5fb; color: #1b4a6e; }
.profile-modal-overlay .profile-eye-btn.is-visible { color: #1b4a6e; }
@media (max-width: 480px) {
  .profile-modal-overlay .profile-login-grid { grid-template-columns: 1fr; }
}
.profile-modal-overlay .profile-avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-modal-overlay .profile-action-btn, .profile-modal-overlay .profile-save-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px !important; font-size: .76rem !important;
  font-weight: 700; border-radius: 10px !important; border: 1px solid #dbe3ec; background: #f4f7fb; color: #1b4a6e; cursor: pointer; min-height: 0 !important; transition: transform .15s, box-shadow .15s;
}
.profile-modal-overlay .profile-action-btn:hover, .profile-modal-overlay .profile-save-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15,23,42,.1); }
.profile-modal-overlay .profile-save-btn { background: #1b4a6e; border-color: #1b4a6e; color: #fff; margin-top: 2px; }
.profile-modal-overlay .profile-delete-btn { color: #dc2626; }
.profile-modal-overlay .profile-delete-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.profile-modal-overlay .profile-hint { margin-top: 7px; font-size: .66rem; color: #94a3b8; }
@media (max-width: 480px) {
  .profile-modal-overlay .profile-fields-grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
}

/* бейдж количества договоров в списке лет */
.profile-panel .user-dropdown .year-item { display: flex; align-items: center; gap: 8px; }
.profile-panel .user-dropdown .year-item .year-label { flex: 1; text-align: left; }
.profile-panel .user-dropdown .year-badge {
  min-width: 26px; padding: 1px 9px; border-radius: 20px; background: #eef5fb; color: #1b4a6e;
  font-size: .68rem; font-weight: 800; text-align: center;
}
.profile-panel .user-dropdown .year-item.active { background: #eef5fb !important; font-weight: 800; }
.profile-panel .user-dropdown .year-item.active .year-badge { background: #1b4a6e; color: #fff; }

/* ===== ЭКРАН ВХОДА: 70% — картинка слева, 30% — панель входа справа ===== */
#loginPage.login-page {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: row-reverse; align-items: stretch; justify-content: flex-start;
  background: #0f3a57; overflow: hidden; z-index: 9999;
}
#loginPage .login-aside {
  width: 30%; flex: 0 0 30%; box-sizing: border-box;
  height: 100%; display: flex; flex-direction: column;
  padding: 20px clamp(12px, 1.3vw, 26px) 16px;
  background: #fff; border-top: 4px solid #ffb347;
  overflow-y: auto; overflow-x: hidden;
}
#loginPage .login-lang { display: flex; justify-content: flex-end; margin-bottom: 12px; }
#loginPage .login-lang select.lang-switcher {
  max-width: 100%; box-sizing: border-box; cursor: pointer;
  background: #fff; color: #1b4a6e; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 5px 8px; font: inherit; font-size: clamp(.6rem, .62vw, .78rem);
}
#loginPage .login-brand { text-align: center; }
#loginPage .login-brand h2 {
  margin: 0; color: #1b4a6e; line-height: 1.25;
  font-size: clamp(.9rem, 1.15vw, 1.3rem); letter-spacing: .2px;
}
#loginPage .login-brand p {
  margin: 6px 0 0; color: #5b6e8c; line-height: 1.35;
  font-size: clamp(.55rem, .6vw, .74rem); font-weight: 700; letter-spacing: .3px;
}
#loginPage .login-form { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; padding: 16px 0; }
#loginPage .login-form .form-group { margin-bottom: 13px; }
#loginPage .login-form .form-group label { margin-bottom: 5px; font-size: clamp(.58rem, .6vw, .75rem); }
#loginPage .login-form .form-group input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px !important; border-radius: 12px !important;
  font-size: clamp(.68rem, .7vw, .88rem) !important;
}
#loginPage .login-form .login-password-wrap input { padding-right: 40px !important; height: auto; }
#loginPage .login-password-eye {
  right: 5px; top: 50%; transform: translateY(-50%) !important;
  width: 28px; height: 28px; font-size: .74rem;
}
#loginPage #loginButton {
  width: 100%; padding: 11px 10px !important; margin-top: 4px !important;
  font-size: clamp(.68rem, .72vw, .92rem) !important; border-radius: 12px !important;
}
#loginPage #loginFooter { margin: 14px 0 0 !important; text-align: center; font-size: .6rem !important; color: #94a3b8; }
#loginPage .login-hero {
  width: 70%; flex: 1 1 70%; height: 100%;
  background: #0f3a57 url('../img/login-hero.svg') center center / cover no-repeat;
}
@media (max-width: 1100px) {
  #loginPage.login-page { flex-direction: column; overflow-y: auto; }
  #loginPage .login-aside { width: 100%; flex: 0 0 auto; height: auto; min-height: auto; }
  #loginPage .login-form { padding: 10px 0 16px; }
  #loginPage .login-hero { width: 100%; flex: 1 1 auto; min-height: 46vh; }
}
/* ===== Стили сетки разрешений пользователей ===== */
.user-permissions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.user-permission-group {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 15px;
}

.user-permission-group h4 {
    margin: 0 0 12px;
    color: #1b4a6e;
    font-size: .85rem;
}

.user-permission-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
}

.user-permission-list .permission-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
}

@media (max-width: 900px) {
    .user-permissions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .user-permission-list {
        grid-template-columns: 1fr;
    }
}

/* ===== Стили переменных шаблонов ===== */
.template-variable {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    background: #f1f5f9;
    color: #1b4a6e;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 0.68rem;
}

.template-variable strong {
    color: #475569;
    font-size: 0.62rem;
    font-weight: 600;
}