<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title><%= title %> · MAD Prix</title>
<link rel="stylesheet" href="<%= base %>/static/style.css">
<script src="<%= base %>/static/app.js" defer></script>
</head>
<body data-base="<%= base %>" data-csrf="<%= csrf %>">
<% if (user) { %>
<header class="topbar">
  <a class="brand" href="<%= base %>/">MAD <span>Prix</span></a>
  <nav>
    <% const nav = [['/', 'Tableau de bord'], ['/suppliers', 'Fournisseurs'], ['/prices', 'Prix'], ['/sync', 'Synchronisation'], ['/settings', 'Paramètres']]; %>
    <% nav.forEach(([href, label]) => { const active = href === '/' ? path === '/' : path.startsWith(href); %>
      <a href="<%= base %><%= href %>" class="<%= active ? 'active' : '' %>"><%= label %></a>
    <% }) %>
  </nav>
  <form method="post" action="<%= base %>/logout" class="logout">
    <input type="hidden" name="_csrf" value="<%= csrf %>">
    <span class="muted"><%= user.username %></span>
    <button class="btn btn-ghost btn-sm">Déconnexion</button>
  </form>
</header>
<% } %>
<main class="container">
<% flash.forEach(f => { %>
  <div class="alert alert-<%= f.type %>"><%= f.msg %></div>
<% }) %>
