<!DOCTYPE html><html lang="nl"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Financiën — Mek-Tech</title><link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/dynamic.css"><link rel="icon" href="/img/favicon.svg"><script src="https://unpkg.com/lucide@latest"></script>
<style>
.fin-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:.5rem;margin-bottom:1rem}
.fin-card{border:1px solid var(--border);border-radius:var(--radius);padding:.75rem;background:var(--bg-card)}
.fin-card .fc-num{font-size:1.3rem;font-weight:700;color:var(--text)}
.fin-card .fc-lbl{font-size:.65rem;color:var(--text-muted);text-transform:uppercase;letter-spacing:.3px}
.tab-bar{display:flex;gap:0;margin-bottom:1rem;background:var(--bg-card);border-radius:var(--radius);border:1px solid var(--border);overflow:hidden}
.tab-btn{padding:.45rem .9rem;font-size:.78rem;font-weight:500;color:var(--text-muted);cursor:pointer;transition:all .12s;border:none;background:none;font-family:inherit;border-right:1px solid var(--border);display:flex;align-items:center;gap:.3rem}
.tab-btn:last-child{border-right:none}
.tab-btn:hover{color:var(--text);background:var(--border-light)}
.tab-btn.active{color:var(--accent);background:rgba(88,166,255,.08);font-weight:600;box-shadow:inset 0 -2px 0 var(--accent)}
.tab-btn svg{width:14px;height:14px}
.pane{display:none}.pane.active{display:block}
.alert-sent{background:var(--green-bg);border:1px solid var(--green);color:var(--green);padding:.4rem .7rem;border-radius:var(--radius);font-size:.78rem;margin-bottom:.75rem;display:flex;align-items:center;gap:.35rem}
.alert-err{background:var(--red-bg);border:1px solid var(--red);color:var(--red);padding:.4rem .7rem;border-radius:var(--radius);font-size:.78rem;margin-bottom:.75rem}
</style></head><body>
<nav class="navbar"><div class="nav-inner"><a href="/" class="nav-brand"><img src="/img/logo.svg" class="nav-logo" alt="Mek-Tech"></a><div style="display:flex;align-items:center;gap:.4rem"><a href="/" class="nav-icon-btn" title="Dashboard"><i data-lucide="layout-dashboard" style="width:15px;height:15px"></i> Dashboard</a><button class="theme-toggle" id="themeToggle" onclick="toggleTheme()"></button><a href="/auth/logout" class="nav-icon-btn" style="color:var(--red)"><i data-lucide="log-out" style="width:15px;height:15px"></i> Uitloggen</a></div></div></nav>
<div class="container" style="max-width:960px">
<a href="javascript:history.back()" class="back-link"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg> Terug</a>
<div class="page-header"><h1><i data-lucide="wallet" style="width:20px;height:20px;color:var(--accent)"></i> Financiën</h1></div>

<div class="fin-grid">
<div class="fin-card"><div class="fc-num"><%= totalHours.toFixed(1) %></div><div class="fc-lbl">Totaal uren</div></div>
<div class="fin-card"><div class="fc-num"><%= billableHours.toFixed(1) %></div><div class="fc-lbl">Facturabel</div></div>
<div class="fin-card"><div class="fc-num">€<%= totalInvoiced.toFixed(0) %></div><div class="fc-lbl">Gefactureerd</div></div>
<div class="fin-card"><div class="fc-num">€<%= totalPaid.toFixed(0) %></div><div class="fc-lbl">Betaald</div></div>
<div class="fin-card"><div class="fc-num" style="color:var(--red)">€<%= totalOutstanding.toFixed(0) %></div><div class="fc-lbl">Openstaand</div></div>
</div>

<div class="tab-bar">
<button class="tab-btn active" data-tab="overview"><i data-lucide="layout-dashboard"></i> Overzicht</button>
<button class="tab-btn" data-tab="time"><i data-lucide="clock"></i> Uren</button>
<button class="tab-btn" data-tab="invoices"><i data-lucide="receipt"></i> Facturen</button>
</div>

