Help me to better design my query so I can gain more performance
The first this I would try is to add
where doc.datum>=@od_datuma
       and  doc.datum &lt;=@do_datuma
because the having clause. Maybe it will give a hint to the query planner.
Then the big question is: why the outer join with the subquery?
Does the " where .. stari_uazi.ART_ID is null " mean that you want to exclude all the rows returning from the subquery? 
I suspect the subquery is the real killer because the search for DOC is not bounded ( DOC.DATUM &lt;@od_datuma ), so it might fetch a huge number of rows, which have not real purpose since the parent query excludes these rows anyway..

My guess is that if you suppress the subquery ( left outer join .. ) you will have something very close from what you want, much faster. If you need to suppress some rows from the result set you can put them in a temporary table and delete them afterwards, this might be faster than the outer join subquery.

Update: so if you want to keep only the rows between @od / @do _datum, remove the left join and add the condition where DOC.DATUM between @od_ and @do_
You will have the same result and it will be much faster.