<div class="pane active" id="pane-overview">
<div class="fin-grid" style="grid-template-columns:1fr 1fr">
<a href="/finance?tab=time" class="fin-card" style="text-decoration:none;color:inherit;cursor:pointer"><div class="fc-num"><%= entries.length %></div><div class="fc-lbl">Recente urenregistraties</div></a>
<a href="/finance?tab=invoices" class="fin-card" style="text-decoration:none;color:inherit;cursor:pointer"><div class="fc-num"><%= invoices.length %></div><div class="fc-lbl">Recente facturen</div></a>
</div>
<div style="display:flex;gap:.35rem;flex-wrap:wrap">
<a href="/time" class="btn btn-secondary" style="font-size:.75rem;padding:.35rem .7rem"><i data-lucide="plus" style="width:12px;height:12px"></i> Uren toevoegen</a>
<a href="/invoices/new" class="btn btn-secondary" style="font-size:.75rem;padding:.35rem .7rem"><i data-lucide="plus" style="width:12px;height:12px"></i> Factuur maken</a>
</div>
</div>

<div class="pane" id="pane-time">
<a href="/time" class="btn btn-primary" style="margin-bottom:.5rem;font-size:.78rem;padding:.35rem .7rem"><i data-lucide="external-link" style="width:12px;height:12px"></i> Open volledige registratie</a>
<table class="data-table"><thead><tr><th>Datum</th><th>Cliënt</th><th>Hours</th><th>Omschrijving</th><th>Fact.</th></tr></thead><tbody>
<% entries.forEach(function(e){ %><tr><td><%= e.date %></td><td><%= e.client_name || '-' %></td><td><strong><%= e.hours %></strong></td><td style="color:var(--text-muted);font-size:.75rem"><%= e.description || '' %></td><td><%= e.billable ? '✓' : '-' %></td></tr><% }) %>
<% if (entries.length === 0) { %><tr><td colspan="5" style="text-align:center;color:var(--text-dim);padding:1rem">Nog geen uren</td></tr><% } %>
</tbody></table>
</div>

<div class="pane" id="pane-invoices">
<a href="/invoices" class="btn btn-primary" style="margin-bottom:.5rem;font-size:.78rem;padding:.35rem .7rem"><i data-lucide="external-link" style="width:12px;height:12px"></i> Alle facturen</a>
<table class="data-table"><thead><tr><th>Nr</th><th>Cliënt</th><th>Datum</th><th>Totaal</th><th>Status</th></tr></thead><tbody>
<% invoices.forEach(function(i){ %><tr><td><a href="/invoices/<%= i.id %>" class="link"><%= i.number %></a></td><td><%= i.client_name %></td><td><%= i.date %></td><td>€<%= (i.total||0).toFixed(2) %></td><td><span class="status-badge <%= i.status %>"><%= i.status %></span></td></tr><% }) %>
<% if (invoices.length === 0) { %><tr><td colspan="5" style="text-align:center;color:var(--text-dim);padding:1rem">Nog geen facturen</td></tr><% } %>
</tbody></table>
</div>
</div>

<script>
document.querySelectorAll('.tab-btn').forEach(function(b){
b.addEventListener('click',function(){
document.querySelectorAll('.tab-btn').forEach(function(x){x.classList.remove('active')});
document.querySelectorAll('.pane').forEach(function(x){x.classList.remove('active')});
this.classList.add('active');
document.getElementById('pane-'+this.dataset.tab).classList.add('active');
var u=new URL(window.location);u.searchParams.set('tab',this.dataset.tab);window.history.replaceState({},'',u);
});
});
var t=new URL(window.location).searchParams.get('tab');if(t){var btn=document.querySelector('.tab-btn[data-tab="'+t+'"]');if(btn)btn.click();}
lucide.createIcons();
</script>
<script src="/js/theme.js"></script></body></html>
