Kaynağa Gözat

finalisationV1

augustin.podvin 8 ay önce
ebeveyn
işleme
58e01dda46
66 değiştirilmiş dosya ile 3323 ekleme ve 4075 silme
  1. 4 1
      .gitignore
  2. 271 24
      MODX_INTEGRATION.md
  3. 7 6
      README.md
  4. 0 27
      api/_bootstrap.php
  5. 0 24
      api/pack.php
  6. 0 51
      api/pdf.php
  7. 0 38
      api/score.php
  8. 0 2713
      audit-structure.json
  9. 1 1
      composer.json
  10. 0 0
      config/audit-structure.json
  11. 17 0
      config/config.loader.php
  12. 13 0
      config/config.local.example.php
  13. 28 0
      config/config.php
  14. 0 1032
      config/pack-onboarding-v1.json
  15. 0 0
      config/packs/pack-onboarding-v1.json
  16. 17 0
      modx/chunks/ae_cost_hidden.html
  17. 37 0
      modx/chunks/ae_cta_unlocked.html
  18. 22 0
      modx/chunks/ae_optional.html
  19. 9 0
      modx/chunks/ae_optional_field.html
  20. 13 0
      modx/chunks/ae_optional_radio.html
  21. 12 0
      modx/chunks/ae_pack_card.html
  22. 10 0
      modx/chunks/ae_pillar_row.html
  23. 12 0
      modx/chunks/ae_question_option.html
  24. 52 0
      modx/chunks/ae_quiz.html
  25. 14 0
      modx/chunks/ae_quiz_progress.html
  26. 50 0
      modx/chunks/ae_results.html
  27. 7 0
      modx/chunks/ae_risk_item.html
  28. 18 0
      modx/chunks/ae_select_pack.html
  29. 38 0
      modx/chunks/ae_unlock_gate.html
  30. 7 0
      modx/chunks/ae_win_item.html
  31. 68 0
      modx/model/audit_express/auditrequest.class.php
  32. 5 0
      modx/model/audit_express/mysql/auditrequest.class.php
  33. 125 0
      modx/model/audit_express/mysql/auditrequest.map.inc.php
  34. 60 0
      modx/plugins/AuditExpress_Init.php
  35. 620 0
      modx/preview-chunks.html
  36. 49 0
      modx/schema/audit_express.mysql.schema.xml
  37. 21 0
      modx/setup/create_tables.sql
  38. 108 0
      modx/setup/install.php
  39. 111 0
      modx/snippets/AuditExpress_Optional.php
  40. 67 0
      modx/snippets/AuditExpress_PDF.php
  41. 159 0
      modx/snippets/AuditExpress_Quiz.php
  42. 175 0
      modx/snippets/AuditExpress_Results.php
  43. 126 0
      modx/snippets/AuditExpress_SelectPack.php
  44. 68 0
      modx/templates/AuditExpress_Base.html
  45. 61 0
      modx/templates/AuditExpress_Landing.html
  46. 36 0
      modx/templates/AuditExpress_Quiz.html
  47. 36 0
      modx/templates/AuditExpress_Results.html
  48. 5 1
      public/api/_bootstrap.php
  49. 23 11
      public/api/email.php
  50. 14 3
      public/api/notify.php
  51. 3 1
      public/api/pack.php
  52. 21 2
      public/api/pdf.php
  53. 26 2
      public/api/score.php
  54. 206 8
      public/assets/css/app.css
  55. 3 0
      public/assets/images/logo-livinweb-dark.svg
  56. 3 0
      public/assets/images/logo-livinweb.svg
  57. 85 104
      public/assets/js/app.js
  58. 4 0
      public/favicon.svg
  59. 59 22
      public/index.php
  60. 78 0
      src/AdminNotifier.php
  61. 115 0
      src/Analytics.php
  62. 20 2
      src/Http.php
  63. 1 1
      src/PackRepository.php
  64. 74 0
      src/RateLimiter.php
  65. 1 1
      src/RulesRepository.php
  66. 28 0
      src/Security.php

+ 4 - 1
.gitignore

@@ -4,9 +4,11 @@
 # Composer archive (ne pas commiter le phar)
 composer.phar
 
-# Stockage local (emails pseudo, PDFs générés)
+# Stockage local (emails pseudo, PDFs générés, rate limit, analytics)
 /storage/outbox/
 /storage/logs/
+/storage/ratelimit/
+/storage/analytics.json
 
 # Fichiers générés / temporaires
 *.pdf
@@ -19,6 +21,7 @@ composer.phar
 # Environnement local
 .env
 .env.local
+config/config.local.php
 
 # IDE / OS
 .cursor/

+ 271 - 24
MODX_INTEGRATION.md

@@ -1,34 +1,281 @@
-# Intégration MODX (guide rapide)
+# Intégration MODX — Audit Express Self
 
-Objectif : garder un front **HTML/CSS/JS** (intégrable dans un template MODX) et quelques endpoints **PHP** pour le calcul + PDF.
+Architecture complète : xPDO en BD + templates/chunks/snippets MODX.
 
-## Option A (simple) : micro-app dans un dossier
+---
 
-1) Copier le contenu de `public/` dans un dossier public de ton site (ex : `https://ton-site.tld/controle-technique/`).
-2) Vérifier que les endpoints sont accessibles :
-   - `.../api/pack.php`
-   - `.../api/score.php`
-   - `.../api/pdf.php`
-3) Mettre à jour le lien Calendly dans `public/index.php` (variable `$bookingUrl`).
+## Vue d'ensemble de l'architecture
 
-## Option B : template MODX + endpoints séparés
+```
+MODX Resource          Template                    Snippet appelé
+─────────────────────  ──────────────────────────  ──────────────────────────────
+/controle-technique/   AuditExpress_Landing        (contenu statique dans la ressource)
+/ct/choix-du-pack/     AuditExpress_Base           [[!AuditExpress_SelectPack]]
+/ct/quiz/              AuditExpress_Quiz           [[!AuditExpress_Quiz]]
+/ct/optional/          AuditExpress_Quiz           [[!AuditExpress_Optional]]
+/ct/resultats/         AuditExpress_Results        [[!AuditExpress_Results]]
+/ct/pdf/               AuditExpress_Results        [[!AuditExpress_PDF]]
+```
 
-1) **Assets**
-   - Copier `public/assets/` dans `assets/controle-technique/` (ou équivalent).
-   - Dans ton template/chunk MODX, inclure :
-     - CSS : `/assets/controle-technique/css/app.css`
-     - JS : `/assets/controle-technique/js/app.js`
+**Objet BD** : `AuditRequest` (table `{prefix}audit_requests`) — créé dès le choix du pack, mis à jour à chaque réponse, finalisé avec le score au moment des résultats.
 
-2) **Container**
-   - Ajouter un conteneur :
-     - `<main id="app" data-api-base="/api" data-booking-url="..."></main>`
+---
 
-3) **Endpoints**
-   - Copier `public/api/` dans un dossier accessible, par ex `/api/controle-technique/`
-   - Puis adapter `data-api-base` en conséquence (ex : `data-api-base="/api/controle-technique"`).
+## 1. Déploiement des fichiers
 
-## Email (V1)
+```
+core/components/audit_express/
+├── model/
+│   └── audit_express/
+│       ├── auditrequest.class.php           ← classe xPDO base
+│       └── mysql/
+│           ├── auditrequest.class.php       ← pilote MySQL
+│           └── auditrequest.map.inc.php     ← map de colonnes
+├── src/                                     ← classes PHP existantes
+│   ├── Engine.php
+│   ├── PackRepository.php
+│   ├── RulesRepository.php
+│   ├── PdfRenderer.php
+│   └── LogMailer.php
+├── config/                                  ← packs JSON existants
+│   ├── pack-onboarding-v1.json
+│   └── packs/…
+├── templates/
+│   └── pdf_a4.php                           ← template PDF existant
+└── schema/
+    └── audit_express.mysql.schema.xml
 
-Le brief prévoit une capture email + PDF. Dans cette V1, `POST /api/email.php` **stocke** les emails dans `storage/outbox/` (pseudo).  
-Quand tu seras prêt : remplacer `AuditExpress\\LogMailer` par une implémentation SMTP/API.
+assets/components/audit_express/
+├── css/app.css
+└── js/ae-base.js                            ← JS minimal (auto-avance radio)
+```
 
+Copier les dossiers source :
+```bash
+cp -r src/          core/components/audit_express/src/
+cp -r config/       core/components/audit_express/config/
+cp -r templates/    core/components/audit_express/templates/
+cp    vendor/       core/components/audit_express/vendor/   # Dompdf
+cp    public/assets/css/app.css   assets/components/audit_express/css/
+```
+
+---
+
+## 2. Base de données
+
+**Option A — Script automatique** (recommandé) :
+```bash
+php modx/setup/install.php
+```
+
+**Option B — SQL manuel** :
+```sql
+-- Ouvrir modx/setup/create_tables.sql, remplacer modx_ par votre préfixe, exécuter.
+```
+
+Colonnes de `audit_requests` :
+
+| Colonne         | Type                              | Rôle |
+|-----------------|-----------------------------------|------|
+| `id`            | INT PK AUTO_INCREMENT             | Clé interne |
+| `audit_uid`     | VARCHAR(36) UNIQUE                | UUID public (URL résultats, PDF) |
+| `pack_id`       | VARCHAR(64)                       | onboarding-v1, validation-facture… |
+| `answers`       | TEXT (JSON)                       | `{"q1":"q1_3","q2":"q2_dk",…}` |
+| `optional_data` | TEXT (JSON)                       | Volume mensuel, coût horaire… |
+| `result`        | MEDIUMTEXT (JSON)                 | Score, piliers, risques, quick wins |
+| `email`         | VARCHAR(255) nullable             | Saisi lors du déblocage |
+| `status`        | ENUM draft/completed/emailed      | État du cycle de vie |
+| `ip_hash`       | VARCHAR(64) nullable              | sha256(IP) — RGPD, pas d'IP en clair |
+| `step`          | TINYINT                           | Index de la question en cours |
+| `created_at`    | DATETIME                          | — |
+| `updated_at`    | DATETIME                          | Mis à jour automatiquement |
+
+---
+
+## 3. System Settings (Gestionnaire → Paramètres système → namespace `audit_express`)
+
+| Clé                    | Valeur à renseigner         |
+|------------------------|-----------------------------|
+| `ae.core_path`         | `{core_path}components/audit_express/` |
+| `ae.resource.landing`  | ID ressource landing        |
+| `ae.resource.select`   | ID ressource choix du pack  |
+| `ae.resource.quiz`     | ID ressource quiz           |
+| `ae.resource.optional` | ID ressource optional       |
+| `ae.resource.results`  | ID ressource résultats      |
+| `ae.resource.pdf`      | ID ressource PDF download   |
+| `ae.booking_url`       | Lien Calendly               |
+| `ae.devis_url`         | URL ou mailto devis         |
+
+---
+
+## 4. Plugin
+
+Créer un plugin **AuditExpress_Init** avec le code de `modx/plugins/AuditExpress_Init.php`.
+
+Événements à cocher :
+- `OnMODXInit` (priorité **1** — avant tout)
+- `OnHandleRequest`
+
+---
+
+## 5. Templates
+
+Importer dans Gestionnaire → Éléments → Templates :
+
+| Fichier source                              | Nom dans MODX               |
+|---------------------------------------------|-----------------------------|
+| `modx/templates/AuditExpress_Landing.html`  | `AuditExpress_Landing`      |
+| `modx/templates/AuditExpress_Base.html`     | `AuditExpress_Base`         |
+| `modx/templates/AuditExpress_Quiz.html`     | `AuditExpress_Quiz`         |
+| `modx/templates/AuditExpress_Results.html`  | `AuditExpress_Results`      |
+
+---
+
+## 6. Chunks
+
+Importer dans Gestionnaire → Éléments → Chunks :
+
+```
+ae_pack_card          modx/chunks/ae_pack_card.html
+ae_select_pack        modx/chunks/ae_select_pack.html
+ae_quiz_progress      modx/chunks/ae_quiz_progress.html
+ae_question_option    modx/chunks/ae_question_option.html
+ae_quiz               modx/chunks/ae_quiz.html
+ae_optional_field     modx/chunks/ae_optional_field.html
+ae_optional_radio     modx/chunks/ae_optional_radio.html
+ae_optional           modx/chunks/ae_optional.html
+ae_pillar_row         modx/chunks/ae_pillar_row.html
+ae_risk_item          modx/chunks/ae_risk_item.html
+ae_win_item           modx/chunks/ae_win_item.html
+ae_cost_hidden        modx/chunks/ae_cost_hidden.html
+ae_unlock_gate        modx/chunks/ae_unlock_gate.html
+ae_cta_unlocked       modx/chunks/ae_cta_unlocked.html
+ae_results            modx/chunks/ae_results.html
+```
+
+---
+
+## 7. Snippets
+
+Importer dans Gestionnaire → Éléments → Snippets (tous en **uncached** `[[!…]]`) :
+
+```
+AuditExpress_SelectPack    modx/snippets/AuditExpress_SelectPack.php
+AuditExpress_Quiz          modx/snippets/AuditExpress_Quiz.php
+AuditExpress_Optional      modx/snippets/AuditExpress_Optional.php
+AuditExpress_Results       modx/snippets/AuditExpress_Results.php
+AuditExpress_PDF           modx/snippets/AuditExpress_PDF.php
+```
+
+---
+
+## 8. Ressources MODX à créer
+
+### Landing (`/controle-technique/`)
+- Template : `AuditExpress_Landing`
+- Contenu : HTML statique (copier le body de `public/index.php`), le bouton "Lancer" pointe vers `/ct/choix-du-pack/`
+
+### Choix du pack (`/ct/choix-du-pack/`)
+- Template : `AuditExpress_Base`
+- Contenu :
+```
+[[!AuditExpress_SelectPack?
+  &quiz_resource_id=`[[++ae.resource.quiz]]`
+  &landing_resource_id=`[[++ae.resource.landing]]`
+]]
+```
+
+### Quiz (`/ct/quiz/`)
+- Template : `AuditExpress_Quiz`
+- Contenu :
+```
+[[!AuditExpress_Quiz?
+  &select_resource_id=`[[++ae.resource.select]]`
+  &optional_resource_id=`[[++ae.resource.optional]]`
+]]
+```
+
+### Optionnel (`/ct/optional/`)
+- Template : `AuditExpress_Quiz`
+- Contenu :
+```
+[[!AuditExpress_Optional?
+  &quiz_resource_id=`[[++ae.resource.quiz]]`
+  &results_resource_id=`[[++ae.resource.results]]`
+]]
+```
+
+### Résultats (`/ct/resultats/`)
+- Template : `AuditExpress_Results`
+- Contenu :
+```
+[[!AuditExpress_Results?
+  &select_resource_id=`[[++ae.resource.select]]`
+  &booking_url=`[[++ae.booking_url]]`
+  &devis_url=`[[++ae.devis_url]]`
+]]
+```
+
+### PDF (`/ct/pdf/`)
+- Template : `AuditExpress_Base` (ou vide)
+- Contenu : `[[!AuditExpress_PDF? &booking_url=`[[++ae.booking_url]]`]]`
+- Cocher "Ne pas mettre en cache"
+
+---
+
+## 9. Flux de données complet
+
+```
+[Landing] → [Choix pack]
+                ↓ POST ae_action=select_pack
+           Crée AuditRequest (BD) → session ae_audit_uid
+                ↓ redirect
+            [Quiz Q1]
+                ↓ POST ae_action=ae_answer (x20)
+           Met à jour AuditRequest.answers + step (BD)
+                ↓ redirect (PRG) — question suivante
+            [Optional]
+                ↓ POST ae_action=ae_optional
+           Engine::compute() → AuditRequest.result + status=completed (BD)
+                ↓ redirect ?audit=<uid>
+            [Résultats]
+           Score + risques toujours visibles
+           Gate email → POST ae_action=ae_capture_email
+                ↓ AuditRequest.email + status=emailed (BD) + PDF généré
+                ↓ redirect ?audit=<uid>&unlocked=1
+           Quick wins + CTAs débloqués
+                ↓ lien /ct/pdf/?audit=<uid>
+            [PDF]
+           Téléchargement direct
+```
+
+---
+
+## 10. RGPD & purge
+
+La purge des données doit être exécutée régulièrement (cron ou tâche planifiée).
+
+### Cron Linux (exemple)
+
+```cron
+# Purge RGPD — 1er jour du mois à 3h (adapter USER, PASS, BASE_MODX)
+0 3 1 * * mysql -u USER -pPASS BASE_MODX -e "DELETE FROM modx_audit_requests WHERE status='draft' AND created_at < DATE_SUB(NOW(), INTERVAL 7 DAY); DELETE FROM modx_audit_requests WHERE status IN ('completed','emailed') AND created_at < DATE_SUB(NOW(), INTERVAL 90 DAY);" >> /var/log/purge-audit.log 2>&1
+```
+
+### SQL à exécuter (ou via script shell)
+
+ n’```sql
+DELETE FROM modx_audit_requests
+WHERE status = 'draft' AND created_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
+
+DELETE FROM modx_audit_requests
+WHERE status IN ('completed','emailed') AND created_at < DATE_SUB(NOW(), INTERVAL 90 DAY);
+```
+
+---
+
+## 11. Email (V1 → production)
+
+La V1 stocke les emails dans `storage/outbox/` via `LogMailer`.  
+Pour passer en production, créer une classe `SmtpMailer` implémentant `AuditExpress\MailerInterface`
+et l'injecter dans `AuditExpress_Results.php` à la place de `LogMailer`.

+ 7 - 6
README.md

@@ -29,11 +29,11 @@ Puis ouvrir `http://localhost:8000`.
 
 ## Configuration
 
-- Packs quiz :
-  - `config/pack-onboarding-v1.json`
-  - `config/packs/validation-facture.json`
-- Quick wins / risques / règles :
-  - `audit-structure.json`
+- **URLs** (`config/config.php`) : `booking_url`, `devis_url`. Copier `config/config.local.example.php` en `config.local.php` pour surcharger.
+- **Sécurité** : rate limiting, taille max du body (1 Mo), liste blanche `allowed_notify_tools`.
+- **Notification admin** : `admin_notify_webhook` — POST JSON à chaque submit (Zapier, Make, endpoint custom).
+- Packs quiz : `config/packs/*.json` (pack-onboarding-v1, validation-facture, process-generique…)
+- Quick wins / risques / règles : `config/audit-structure.json`
 
 ## Endpoints (V1)
 
@@ -41,8 +41,9 @@ Puis ouvrir `http://localhost:8000`.
 - `POST /api/score.php` (JSON) → calcule score + résultats
 - `POST /api/pdf.php` (JSON) → génère et renvoie un PDF
 - `POST /api/email.php` (JSON) → **pseudo** envoi : stocke dans `storage/outbox/`
+- `POST /api/notify.php` (JSON) → inscription intérêt outil à venir
 
 ## Intégration MODX
 
-Approche recommandée : intégrer les **templates HTML/CSS/JS** côté MODX, et garder les endpoints PHP (dossier `api/`) accessibles sur le même domaine.
+Approche recommandée : intégrer les **templates HTML/CSS/JS** côté MODX, et garder les endpoints PHP (dossier `public/api/`) accessibles sur le même domaine.
 

+ 0 - 27
api/_bootstrap.php

@@ -1,27 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-$root = dirname(__DIR__);
-
-// Composer autoload (required for Dompdf + PSR-4 classes)
-$autoload = $root . '/vendor/autoload.php';
-if (is_file($autoload)) {
-    require $autoload;
-}
-
-// Fallback (when dependencies aren't installed yet)
-spl_autoload_register(function (string $class) use ($root): void {
-    $prefix = 'AuditExpress\\';
-    if (!str_starts_with($class, $prefix)) {
-        return;
-    }
-    $relative = substr($class, strlen($prefix));
-    $path = $root . '/src/' . str_replace('\\', '/', $relative) . '.php';
-    if (is_file($path)) {
-        require $path;
-    }
-});
-
-return $root;
-

+ 0 - 24
api/pack.php

@@ -1,24 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-use AuditExpress\Http;
-use AuditExpress\PackRepository;
-
-$root = require __DIR__ . '/_bootstrap.php';
-
-if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
-    Http::methodNotAllowed(['GET']);
-    exit;
-}
-
-$packId = (string) ($_GET['pack'] ?? 'onboarding-v1');
-
-try {
-    $repo = new PackRepository($root);
-    $pack = $repo->getPack($packId);
-    Http::json(['pack' => $pack]);
-} catch (Throwable $e) {
-    Http::json(['error' => $e->getMessage()], 404);
-}
-

+ 0 - 51
api/pdf.php

@@ -1,51 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-use AuditExpress\Engine;
-use AuditExpress\Http;
-use AuditExpress\PackRepository;
-use AuditExpress\PdfRenderer;
-use AuditExpress\RulesRepository;
-
-$root = require __DIR__ . '/_bootstrap.php';
-
-if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
-    Http::methodNotAllowed(['POST']);
-    exit;
-}
-
-$body = Http::readJsonBody();
-$packId = (string) ($body['pack_id'] ?? 'onboarding-v1');
-$answers = $body['answers'] ?? [];
-$optional = $body['optional'] ?? [];
-
-if (!is_array($answers) || !is_array($optional)) {
-    Http::json(['error' => 'Invalid payload'], 400);
-    exit;
-}
-
-$bookingUrl = (string) ($body['booking_url'] ?? '');
-
-try {
-    $packRepo = new PackRepository($root);
-    $rulesRepo = new RulesRepository($root);
-    $pack = $packRepo->getPack($packId);
-    $rules = $rulesRepo->getRules();
-
-    $result = Engine::compute($pack, $answers, $optional, $rules);
-
-    $pdf = (new PdfRenderer($root))->renderPdfBytes($pack, $result, [
-        'booking_url' => $bookingUrl,
-        'date' => date('Y-m-d'),
-    ]);
-
-    $filename = 'controle-technique-' . ($pack['pack_id'] ?? 'resultat') . '.pdf';
-    header('Content-Type: application/pdf');
-    header('Content-Disposition: attachment; filename="' . $filename . '"');
-    header('Content-Length: ' . strlen($pdf));
-    echo $pdf;
-} catch (Throwable $e) {
-    Http::json(['error' => $e->getMessage()], 400);
-}
-

+ 0 - 38
api/score.php

@@ -1,38 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-use AuditExpress\Engine;
-use AuditExpress\Http;
-use AuditExpress\PackRepository;
-use AuditExpress\RulesRepository;
-
-$root = require __DIR__ . '/_bootstrap.php';
-
-if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
-    Http::methodNotAllowed(['POST']);
-    exit;
-}
-
-$body = Http::readJsonBody();
-$packId = (string) ($body['pack_id'] ?? 'onboarding-v1');
-$answers = $body['answers'] ?? [];
-$optional = $body['optional'] ?? [];
-
-if (!is_array($answers) || !is_array($optional)) {
-    Http::json(['error' => 'Invalid payload'], 400);
-    exit;
-}
-
-try {
-    $packRepo = new PackRepository($root);
-    $rulesRepo = new RulesRepository($root);
-    $pack = $packRepo->getPack($packId);
-    $rules = $rulesRepo->getRules();
-
-    $result = Engine::compute($pack, $answers, $optional, $rules);
-    Http::json(['result' => $result]);
-} catch (Throwable $e) {
-    Http::json(['error' => $e->getMessage()], 400);
-}
-

+ 0 - 2713
audit-structure.json

@@ -1,2713 +0,0 @@
-{
-  "quick_wins": [
-    {
-      "id": 1,
-      "title": "Formaliser une checklist \"jour 1 prêt\" (1 page)",
-      "effect": "Moins d'oublis, visibilité partagée",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 2,
-      "title": "Nommer un owner onboarding et un relais",
-      "effect": "Cohérence, arbitrage, amélioration continue",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 3,
-      "title": "Créer un modèle de plan 30-60-90 jours",
-      "effect": "Clarifie attentes, réduit ambiguïtés",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 4,
-      "title": "Standardiser 5 modèles d'emails (préboarding, jour 1, accès, matériel, feedback)",
-      "effect": "Répétabilité, standardisation",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE",
-        "PREUVE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 5,
-      "title": "Créer un \"kit manager\" (ce qu'il doit faire, quand)",
-      "effect": "Clarté des rôles, moins d'oublis",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 6,
-      "title": "Ajouter une étape \"pré-check\" 48h avant jour 1",
-      "effect": "Moins d'incidents, contrôle préventif",
-      "effort": "S",
-      "prerequisites": [
-        "1"
-      ],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 7,
-      "title": "Définir un chemin \"exceptions\" (arrivée urgente, matériel en retard, remote)",
-      "effect": "Gestion prévisible des cas particuliers",
-      "effort": "M",
-      "prerequisites": [
-        "1"
-      ],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 8,
-      "title": "Mettre un tableau de statut unique (à jour) \"par personne\"",
-      "effect": "Moins de relances, visibilité partagée",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE",
-        "FIABILITE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 9,
-      "title": "Ajouter 3 statuts obligatoires (à faire, en cours, prêt)",
-      "effect": "Visibilité de l'état, moins de relances",
-      "effort": "S",
-      "prerequisites": [
-        "8"
-      ],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 10,
-      "title": "Mettre un point de contrôle hebdo 15 min sur onboarding en cours",
-      "effect": "Détection précoce des blocages",
-      "effort": "S",
-      "prerequisites": [
-        "8"
-      ],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 11,
-      "title": "Ajouter une date cible \"jour 1\" et \"fin semaine 1\" visibles",
-      "effect": "Pilotage, anticipation",
-      "effort": "S",
-      "prerequisites": [
-        "8"
-      ],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 12,
-      "title": "Créer une règle simple de validation des demandes d'accès (qui valide quoi)",
-      "effect": "Moins d'erreurs, délais prévisibles",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 13,
-      "title": "Mettre des rôles types (pack accès par rôle)",
-      "effect": "Standardisation, moins de rework",
-      "effort": "L",
-      "prerequisites": [
-        "12"
-      ],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 14,
-      "title": "Créer une check \"sécurité\" minimum (droits, documents sensibles)",
-      "effect": "Risque maîtrisé, conformité",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 15,
-      "title": "Mettre une revue mensuelle des incidents onboarding (top 3 causes)",
-      "effect": "Amélioration continue, prévention",
-      "effort": "S",
-      "prerequisites": [
-        "16"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 16,
-      "title": "Écrire une mini procédure \"accès manquant\" (qui, délai, escalade)",
-      "effect": "Résolution rapide, continuité",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE",
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 17,
-      "title": "Centraliser documents onboarding dans un dossier unique par personne",
-      "effect": "Preuve, reprise rapide en cas de départ",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 18,
-      "title": "Rendre obligatoire la trace \"validé par + date\" sur étapes clés",
-      "effect": "Traçabilité, preuve, audit trail",
-      "effort": "M",
-      "prerequisites": [
-        "17"
-      ],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 19,
-      "title": "Rendre obligatoire l'attachement \"preuve\" (contrat, validation, matériel)",
-      "effect": "Preuve, transmissibilité",
-      "effort": "M",
-      "prerequisites": [
-        "17"
-      ],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 20,
-      "title": "Ajouter un changelog simple sur modifications sensibles (droits, contenus)",
-      "effect": "Traçabilité, conformité",
-      "effort": "M",
-      "prerequisites": [
-        "17"
-      ],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 21,
-      "title": "Mettre une délégation par défaut en cas d'absence (binôme)",
-      "effect": "Continuité, moins de dépendance",
-      "effort": "S",
-      "prerequisites": [
-        "2"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 22,
-      "title": "Documenter \"si X absent, faire Y\" (1 page)",
-      "effect": "Transmissibilité, continuité",
-      "effort": "S",
-      "prerequisites": [
-        "2"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 23,
-      "title": "Créer une escalade automatique ou manuelle après X jours de blocage",
-      "effect": "Blocages courts, continuité",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 24,
-      "title": "Plan de secours si canal principal indisponible (ex : email down)",
-      "effect": "Continuité en cas de panne",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 25,
-      "title": "Tester 1 fois par trimestre un scénario \"jour 1 sans RH\"",
-      "effect": "Validation de la résilience",
-      "effort": "S",
-      "prerequisites": [
-        "21",
-        "22"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 26,
-      "title": "Réduire le nombre de canaux (choisir 1 canal standard pour demandes)",
-      "effect": "Moins de pertes, moins d'oublis",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 27,
-      "title": "Supprimer 1 double saisie (une source de vérité)",
-      "effect": "Moins d'erreurs, gain de temps",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 28,
-      "title": "Regrouper les demandes en batch (2 créneaux/semaine)",
-      "effect": "Gain de temps, moins de switches",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 29,
-      "title": "Mettre des champs obligatoires sur demande d'accès pour éviter retours",
-      "effect": "Moins de relances, moins d'allers-retours",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "COUT",
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 30,
-      "title": "Limiter les validations \"à la tête du client\" via seuils simples",
-      "effect": "Moins de variabilité, gain de temps",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 3
-    },
-    {
-      "id": 31,
-      "title": "Définir 2 KPI : \"jour 1 prêt\" + \"incidents onboarding/semaine 1\"",
-      "effect": "Mesure, amélioration continue",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 32,
-      "title": "Ajouter une question \"feedback nouvel arrivant\" à J+7 (3 questions)",
-      "effect": "Mesure qualitative, amélioration",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 33,
-      "title": "Ajouter une rétrospective mensuelle 20 min (owner + relais)",
-      "effect": "Amélioration continue, alignement",
-      "effort": "S",
-      "prerequisites": [
-        "2"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 34,
-      "title": "Standardiser un parcours \"première semaine\" (agenda type)",
-      "effect": "Expérience cohérente, moins d'oublis",
-      "effort": "M",
-      "prerequisites": [
-        "1"
-      ],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 35,
-      "title": "Ajouter un buddy systématique (si possible)",
-      "effect": "Intégration, continuité",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 36,
-      "title": "Créer un espace \"ressources\" unique (liens, procédures, contacts)",
-      "effect": "Autonomie, moins de relances",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 37,
-      "title": "Créer un espace de documentation partagé pour ce process (Notion, Confluence, SharePoint…)",
-      "effect": "Transmissibilité, moins de dépendance individuelle",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE",
-        "PREUVE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 38,
-      "title": "Nommer un responsable process + un suppléant avec accès complets",
-      "effect": "Continuité, cohérence, arbitrage rapide",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE",
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 39,
-      "title": "Mettre en place un tableau de suivi partagé (Trello, Monday, Notion ou Asana)",
-      "effect": "Visibilité temps réel, moins de relances par email",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "CLARTE",
-        "COUT"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 40,
-      "title": "Définir un chemin pour les exceptions avec responsable et délai (1 page)",
-      "effect": "Gestion prévisible, moins de blocages improvisés",
-      "effort": "S",
-      "prerequisites": [
-        "37"
-      ],
-      "tags": [
-        "CLARTE",
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 41,
-      "title": "Remplacer la collecte d'informations par email par un formulaire en ligne (Google Forms, Typeform, JotForm…)",
-      "effect": "Données complètes dès le départ, moins d'allers-retours",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE",
-        "COUT"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 42,
-      "title": "Définir des règles de validation par seuil et par rôle et les écrire en 1 page",
-      "effect": "Moins de variabilité, décisions plus rapides",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 43,
-      "title": "Connecter 2 outils pour éliminer la principale double saisie (Zapier, Make ou API native)",
-      "effect": "Gain de temps direct, suppression d'une source d'erreurs",
-      "effort": "L",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 44,
-      "title": "Centraliser les documents dans un dossier structuré unique par occurrence (Drive, SharePoint…)",
-      "effect": "Retrouvabilité, preuve, gain de temps en cas de contrôle",
-      "effort": "M",
-      "prerequisites": [
-        "37"
-      ],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 45,
-      "title": "Activer l'historique des modifications dans les outils existants (versioning, logs)",
-      "effect": "Traçabilité sans effort supplémentaire",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "PREUVE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 46,
-      "title": "Créer un mode opératoire 1 page : étapes, rôles, outils, cas particuliers",
-      "effect": "Transmissibilité immédiate, onboarding d'un remplaçant en moins de 15 min",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "PREUVE",
-        "CLARTE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 47,
-      "title": "Identifier un backup pour chaque rôle critique et lui donner les accès nécessaires maintenant",
-      "effect": "Continuité garantie, zéro surprise en cas d'absence",
-      "effort": "S",
-      "prerequisites": [
-        "38"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 48,
-      "title": "Configurer des alertes automatiques en cas de retard ou blocage (email, notification outil)",
-      "effect": "Détection précoce, blocages courts",
-      "effort": "M",
-      "prerequisites": [
-        "39"
-      ],
-      "tags": [
-        "RESILIENCE",
-        "FIABILITE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 49,
-      "title": "Choisir 1 ou 2 KPI simples et les suivre mensuellement (délai, taux d'erreur, volume traité)",
-      "effect": "Pilotage factuel, amélioration continue",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 50,
-      "title": "Regrouper les outils autour d'une plateforme centrale (CRM, ERP ou outil métier intégré)",
-      "effect": "Suppression des silos, gain de temps, données unifiées",
-      "effort": "L",
-      "prerequisites": [],
-      "tags": [
-        "COUT"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 51,
-      "title": "Créer un log d'incidents partagé (même un Google Sheet) pour tracer et analyser les anomalies",
-      "effect": "Récurrence évitée, causes racines identifiées",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 52,
-      "title": "Mettre en place une validation électronique pour les approbations importantes (email structuré ou outil)",
-      "effect": "Traçabilité des validations, séparation des rôles",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "PREUVE",
-        "FIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 53,
-      "title": "Automatiser les notifications et rappels sur les étapes en attente",
-      "effect": "Moins de relances manuelles, moins d'oublis",
-      "effort": "M",
-      "prerequisites": [
-        "39"
-      ],
-      "tags": [
-        "RESILIENCE",
-        "COUT"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 54,
-      "title": "Remplacer le suivi Excel par un outil dédié adapté au process (CRM, ticketing, gestion de projet…)",
-      "effect": "Statuts automatiques, historique, collaboration temps réel",
-      "effort": "L",
-      "prerequisites": [],
-      "tags": [
-        "COUT",
-        "CLARTE"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 55,
-      "title": "Définir des champs obligatoires dans les formulaires/outils pour éviter les informations manquantes",
-      "effect": "Moins de relances, données complètes dès la saisie",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "FIABILITE",
-        "COUT"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 56,
-      "title": "Documenter le plan de continuité : 'si X est absent, faire Y, contacter Z, accès ici'",
-      "effect": "Zéro panique en cas d'absence imprévue",
-      "effort": "S",
-      "prerequisites": [
-        "46"
-      ],
-      "tags": [
-        "RESILIENCE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 57,
-      "title": "Cartographier le process en atelier (2h)",
-      "effect": "Alignement équipe + identification des vrais goulots",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "FRICTION"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 58,
-      "title": "Automatiser les relances et notifications",
-      "effect": "Fin des relances manuelles, délais réduits",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "FRICTION"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 59,
-      "title": "Centraliser les données dans un outil unique",
-      "effect": "Moins de ressaisies, données fiables",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "DONNEES"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 60,
-      "title": "Créer un tableau de bord statut temps réel",
-      "effect": "Visibilité instantanée, relances divisées par 3",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COLLABORATION"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 61,
-      "title": "Documenter et valider les règles de décision",
-      "effect": "Réduction des exceptions, onboarding facilité",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "VARIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 62,
-      "title": "Intégrer les outils via API / webhooks",
-      "effect": "Suppression des ressaisies entre outils",
-      "effort": "L",
-      "prerequisites": [],
-      "tags": [
-        "OUTILS"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 63,
-      "title": "Nommer un owner de process + suppléant",
-      "effect": "Arbitrage rapide, continuité garantie",
-      "effort": "S",
-      "prerequisites": [],
-      "tags": [
-        "DEPLOIEMENT"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 64,
-      "title": "Standardiser le traitement des exceptions",
-      "effect": "Moins d'imprévisibilité, délais maîtrisés",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "VARIABILITE"
-      ],
-      "impact": 4
-    },
-    {
-      "id": 65,
-      "title": "Réduire les étapes de validation redondantes",
-      "effect": "Délai de traitement divisé par 2",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "COLLABORATION"
-      ],
-      "impact": 5
-    },
-    {
-      "id": 66,
-      "title": "Implémenter une traçabilité complète (audit log)",
-      "effect": "Conformité assurée, litiges traitables en 10 min",
-      "effort": "M",
-      "prerequisites": [],
-      "tags": [
-        "RISQUE"
-      ],
-      "impact": 5
-    }
-  ],
-  "risks_onboarding": [
-    {
-      "id": 1,
-      "title": "Jour 1 partiellement prêt",
-      "what_happens": "Des accès ou éléments critiques arrivent en retard et créent du rework la première semaine.",
-      "severity": 5,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 2,
-      "title": "Accès critiques manquants en semaine 1",
-      "what_happens": "Le collaborateur ne peut pas travailler efficacement, perte de productivité et image employeur dégradée.",
-      "severity": 5,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 3,
-      "title": "Oubli matériel ou badge",
-      "what_happens": "Rattrapage en urgence, perte de temps et mauvaise première impression.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 4,
-      "title": "Rework massif sur droits et outils",
-      "what_happens": "Corrections multiples, temps perdu, frustration.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 5,
-      "title": "Dépendance à une personne clé",
-      "what_happens": "Rupture en cas de départ ou absence, onboarding bloqué.",
-      "severity": 5,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 6,
-      "title": "Absence sans relais → onboarding bloqué",
-      "what_happens": "Process arrêté, jour 1 raté, escalade non maîtrisée.",
-      "severity": 5,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 7,
-      "title": "Statut flou → relances permanentes",
-      "what_happens": "Coordination chronophage, perte de temps, frustration.",
-      "severity": 4,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 8,
-      "title": "Documents dispersés → perte de preuve",
-      "what_happens": "Impossible de prouver ou reprendre vite en cas de départ.",
-      "severity": 4,
-      "tags": [
-        "PREUVE"
-      ]
-    },
-    {
-      "id": 9,
-      "title": "Mauvaise attribution des responsabilités",
-      "what_happens": "Étapes non faites, confusion, délais non tenus.",
-      "severity": 4,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 10,
-      "title": "Plan 30-60-90 absent → performance floue",
-      "what_happens": "Attentes floues, allers-retours, ambiguïtés.",
-      "severity": 3,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 11,
-      "title": "Incidents non tracés → répétition",
-      "what_happens": "Mêmes erreurs répétées, pas d'amélioration.",
-      "severity": 4,
-      "tags": [
-        "PREUVE",
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 12,
-      "title": "Droits trop larges → risque sécurité",
-      "what_happens": "Exposition de données sensibles, non-conformité.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 13,
-      "title": "Droits pas revus → risque persistant",
-      "what_happens": "Accès obsolètes, risque sécurité et conformité.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 14,
-      "title": "Exceptions gérées au cas par cas → variabilité",
-      "what_happens": "Incohérence, temps perdu, imprévisibilité.",
-      "severity": 3,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 15,
-      "title": "Mesure absente → pas d'amélioration",
-      "what_happens": "Pas de visibilité sur les problèmes, stagnation.",
-      "severity": 3,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 16,
-      "title": "Escalade absente → blocages longs",
-      "what_happens": "Retards non traités, frustration, jour 1 raté.",
-      "severity": 4,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 17,
-      "title": "Double saisie → erreurs d'info",
-      "what_happens": "Incohérences, temps perdu, source d'erreurs.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    },
-    {
-      "id": 18,
-      "title": "Trop d'outils/canaux → pertes et oublis",
-      "what_happens": "Fragmentation, switches, informations perdues.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    },
-    {
-      "id": 19,
-      "title": "Process non transmissible → rupture lors d'un départ",
-      "what_happens": "Impossible de reprendre en 10 minutes, perte de savoir-faire.",
-      "severity": 5,
-      "tags": [
-        "PREUVE",
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 20,
-      "title": "Coût caché sous-estimé → saturation équipe",
-      "what_happens": "Équipe saturée, burnout, turnover.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    }
-  ],
-  "rules": {
-    "quick_wins_triggers": [
-      {
-        "trigger": {
-          "question": "Q1",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          1,
-          2,
-          4
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q2",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          2,
-          21,
-          22
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q3",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          3,
-          5,
-          34
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q4",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          8,
-          9,
-          10
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q5",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          1,
-          6,
-          16
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q6",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          6,
-          10,
-          16
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q7",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          12,
-          29,
-          16
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q8",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          13,
-          14,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q9",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          17,
-          18,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q10",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          17,
-          19,
-          36
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q11",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          21,
-          22,
-          25
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q12",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          4,
-          5,
-          34
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q13",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          21,
-          22,
-          23
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q14",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          23,
-          16,
-          10
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q15",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          31,
-          15,
-          32
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q16",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          16,
-          23,
-          15
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q17",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          26,
-          28,
-          8
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q18",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          27,
-          29
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q19",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          8,
-          26,
-          29
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q20",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          1,
-          23,
-          31
-        ],
-        "weight": 0.5
-      }
-    ],
-    "risk_triggers": [
-      {
-        "trigger": {
-          "question": "Q1",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          7,
-          9,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q2",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          5,
-          9,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q3",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          10,
-          9
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q4",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          7,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q5",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          1,
-          2,
-          3
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q6",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          1,
-          3
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q7",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          2,
-          4,
-          14
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q8",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          12,
-          13
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q9",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          8,
-          11,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q10",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          8,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q11",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          5,
-          6,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q12",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          9,
-          14
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q13",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          5,
-          6
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q14",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          16,
-          1
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q15",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          15,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q16",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          16,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q17",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          18,
-          17
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q18",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          17,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q19",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          7,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "Q20",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          20
-        ],
-        "weight": 0.5
-      }
-    ]
-  },
-  "risks_generic": [
-    {
-      "id": 1,
-      "title": "Process non documenté",
-      "what_happens": "Tout repose sur la mémoire des individus ou des emails épars introuvables. Quand quelqu'un part ou est absent, l'équipe fouille dans les boîtes mail pour reconstituer comment ça marche — sans garantie de retrouver la bonne version.",
-      "severity": 5,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 2,
-      "title": "Pas de responsable identifié",
-      "what_happens": "Quand un problème surgit (facture bloquée, demande sans suite, délai dépassé), personne ne sait qui doit trancher. Les emails tournent en rond et les décisions traînent jusqu'à ce que quelqu'un prenne les choses en main par défaut.",
-      "severity": 5,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 3,
-      "title": "Suivi par email = relances constantes",
-      "what_happens": "Quand l'avancement existe uniquement dans des fils d'emails ou un Excel local non partagé, chaque partie prenante doit relancer pour savoir où ça en est. C'est du temps perdu que un outil de suivi partagé élimine en quelques jours.",
-      "severity": 4,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 4,
-      "title": "Exceptions gérées au fil de l'eau",
-      "what_happens": "Chaque cas hors-norme génère un email, une réunion improvisée ou un appel. Sans chemin défini, le délai de traitement dépend de qui est disponible ce jour-là — et varie à chaque fois.",
-      "severity": 3,
-      "tags": [
-        "CLARTE"
-      ]
-    },
-    {
-      "id": 5,
-      "title": "Pas de vérification avant de continuer",
-      "what_happens": "Sans formulaire avec champs obligatoires ou checklist de validation, les données manquantes ou erronées passent à l'étape suivante. Le rework en aval coûte 3 à 5 fois plus cher que la vérification initiale.",
-      "severity": 5,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 6,
-      "title": "Collecte d'informations par email",
-      "what_happens": "Un email de demande sans format fixe retourne des informations incomplètes dans 60 % des cas. Résultat : 2 à 4 allers-retours avant de pouvoir traiter. Un formulaire en ligne avec champs obligatoires règle ça en une heure.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 7,
-      "title": "Accès partagés ou non contrôlés",
-      "what_happens": "Mot de passe commun, accès administrateur pour tout le monde, fichier Excel modifiable par tous… N'importe qui peut effacer une donnée ou modifier un enregistrement sans laisser de trace.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 8,
-      "title": "Validations par email sans workflow",
-      "what_happens": "Un 'OK' dans un email n'est pas une validation traçable. Si la boîte mail est inaccessible ou que la personne quitte l'entreprise, la preuve d'approbation disparaît avec elle.",
-      "severity": 4,
-      "tags": [
-        "FIABILITE"
-      ]
-    },
-    {
-      "id": 9,
-      "title": "Aucune trace de qui a fait quoi",
-      "what_happens": "En cas de litige ou de question ('qui a validé ça ?', 'quand a-t-on reçu ce document ?'), la seule preuve disponible est une recherche dans les emails — longue, incomplète, et non opposable. Un outil avec historique horodaté change tout.",
-      "severity": 5,
-      "tags": [
-        "PREUVE"
-      ]
-    },
-    {
-      "id": 10,
-      "title": "Documents dans les boîtes email",
-      "what_happens": "Les pièces jointes échangées par email vivent sur le poste ou dans la boîte de la personne qui les a reçues. Un départ, un accident, une réinitialisation de compte — et ces documents sont irrécupérables.",
-      "severity": 4,
-      "tags": [
-        "PREUVE"
-      ]
-    },
-    {
-      "id": 11,
-      "title": "Process non transmissible",
-      "what_happens": "Si tout le process est dans la tête d'une personne, dans sa boîte email ou sur son Excel local, personne d'autre ne peut reprendre sans passer 1 à 2 jours à reconstituer l'historique. Un mode opératoire partagé sur Drive ou Notion réduit ce risque à zéro.",
-      "severity": 5,
-      "tags": [
-        "PREUVE",
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 12,
-      "title": "Chacun exécute à sa façon",
-      "what_happens": "Sans template ni mode opératoire partagé, deux personnes qui font 'la même chose' produisent des résultats différents. Les erreurs et oublis varient selon les individus — impossible à corriger sans standardiser.",
-      "severity": 3,
-      "tags": [
-        "PREUVE"
-      ]
-    },
-    {
-      "id": 13,
-      "title": "Dépendance à une personne clé",
-      "what_happens": "Les accès aux outils sont sur son compte, les fichiers Excel sont sur son poste, les contacts fournisseurs sont dans sa boîte mail. En cas d'absence imprévue, l'équipe ne peut pas avancer — même si elle le voulait.",
-      "severity": 5,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 14,
-      "title": "Blocages invisibles jusqu'à la crise",
-      "what_happens": "Sans alerte automatique, une demande en attente depuis 5 jours reste silencieuse jusqu'à ce que quelqu'un s'en plaigne. Avec une règle d'escalade ou une notification automatique, le même blocage est résolu en 24h.",
-      "severity": 4,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 15,
-      "title": "Pilotage à vue",
-      "what_happens": "Sans KPI suivi régulièrement (délai moyen, taux d'erreur, volume traité), les problèmes chroniques passent pour normaux. Un seul tableau de bord, même simple, suffit à déclencher les bonnes conversations.",
-      "severity": 3,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 16,
-      "title": "Incidents qui se répètent",
-      "what_happens": "Chaque anomalie est traitée en urgence par email ou appel, puis oubliée. Sans log partagé, les mêmes erreurs reviennent tous les mois. Tenir un simple tableau 'incident / cause / action' suffit à briser ce cycle.",
-      "severity": 4,
-      "tags": [
-        "RESILIENCE"
-      ]
-    },
-    {
-      "id": 17,
-      "title": "Email + Excel + Word + messagerie + Drive…",
-      "what_happens": "Plus il y a d'outils non connectés, plus le risque de perte d'information est élevé. L'information saisie dans un email doit être recopiée dans l'Excel, puis dans le logiciel — chaque transfert est une occasion d'erreur ou d'oubli.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    },
-    {
-      "id": 18,
-      "title": "Copier-coller comme méthode de travail",
-      "what_happens": "Re-saisir manuellement des données depuis un email dans un Excel, puis dans un logiciel : sur 100 occurrences, c'est en moyenne 3 à 5 jours-homme perdus par mois — et une source d'erreurs difficile à détecter.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    },
-    {
-      "id": 19,
-      "title": "Plus de 5 échanges par dossier",
-      "what_happens": "5 emails ou messages pour finaliser une occurrence de ce process = environ 30 min de coordination gaspillée par dossier. Multiplié par le volume mensuel, cela représente un poste de coût invisible mais bien réel.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    },
-    {
-      "id": 20,
-      "title": "Coût caché non chiffré",
-      "what_happens": "Additionner le temps de relance, le temps de re-saisie, le temps de recherche dans les emails et le temps de correction des erreurs donne souvent un total surprenant. Ce coût reste invisible car personne ne l'a jamais mesuré.",
-      "severity": 4,
-      "tags": [
-        "COUT"
-      ]
-    }
-  ],
-  "rules_generic": {
-    "quick_wins_triggers": [
-      {
-        "trigger": {
-          "question": "G1",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          46,
-          37,
-          40
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G2",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          38,
-          47,
-          56
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G3",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          39,
-          54,
-          53
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G4",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          40,
-          48,
-          51
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G5",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          41,
-          55,
-          45
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G6",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          41,
-          55,
-          42
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G7",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          42,
-          45,
-          52
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G8",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          42,
-          52,
-          53
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G9",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          45,
-          44,
-          52
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G10",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          44,
-          37,
-          46
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G11",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          56,
-          47,
-          46
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G12",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          46,
-          37,
-          40
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G13",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          47,
-          56,
-          38
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G14",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          48,
-          53,
-          51
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G15",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          49,
-          51,
-          39
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G16",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          51,
-          48,
-          49
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G17",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          50,
-          43,
-          54
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G18",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          43,
-          41,
-          55
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G19",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          39,
-          53,
-          43
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G20",
-          "condition": "score <= 2"
-        },
-        "quick_win_ids": [
-          46,
-          48,
-          49
-        ],
-        "weight": 0.5
-      }
-    ],
-    "risk_triggers": [
-      {
-        "trigger": {
-          "question": "G1",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          1,
-          3,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G2",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          2,
-          13,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G3",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          3,
-          19
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G4",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          4,
-          3
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G5",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          5,
-          6,
-          8
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G6",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          6,
-          5
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G7",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          7,
-          9
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G8",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          8,
-          7
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G9",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          9,
-          10,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G10",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          10,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G11",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          11,
-          13,
-          2
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G12",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          12,
-          4
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G13",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          13,
-          11
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G14",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          14,
-          3
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G15",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          15,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G16",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          16,
-          15
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G17",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          17,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G18",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          18,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G19",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          19,
-          20
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "G20",
-          "condition": "score <= 2"
-        },
-        "risk_ids": [
-          20
-        ],
-        "weight": 0.5
-      }
-    ]
-  },
-  "risks_v2": [
-    {
-      "id": 1,
-      "title": "Goulot d'étranglement humain",
-      "what_happens": "Le process mobilise un temps excessif. À volume constant ou croissant, l'équipe sature et les délais dérivent sans levier d'amélioration.",
-      "severity": 5,
-      "tags": [
-        "FRICTION"
-      ]
-    },
-    {
-      "id": 2,
-      "title": "Surcharge de relances permanentes",
-      "what_happens": "Les relances deviennent un travail à plein temps. Elles masquent un problème de visibilité ou de fiabilité qui ne se résoudra pas seul.",
-      "severity": 4,
-      "tags": [
-        "FRICTION"
-      ]
-    },
-    {
-      "id": 3,
-      "title": "Erreurs par ressaisie multiple",
-      "what_happens": "Chaque ressaisie est un risque d'erreur. À fort volume, les incohérences s'accumulent et deviennent coûteuses à corriger.",
-      "severity": 4,
-      "tags": [
-        "FRICTION",
-        "DONNEES"
-      ]
-    },
-    {
-      "id": 4,
-      "title": "Volume non maîtrisé en croissance",
-      "what_happens": "La charge augmente sans que le process s'adapte. Sans action, la qualité d'exécution se dégrade et les incidents se multiplient.",
-      "severity": 5,
-      "tags": [
-        "VOLUME"
-      ]
-    },
-    {
-      "id": 5,
-      "title": "Délais excessifs impactant les clients",
-      "what_happens": "Un délai de traitement long dégrade l'expérience client ou partenaire et génère des escalades récurrentes.",
-      "severity": 4,
-      "tags": [
-        "VOLUME"
-      ]
-    },
-    {
-      "id": 6,
-      "title": "Risque de conformité non couvert",
-      "what_happens": "Sans traçabilité ni contrôle, un audit ou un litige expose l'organisation. L'impact peut être financier, réglementaire ou réputationnel.",
-      "severity": 5,
-      "tags": [
-        "RISQUE"
-      ]
-    },
-    {
-      "id": 7,
-      "title": "Données dispersées ou non fiables",
-      "what_happens": "Des données incomplètes ou contradictoires conduisent à de mauvaises décisions et rendent toute automatisation risquée sans phase de nettoyage.",
-      "severity": 4,
-      "tags": [
-        "DONNEES"
-      ]
-    },
-    {
-      "id": 8,
-      "title": "Fragmentation entre outils sans intégration",
-      "what_happens": "Chaque transfert manuel entre outils est une source d'erreur et de délai. L'absence d'intégration bloque toute montée en échelle.",
-      "severity": 4,
-      "tags": [
-        "OUTILS"
-      ]
-    },
-    {
-      "id": 9,
-      "title": "Règles implicites = variabilité non contrôlée",
-      "what_happens": "Sans règles documentées, chaque personne applique sa propre interprétation. Le résultat est imprévisible et difficile à améliorer.",
-      "severity": 4,
-      "tags": [
-        "VARIABILITE"
-      ]
-    },
-    {
-      "id": 10,
-      "title": "Absence d'owner = projet bloqué",
-      "what_happens": "Sans responsable identifié, les projets de transformation tournent en rond. Les décisions traînent et les équipes se déresponsabilisent.",
-      "severity": 5,
-      "tags": [
-        "DEPLOIEMENT"
-      ]
-    }
-  ],
-  "rules_v2": {
-    "quick_wins_triggers": [
-      {
-        "trigger": {
-          "question": "H1",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          57,
-          58
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H2",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          58,
-          60
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H3",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          59,
-          62
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H4",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          60,
-          59
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H5",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          58,
-          65
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H6",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          65,
-          57
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H7",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          57,
-          58
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H8",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          66,
-          61
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H9",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          66,
-          59
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H10",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          66
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H11",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          59,
-          62
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H12",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          59,
-          66
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H13",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          59,
-          61
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H14",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          62,
-          57
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H15",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          62,
-          58
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H16",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          57
-        ],
-        "weight": 0.8
-      },
-      {
-        "trigger": {
-          "question": "H17",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          64,
-          61
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H18",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          61,
-          64
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H19",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          64,
-          61
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H20",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          60,
-          65
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H21",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          65,
-          60
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H22",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          60,
-          58
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H23",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          63
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H24",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          57,
-          63
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H25",
-          "condition": "score >= 2"
-        },
-        "quick_win_ids": [
-          57,
-          60
-        ],
-        "weight": 1
-      }
-    ],
-    "risk_triggers": [
-      {
-        "trigger": {
-          "question": "H1",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          1
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H2",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          2
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H3",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          3
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H4",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          3,
-          7
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H5",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          4
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H6",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          5
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H7",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          4
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H8",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          6
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H9",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          6
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H10",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          6
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H11",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          7,
-          3
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H12",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          7
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H13",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          7,
-          6
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H14",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          8
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H15",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          8,
-          3
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H17",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          9
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H18",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          9
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H19",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          9
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H20",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          1,
-          5
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H21",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          5,
-          2
-        ],
-        "weight": 1.2
-      },
-      {
-        "trigger": {
-          "question": "H22",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          2,
-          5
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H23",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          10
-        ],
-        "weight": 1.5
-      },
-      {
-        "trigger": {
-          "question": "H24",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          10
-        ],
-        "weight": 1
-      },
-      {
-        "trigger": {
-          "question": "H25",
-          "condition": "score >= 2"
-        },
-        "risk_ids": [
-          10
-        ],
-        "weight": 1
-      }
-    ]
-  }
-}

+ 1 - 1
composer.json

@@ -1,5 +1,5 @@
 {
-  "name": "intersel/audit-express-self",
+  "name": "livinweb/audit-express-self",
   "description": "Contrôle technique d’un process (quiz self-serve) - HTML/CSS/JS + PHP",
   "type": "project",
   "require": {

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
config/audit-structure.json


+ 17 - 0
config/config.loader.php

@@ -0,0 +1,17 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * Charge la configuration en fusionnant config.php et config.local.php (si présent)
+ */
+function load_config(string $root): array
+{
+    $main = require $root . '/config/config.php';
+    $local = $root . '/config/config.local.php';
+    if (is_file($local)) {
+        $overrides = require $local;
+        return array_merge($main, $overrides);
+    }
+    return $main;
+}

+ 13 - 0
config/config.local.example.php

@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * Exemple de surcharge locale.
+ * Copier en config.local.php et adapter les valeurs.
+ */
+return [
+    'booking_url' => 'https://votre-lien-calendly.com/rendez-vous',
+    'devis_url'   => 'mailto:contact@votredomaine.fr?subject=Demande%20de%20devis',
+    // 'admin_notify_webhook' => 'https://hooks.zapier.com/...',  // POST à chaque submit
+];

+ 28 - 0
config/config.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * Configuration Audit Express Self
+ *
+ * Pour surcharger en local : créer config/config.local.php (ignoré par git)
+ * et définir les clés à modifier.
+ */
+return [
+    // URLs (à adapter selon l'environnement)
+    'booking_url' => 'https://calendly.com/livinweb/diagnostic',
+    'devis_url'   => 'mailto:contact@livinweb.fr?subject=Demande%20de%20devis%20%E2%80%94%20Audit%20Express',
+
+    // Sécurité
+    'max_body_bytes'   => 1_048_576,  // 1 Mo pour les requêtes JSON
+    'rate_limit'       => [
+        'notify' => ['requests' => 10, 'window' => 60],   // 10 req/min
+        'score'  => ['requests' => 30, 'window' => 60],   // 30 req/min
+        'pdf'    => ['requests' => 20, 'window' => 60],   // 20 req/min
+        'email'  => ['requests' => 10, 'window' => 60],   // 10 req/min
+    ],
+    'allowed_notify_tools' => ['process-mapper'],  // Liste blanche pour notify.php
+
+    // Notification admin : webhook appelé à chaque submit (POST JSON : source, pack_id, answers, optional, result, pdf_base64)
+    'admin_notify_webhook' => 'https://hook.eu1.make.com/hwpp9vg8i8sw32wroqfb1y1923vb6plp',
+];

+ 0 - 1032
config/pack-onboarding-v1.json

@@ -1,1032 +0,0 @@
-{
-  "pack_id": "onboarding-v1",
-  "pack_title": "Onboarding collaborateur",
-  "pillars": [
-    {
-      "id": "CLARTE",
-      "label": "Clarté du flux"
-    },
-    {
-      "id": "FIABILITE",
-      "label": "Fiabilité et contrôle"
-    },
-    {
-      "id": "PREUVE",
-      "label": "Traçabilité et preuve"
-    },
-    {
-      "id": "RESILIENCE",
-      "label": "Résilience et continuité"
-    },
-    {
-      "id": "COUT",
-      "label": "Coût caché et friction"
-    }
-  ],
-  "questions": [
-    {
-      "id": "Q1",
-      "pillar_id": "CLARTE",
-      "label": "Votre onboarding est-il décrit quelque part, avec les étapes clés et les responsables ?",
-      "help": "Sans description partagée, le process dépend des individus et génère variabilité.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q1_0",
-          "label": "Non, rien d'écrit",
-          "points": 0
-        },
-        {
-          "id": "q1_2",
-          "label": "Partiellement (checklist incomplète)",
-          "points": 2
-        },
-        {
-          "id": "q1_3",
-          "label": "Oui, checklist complète mais pas à jour",
-          "points": 3
-        },
-        {
-          "id": "q1_5",
-          "label": "Oui, clair et à jour",
-          "points": 5
-        },
-        {
-          "id": "q1_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q1_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q2",
-      "pillar_id": "CLARTE",
-      "label": "Qui est responsable du \"process\" onboarding de bout en bout ?",
-      "help": "Ownership = cohérence, arbitrage, amélioration continue.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q2_0",
-          "label": "Personne / pas clair",
-          "points": 0
-        },
-        {
-          "id": "q2_2",
-          "label": "Une personne \"de fait\" mais pas officiel",
-          "points": 2
-        },
-        {
-          "id": "q2_4",
-          "label": "Responsable identifié, mais sans relais",
-          "points": 4
-        },
-        {
-          "id": "q2_5",
-          "label": "Responsable + relais / binôme",
-          "points": 5
-        },
-        {
-          "id": "q2_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q2_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q3",
-      "pillar_id": "CLARTE",
-      "label": "Le nouveau collaborateur a-t-il un plan 30-60-90 jours (ou équivalent) validé ?",
-      "help": "Clarifie attentes, réduit allers-retours et ambiguïtés.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q3_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q3_2",
-          "label": "Informel",
-          "points": 2
-        },
-        {
-          "id": "q3_3",
-          "label": "Oui mais pas systématique",
-          "points": 3
-        },
-        {
-          "id": "q3_5",
-          "label": "Oui systématique et partagé",
-          "points": 5
-        },
-        {
-          "id": "q3_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q3_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q4",
-      "pillar_id": "CLARTE",
-      "label": "Avez-vous une \"source unique\" pour suivre le statut onboarding (jour 1 prêt, accès, matériel, formation) ?",
-      "help": "Visibilité de l'état réduit relances.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q4_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q4_2",
-          "label": "Plusieurs supports non synchronisés",
-          "points": 2
-        },
-        {
-          "id": "q4_4",
-          "label": "Un support unique mais manuel",
-          "points": 4
-        },
-        {
-          "id": "q4_5",
-          "label": "Un support unique avec alertes / rappels",
-          "points": 5
-        },
-        {
-          "id": "q4_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q4_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q5",
-      "pillar_id": "FIABILITE",
-      "label": "\"Jour 1 prêt\" : à quelle fréquence tout est prêt (matériel + accès + infos) sans rattrapage ?",
-      "help": "Fiabilité perçue, perte de temps cachée.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q5_0",
-          "label": "Rarement",
-          "points": 0
-        },
-        {
-          "id": "q5_2",
-          "label": "1 fois sur 2",
-          "points": 2
-        },
-        {
-          "id": "q5_4",
-          "label": "Souvent",
-          "points": 4
-        },
-        {
-          "id": "q5_5",
-          "label": "Presque toujours",
-          "points": 5
-        },
-        {
-          "id": "q5_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q5_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q6",
-      "pillar_id": "FIABILITE",
-      "label": "Avez-vous un contrôle \"avant jour 1\" (check final) avec responsable et deadline ?",
-      "help": "Contrôle préventif diminue incidents.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q6_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q6_2",
-          "label": "Oui mais pas systématique",
-          "points": 2
-        },
-        {
-          "id": "q6_4",
-          "label": "Oui systématique",
-          "points": 4
-        },
-        {
-          "id": "q6_5",
-          "label": "Oui + escalade si retard",
-          "points": 5
-        },
-        {
-          "id": "q6_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q6_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q7",
-      "pillar_id": "FIABILITE",
-      "label": "Les demandes d'accès (outils, droits) passent-elles par un canal standard avec validation ?",
-      "help": "Autorisation / approbation = contrôle interne, limite erreurs.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q7_0",
-          "label": "Non, messages dispersés",
-          "points": 0
-        },
-        {
-          "id": "q7_2",
-          "label": "Oui, mais sans validation claire",
-          "points": 2
-        },
-        {
-          "id": "q7_4",
-          "label": "Oui, canal standard + validation",
-          "points": 4
-        },
-        {
-          "id": "q7_5",
-          "label": "Oui, + règles par rôle",
-          "points": 5
-        },
-        {
-          "id": "q7_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q7_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q8",
-      "pillar_id": "FIABILITE",
-      "label": "Les informations sensibles (RH, contrats, docs) sont-elles gérées avec des droits d'accès adaptés ?",
-      "help": "Contrôle d'accès limite risque et erreurs.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q8_0",
-          "label": "Non / inconnu",
-          "points": 0
-        },
-        {
-          "id": "q8_2",
-          "label": "Partiellement",
-          "points": 2
-        },
-        {
-          "id": "q8_4",
-          "label": "Oui globalement",
-          "points": 4
-        },
-        {
-          "id": "q8_5",
-          "label": "Oui, avec revue régulière des accès",
-          "points": 5
-        },
-        {
-          "id": "q8_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q8_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q9",
-      "pillar_id": "PREUVE",
-      "label": "Pouvez-vous retracer facilement \"qui a fait quoi, quand\" sur les étapes clés (contrat, accès, matériel, validations) ?",
-      "help": "Un audit trail repose sur événements horodatés et attribution.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q9_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q9_2",
-          "label": "Partiellement",
-          "points": 2
-        },
-        {
-          "id": "q9_4",
-          "label": "Oui sur la majorité",
-          "points": 4
-        },
-        {
-          "id": "q9_5",
-          "label": "Oui, historisé et horodaté",
-          "points": 5
-        },
-        {
-          "id": "q9_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q9_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q10",
-      "pillar_id": "PREUVE",
-      "label": "Les documents et validations sont-ils rattachés au dossier du collaborateur (au même endroit) ?",
-      "help": "Preuve et recherche rapide.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q10_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q10_2",
-          "label": "Dispersés",
-          "points": 2
-        },
-        {
-          "id": "q10_4",
-          "label": "Centralisés mais incomplets",
-          "points": 4
-        },
-        {
-          "id": "q10_5",
-          "label": "Centralisés et complets",
-          "points": 5
-        },
-        {
-          "id": "q10_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q10_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q11",
-      "pillar_id": "PREUVE",
-      "label": "En cas de départ d'un manager ou RH, est-ce que quelqu'un peut reprendre l'onboarding en 10 minutes ?",
-      "help": "Traçabilité opérationnelle = transmissibilité.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q11_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q11_2",
-          "label": "Difficile",
-          "points": 2
-        },
-        {
-          "id": "q11_4",
-          "label": "Oui avec effort",
-          "points": 4
-        },
-        {
-          "id": "q11_5",
-          "label": "Oui facilement",
-          "points": 5
-        },
-        {
-          "id": "q11_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q11_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q12",
-      "pillar_id": "PREUVE",
-      "label": "Avez-vous des \"modèles\" standard (emails, checklists, messages jour 1, kits) ?",
-      "help": "Standardisation crée répétabilité et preuve.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q12_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q12_2",
-          "label": "Quelques modèles",
-          "points": 2
-        },
-        {
-          "id": "q12_4",
-          "label": "Oui mais pas à jour",
-          "points": 4
-        },
-        {
-          "id": "q12_5",
-          "label": "Oui à jour et utilisés systématiquement",
-          "points": 5
-        },
-        {
-          "id": "q12_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q12_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q13",
-      "pillar_id": "RESILIENCE",
-      "label": "Si la personne clé (RH/Office/IT) est absente, l'onboarding continue-t-il sans dégrader le jour 1 ?",
-      "help": "Réduire les points uniques de défaillance est un principe de continuité.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q13_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q13_2",
-          "label": "Partiellement",
-          "points": 2
-        },
-        {
-          "id": "q13_4",
-          "label": "Oui mais plus lent",
-          "points": 4
-        },
-        {
-          "id": "q13_5",
-          "label": "Oui sans impact majeur",
-          "points": 5
-        },
-        {
-          "id": "q13_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q13_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q14",
-      "pillar_id": "RESILIENCE",
-      "label": "Avez-vous un mécanisme d'escalade si une étape critique est en retard (accès, matériel, contrat) ?",
-      "help": "Continuité = réagir vite en cas de blocage.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q14_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q14_2",
-          "label": "Informel",
-          "points": 2
-        },
-        {
-          "id": "q14_4",
-          "label": "Oui, règle claire",
-          "points": 4
-        },
-        {
-          "id": "q14_5",
-          "label": "Oui, règle + responsable + délai",
-          "points": 5
-        },
-        {
-          "id": "q14_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q14_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q15",
-      "pillar_id": "RESILIENCE",
-      "label": "Mesurez-vous au moins 1 indicateur onboarding (ex : \"jour 1 prêt\", temps de mise en productivité, incidents) ?",
-      "help": "Sans mesure, pas d'amélioration continue.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q15_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q15_2",
-          "label": "Mesure ponctuelle",
-          "points": 2
-        },
-        {
-          "id": "q15_4",
-          "label": "Mesure mensuelle",
-          "points": 4
-        },
-        {
-          "id": "q15_5",
-          "label": "Mesure régulière + actions",
-          "points": 5
-        },
-        {
-          "id": "q15_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q15_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q16",
-      "pillar_id": "RESILIENCE",
-      "label": "Avez-vous une procédure simple en cas d'incident onboarding (ex : accès manquant) : qui contacter, délai, résolution ?",
-      "help": "Continuité opérationnelle, proche de la logique de plan de contingence.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q16_0",
-          "label": "Non",
-          "points": 0
-        },
-        {
-          "id": "q16_2",
-          "label": "Informel",
-          "points": 2
-        },
-        {
-          "id": "q16_4",
-          "label": "Oui",
-          "points": 4
-        },
-        {
-          "id": "q16_5",
-          "label": "Oui + suivi des incidents",
-          "points": 5
-        },
-        {
-          "id": "q16_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q16_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q17",
-      "pillar_id": "COUT",
-      "label": "Combien de canaux/outils utilisez-vous pour un onboarding (hors email) ?",
-      "help": "Plus d'outils fragmentés = plus de switches, oublis, double saisie.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q17_5",
-          "label": "0 à 1",
-          "points": 5
-        },
-        {
-          "id": "q17_4",
-          "label": "2 à 3",
-          "points": 4
-        },
-        {
-          "id": "q17_2",
-          "label": "4 à 6",
-          "points": 2
-        },
-        {
-          "id": "q17_0",
-          "label": "7+",
-          "points": 0
-        },
-        {
-          "id": "q17_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q17_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q18",
-      "pillar_id": "COUT",
-      "label": "Double saisie : à quelle fréquence saisissez-vous les mêmes infos à plusieurs endroits ?",
-      "help": "Double saisie = temps perdu + source d'erreurs.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q18_0",
-          "label": "Souvent",
-          "points": 0
-        },
-        {
-          "id": "q18_2",
-          "label": "Parfois",
-          "points": 2
-        },
-        {
-          "id": "q18_4",
-          "label": "Rarement",
-          "points": 4
-        },
-        {
-          "id": "q18_5",
-          "label": "Jamais",
-          "points": 5
-        },
-        {
-          "id": "q18_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q18_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q19",
-      "pillar_id": "COUT",
-      "label": "Relances : combien de relances \"internes\" par onboarding (en moyenne) ?",
-      "help": "Relances = proxy direct de friction.",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q19_0",
-          "label": "10+",
-          "points": 0
-        },
-        {
-          "id": "q19_2",
-          "label": "5 à 9",
-          "points": 2
-        },
-        {
-          "id": "q19_4",
-          "label": "2 à 4",
-          "points": 4
-        },
-        {
-          "id": "q19_5",
-          "label": "0 à 1",
-          "points": 5
-        },
-        {
-          "id": "q19_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q19_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    },
-    {
-      "id": "Q20",
-      "pillar_id": "COUT",
-      "label": "Urgence : pourquoi faites-vous ce contrôle technique maintenant ?",
-      "help": "Sert à adapter le ton et la priorisation (sans trop influencer le score global).",
-      "type": "radio",
-      "options": [
-        {
-          "id": "q20_2",
-          "label": "Curiosité",
-          "points": 2
-        },
-        {
-          "id": "q20_1",
-          "label": "Incidents répétés / jour 1 raté",
-          "points": 1
-        },
-        {
-          "id": "q20_4a",
-          "label": "Croissance / vague recrutement",
-          "points": 4
-        },
-        {
-          "id": "q20_3",
-          "label": "Départ personne clé / réorganisation",
-          "points": 3
-        },
-        {
-          "id": "q20_4b",
-          "label": "Audit / exigence interne",
-          "points": 4
-        },
-        {
-          "id": "q20_dk",
-          "label": "Je ne sais pas",
-          "points": 1
-        },
-        {
-          "id": "q20_na",
-          "label": "Non pertinent — N/A",
-          "points": 3
-        }
-      ]
-    }
-  ],
-  "scoring": {
-    "level_thresholds": {
-      "A": {
-        "min": 85,
-        "max": 100,
-        "label": "Excellente maîtrise"
-      },
-      "B": {
-        "min": 70,
-        "max": 84,
-        "label": "Solide mais perfectible"
-      },
-      "C": {
-        "min": 50,
-        "max": 69,
-        "label": "À améliorer"
-      },
-      "D": {
-        "min": 0,
-        "max": 49,
-        "label": "Risques élevés"
-      }
-    },
-    "anti_cheat_caps": {
-      "Q1": {
-        "trigger_points": 0,
-        "pillar_id": "CLARTE",
-        "cap": 12
-      },
-      "Q9": {
-        "trigger_points": 0,
-        "pillar_id": "PREUVE",
-        "cap": 10
-      },
-      "Q5": {
-        "trigger_points": 0,
-        "pillar_id": "FIABILITE",
-        "cap": 12
-      }
-    }
-  },
-  "confidence": {
-    "dk_count_thresholds": {
-      "high": {
-        "max_dk": 2,
-        "label": "Haute confiance"
-      },
-      "medium": {
-        "min_dk": 3,
-        "max_dk": 5,
-        "label": "Confiance moyenne"
-      },
-      "low": {
-        "min_dk": 6,
-        "label": "Faible confiance"
-      }
-    }
-  },
-  "cost_hidden": {
-    "formula": "minutes_per_onboarding = Q19_minutes + Q18_minutes + Q5_minutes + Q17_minutes",
-    "default_hourly_cost": 50,
-    "components": {
-      "Q19": {
-        "option_mapping": {
-          "q19_5": 10,
-          "q19_4": 30,
-          "q19_2": 60,
-          "q19_0": 90
-        }
-      },
-      "Q18": {
-        "option_mapping": {
-          "q18_5": 0,
-          "q18_4": 10,
-          "q18_2": 25,
-          "q18_0": 45
-        }
-      },
-      "Q5": {
-        "option_mapping": {
-          "q5_0": 120,
-          "q5_2": 60,
-          "q5_4": 30,
-          "q5_5": 10
-        }
-      },
-      "Q17": {
-        "option_mapping": {
-          "q17_5": 5,
-          "q17_4": 15,
-          "q17_2": 30,
-          "q17_0": 45
-        }
-      }
-    },
-    "cap_max_hours": 12,
-    "cap_min_hours": 0.5,
-    "cap_min_condition": "friction_faibles_count >= 2",
-    "friction_faibles_definition": "Q17 (0-1 ou 2-3), Q18 (jamais ou rarement), Q19 (0-1), Q5 (souvent ou presque toujours) - option avec points >= 4"
-  },
-  "optional_questions": {
-    "company_size": {
-      "id": "company_size",
-      "label": "Taille d'entreprise",
-      "type": "radio",
-      "required": false,
-      "options": [
-        {
-          "id": "size_1_10",
-          "label": "1-10"
-        },
-        {
-          "id": "size_11_50",
-          "label": "11-50"
-        },
-        {
-          "id": "size_51_200",
-          "label": "51-200"
-        },
-        {
-          "id": "size_200_plus",
-          "label": "200+"
-        }
-      ]
-    },
-    "role": {
-      "id": "role",
-      "label": "Fonction",
-      "type": "radio",
-      "required": false,
-      "options": [
-        {
-          "id": "role_rh",
-          "label": "RH"
-        },
-        {
-          "id": "role_ops",
-          "label": "Ops"
-        },
-        {
-          "id": "role_finance",
-          "label": "Finance"
-        },
-        {
-          "id": "role_it",
-          "label": "IT"
-        },
-        {
-          "id": "role_direction",
-          "label": "Direction"
-        },
-        {
-          "id": "role_autre",
-          "label": "Autre"
-        }
-      ]
-    },
-    "hourly_cost": {
-      "id": "hourly_cost",
-      "label": "Coût horaire indicatif (optionnel)",
-      "type": "radio",
-      "required": false,
-      "options": [
-        {
-          "id": "cost_lt_35",
-          "label": "<35€",
-          "value": 35
-        },
-        {
-          "id": "cost_35_60",
-          "label": "35-60€",
-          "value": 50
-        },
-        {
-          "id": "cost_60_90",
-          "label": "60-90€",
-          "value": 75
-        },
-        {
-          "id": "cost_gt_90",
-          "label": "90€+",
-          "value": 90
-        }
-      ]
-    },
-    "monthly_volume_recruits": {
-      "id": "monthly_volume_recruits",
-      "label": "Recrutements par mois",
-      "type": "radio",
-      "required_for_cost": true,
-      "options": [
-        {
-          "id": "vol_0_2",
-          "label": "0-2",
-          "value": 1
-        },
-        {
-          "id": "vol_3_5",
-          "label": "3-5",
-          "value": 4
-        },
-        {
-          "id": "vol_6_10",
-          "label": "6-10",
-          "value": 8
-        },
-        {
-          "id": "vol_11_20",
-          "label": "11-20",
-          "value": 15
-        },
-        {
-          "id": "vol_21_plus",
-          "label": "21+",
-          "value": 25
-        }
-      ]
-    }
-  }
-}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
config/packs/pack-onboarding-v1.json


+ 17 - 0
modx/chunks/ae_cost_hidden.html

@@ -0,0 +1,17 @@
+<!-- Chunk : ae_cost_hidden
+     Placeholders : [[+hours_per_month]] [[+eur_per_month]]
+-->
+<div class="cost-block">
+  <div class="h2">Coût caché estimé</div>
+  <div class="cost-figures">
+    <div class="cost-fig">
+      <span class="val">[[+hours_per_month]] h</span>
+      <span class="lbl">par mois (estimé)</span>
+    </div>
+    <div class="cost-fig">
+      <span class="val">~[[+eur_per_month]] €</span>
+      <span class="lbl">par mois (indicatif)</span>
+    </div>
+  </div>
+  <p class="hint">Estimation indicative, à valider par mesure réelle.</p>
+</div>

+ 37 - 0
modx/chunks/ae_cta_unlocked.html

@@ -0,0 +1,37 @@
+<!-- Chunk : ae_cta_unlocked
+     Affiché après la capture email (email débloqué).
+     Placeholders : [[+booking_url]] [[+devis_url]] [[+select_url]] [[+action_url]] [[+audit_uid]] [[+email]]
+-->
+<div class="unlocked-ctas">
+  <div class="unlocked-ctas__inner">
+
+    <div class="h2" style="margin-bottom:6px">Et maintenant ?</div>
+    <p class="lead" style="margin-bottom:24px">
+      Votre diagnostic révèle des opportunités concrètes. Nous pouvons vous aider
+      à les transformer en plan d'action avec les bons outils digitaux.
+    </p>
+
+    <div class="cta-block">
+      [[+booking_url:notempty=`<a class="btn btn--primary btn--cta-main" href="[[+booking_url]]" target="_blank" rel="noreferrer">📅&nbsp;Réserver un appel découverte gratuit — 30 min</a>`]]
+      [[+devis_url:notempty=`<a class="btn btn--outline btn--cta-secondary" href="[[+devis_url]]">✉&nbsp;Demander un devis</a>`]]
+    </div>
+
+    <p class="hint" style="text-align:center;margin-top:10px">
+      Pas d'engagement. On analyse vos résultats ensemble et on vous propose une solution adaptée.
+    </p>
+
+    <hr style="border:none;border-top:1px solid var(--border,#e2e8f0);margin:24px 0">
+
+    <div class="btnrow" style="justify-content:center;gap:10px">
+      <!-- Téléchargement PDF direct -->
+      <a class="btn btn--outline"
+         href="[[+action_url:replace=`resultats==pdf`]]?audit=[[+audit_uid]]">
+        ⬇&nbsp;Télécharger mon PDF
+      </a>
+      <a class="btn btn--outline" href="[[+select_url]]" style="font-size:13px">
+        Diagnostiquer un autre process
+      </a>
+    </div>
+
+  </div>
+</div>

+ 22 - 0
modx/chunks/ae_optional.html

@@ -0,0 +1,22 @@
+<!-- Chunk : ae_optional
+     Placeholders : [[+fields]] [[+action_url]] [[+quiz_url]] [[+audit_uid]]
+-->
+<div class="grid">
+  <div class="card">
+    <span class="tag tag--new" style="margin-bottom:12px;display:inline-block">Optionnel</span>
+    <h1 class="h1">Quelques infos pour le coût caché</h1>
+    <p class="lead">Ces données servent uniquement à estimer le coût caché en heures/mois (indicatif). Vous pouvez passer directement.</p>
+
+    <form method="POST" action="[[+action_url]]">
+      <input type="hidden" name="ae_action"  value="ae_optional">
+      <input type="hidden" name="audit_uid"  value="[[+audit_uid]]">
+
+      [[+fields]]
+
+      <div class="btnrow" style="margin-top:20px">
+        <a href="[[+quiz_url]]" class="btn btn--outline">← Retour au quiz</a>
+        <button type="submit" class="btn btn--primary">Voir mes résultats →</button>
+      </div>
+    </form>
+  </div>
+</div>

+ 9 - 0
modx/chunks/ae_optional_field.html

@@ -0,0 +1,9 @@
+<!-- Chunk : ae_optional_field
+     Placeholders : [[+label]] [[+radios]]
+-->
+<div class="field">
+  <label>[[+label]]</label>
+  <div class="options" style="margin-top:6px">
+    [[+radios]]
+  </div>
+</div>

+ 13 - 0
modx/chunks/ae_optional_radio.html

@@ -0,0 +1,13 @@
+<!-- Chunk : ae_optional_radio
+     Placeholders : [[+key]] [[+value]] [[+label]] [[+checked]]
+-->
+<label class="opt" for="opt_[[+key]]_[[+value]]">
+  <input
+    id="opt_[[+key]]_[[+value]]"
+    type="radio"
+    name="opt_[[+key]]"
+    value="[[+value]]"
+    [[+checked]]
+  >
+  <div><strong>[[+label]]</strong></div>
+</label>

+ 12 - 0
modx/chunks/ae_pack_card.html

@@ -0,0 +1,12 @@
+<!-- Chunk : ae_pack_card
+     Placeholders : [[+pack_id]] [[+title]] [[+desc]] [[+tag]] [[+tag_class]] [[+action_url]]
+-->
+<form method="POST" action="[[+action_url]]" style="display:contents">
+  <input type="hidden" name="ae_action" value="select_pack">
+  <input type="hidden" name="pack_id" value="[[+pack_id]]">
+  <button type="submit" class="pack-card" style="width:100%;text-align:left;cursor:pointer;background:none;border:none;padding:0">
+    <span class="tag [[+tag_class]]">[[+tag]]</span>
+    <div class="title" style="margin-top:8px">[[+title]] <span class="arrow">→</span></div>
+    <div class="desc">[[+desc]]</div>
+  </button>
+</form>

+ 10 - 0
modx/chunks/ae_pillar_row.html

@@ -0,0 +1,10 @@
+<!-- Chunk : ae_pillar_row
+     Placeholders : [[+label]] [[+score]] [[+max]] [[+pct]]
+-->
+<div class="pRow">
+  <div class="name">[[+label]]</div>
+  <div class="val">[[+score]]/[[+max]]</div>
+  <div class="bar">
+    <div style="width:[[+pct]]%"></div>
+  </div>
+</div>

+ 12 - 0
modx/chunks/ae_question_option.html

@@ -0,0 +1,12 @@
+
+<label class="opt" for="opt_[[+alias]]">
+  <input
+    id="[[+id]]"
+    type="radio"
+    name="option_id"
+    value="[[+alias]]"
+    data-question-id="[[+id]]"
+    class="ae-radio-auto"
+  >
+  <div><strong>[[+pagetitle]]</strong></div>
+</label>

+ 52 - 0
modx/chunks/ae_quiz.html

@@ -0,0 +1,52 @@
+<!-- Chunk : ae_quiz
+     Placeholders : [[+progress]] [[+question_id]] [[+question]] [[+help]] [[+options]]
+                    [[+action_url]] [[+select_url]] [[+audit_uid]]
+                    [[+can_prev]] [[+can_next]] [[+btn_next]] [[+btn_class]]
+-->
+<div class="grid">
+  <div class="card">
+    [[+progress]]
+
+    <form method="POST" action="[[+action_url]]" id="ae-quiz-form">
+      <input type="hidden" name="ae_action"   value="ae_answer">
+      <input type="hidden" name="audit_uid"   value="[[+audit_uid]]">
+      <input type="hidden" name="question_id" value="[[+question_id]]">
+
+      <div class="qTitle">[[+question]]</div>
+      [[+help]]
+
+      <div class="options" id="ae-options">
+        [[+options]]
+      </div>
+
+      <div class="btnrow" style="margin-top:18px">
+        <!-- Bouton Précédent via formulaire séparé (évite les conflits de submit) -->
+        <button type="submit" form="ae-prev-form" class="btn btn--outline" [[+can_prev]]>← Précédent</button>
+        <button type="submit" class="btn [[+btn_class]]" [[+can_next]] id="ae-btn-next">[[+btn_next]]</button>
+      </div>
+      <p class="hint" style="margin-top:10px">Vous pouvez modifier vos réponses avant la fin.</p>
+    </form>
+
+    <!-- Formulaire précédent (soumission indépendante) -->
+    <form method="POST" action="[[+action_url]]" id="ae-prev-form" style="display:none">
+      <input type="hidden" name="ae_action" value="ae_prev">
+      <input type="hidden" name="audit_uid" value="[[+audit_uid]]">
+    </form>
+  </div>
+</div>
+
+<!-- Auto-avance au clic radio (380 ms, comme la version JS SPA) -->
+<script>
+(function () {
+  var form = document.getElementById('ae-quiz-form');
+  var opts = document.getElementById('ae-options');
+  if (!form || !opts) return;
+  opts.addEventListener('change', function (e) {
+    if (e.target && e.target.type === 'radio') {
+      var btn = document.getElementById('ae-btn-next');
+      if (btn) btn.removeAttribute('disabled');
+      setTimeout(function () { form.submit(); }, 380);
+    }
+  });
+})();
+</script>

+ 14 - 0
modx/chunks/ae_quiz_progress.html

@@ -0,0 +1,14 @@
+<div class="quizHead">
+  <span class="tag" style="font-size:11px">[[+pagetitle]]</span>
+  <div class="quizStep">
+    <strong class="js-pos"></strong><span class="js-total"></span>
+  </div>
+</div>
+<div class="progressWrap">
+  <div class="progress">
+    <div class="js-bar" style="width:0%"></div>
+  </div>
+  <div class="progressMeta">
+    <span class="progressPct js-pct">0&nbsp;%</span>
+  </div>
+</div>

+ 50 - 0
modx/chunks/ae_results.html

@@ -0,0 +1,50 @@
+<!-- Chunk : ae_results
+     Placeholders : [[+pack_title]] [[+score_total]] [[+level]] [[+level_label]]
+                    [[+dot_color]] [[+confidence]] [[+pillars_html]]
+                    [[+risks_html]] [[+wins_html]] [[+cost_html]] [[+gate_html]] [[+unlocked]]
+-->
+<div class="grid">
+
+  <!-- Carte score global -->
+  <div class="card">
+    <div style="display:flex;align-items:center;gap:10px;margin-bottom:16px">
+      <span class="tag">[[+pack_title]]</span>
+    </div>
+    <div class="scoreBox">
+      <div>
+        <div class="scoreLabel">Score global</div>
+        <div class="scoreBig">[[+score_total]]/100</div>
+        <div class="level-badge" style="margin-top:10px">
+          <span class="level-dot" style="background:[[+dot_color]]"></span>
+          <span>[[+level]] — [[+level_label]]</span>
+        </div>
+        <div class="confidence">Confiance du diagnostic : [[+confidence]]</div>
+      </div>
+    </div>
+    <div class="pillars">
+      [[+pillars_html]]
+    </div>
+  </div>
+
+  <!-- 3 risques probables (toujours visibles) -->
+  <div class="card">
+    <div class="h2">3 risques probables</div>
+    [[+risks_html:notempty=`<ol class="list">[[+risks_html]]</ol>`:else=`<p class="muted small">Aucun risque majeur détecté.</p>`]]
+  </div>
+
+  <!-- Coût caché (si calculé) -->
+  [[+cost_html]]
+
+  <!-- Gate email OU CTAs débloqués -->
+  [[+gate_html]]
+
+  <!-- Quick wins (uniquement si débloqué) -->
+  [[+wins_html:notempty=`
+  <div class="card">
+    <div class="h2">5 quick wins prioritaires</div>
+    <ol class="list">[[+wins_html]]</ol>
+    <p class="hint" style="margin-top:8px">Le PDF contient les 5 actions avec détail effort/impact.</p>
+  </div>
+  `]]
+
+</div>

+ 7 - 0
modx/chunks/ae_risk_item.html

@@ -0,0 +1,7 @@
+<!-- Chunk : ae_risk_item
+     Placeholders : [[+title]] [[+what_happens]]
+-->
+<li>
+  <strong>[[+title]]</strong>
+  <div class="hint">[[+what_happens]]</div>
+</li>

+ 18 - 0
modx/chunks/ae_select_pack.html

@@ -0,0 +1,18 @@
+<!-- Chunk : ae_select_pack
+     Placeholders : [[+cards]] [[+landing_url]]
+-->
+<div class="grid">
+  <div class="card">
+    <h1 class="h1">Choisissez le process à diagnostiquer</h1>
+    <p class="lead">Sélectionnez un pack pré-configuré ou utilisez le questionnaire universel.</p>
+
+    <div class="section-label" style="margin-top:18px">Packs disponibles</div>
+    <div class="grid grid--2">
+      [[+cards]]
+    </div>
+
+    <div class="btnrow" style="margin-top:18px">
+      <a href="[[+landing_url]]" class="btn btn--outline">← Retour</a>
+    </div>
+  </div>
+</div>

+ 38 - 0
modx/chunks/ae_unlock_gate.html

@@ -0,0 +1,38 @@
+<!-- Chunk : ae_unlock_gate
+     Affiché quand l'email n'a pas encore été saisi.
+     Placeholders : [[+action_url]] [[+audit_uid]] [[+risks_html]] [[+email]]
+-->
+<div class="unlock-gate">
+  <div class="unlock-gate__inner">
+    <div class="unlock-gate__icon">↓</div>
+    <div class="h2" style="margin-bottom:6px">Débloquez vos axes d'amélioration</div>
+    <p class="lead" style="margin-bottom:20px">
+      Entrez votre email professionnel pour accéder aux 5 actions prioritaires
+      et télécharger votre PDF synthèse.
+    </p>
+
+    <!-- Teaser risques -->
+    <div class="unlock-risks">
+      [[+risks_html]]
+    </div>
+
+    <form class="unlock-form" method="POST" action="[[+action_url]]">
+      <input type="hidden" name="ae_action"  value="ae_capture_email">
+      <input type="hidden" name="audit_uid"  value="[[+audit_uid]]">
+      <div class="unlock-row">
+        <input
+          type="email"
+          name="email"
+          required
+          placeholder="vous@entreprise.com"
+          autocomplete="email"
+          value="[[+email]]"
+        >
+        <button class="btn btn--primary btn--unlock" type="submit">Débloquer →</button>
+      </div>
+      <p class="hint" style="margin-top:8px;text-align:center">
+        Aucun spam. Désinscription en 1 clic.
+      </p>
+    </form>
+  </div>
+</div>

+ 7 - 0
modx/chunks/ae_win_item.html

@@ -0,0 +1,7 @@
+<!-- Chunk : ae_win_item
+     Placeholders : [[+title]] [[+effect]] [[+effort]]
+-->
+<li>
+  <strong>[[+title]]</strong>
+  <div class="hint">[[+effect]] · Effort : [[+effort]]</div>
+</li>

+ 68 - 0
modx/model/audit_express/auditrequest.class.php

@@ -0,0 +1,68 @@
+<?php
+/**
+ * AuditRequest — Classe xPDO de base
+ * Représente une session d'audit (quiz + résultat) en base de données.
+ */
+class AuditRequest extends xPDOSimpleObject
+{
+    /**
+     * Retourne les réponses sous forme de tableau PHP.
+     */
+    public function getAnswersArray(): array
+    {
+        $raw = $this->get('answers');
+        if (!$raw) return [];
+        return json_decode($raw, true) ?? [];
+    }
+
+    /**
+     * Enregistre un tableau de réponses en JSON.
+     */
+    public function setAnswersArray(array $answers): void
+    {
+        $this->set('answers', json_encode($answers, JSON_UNESCAPED_UNICODE));
+    }
+
+    /**
+     * Retourne les données optionnelles sous forme de tableau PHP.
+     */
+    public function getOptionalArray(): array
+    {
+        $raw = $this->get('optional_data');
+        if (!$raw) return [];
+        return json_decode($raw, true) ?? [];
+    }
+
+    public function setOptionalArray(array $optional): void
+    {
+        $this->set('optional_data', json_encode($optional, JSON_UNESCAPED_UNICODE));
+    }
+
+    /**
+     * Retourne le résultat calculé sous forme de tableau PHP.
+     */
+    public function getResultArray(): array
+    {
+        $raw = $this->get('result');
+        if (!$raw) return [];
+        return json_decode($raw, true) ?? [];
+    }
+
+    public function setResultArray(array $result): void
+    {
+        $this->set('result', json_encode($result, JSON_UNESCAPED_UNICODE));
+    }
+
+    /**
+     * Met à jour updated_at automatiquement avant chaque save().
+     */
+    public function save($cacheFlag = null): bool
+    {
+        $now = (new \DateTime())->format('Y-m-d H:i:s');
+        if (!$this->get('created_at')) {
+            $this->set('created_at', $now);
+        }
+        $this->set('updated_at', $now);
+        return parent::save($cacheFlag);
+    }
+}

+ 5 - 0
modx/model/audit_express/mysql/auditrequest.class.php

@@ -0,0 +1,5 @@
+<?php
+/**
+ * AuditRequest — Pilote MySQL xPDO
+ */
+class AuditRequestMysql extends AuditRequest {}

+ 125 - 0
modx/model/audit_express/mysql/auditrequest.map.inc.php

@@ -0,0 +1,125 @@
+<?php
+/**
+ * AuditRequest — Map xPDO MySQL
+ * Généré depuis schema/audit_express.mysql.schema.xml
+ */
+$xpdo_meta_map['AuditRequest'] = [
+    'package'  => 'audit_express',
+    'version'  => '1.1',
+    'table'    => 'audit_requests',
+    'extends'  => 'xPDOSimpleObject',
+
+    'fields' => [
+        'audit_uid'     => '',
+        'pack_id'       => '',
+        'answers'       => null,
+        'optional_data' => null,
+        'result'        => null,
+        'email'         => null,
+        'status'        => 'draft',
+        'ip_hash'       => null,
+        'step'          => 0,
+        'created_at'    => null,
+        'updated_at'    => null,
+    ],
+
+    'fieldMeta' => [
+        'audit_uid' => [
+            'dbtype'    => 'varchar',
+            'precision' => '36',
+            'phptype'   => 'string',
+            'null'      => false,
+            'default'   => '',
+            'index'     => 'unique',
+        ],
+        'pack_id' => [
+            'dbtype'    => 'varchar',
+            'precision' => '64',
+            'phptype'   => 'string',
+            'null'      => false,
+            'default'   => '',
+        ],
+        'answers' => [
+            'dbtype'  => 'text',
+            'phptype' => 'string',
+            'null'    => true,
+        ],
+        'optional_data' => [
+            'dbtype'  => 'text',
+            'phptype' => 'string',
+            'null'    => true,
+        ],
+        'result' => [
+            'dbtype'  => 'mediumtext',
+            'phptype' => 'string',
+            'null'    => true,
+        ],
+        'email' => [
+            'dbtype'    => 'varchar',
+            'precision' => '255',
+            'phptype'   => 'string',
+            'null'      => true,
+        ],
+        'status' => [
+            'dbtype'    => 'enum',
+            'precision' => "'draft','completed','emailed'",
+            'phptype'   => 'string',
+            'null'      => false,
+            'default'   => 'draft',
+        ],
+        'ip_hash' => [
+            'dbtype'    => 'varchar',
+            'precision' => '64',
+            'phptype'   => 'string',
+            'null'      => true,
+        ],
+        'step' => [
+            'dbtype'    => 'tinyint',
+            'precision' => '3',
+            'phptype'   => 'integer',
+            'null'      => false,
+            'default'   => 0,
+        ],
+        'created_at' => [
+            'dbtype'  => 'datetime',
+            'phptype' => 'datetime',
+            'null'    => false,
+        ],
+        'updated_at' => [
+            'dbtype'  => 'datetime',
+            'phptype' => 'datetime',
+            'null'    => false,
+        ],
+    ],
+
+    'indexes' => [
+        'PRIMARY' => [
+            'alias'   => 'PRIMARY',
+            'primary' => true,
+            'unique'  => true,
+            'type'    => 'BTREE',
+            'columns' => ['id' => ['length' => '', 'collation' => 'A', 'null' => false]],
+        ],
+        'audit_uid' => [
+            'alias'   => 'audit_uid',
+            'primary' => false,
+            'unique'  => true,
+            'type'    => 'BTREE',
+            'columns' => ['audit_uid' => ['length' => '', 'collation' => 'A', 'null' => false]],
+        ],
+        'status' => [
+            'alias'   => 'status',
+            'primary' => false,
+            'unique'  => false,
+            'type'    => 'BTREE',
+            'columns' => ['status' => ['length' => '', 'collation' => 'A', 'null' => false]],
+        ],
+        'created_at' => [
+            'alias'   => 'created_at',
+            'primary' => false,
+            'unique'  => false,
+            'type'    => 'BTREE',
+            'columns' => ['created_at' => ['length' => '', 'collation' => 'A', 'null' => false]],
+        ],
+    ],
+];

+ 60 - 0
modx/plugins/AuditExpress_Init.php

@@ -0,0 +1,60 @@
+<?php
+/**
+ * Plugin : AuditExpress_Init
+ *
+ * Événements à attacher :
+ *   - OnMODXInit  (priorité 1) — charge le modèle xPDO à chaque requête
+ *   - OnHandleRequest             — redirige si session expirée sur pages quiz/résultats
+ *
+ * Paramètre plugin :
+ *   core_path  — chemin vers components/audit_express/ (facultatif, auto-détecté)
+ */
+
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+
+// ── Charger le modèle xPDO ────────────────────────────────────────────────
+if ($modx->addPackage('audit_express', $corePath . 'model/')) {
+    // Optionnel : logger la version au démarrage (utile pour le debug)
+    // $modx->log(xPDO::LOG_LEVEL_DEBUG, '[AuditExpress] modèle chargé depuis ' . $corePath . 'model/');
+}
+
+// ── OnHandleRequest : guard sur les ressources protégées ──────────────────
+if ($modx->event->name === 'OnHandleRequest') {
+
+    $protectedResources = [
+        (int) $modx->getOption('ae.resource.quiz',     null, 0),
+        (int) $modx->getOption('ae.resource.optional', null, 0),
+        (int) $modx->getOption('ae.resource.results',  null, 0),
+    ];
+
+    $currentResourceId = (int) $modx->resource?->get('id');
+
+    if ($currentResourceId && in_array($currentResourceId, $protectedResources, true)) {
+        $selectResourceId = (int) $modx->getOption('ae.resource.select', null, 0);
+
+        // Ressource quiz/optional : nécessite ae_audit_uid en session
+        if (in_array($currentResourceId, [
+            (int) $modx->getOption('ae.resource.quiz',     null, 0),
+            (int) $modx->getOption('ae.resource.optional', null, 0),
+        ], true)) {
+            if (empty($_SESSION['ae_audit_uid'])) {
+                $url = $selectResourceId
+                    ? $modx->makeUrl($selectResourceId, '', '', 'full')
+                    : '/';
+                $modx->sendRedirect($url);
+            }
+        }
+
+        // Ressource résultats : nécessite le paramètre ?audit= OU la session
+        if ($currentResourceId === (int) $modx->getOption('ae.resource.results', null, 0)) {
+            $uid = trim($_GET['audit'] ?? $_SESSION['ae_audit_uid'] ?? '');
+            if (!$uid) {
+                $url = $selectResourceId
+                    ? $modx->makeUrl($selectResourceId, '', '', 'full')
+                    : '/';
+                $modx->sendRedirect($url);
+            }
+        }
+    }
+}

+ 620 - 0
modx/preview-chunks.html

@@ -0,0 +1,620 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <title>Spec visuelle — Chunks & Templates · Audit Express</title>
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link rel="stylesheet" href="../public/assets/css/app.css">
+  <style>
+    /* ══════════════════════════════════
+       SYSTÈME D'ANNOTATION
+    ══════════════════════════════════ */
+
+    /* Chaque élément annoté */
+    [data-chunk] {
+      position: relative;
+    }
+    [data-chunk]::before {
+      content: attr(data-chunk);
+      position: absolute;
+      top: -1px;
+      left: -1px;
+      z-index: 10;
+      font-family: 'Courier New', monospace;
+      font-size: 10px;
+      font-weight: 700;
+      letter-spacing: .3px;
+      padding: 2px 7px;
+      border-radius: 3px 0 3px 0;
+      line-height: 1.6;
+      pointer-events: none;
+      white-space: nowrap;
+    }
+    [data-chunk] {
+      outline: 2px solid;
+      outline-offset: 1px;
+    }
+
+    /* Couleurs par catégorie */
+    [data-chunk^="ae_pack"]     { outline-color: #e2a300; }
+    [data-chunk^="ae_pack"]::before  { background: #e2a300; color: #fff; }
+    [data-chunk^="ae_select"]   { outline-color: #e2a300; }
+    [data-chunk^="ae_select"]::before { background: #e2a300; color: #fff; }
+
+    [data-chunk^="ae_quiz"]     { outline-color: #7c3aed; }
+    [data-chunk^="ae_quiz"]::before  { background: #7c3aed; color: #fff; }
+    [data-chunk^="ae_question"] { outline-color: #a855f7; }
+    [data-chunk^="ae_question"]::before { background: #a855f7; color: #fff; }
+    [data-chunk^="ae_optional"] { outline-color: #0891b2; }
+    [data-chunk^="ae_optional"]::before { background: #0891b2; color: #fff; }
+
+    [data-chunk^="ae_pillar"]   { outline-color: #059669; }
+    [data-chunk^="ae_pillar"]::before { background: #059669; color: #fff; }
+    [data-chunk^="ae_risk"]     { outline-color: #dc2626; }
+    [data-chunk^="ae_risk"]::before { background: #dc2626; color: #fff; }
+    [data-chunk^="ae_win"]      { outline-color: #16a34a; }
+    [data-chunk^="ae_win"]::before { background: #16a34a; color: #fff; }
+    [data-chunk^="ae_cost"]     { outline-color: #d97706; }
+    [data-chunk^="ae_cost"]::before { background: #d97706; color: #fff; }
+    [data-chunk^="ae_unlock"]   { outline-color: #173258; }
+    [data-chunk^="ae_unlock"]::before { background: #173258; color: #fff; }
+    [data-chunk^="ae_cta"]      { outline-color: #00bef3; }
+    [data-chunk^="ae_cta"]::before { background: #00bef3; color: #fff; }
+    [data-chunk^="ae_results"]  { outline-color: #2F506D; }
+    [data-chunk^="ae_results"]::before { background: #2F506D; color: #fff; }
+
+    /* Templates */
+    [data-tpl] {
+      position: relative;
+      outline: 3px dashed #04173d;
+      outline-offset: 6px;
+    }
+    [data-tpl]::after {
+      content: 'Template : ' attr(data-tpl);
+      position: absolute;
+      top: -20px;
+      right: 0;
+      font-family: 'Courier New', monospace;
+      font-size: 10px;
+      font-weight: 700;
+      background: #04173d;
+      color: #fff;
+      padding: 2px 8px;
+      border-radius: 3px;
+      white-space: nowrap;
+    }
+
+    /* MODE SANS ANNOTATIONS */
+    body.no-annot [data-chunk] { outline: none; }
+    body.no-annot [data-chunk]::before { display: none; }
+    body.no-annot [data-tpl] { outline: none; }
+    body.no-annot [data-tpl]::after { display: none; }
+
+    /* ══════════════════════════════════
+       LAYOUT DE LA PAGE PREVIEW
+    ══════════════════════════════════ */
+    body { background: #eef2f7; }
+
+    .pv-toolbar {
+      position: sticky;
+      top: 0;
+      z-index: 100;
+      background: #04173d;
+      color: #fff;
+      padding: 10px 20px;
+      display: flex;
+      align-items: center;
+      gap: 16px;
+      flex-wrap: wrap;
+      margin: -32px -18px 32px;
+    }
+    .pv-toolbar strong { font-size: 13px; letter-spacing: .3px; }
+    .pv-toggle {
+      display: inline-flex; align-items: center; gap: 8px;
+      background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
+      color: #fff; font-size: 12px; font-weight: 700;
+      padding: 5px 13px; border-radius: 4px; cursor: pointer;
+      transition: background .15s;
+    }
+    .pv-toggle:hover { background: rgba(255,255,255,.22); }
+    .pv-toggle .dot {
+      width: 10px; height: 10px; border-radius: 50%;
+      background: #00bef3; transition: background .2s;
+    }
+    body.no-annot .pv-toggle .dot { background: #6b7280; }
+
+    .pv-legend {
+      display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto;
+    }
+    .pv-leg {
+      display: inline-flex; align-items: center; gap: 5px;
+      font-size: 10px; font-weight: 700; color: #fff;
+      opacity: .8;
+    }
+    .pv-leg span {
+      width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
+    }
+
+    .pv-nav {
+      display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 4px;
+    }
+    .pv-nav a {
+      color: rgba(255,255,255,.65); font-size: 11px; text-decoration: none;
+      padding-bottom: 1px; border-bottom: 1px solid transparent;
+      transition: color .15s, border-color .15s;
+    }
+    .pv-nav a:hover { color: #00bef3; border-color: #00bef3; }
+
+    /* Séparateurs d'étape */
+    .pv-step {
+      display: flex; align-items: center; gap: 14px;
+      margin: 52px 0 24px;
+      font-size: 11px; font-weight: 700; letter-spacing: .8px;
+      text-transform: uppercase; color: #5e789a;
+    }
+    .pv-step::before {
+      content: ''; width: 32px; height: 3px;
+      background: #04173d; border-radius: 2px; flex-shrink: 0;
+    }
+    .pv-step::after {
+      content: ''; flex: 1; height: 1px; background: #dde5ed;
+    }
+
+    /* Zones de padding autour des chunks pour que les labels soient lisibles */
+    .pv-box {
+      padding: 16px;
+      background: #fff;
+      border-radius: 6px;
+      margin-bottom: 24px;
+    }
+    .pv-box + .pv-box { margin-top: 0; }
+    .pv-box--tight { padding: 8px; }
+    .pv-caption {
+      font-size: 11px; color: #5e789a; margin: 0 0 10px;
+      font-style: italic;
+    }
+
+    /* Surcharge mineure pour l'imbrication profonde */
+    [data-chunk] [data-chunk]::before { top: 2px; left: 2px; font-size: 9px; padding: 1px 5px; }
+
+    /* Surcharge unlock-gate pour qu'elle s'affiche bien */
+    .unlock-gate { margin-bottom: 0 !important; }
+  </style>
+</head>
+<body>
+<div class="container">
+
+  <!-- ── Toolbar sticky ── -->
+  <div class="pv-toolbar">
+    <div>
+      <strong>Spec visuelle — Chunks &amp; Templates</strong>
+      <div class="pv-nav" style="margin-top:6px">
+        <a href="#step-select">① Choix pack</a>
+        <a href="#step-quiz">② Quiz</a>
+        <a href="#step-optional">③ Optionnel</a>
+        <a href="#step-results">④ Résultats</a>
+        <a href="#step-full">⑤ Page complète</a>
+      </div>
+    </div>
+    <button class="pv-toggle" onclick="document.body.classList.toggle('no-annot')">
+      <span class="dot"></span> Annotations ON/OFF
+    </button>
+    <div class="pv-legend">
+      <span class="pv-leg"><span style="background:#e2a300"></span> Pack/Sélection</span>
+      <span class="pv-leg"><span style="background:#7c3aed"></span> Quiz</span>
+      <span class="pv-leg"><span style="background:#0891b2"></span> Optionnel</span>
+      <span class="pv-leg"><span style="background:#059669"></span> Piliers</span>
+      <span class="pv-leg"><span style="background:#dc2626"></span> Risques</span>
+      <span class="pv-leg"><span style="background:#16a34a"></span> Wins</span>
+      <span class="pv-leg"><span style="background:#173258"></span> Gate/CTA</span>
+    </div>
+  </div>
+
+
+  <!-- ════════════════════════════════════════════════════
+       ① CHOIX DU PACK
+  ════════════════════════════════════════════════════ -->
+  <div id="step-select" class="pv-step">① Choix du pack</div>
+
+  <div data-tpl="AuditExpress_Base">
+    <div class="pv-box">
+      <p class="pv-caption">Ressource MODX : <code>[[!AuditExpress_SelectPack]]</code></p>
+
+      <div data-chunk="ae_select_pack">
+        <div class="grid">
+          <div class="card">
+            <h1 class="h1">Choisissez le process à diagnostiquer</h1>
+            <p class="lead">Sélectionnez un pack pré-configuré ou utilisez le questionnaire universel.</p>
+
+            <div class="section-label" style="margin-top:18px">Packs disponibles</div>
+            <div class="grid grid--2">
+
+              <div data-chunk="ae_pack_card">
+                <div class="pack-card">
+                  <span class="tag tag--pre">Pré-configuré</span>
+                  <div class="title" style="margin-top:8px">Onboarding collaborateur <span class="arrow">→</span></div>
+                  <div class="desc">Fiabilisez l'intégration de vos nouveaux collaborateurs.</div>
+                </div>
+              </div>
+
+              <div data-chunk="ae_pack_card">
+                <div class="pack-card">
+                  <span class="tag tag--pre">Pré-configuré</span>
+                  <div class="title" style="margin-top:8px">Validation de facture <span class="arrow">→</span></div>
+                  <div class="desc">Évaluez la robustesse de votre circuit factures.</div>
+                </div>
+              </div>
+
+              <div data-chunk="ae_pack_card">
+                <div class="pack-card">
+                  <span class="tag tag--new">Universel</span>
+                  <div class="title" style="margin-top:8px">Process générique <span class="arrow">→</span></div>
+                  <div class="desc">Applicable à tout process opérationnel.</div>
+                </div>
+              </div>
+
+            </div>
+            <div class="btnrow" style="margin-top:18px">
+              <a href="#" class="btn btn--outline">← Retour</a>
+            </div>
+          </div>
+        </div>
+      </div><!-- /ae_select_pack -->
+
+    </div>
+  </div><!-- /Template AuditExpress_Base -->
+
+
+  <!-- ════════════════════════════════════════════════════
+       ② QUIZ — 1 QUESTION
+  ════════════════════════════════════════════════════ -->
+  <div id="step-quiz" class="pv-step">② Quiz — une question</div>
+
+  <div data-tpl="AuditExpress_Quiz">
+    <div class="pv-box">
+      <p class="pv-caption">Ressource MODX : <code>[[!AuditExpress_Quiz]]</code></p>
+
+      <div data-chunk="ae_quiz">
+        <div class="grid">
+          <div class="card">
+
+            <!-- Sous-chunk progress, injecté via [[+progress]] -->
+            <div data-chunk="ae_quiz_progress">
+              <div class="quizHead">
+                <span class="tag" style="font-size:11px">Onboarding collaborateur</span>
+                <div class="quizStep"><strong>5</strong><span> / 20</span></div>
+              </div>
+              <div class="progressWrap">
+                <div class="progress"><div style="width:20%"></div></div>
+                <div class="progressMeta">
+                  <span class="progressPct">20&nbsp;%</span>
+                  <span class="progressRemain">encore 15 questions</span>
+                </div>
+              </div>
+            </div><!-- /ae_quiz_progress -->
+
+            <form method="POST" action="#" id="ae-quiz-form-demo">
+              <input type="hidden" name="ae_action" value="ae_answer">
+              <input type="hidden" name="question_id" value="q5">
+
+              <div class="qTitle">Les étapes et responsabilités du process sont-elles formalisées quelque part ?</div>
+              <p class="qHelp">Procédure écrite, workflow dans un outil, checklist partagée — tout format compte.</p>
+
+              <!-- Chaque option = ae_question_option, injectées via [[+options]] -->
+              <div class="options">
+
+                <div data-chunk="ae_question_option">
+                  <label class="opt" for="d_q5_0">
+                    <input id="d_q5_0" type="radio" name="option_id" value="q5_0">
+                    <div><strong>Oui, un processus clair et documenté existe</strong></div>
+                  </label>
+                </div>
+
+                <div data-chunk="ae_question_option">
+                  <label class="opt opt--selected" for="d_q5_2">
+                    <input id="d_q5_2" type="radio" name="option_id" value="q5_2" checked>
+                    <div><strong>Partiellement — quelques étapes sont formalisées</strong></div>
+                  </label>
+                </div>
+
+                <div data-chunk="ae_question_option">
+                  <label class="opt" for="d_q5_4">
+                    <input id="d_q5_4" type="radio" name="option_id" value="q5_4">
+                    <div><strong>Non, chacun fait à sa manière</strong></div>
+                  </label>
+                </div>
+
+                <div data-chunk="ae_question_option">
+                  <label class="opt opt--na" for="d_q5_na">
+                    <input id="d_q5_na" type="radio" name="option_id" value="q5_na">
+                    <div><strong>Je ne sais pas / Non pertinent</strong></div>
+                  </label>
+                </div>
+
+              </div><!-- /options -->
+
+              <div class="btnrow" style="margin-top:18px">
+                <button type="button" class="btn btn--outline">← Précédent</button>
+                <button type="button" class="btn btn--primary">Suivant →</button>
+              </div>
+              <p class="hint" style="margin-top:10px">Vous pouvez modifier vos réponses avant la fin.</p>
+            </form>
+
+          </div>
+        </div>
+      </div><!-- /ae_quiz -->
+
+    </div>
+  </div><!-- /Template AuditExpress_Quiz -->
+
+
+  <!-- ════════════════════════════════════════════════════
+       ③ QUESTIONS OPTIONNELLES
+  ════════════════════════════════════════════════════ -->
+  <div id="step-optional" class="pv-step">③ Questions optionnelles</div>
+
+  <div data-tpl="AuditExpress_Quiz">
+    <div class="pv-box">
+      <p class="pv-caption">Ressource MODX : <code>[[!AuditExpress_Optional]]</code> — même template que le quiz</p>
+
+      <div data-chunk="ae_optional">
+        <div class="grid">
+          <div class="card">
+            <span class="tag tag--new" style="margin-bottom:12px;display:inline-block">Optionnel</span>
+            <h1 class="h1">Quelques infos pour le coût caché</h1>
+            <p class="lead">Ces données servent à estimer le coût caché en heures/mois. Vous pouvez passer directement.</p>
+
+            <form method="POST" action="#">
+
+              <!-- Chaque groupe = ae_optional_field, injecté via [[+fields]] -->
+              <div data-chunk="ae_optional_field">
+                <div class="field">
+                  <label>Volume mensuel traité par ce process</label>
+                  <div class="options" style="margin-top:6px">
+
+                    <!-- Chaque radio = ae_optional_radio -->
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt" for="d_vol_50">
+                        <input id="d_vol_50" type="radio" name="opt_vol" value="50">
+                        <div><strong>Moins de 50 dossiers/mois</strong></div>
+                      </label>
+                    </div>
+
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt opt--selected" for="d_vol_200">
+                        <input id="d_vol_200" type="radio" name="opt_vol" value="200" checked>
+                        <div><strong>50 à 200 dossiers/mois</strong></div>
+                      </label>
+                    </div>
+
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt" for="d_vol_500">
+                        <input id="d_vol_500" type="radio" name="opt_vol" value="500">
+                        <div><strong>Plus de 200 dossiers/mois</strong></div>
+                      </label>
+                    </div>
+
+                  </div>
+                </div>
+              </div><!-- /ae_optional_field -->
+
+              <div data-chunk="ae_optional_field">
+                <div class="field">
+                  <label>Coût horaire chargé d'un collaborateur</label>
+                  <div class="options" style="margin-top:6px">
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt" for="d_ch_40"><input id="d_ch_40" type="radio" name="opt_ch" value="40"><div><strong>Moins de 40 €/h</strong></div></label>
+                    </div>
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt opt--selected" for="d_ch_60"><input id="d_ch_60" type="radio" name="opt_ch" value="60" checked><div><strong>40 à 80 €/h</strong></div></label>
+                    </div>
+                    <div data-chunk="ae_optional_radio">
+                      <label class="opt" for="d_ch_100"><input id="d_ch_100" type="radio" name="opt_ch" value="100"><div><strong>Plus de 80 €/h</strong></div></label>
+                    </div>
+                  </div>
+                </div>
+              </div><!-- /ae_optional_field -->
+
+              <div class="btnrow" style="margin-top:20px">
+                <a href="#" class="btn btn--outline">← Retour au quiz</a>
+                <button type="button" class="btn btn--primary">Voir mes résultats →</button>
+              </div>
+            </form>
+          </div>
+        </div>
+      </div><!-- /ae_optional -->
+
+    </div>
+  </div><!-- /Template AuditExpress_Quiz -->
+
+
+  <!-- ════════════════════════════════════════════════════
+       ④ RÉSULTATS — ÉTAT NON DÉBLOQUÉ
+  ════════════════════════════════════════════════════ -->
+  <div id="step-results" class="pv-step">④ Résultats — avant déblocage email</div>
+
+  <div data-tpl="AuditExpress_Results">
+    <div class="pv-box">
+      <p class="pv-caption">Ressource MODX : <code>[[!AuditExpress_Results]]</code> — <strong>[[+gate_html]]</strong> = ae_unlock_gate (email non saisi)</p>
+
+      <div data-chunk="ae_results">
+        <div class="grid">
+
+          <!-- Carte score -->
+          <div class="card">
+            <div style="display:flex;align-items:center;gap:10px;margin-bottom:16px">
+              <span class="tag">Onboarding collaborateur</span>
+            </div>
+            <div class="scoreBox">
+              <div>
+                <div class="scoreLabel">Score global</div>
+                <div class="scoreBig">67/100</div>
+                <div class="level-badge" style="margin-top:10px">
+                  <span class="level-dot" style="background:#c07c10"></span>
+                  <span>C — Fragile</span>
+                </div>
+                <div class="confidence">Confiance du diagnostic : Élevée (2 DK)</div>
+              </div>
+            </div>
+            <!-- [[+pillars_html]] = 5 × ae_pillar_row -->
+            <div class="pillars">
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Clarté du flux</div><div class="val">14/20</div><div class="bar"><div style="width:70%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Fiabilité</div><div class="val">11/20</div><div class="bar"><div style="width:55%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Traçabilité</div><div class="val">10/20</div><div class="bar"><div style="width:50%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Résilience</div><div class="val">15/20</div><div class="bar"><div style="width:75%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Coût caché</div><div class="val">17/20</div><div class="bar"><div style="width:85%"></div></div></div></div>
+            </div>
+          </div>
+
+          <!-- [[+risks_html]] = 3 × ae_risk_item -->
+          <div class="card">
+            <div class="h2">3 risques probables</div>
+            <ol class="list">
+              <div data-chunk="ae_risk_item"><li><strong>Statut flou → relances permanentes</strong><div class="hint">Sans état visible partagé, chaque intervenant doit relancer.</div></li></div>
+              <div data-chunk="ae_risk_item"><li><strong>Documents dispersés entre emails, Drive et postes locaux</strong><div class="hint">Un dossier incomplet bloque le traitement et génère des erreurs.</div></li></div>
+              <div data-chunk="ae_risk_item"><li><strong>Dépendance à une personne clé non remplaçable</strong><div class="hint">En cas d'absence, le process s'arrête ou se dégrade fortement.</div></li></div>
+            </ol>
+          </div>
+
+          <!-- [[+cost_html]] = ae_cost_hidden -->
+          <div data-chunk="ae_cost_hidden">
+            <div class="cost-block">
+              <div class="h2">Coût caché estimé</div>
+              <div class="cost-figures">
+                <div class="cost-fig"><span class="val">18 h</span><span class="lbl">par mois (estimé)</span></div>
+                <div class="cost-fig"><span class="val">~1 080 €</span><span class="lbl">par mois (indicatif)</span></div>
+              </div>
+              <p class="hint">Estimation indicative, à valider par mesure réelle.</p>
+            </div>
+          </div>
+
+          <!-- [[+gate_html]] = ae_unlock_gate (email non saisi) -->
+          <div data-chunk="ae_unlock_gate">
+            <div class="unlock-gate">
+              <div class="unlock-gate__inner">
+                <div class="unlock-gate__icon">↓</div>
+                <div class="h2" style="margin-bottom:6px">Débloquez vos axes d'amélioration</div>
+                <p class="lead" style="margin-bottom:20px">Entrez votre email professionnel pour accéder aux 5 actions prioritaires et télécharger votre PDF synthèse.</p>
+                <div class="unlock-risks">
+                  <div class="unlock-risk"><div class="unlock-risk__num">1</div><div class="unlock-risk__body"><strong>Statut flou → relances permanentes</strong><span>Sans état visible partagé, chaque intervenant doit relancer.</span></div></div>
+                  <div class="unlock-risk"><div class="unlock-risk__num">2</div><div class="unlock-risk__body"><strong>Documents dispersés</strong><span>Un dossier incomplet ou introuvable bloque le traitement.</span></div></div>
+                </div>
+                <form class="unlock-form" method="POST" action="#">
+                  <div class="unlock-row">
+                    <input type="email" name="email" placeholder="vous@entreprise.com">
+                    <button class="btn btn--primary btn--unlock" type="button">Débloquer →</button>
+                  </div>
+                  <p class="hint" style="margin-top:8px;text-align:center">Aucun spam. Désinscription en 1 clic.</p>
+                </form>
+              </div>
+            </div>
+          </div><!-- /ae_unlock_gate -->
+
+          <!-- [[+wins_html]] = vide (non débloqué) — absent ici -->
+
+        </div>
+      </div><!-- /ae_results -->
+
+    </div>
+  </div><!-- /Template AuditExpress_Results -->
+
+
+  <!-- ════════════════════════════════════════════════════
+       ⑤ PAGE COMPLÈTE — ÉTAT DÉBLOQUÉ
+  ════════════════════════════════════════════════════ -->
+  <div id="step-full" class="pv-step">⑤ Résultats — après déblocage email (état final)</div>
+
+  <div data-tpl="AuditExpress_Results">
+    <div class="pv-box">
+      <p class="pv-caption">Même ressource, même template. <strong>[[+gate_html]]</strong> = ae_cta_unlocked &amp; <strong>[[+wins_html]]</strong> = 5 × ae_win_item (débloqués)</p>
+
+      <div data-chunk="ae_results">
+        <div class="grid">
+
+          <div class="card">
+            <div style="display:flex;align-items:center;gap:10px;margin-bottom:16px"><span class="tag">Onboarding collaborateur</span></div>
+            <div class="scoreBox">
+              <div>
+                <div class="scoreLabel">Score global</div>
+                <div class="scoreBig">67/100</div>
+                <div class="level-badge" style="margin-top:10px">
+                  <span class="level-dot" style="background:#c07c10"></span><span>C — Fragile</span>
+                </div>
+                <div class="confidence">Confiance du diagnostic : Élevée</div>
+              </div>
+            </div>
+            <div class="pillars">
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Clarté du flux</div><div class="val">14/20</div><div class="bar"><div style="width:70%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Fiabilité</div><div class="val">11/20</div><div class="bar"><div style="width:55%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Traçabilité</div><div class="val">10/20</div><div class="bar"><div style="width:50%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Résilience</div><div class="val">15/20</div><div class="bar"><div style="width:75%"></div></div></div></div>
+              <div data-chunk="ae_pillar_row"><div class="pRow"><div class="name">Coût caché</div><div class="val">17/20</div><div class="bar"><div style="width:85%"></div></div></div></div>
+            </div>
+          </div>
+
+          <div class="card">
+            <div class="h2">3 risques probables</div>
+            <ol class="list">
+              <div data-chunk="ae_risk_item"><li><strong>Statut flou → relances permanentes</strong><div class="hint">Sans état visible partagé, chaque intervenant doit relancer.</div></li></div>
+              <div data-chunk="ae_risk_item"><li><strong>Documents dispersés entre emails, Drive et postes locaux</strong><div class="hint">Un dossier incomplet bloque le traitement et génère des erreurs.</div></li></div>
+              <div data-chunk="ae_risk_item"><li><strong>Dépendance à une personne clé</strong><div class="hint">En cas d'absence, le process s'arrête ou se dégrade fortement.</div></li></div>
+            </ol>
+          </div>
+
+          <div data-chunk="ae_cost_hidden">
+            <div class="cost-block">
+              <div class="h2">Coût caché estimé</div>
+              <div class="cost-figures">
+                <div class="cost-fig"><span class="val">18 h</span><span class="lbl">par mois (estimé)</span></div>
+                <div class="cost-fig"><span class="val">~1 080 €</span><span class="lbl">par mois (indicatif)</span></div>
+              </div>
+              <p class="hint">Estimation indicative, à valider par mesure réelle.</p>
+            </div>
+          </div>
+
+          <!-- [[+gate_html]] = ae_cta_unlocked (email déjà saisi) -->
+          <div data-chunk="ae_cta_unlocked">
+            <div style="background:#fff;border:1px solid var(--border);border-radius:var(--radius);padding:32px 28px">
+              <div class="h2" style="margin-bottom:6px">Et maintenant ?</div>
+              <p class="lead" style="margin-bottom:24px">Votre diagnostic révèle des opportunités concrètes. Nous pouvons vous aider à les transformer en plan d'action.</p>
+              <div style="display:flex;flex-wrap:wrap;gap:10px;justify-content:center">
+                <a class="btn btn--primary" href="#">📅&nbsp;Réserver un appel découverte — 30 min</a>
+                <a class="btn btn--outline" href="#">✉&nbsp;Demander un devis</a>
+              </div>
+              <hr style="border:none;border-top:1px solid var(--border);margin:24px 0">
+              <div class="btnrow" style="justify-content:center;gap:10px">
+                <a class="btn btn--outline" href="#">⬇&nbsp;Télécharger mon PDF</a>
+                <a class="btn btn--outline" href="#" style="font-size:13px">Diagnostiquer un autre process</a>
+              </div>
+            </div>
+          </div><!-- /ae_cta_unlocked -->
+
+          <!-- [[+wins_html]] = 5 × ae_win_item (visible car unlocked) -->
+          <div class="card">
+            <div class="h2">5 quick wins prioritaires</div>
+            <ol class="list">
+              <div data-chunk="ae_win_item"><li><strong>Checklist jour 1 partagée</strong><div class="hint">Réduction des oublis à l'intégration · Effort : S</div></li></div>
+              <div data-chunk="ae_win_item"><li><strong>Pré-check 48 h avant arrivée</strong><div class="hint">Accès outils prêts dès J1 · Effort : S</div></li></div>
+              <div data-chunk="ae_win_item"><li><strong>Tableau de statut unique</strong><div class="hint">Fin des relances sur l'avancement · Effort : M</div></li></div>
+              <div data-chunk="ae_win_item"><li><strong>Centraliser les documents</strong><div class="hint">Dossier toujours complet et retrouvable · Effort : S</div></li></div>
+              <div data-chunk="ae_win_item"><li><strong>Escalade simple formalisée</strong><div class="hint">Moins de blocages en cas d'absence · Effort : S</div></li></div>
+            </ol>
+            <p class="hint" style="margin-top:8px">Le PDF contient les 5 actions avec détail effort/impact.</p>
+          </div>
+
+        </div>
+      </div><!-- /ae_results -->
+
+    </div>
+  </div><!-- /Template AuditExpress_Results -->
+
+
+  <footer class="footer" style="margin-top:48px">
+    Spec visuelle chunks &amp; templates — Audit Express Self · Livinweb
+  </footer>
+
+</div>
+</body>
+</html>

+ 49 - 0
modx/schema/audit_express.mysql.schema.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Schéma xPDO — Audit Express Self
+    Table : audit_requests
+    Déploiement : voir modx/setup/install.php
+-->
+<model package="audit_express"
+       baseClass="xPDOObject"
+       platform="mysql"
+       defaultEngine="InnoDB"
+       phpdoc-package="AuditExpress"
+       version="1.1">
+
+    <object class="AuditRequest" table="audit_requests" extends="xPDOSimpleObject">
+
+        <!-- Identifiant public UUID (partageable dans l'URL résultats) -->
+        <field key="audit_uid"     dbtype="varchar"  precision="36"                        phptype="string"   null="false" default=""      index="unique" />
+        <!-- Pack sélectionné (ex : onboarding-v1, validation-facture) -->
+        <field key="pack_id"       dbtype="varchar"  precision="64"                        phptype="string"   null="false" default="" />
+        <!-- Réponses JSON : {"q1":"q1_3","q2":"q2_dk",...} -->
+        <field key="answers"       dbtype="text"                                           phptype="string"   null="true"  default="null" />
+        <!-- Données optionnelles JSON (volume, coût horaire…) -->
+        <field key="optional_data" dbtype="text"                                           phptype="string"   null="true"  default="null" />
+        <!-- Résultat calculé JSON (score, piliers, risques, quick_wins…) -->
+        <field key="result"        dbtype="mediumtext"                                     phptype="string"   null="true"  default="null" />
+        <!-- Email saisi lors de la capture (optionnel, RGPD) -->
+        <field key="email"         dbtype="varchar"  precision="255"                       phptype="string"   null="true"  default="null" />
+        <!-- draft → completed → emailed -->
+        <field key="status"        dbtype="enum"     precision="'draft','completed','emailed'" phptype="string" null="false" default="draft" />
+        <!-- Hash de l'IP (sha256) — pas d'IP en clair, RGPD -->
+        <field key="ip_hash"       dbtype="varchar"  precision="64"                        phptype="string"   null="true"  default="null" />
+        <!-- Étape courante (index question, 0-based) — pour reprise -->
+        <field key="step"          dbtype="tinyint"  precision="3"                         phptype="integer"  null="false" default="0" />
+        <field key="created_at"    dbtype="datetime"                                       phptype="datetime" null="false" />
+        <field key="updated_at"    dbtype="datetime"                                       phptype="datetime" null="false" />
+
+        <index alias="audit_uid" name="audit_uid" primary="false" unique="true" type="BTREE">
+            <column key="audit_uid" length="" collation="A" null="false" />
+        </index>
+        <index alias="status" name="status" primary="false" unique="false" type="BTREE">
+            <column key="status" length="" collation="A" null="false" />
+        </index>
+        <index alias="created_at" name="created_at" primary="false" unique="false" type="BTREE">
+            <column key="created_at" length="" collation="A" null="false" />
+        </index>
+
+    </object>
+
+</model>

+ 21 - 0
modx/setup/create_tables.sql

@@ -0,0 +1,21 @@
+-- Audit Express — création de table (exécuter si install.php ne peut pas tourner)
+-- Remplacer `modx_` par votre préfixe MODX réel.
+
+CREATE TABLE IF NOT EXISTS `modx_audit_requests` (
+  `id`            INT(10) UNSIGNED    NOT NULL AUTO_INCREMENT,
+  `audit_uid`     VARCHAR(36)         NOT NULL DEFAULT '',
+  `pack_id`       VARCHAR(64)         NOT NULL DEFAULT '',
+  `answers`       TEXT                         DEFAULT NULL,
+  `optional_data` TEXT                         DEFAULT NULL,
+  `result`        MEDIUMTEXT                   DEFAULT NULL,
+  `email`         VARCHAR(255)                 DEFAULT NULL,
+  `status`        ENUM('draft','completed','emailed') NOT NULL DEFAULT 'draft',
+  `ip_hash`       VARCHAR(64)                  DEFAULT NULL,
+  `step`          TINYINT(3)          NOT NULL DEFAULT 0,
+  `created_at`    DATETIME            NOT NULL,
+  `updated_at`    DATETIME            NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `audit_uid` (`audit_uid`),
+  KEY `status` (`status`),
+  KEY `created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

+ 108 - 0
modx/setup/install.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * Script d'installation Audit Express — MODX
+ * ============================================
+ * À exécuter UNE SEULE FOIS après le déploiement du composant.
+ * Requiert que MODX soit correctement configuré (config.core.php présent).
+ *
+ * Usage : php modx/setup/install.php
+ *   ou via le navigateur (protéger avec .htaccess ensuite)
+ *
+ * Ce script :
+ *   1. Crée la table `audit_requests` via xPDO
+ *   2. Crée les System Settings ae.*
+ *   3. Génère le SQL de création au cas où xPDO échoue (fallback)
+ */
+
+declare(strict_types=1);
+
+// ── Bootstrap MODX ────────────────────────────────────────────────────────
+define('MODX_API_MODE', true);
+$modxCorePath = dirname(__DIR__, 3) . '/core/';   // adapter si nécessaire
+require_once $modxCorePath . 'model/modx/modx.class.php';
+
+$modx = new modX();
+$modx->initialize('mgr');
+$modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
+$modx->setLogTarget('ECHO');
+
+echo "<pre>\n";
+
+// ── 1. Charger le package xPDO ────────────────────────────────────────────
+$corePath = $modx->getOption('core_path') . 'components/audit_express/';
+$modx->addPackage('audit_express', $corePath . 'model/');
+
+// Générer les tables à partir du schéma XML
+$manager   = $modx->getManager();
+$generator = $manager->getGenerator();
+
+// Créer la table (ignore si elle existe déjà)
+$result = $manager->createObjectContainer('AuditRequest');
+if ($result) {
+    echo "[OK] Table `audit_requests` créée.\n";
+} else {
+    echo "[INFO] Table `audit_requests` déjà existante ou erreur silencieuse.\n";
+}
+
+// ── 2. System Settings ────────────────────────────────────────────────────
+$settings = [
+    'ae.core_path'      => $corePath,
+    'ae.resource.landing'  => '',
+    'ae.resource.select'   => '',
+    'ae.resource.quiz'     => '',
+    'ae.resource.optional' => '',
+    'ae.resource.results'  => '',
+    'ae.resource.pdf'      => '',
+    'ae.booking_url'    => 'https://calendly.com/livinweb/diagnostic',
+    'ae.devis_url'      => 'mailto:contact@livinweb.fr',
+];
+
+foreach ($settings as $key => $value) {
+    $existing = $modx->getObject('modSystemSetting', ['key' => $key]);
+    if (!$existing) {
+        $setting = $modx->newObject('modSystemSetting');
+        $setting->fromArray([
+            'key'       => $key,
+            'value'     => $value,
+            'xtype'     => 'textfield',
+            'namespace' => 'audit_express',
+            'area'      => 'ae_settings',
+        ]);
+        $setting->save();
+        echo "[OK] Setting créé : $key\n";
+    } else {
+        echo "[SKIP] Setting existant : $key\n";
+    }
+}
+
+// ── 3. SQL de fallback ────────────────────────────────────────────────────
+$tablePrefix = $modx->getOption('table_prefix', null, 'modx_');
+$sql = <<<SQL
+-- Fallback SQL (exécuter manuellement si le script échoue)
+CREATE TABLE IF NOT EXISTS `{$tablePrefix}audit_requests` (
+  `id`            INT(10) UNSIGNED    NOT NULL AUTO_INCREMENT,
+  `audit_uid`     VARCHAR(36)         NOT NULL DEFAULT '',
+  `pack_id`       VARCHAR(64)         NOT NULL DEFAULT '',
+  `answers`       TEXT                         DEFAULT NULL,
+  `optional_data` TEXT                         DEFAULT NULL,
+  `result`        MEDIUMTEXT                   DEFAULT NULL,
+  `email`         VARCHAR(255)                 DEFAULT NULL,
+  `status`        ENUM('draft','completed','emailed') NOT NULL DEFAULT 'draft',
+  `ip_hash`       VARCHAR(64)                  DEFAULT NULL,
+  `step`          TINYINT(3)          NOT NULL DEFAULT 0,
+  `created_at`    DATETIME            NOT NULL,
+  `updated_at`    DATETIME            NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `audit_uid` (`audit_uid`),
+  KEY `status` (`status`),
+  KEY `created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+SQL;
+
+$sqlFile = __DIR__ . '/create_tables.sql';
+file_put_contents($sqlFile, $sql);
+echo "[OK] SQL de fallback écrit dans : $sqlFile\n";
+
+echo "\nInstallation terminée.\n";
+echo "→ Renseignez les IDs de ressources dans System Settings (ae.resource.*).\n";
+echo "</pre>\n";

+ 111 - 0
modx/snippets/AuditExpress_Optional.php

@@ -0,0 +1,111 @@
+<?php
+/**
+ * Snippet : AuditExpress_Optional
+ * Vue "Questions optionnelles" (coût caché)
+ *
+ * Propriétés :
+ *   &quiz_resource_id    = `5`
+ *   &results_resource_id = `7`
+ *
+ * POST action : ae_optional
+ *   → sauvegarde les données optionnelles
+ *   → calcule le score via Engine
+ *   → met à jour AuditRequest (result, status=completed)
+ *   → redirige vers résultats
+ */
+
+declare(strict_types=1);
+
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+$modx->addPackage('audit_express', $corePath . 'model/');
+require_once $corePath . 'src/PackRepository.php';
+require_once $corePath . 'src/Engine.php';
+require_once $corePath . 'src/RulesRepository.php';
+
+$quizResourceId    = (int) ($scriptProperties['quiz_resource_id']    ?? $modx->getOption('ae.resource.quiz',    null, 0));
+$resultsResourceId = (int) ($scriptProperties['results_resource_id'] ?? $modx->getOption('ae.resource.results', null, 0));
+
+// ── Récupérer l'audit ──────────────────────────────────────────────────────
+$auditUid = $_SESSION['ae_audit_uid'] ?? '';
+if (!$auditUid) {
+    $modx->sendRedirect($quizResourceId ? $modx->makeUrl($quizResourceId, '', '', 'full') : '/');
+    return '';
+}
+
+/** @var AuditRequest|null $auditReq */
+$auditReq = $modx->getObject('AuditRequest', ['audit_uid' => $auditUid]);
+if (!$auditReq) {
+    $modx->sendRedirect($quizResourceId ? $modx->makeUrl($quizResourceId, '', '', 'full') : '/');
+    return '';
+}
+
+$packId = $auditReq->get('pack_id');
+$repo   = new \AuditExpress\PackRepository($corePath . 'config/');
+$pack   = $repo->getPack($packId);
+
+// ── POST : sauvegarder + calculer ─────────────────────────────────────────
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['ae_action'] ?? '') === 'ae_optional') {
+    // Collecter les données optionnelles postées (valeurs numériques)
+    $optional = [];
+    foreach ($pack['optional_questions'] ?? [] as $key => $oq) {
+        if (isset($_POST['opt_' . $key])) {
+            $optional[$key] = (int) $_POST['opt_' . $key];
+        }
+    }
+    $auditReq->setOptionalArray($optional);
+
+    // Calcul du score
+    $rulesRepo  = new \AuditExpress\RulesRepository($corePath);
+    $rulesBundle = $rulesRepo->getRules();
+    $answers = $auditReq->getAnswersArray();
+
+    try {
+        $result = \AuditExpress\Engine::compute($pack, $answers, $optional, $rulesBundle);
+        $auditReq->setResultArray($result);
+        $auditReq->set('status', 'completed');
+        $auditReq->save();
+    } catch (\InvalidArgumentException $e) {
+        // Réponse(s) manquante(s) → retour quiz
+        $modx->sendRedirect($quizResourceId ? $modx->makeUrl($quizResourceId, '', '', 'full') : '/');
+        return '';
+    }
+
+    $resultsUrl = $resultsResourceId
+        ? $modx->makeUrl($resultsResourceId, '', 'audit=' . $auditUid, 'full')
+        : '/resultats/?audit=' . $auditUid;
+    $modx->sendRedirect($resultsUrl);
+    return '';
+}
+
+// ── Rendu GET ──────────────────────────────────────────────────────────────
+$optQs     = $pack['optional_questions'] ?? [];
+$optional  = $auditReq->getOptionalArray();
+$quizUrl   = $quizResourceId ? $modx->makeUrl($quizResourceId, '', '', 'full') : '/';
+$actionUrl = $modx->makeUrl($modx->resource->get('id'), '', '', 'full');
+
+$fieldsHtml = '';
+foreach ($optQs as $key => $oq) {
+    $cur = $optional[$key] ?? null;
+    $radiosHtml = '';
+    foreach ($oq['options'] as $opt) {
+        $val = (string) ($opt['value'] ?? $opt['id']);
+        $radiosHtml .= $modx->getChunk('ae_optional_radio', [
+            'key'     => htmlspecialchars($key, ENT_QUOTES),
+            'value'   => htmlspecialchars($val, ENT_QUOTES),
+            'label'   => htmlspecialchars($opt['label'], ENT_QUOTES),
+            'checked' => ((string) $cur === $val) ? 'checked' : '',
+        ]);
+    }
+    $fieldsHtml .= $modx->getChunk('ae_optional_field', [
+        'label'  => htmlspecialchars($oq['label'], ENT_QUOTES),
+        'radios' => $radiosHtml,
+    ]);
+}
+
+return $modx->getChunk('ae_optional', [
+    'fields'     => $fieldsHtml,
+    'action_url' => $actionUrl,
+    'quiz_url'   => $quizUrl,
+    'audit_uid'  => htmlspecialchars($auditUid, ENT_QUOTES),
+]);

+ 67 - 0
modx/snippets/AuditExpress_PDF.php

@@ -0,0 +1,67 @@
+<?php
+/**
+ * Snippet : AuditExpress_PDF
+ * Génère et télécharge le PDF à la demande (depuis la page résultats, bouton "Télécharger").
+ *
+ * Appelé en mode uncached via un lien direct :
+ *   /audit-express/pdf/?audit=<uid>
+ * ou via une ressource dédiée avec ce snippet.
+ *
+ * Propriétés :
+ *   &booking_url = `https://calendly.com/livinweb/diagnostic`
+ *
+ * Envoie directement les headers PDF + contenu binaire, puis exit.
+ */
+
+declare(strict_types=1);
+
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+$modx->addPackage('audit_express', $corePath . 'model/');
+require_once $corePath . 'src/PackRepository.php';
+require_once $corePath . 'src/PdfRenderer.php';
+
+$bookingUrl = $scriptProperties['booking_url'] ?? $modx->getOption('ae.booking_url', null, '');
+
+$auditUid = trim($_GET['audit'] ?? '');
+if (!$auditUid) {
+    http_response_code(400);
+    echo json_encode(['error' => 'audit_uid manquant']);
+    return '';
+}
+
+/** @var AuditRequest|null $auditReq */
+$auditReq = $modx->getObject('AuditRequest', ['audit_uid' => $auditUid]);
+if (!$auditReq || $auditReq->get('status') === 'draft') {
+    http_response_code(404);
+    echo json_encode(['error' => 'Audit non trouvé ou non terminé']);
+    return '';
+}
+
+try {
+    $packId  = $auditReq->get('pack_id');
+    $repo    = new \AuditExpress\PackRepository($corePath . 'config/');
+    $pack    = $repo->getPack($packId);
+    $result  = $auditReq->getResultArray();
+
+    $renderer = new \AuditExpress\PdfRenderer(
+        $corePath . 'templates/pdf_a4.php',
+        $corePath . '../vendor/autoload.php'
+    );
+    $pdfBytes = $renderer->render($pack, $result, $bookingUrl);
+
+    $filename = 'controle-technique-' . preg_replace('/[^a-z0-9\-]/', '', $packId) . '.pdf';
+
+    header('Content-Type: application/pdf');
+    header('Content-Disposition: attachment; filename="' . $filename . '"');
+    header('Content-Length: ' . strlen($pdfBytes));
+    header('Cache-Control: no-store');
+    echo $pdfBytes;
+    exit;
+
+} catch (\Throwable $e) {
+    http_response_code(500);
+    $modx->log(xPDO::LOG_LEVEL_ERROR, '[AuditExpress] PDF: ' . $e->getMessage());
+    echo json_encode(['error' => 'Erreur génération PDF']);
+    return '';
+}

+ 159 - 0
modx/snippets/AuditExpress_Quiz.php

@@ -0,0 +1,159 @@
+<?php
+/**
+ * Snippet : AuditExpress_Quiz
+ * Vue "Question N/20" — 1 question par chargement de page, PRG pattern
+ *
+ * Propriétés :
+ *   &select_resource_id   = `4`  Ressource choix du pack
+ *   &optional_resource_id = `6`  Ressource questions optionnelles
+ *
+ * Session attendue : ae_audit_uid, ae_pack_id
+ *
+ * POST action : ae_answer
+ *   body : question_id, option_id
+ *   → sauvegarde la réponse dans AuditRequest.answers
+ *   → incrémente AuditRequest.step
+ *   → redirige sur la même ressource (question suivante) ou vers optional
+ */
+
+declare(strict_types=1);
+
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+$modx->addPackage('audit_express', $corePath . 'model/');
+require_once $corePath . 'src/PackRepository.php';
+
+$selectResourceId   = (int) ($scriptProperties['select_resource_id']   ?? $modx->getOption('ae.resource.select',   null, 0));
+$optionalResourceId = (int) ($scriptProperties['optional_resource_id'] ?? $modx->getOption('ae.resource.optional', null, 0));
+
+// ── Récupérer l'audit en cours ─────────────────────────────────────────────
+$auditUid = $_SESSION['ae_audit_uid'] ?? '';
+if (!$auditUid) {
+    $url = $selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/';
+    $modx->sendRedirect($url);
+    return '';
+}
+
+/** @var AuditRequest|null $auditReq */
+$auditReq = $modx->getObject('AuditRequest', ['audit_uid' => $auditUid]);
+if (!$auditReq) {
+    unset($_SESSION['ae_audit_uid'], $_SESSION['ae_pack_id']);
+    $url = $selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/';
+    $modx->sendRedirect($url);
+    return '';
+}
+
+$packId = $auditReq->get('pack_id');
+$repo   = new \AuditExpress\PackRepository($corePath . 'config/');
+$pack   = $repo->getPack($packId);
+$questions = $pack['questions'] ?? [];
+$total     = count($questions);
+
+// ── Traitement POST ────────────────────────────────────────────────────────
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['ae_action'] ?? '') === 'ae_answer') {
+    $questionId = trim($_POST['question_id'] ?? '');
+    $optionId   = trim($_POST['option_id']   ?? '');
+
+    // Valider que l'option appartient bien à la question
+    $validOption = false;
+    foreach ($questions as $q) {
+        if ($q['id'] === $questionId) {
+            foreach ($q['options'] as $opt) {
+                if ($opt['id'] === $optionId) { $validOption = true; break 2; }
+            }
+        }
+    }
+
+    if ($validOption) {
+        $answers = $auditReq->getAnswersArray();
+        $answers[$questionId] = $optionId;
+        $auditReq->setAnswersArray($answers);
+
+        // Calculer le nouvel index : prochaine question sans réponse
+        $nextStep = 0;
+        foreach ($questions as $idx => $q) {
+            if (empty($answers[$q['id']])) { $nextStep = $idx; break; }
+            $nextStep = $idx + 1;
+        }
+
+        $auditReq->set('step', min($nextStep, $total));
+        $auditReq->save();
+
+        // Toutes les questions répondues → aller vers optional
+        if ($nextStep >= $total) {
+            $optUrl = $optionalResourceId
+                ? $modx->makeUrl($optionalResourceId, '', '', 'full')
+                : '/optional/';
+            $modx->sendRedirect($optUrl);
+            return '';
+        }
+    }
+
+    // Rediriger vers la même page (PRG) pour afficher la prochaine question
+    $modx->sendRedirect($modx->makeUrl($modx->resource->get('id'), '', '', 'full'));
+    return '';
+}
+
+// ── Action "retour" ────────────────────────────────────────────────────────
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['ae_action'] ?? '') === 'ae_prev') {
+    $currentStep = max(0, $auditReq->get('step') - 1);
+    $auditReq->set('step', $currentStep);
+    $auditReq->save();
+    $modx->sendRedirect($modx->makeUrl($modx->resource->get('id'), '', '', 'full'));
+    return '';
+}
+
+// ── Rendu GET ──────────────────────────────────────────────────────────────
+$step = (int) $auditReq->get('step');
+$step = max(0, min($step, $total - 1));
+
+$q      = $questions[$step];
+$pos    = $step + 1;
+$pct    = (int) round(($step / $total) * 100);
+$isLast = ($step === $total - 1);
+$answers = $auditReq->getAnswersArray();
+$selected = $answers[$q['id']] ?? '';
+
+// Construire les options radio
+$optionsHtml = '';
+foreach ($q['options'] as $opt) {
+    $isSelected = ($selected === $opt['id']);
+    $isNa       = ($opt['id'] === 'NA' || str_ends_with(strtolower($opt['id']), '_na'));
+    $optionsHtml .= $modx->getChunk('ae_question_option', [
+        'question_id' => htmlspecialchars($q['id'], ENT_QUOTES),
+        'option_id'   => htmlspecialchars($opt['id'], ENT_QUOTES),
+        'label'       => htmlspecialchars($opt['label'], ENT_QUOTES),
+        'checked'     => $isSelected ? 'checked' : '',
+        'cls_selected'=> $isSelected ? 'opt--selected' : '',
+        'cls_na'      => $isNa       ? 'opt--na'       : '',
+    ]);
+}
+
+$actionUrl    = $modx->makeUrl($modx->resource->get('id'), '', '', 'full');
+$selectUrl    = $selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/';
+$remainLabel  = $isLast
+    ? 'Dernière question'
+    : 'encore ' . ($total - $pos) . ' question' . ($total - $pos > 1 ? 's' : '');
+
+$progressHtml = $modx->getChunk('ae_quiz_progress', [
+    'pos'          => $pos,
+    'total'        => $total,
+    'pct'          => $pct,
+    'remain_label' => htmlspecialchars($remainLabel, ENT_QUOTES),
+    'pack_title'   => htmlspecialchars($pack['pack_title'] ?? $packId, ENT_QUOTES),
+]);
+
+return $modx->getChunk('ae_quiz', [
+    'progress'    => $progressHtml,
+    'question_id' => htmlspecialchars($q['id'], ENT_QUOTES),
+    'question'    => htmlspecialchars($q['label'], ENT_QUOTES),
+    'help'        => isset($q['help']) ? '<p class="qHelp">' . htmlspecialchars($q['help'], ENT_QUOTES) . '</p>' : '',
+    'options'     => $optionsHtml,
+    'action_url'  => $actionUrl,
+    'select_url'  => $selectUrl,
+    'audit_uid'   => htmlspecialchars($auditUid, ENT_QUOTES),
+    'can_prev'    => $step > 0 ? '' : 'disabled',
+    'btn_next'    => $isLast ? 'Voir mon résultat →' : 'Suivant →',
+    'btn_class'   => $selected ? 'btn--primary' : 'btn--outline',
+    'can_next'    => $selected ? '' : 'disabled',
+]);

+ 175 - 0
modx/snippets/AuditExpress_Results.php

@@ -0,0 +1,175 @@
+<?php
+/**
+ * Snippet : AuditExpress_Results
+ * Vue "Résultats du diagnostic"
+ *
+ * Propriétés :
+ *   &select_resource_id = `4`  Pour "Diagnostiquer un autre process"
+ *   &booking_url        = `https://calendly.com/livinweb/diagnostic`
+ *   &devis_url          = `mailto:contact@livinweb.fr`
+ *
+ * L'audit_uid passe en GET (?audit=xxxx) ou est lu depuis la session.
+ *
+ * POST action : ae_capture_email
+ *   → sauvegarde l'email dans AuditRequest
+ *   → génère + envoie le PDF
+ *   → redirige sur la même page avec ?unlocked=1
+ */
+
+declare(strict_types=1);
+
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+$modx->addPackage('audit_express', $corePath . 'model/');
+require_once $corePath . 'src/PdfRenderer.php';
+require_once $corePath . 'src/LogMailer.php';
+
+$selectResourceId = (int) ($scriptProperties['select_resource_id'] ?? $modx->getOption('ae.resource.select', null, 0));
+$bookingUrl       = $scriptProperties['booking_url'] ?? $modx->getOption('ae.booking_url', null, '');
+$devisUrl         = $scriptProperties['devis_url']   ?? $modx->getOption('ae.devis_url',   null, '');
+
+// ── Charger l'audit ────────────────────────────────────────────────────────
+$auditUid = trim($_GET['audit'] ?? $_SESSION['ae_audit_uid'] ?? '');
+if (!$auditUid) {
+    $modx->sendRedirect($selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/');
+    return '';
+}
+
+/** @var AuditRequest|null $auditReq */
+$auditReq = $modx->getObject('AuditRequest', ['audit_uid' => $auditUid]);
+if (!$auditReq || $auditReq->get('status') === 'draft') {
+    $modx->sendRedirect($selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/');
+    return '';
+}
+
+// ── POST : capture email + PDF ─────────────────────────────────────────────
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['ae_action'] ?? '') === 'ae_capture_email') {
+    $email = trim(filter_var($_POST['email'] ?? '', FILTER_SANITIZE_EMAIL));
+    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
+        $auditReq->set('email', $email);
+        $auditReq->set('status', 'emailed');
+        $auditReq->save();
+
+        // Stocker en session pour pré-remplir le formulaire PDF
+        $_SESSION['ae_email'] = $email;
+        $_SESSION['ae_unlocked_' . $auditUid] = true;
+
+        // Générer et envoyer le PDF (LogMailer V1 = stockage fichier)
+        try {
+            $packId  = $auditReq->get('pack_id');
+            $repo    = new \AuditExpress\PackRepository($corePath . 'config/');
+            $pack    = $repo->getPack($packId);
+            $result  = $auditReq->getResultArray();
+            $answers = $auditReq->getAnswersArray();
+
+            $renderer = new \AuditExpress\PdfRenderer(
+                $corePath . 'templates/pdf_a4.php',
+                $corePath . '../vendor/autoload.php'
+            );
+            $pdfBytes = $renderer->render($pack, $result, $bookingUrl);
+
+            $mailer = new \AuditExpress\LogMailer($corePath . '../storage/outbox/');
+            $mailer->send(
+                $email,
+                'Votre diagnostic — Contrôle technique process',
+                "Bonjour,\n\nVeuillez trouver ci-joint votre synthèse PDF.\n\nBonne continuation,\nL'équipe Livinweb",
+                $pdfBytes,
+                'controle-technique-' . $packId . '.pdf'
+            );
+        } catch (\Throwable $e) {
+            // Ne pas bloquer l'utilisateur si le PDF échoue
+            $modx->log(xPDO::LOG_LEVEL_ERROR, '[AuditExpress] PDF error: ' . $e->getMessage());
+        }
+    }
+
+    $selfUrl = $modx->makeUrl($modx->resource->get('id'), '', 'audit=' . $auditUid . '&unlocked=1', 'full');
+    $modx->sendRedirect($selfUrl);
+    return '';
+}
+
+// ── Rendu GET ──────────────────────────────────────────────────────────────
+$r        = $auditReq->getResultArray();
+$unlocked = isset($_GET['unlocked']) || ($_SESSION['ae_unlocked_' . $auditUid] ?? false);
+$email    = $auditReq->get('email') ?? ($_SESSION['ae_email'] ?? '');
+
+$actionUrl  = $modx->makeUrl($modx->resource->get('id'), '', 'audit=' . $auditUid, 'full');
+$selectUrl  = $selectResourceId ? $modx->makeUrl($selectResourceId, '', '', 'full') : '/';
+
+// Niveaux
+$levelColors = ['A' => '#1e8a5e', 'B' => '#1e8a5e', 'C' => '#c07c10', 'D' => '#b83040'];
+$dotColor    = $levelColors[$r['level'] ?? ''] ?? '#2F506D';
+
+// Piliers
+$pillarsHtml = '';
+foreach ($r['pillars'] ?? [] as $p) {
+    $pct = $p['max'] ? (int) round(($p['score'] / $p['max']) * 100) : 0;
+    $pillarsHtml .= $modx->getChunk('ae_pillar_row', [
+        'label' => htmlspecialchars($p['label'], ENT_QUOTES),
+        'score' => $p['score'],
+        'max'   => $p['max'],
+        'pct'   => $pct,
+    ]);
+}
+
+// Risques
+$risksHtml = '';
+foreach ($r['risks_top3'] ?? [] as $risk) {
+    $risksHtml .= $modx->getChunk('ae_risk_item', [
+        'title'       => htmlspecialchars($risk['title'], ENT_QUOTES),
+        'what_happens'=> htmlspecialchars($risk['what_happens'], ENT_QUOTES),
+    ]);
+}
+
+// Quick wins (uniquement si débloqué)
+$winsHtml = '';
+if ($unlocked) {
+    foreach ($r['quick_wins_preview'] ?? [] as $win) {
+        $winsHtml .= $modx->getChunk('ae_win_item', [
+            'title'  => htmlspecialchars($win['title'], ENT_QUOTES),
+            'effect' => htmlspecialchars($win['effect'], ENT_QUOTES),
+            'effort' => htmlspecialchars($win['effort'], ENT_QUOTES),
+        ]);
+    }
+}
+
+// Coût caché
+$costHtml = '';
+$cost = $r['cost_hidden'] ?? null;
+if ($cost) {
+    $costHtml = $modx->getChunk('ae_cost_hidden', [
+        'hours_per_month' => $cost['hours_per_month'],
+        'eur_per_month'   => $cost['eur_per_month'],
+    ]);
+}
+
+// Gate email ou CTAs débloqués
+$gateOrCtaHtml = $unlocked
+    ? $modx->getChunk('ae_cta_unlocked', [
+        'booking_url' => htmlspecialchars($bookingUrl, ENT_QUOTES),
+        'devis_url'   => htmlspecialchars($devisUrl,   ENT_QUOTES),
+        'select_url'  => $selectUrl,
+        'action_url'  => $actionUrl,
+        'email'       => htmlspecialchars($email, ENT_QUOTES),
+        'audit_uid'   => htmlspecialchars($auditUid, ENT_QUOTES),
+      ])
+    : $modx->getChunk('ae_unlock_gate', [
+        'action_url' => $actionUrl,
+        'audit_uid'  => htmlspecialchars($auditUid, ENT_QUOTES),
+        'risks_html' => $risksHtml,
+        'email'      => htmlspecialchars($email, ENT_QUOTES),
+      ]);
+
+return $modx->getChunk('ae_results', [
+    'pack_title'   => htmlspecialchars($r['pack_title'] ?? $auditReq->get('pack_id'), ENT_QUOTES),
+    'score_total'  => $r['score_total'] ?? 0,
+    'level'        => $r['level'] ?? '—',
+    'level_label'  => htmlspecialchars($r['level_label'] ?? '', ENT_QUOTES),
+    'dot_color'    => $dotColor,
+    'confidence'   => htmlspecialchars($r['confidence']['label'] ?? '', ENT_QUOTES),
+    'pillars_html' => $pillarsHtml,
+    'risks_html'   => $risksHtml,
+    'wins_html'    => $winsHtml,
+    'cost_html'    => $costHtml,
+    'gate_html'    => $gateOrCtaHtml,
+    'unlocked'     => $unlocked ? '1' : '',
+]);

+ 126 - 0
modx/snippets/AuditExpress_SelectPack.php

@@ -0,0 +1,126 @@
+<?php
+/**
+ * Snippet : AuditExpress_SelectPack
+ * Vue "Choisir un pack"
+ *
+ * Propriétés (dans le tag snippet MODX) :
+ *   &quiz_resource_id  = `5`   ID de la ressource quiz
+ *   &landing_resource_id = `3` ID de la ressource landing
+ *
+ * POST action : ae_select_pack
+ *   → crée un AuditRequest en BD, stocke audit_uid en session
+ *   → redirige vers la ressource quiz
+ */
+
+declare(strict_types=1);
+
+// ── Bootstrap ──────────────────────────────────────────────────────────────
+$corePath = $modx->getOption('ae.core_path', null,
+    $modx->getOption('core_path') . 'components/audit_express/');
+$modx->addPackage('audit_express', $corePath . 'model/');
+
+require_once $corePath . 'src/PackRepository.php';
+
+$quizResourceId    = (int) ($scriptProperties['quiz_resource_id']    ?? $modx->getOption('ae.resource.quiz', null, 0));
+$landingResourceId = (int) ($scriptProperties['landing_resource_id'] ?? $modx->getOption('ae.resource.landing', null, 0));
+
+// ── Traitement POST ────────────────────────────────────────────────────────
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['ae_action'] ?? '') === 'select_pack') {
+    $packId = trim($_POST['pack_id'] ?? '');
+    if (!$packId) {
+        $modx->sendRedirect($modx->makeUrl($modx->resource->get('id'), '', '', 'full'));
+        return '';
+    }
+
+    // Vérifier que le pack existe
+    $repo = new \AuditExpress\PackRepository($corePath . 'config/');
+    try {
+        $packData = $repo->getPack($packId);
+    } catch (\InvalidArgumentException $e) {
+        $modx->sendRedirect($modx->makeUrl($modx->resource->get('id'), '', '', 'full'));
+        return '';
+    }
+
+    // Créer l'objet AuditRequest en BD
+    /** @var AuditRequest $auditReq */
+    $auditReq = $modx->newObject('AuditRequest');
+    $auditReq->set('audit_uid',  sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff),
+        mt_rand(0, 0x0fff) | 0x4000,
+        mt_rand(0, 0x3fff) | 0x8000,
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
+    ));
+    $auditReq->set('pack_id', $packId);
+    $auditReq->set('status',  'draft');
+    $auditReq->set('step',    0);
+    $auditReq->set('ip_hash', hash('sha256', $_SERVER['REMOTE_ADDR'] ?? ''));
+    $auditReq->setAnswersArray([]);
+    $auditReq->setOptionalArray([]);
+    $auditReq->save();
+
+    // Stocker en session
+    $modx->user->getUserProfile(); // init session MODX
+    $_SESSION['ae_audit_uid'] = $auditReq->get('audit_uid');
+    $_SESSION['ae_pack_id']   = $packId;
+
+    // Rediriger vers quiz
+    $quizUrl = $quizResourceId
+        ? $modx->makeUrl($quizResourceId, '', '', 'full')
+        : '/quiz/';
+    $modx->sendRedirect($quizUrl);
+    return '';
+}
+
+// ── Rendu GET ──────────────────────────────────────────────────────────────
+$packCatalogue = [
+    [
+        'id'       => 'onboarding-v1',
+        'title'    => 'Onboarding collaborateur',
+        'desc'     => "Fiabilisez l'intégration de vos nouveaux collaborateurs : clarté du flux, traçabilité, continuité.",
+        'tag'      => 'Pré-configuré',
+        'tagClass' => 'tag--pre',
+    ],
+    [
+        'id'       => 'validation-facture',
+        'title'    => 'Validation de facture',
+        'desc'     => 'Contrôles, séparation des tâches, preuve : évaluez la robustesse de votre circuit factures.',
+        'tag'      => 'Pré-configuré',
+        'tagClass' => 'tag--pre',
+    ],
+    [
+        'id'       => 'process-generique',
+        'title'    => 'Process générique',
+        'desc'     => 'Applicable à tout process opérationnel : achat, production, relation client, support, projet…',
+        'tag'      => 'Universel',
+        'tagClass' => 'tag--new',
+    ],
+    [
+        'id'       => 'process-generique-v2',
+        'title'    => 'Diagnostic d\'opportunité',
+        'desc'     => 'Évaluez sur 8 axes si ce process est prioritaire à automatiser : friction, volume, risque, données, outils, variabilité, collaboration, déploiement.',
+        'tag'      => 'Diagnostic d\'opportunité',
+        'tagClass' => 'tag--v2',
+    ],
+];
+
+$actionUrl = $modx->makeUrl($modx->resource->get('id'), '', '', 'full');
+$landingUrl = $landingResourceId ? $modx->makeUrl($landingResourceId, '', '', 'full') : '/';
+
+$cards = '';
+foreach ($packCatalogue as $p) {
+    $cards .= $modx->getChunk('ae_pack_card', [
+        'pack_id'    => htmlspecialchars($p['id'], ENT_QUOTES),
+        'title'      => htmlspecialchars($p['title'], ENT_QUOTES),
+        'desc'       => htmlspecialchars($p['desc'], ENT_QUOTES),
+        'tag'        => htmlspecialchars($p['tag'], ENT_QUOTES),
+        'tag_class'  => htmlspecialchars($p['tagClass'], ENT_QUOTES),
+        'action_url' => $actionUrl,
+    ]);
+}
+
+return $modx->getChunk('ae_select_pack', [
+    'cards'       => $cards,
+    'action_url'  => $actionUrl,
+    'landing_url' => $landingUrl,
+]);

+ 68 - 0
modx/templates/AuditExpress_Base.html

@@ -0,0 +1,68 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <title>[[*pagetitle]] — Contrôle technique process · Livinweb</title>
+  <meta name="description" content="[[*description:default=`En 7 minutes, obtenez une note sur 100, vos risques probables et 5 actions prioritaires pour fiabiliser votre process.`]]">
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link rel="stylesheet" href="[[++assets_url]]components/audit_express/css/app.css">
+  [[*ae_extra_head]]
+</head>
+<body>
+  <div class="container">
+
+    <header class="header">
+      <div>
+        <div class="brand__logo">
+          <a href="[[~[[++ae.resource.landing]]]]" style="color:inherit;text-decoration:none">Contrôle technique process</a>
+        </div>
+        <div class="brand__sub">
+          Diagnostic self-serve ·
+          <a href="https://livinweb.fr" target="_blank" rel="noreferrer" style="color:inherit;text-decoration:none">Livinweb</a>
+        </div>
+      </div>
+      <span class="brand__badge">V2</span>
+    </header>
+
+    <main id="app">
+      [[*content]]
+    </main>
+
+    <footer class="footer">
+      <a href="#" id="privacyLink">Données &amp; confidentialité</a>
+      &nbsp;·&nbsp;
+      <a href="https://livinweb.fr" target="_blank" rel="noreferrer">Livinweb</a>
+    </footer>
+
+  </div><!-- /.container -->
+
+  <!-- Dialog confidentialité -->
+  <dialog id="privacyDialog" class="dialog">
+    <div class="dialog__inner">
+      <div class="dialog__head">
+        <strong>Données &amp; confidentialité</strong>
+        <button class="btn btn--outline" style="padding:6px 12px;font-size:13px" id="closePrivacy">Fermer</button>
+      </div>
+      <div class="dialog__body">
+        <p><strong>Données collectées</strong> : réponses au questionnaire, et email uniquement si vous demandez le PDF.</p>
+        <p><strong>Finalité</strong> : calculer un score, générer votre PDF, et vous l'envoyer.</p>
+        <p><strong>Durée</strong> : sessions sans email 7 jours ; avec email 90 jours max.</p>
+        <p><strong>Droits</strong> : accès, rectification, effacement. Contact :
+          <a href="mailto:[[++emailsender]]">[[++emailsender]]</a></p>
+      </div>
+    </div>
+  </dialog>
+
+  <script src="[[++assets_url]]components/audit_express/js/ae-base.js"></script>
+  <script>
+    var link = document.getElementById('privacyLink');
+    var dlg  = document.getElementById('privacyDialog');
+    var cls  = document.getElementById('closePrivacy');
+    if (link && dlg) link.addEventListener('click', function(e){ e.preventDefault(); dlg.showModal(); });
+    if (cls  && dlg) cls.addEventListener('click', function(){ dlg.close(); });
+  </script>
+  [[*ae_extra_js]]
+</body>
+</html>

+ 61 - 0
modx/templates/AuditExpress_Landing.html

@@ -0,0 +1,61 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <title>Contrôle technique de votre process — Livinweb</title>
+  <meta name="description" content="En 7 minutes, obtenez une note sur 100, vos risques probables et 5 actions prioritaires pour fiabiliser votre process.">
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link rel="stylesheet" href="[[++assets_url]]components/audit_express/css/app.css">
+</head>
+<body>
+  <div class="container">
+
+    <header class="header">
+      <div>
+        <div class="brand__logo">Contrôle technique process</div>
+        <div class="brand__sub">
+          Diagnostic self-serve ·
+          <a href="https://livinweb.fr" target="_blank" rel="noreferrer" style="color:inherit;text-decoration:none">Livinweb</a>
+        </div>
+      </div>
+      <span class="brand__badge">V2</span>
+    </header>
+
+    <main id="app">
+      [[*content]]
+    </main>
+
+    <footer class="footer">
+      <a href="#" id="privacyLink">Données &amp; confidentialité</a>
+      &nbsp;·&nbsp;
+      <a href="https://livinweb.fr" target="_blank" rel="noreferrer">Livinweb</a>
+    </footer>
+
+  </div>
+
+  <dialog id="privacyDialog" class="dialog">
+    <div class="dialog__inner">
+      <div class="dialog__head">
+        <strong>Données &amp; confidentialité</strong>
+        <button class="btn btn--outline" style="padding:6px 12px;font-size:13px" id="closePrivacy">Fermer</button>
+      </div>
+      <div class="dialog__body">
+        <p><strong>Données collectées</strong> : réponses au questionnaire, et email uniquement si vous demandez le PDF.</p>
+        <p><strong>Finalité</strong> : calculer un score, générer votre PDF, et vous l'envoyer.</p>
+        <p><strong>Durée</strong> : sessions sans email 7 jours ; avec email 90 jours max.</p>
+        <p><strong>Droits</strong> : accès, rectification, effacement. Contact : <a href="mailto:contact@livinweb.fr">contact@livinweb.fr</a></p>
+      </div>
+    </div>
+  </dialog>
+
+  <script>
+    var link = document.getElementById('privacyLink');
+    var dlg  = document.getElementById('privacyDialog');
+    var cls  = document.getElementById('closePrivacy');
+    if (link && dlg) link.addEventListener('click', function(e){ e.preventDefault(); dlg.showModal(); });
+    if (cls  && dlg) cls.addEventListener('click', function(){ dlg.close(); });
+  </script>
+</body>
+</html>

+ 36 - 0
modx/templates/AuditExpress_Quiz.html

@@ -0,0 +1,36 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <title>[[*pagetitle]] — Contrôle technique process</title>
+  <meta name="robots" content="noindex,nofollow">
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link rel="stylesheet" href="[[++assets_url]]components/audit_express/css/app.css">
+</head>
+<body>
+  <div class="container">
+
+    <header class="header">
+      <div>
+        <div class="brand__logo">
+          <a href="[[~[[++ae.resource.landing]]]]" style="color:inherit;text-decoration:none">Contrôle technique process</a>
+        </div>
+        <div class="brand__sub">Diagnostic self-serve · Livinweb</div>
+      </div>
+    </header>
+
+    <main id="app">
+      [[*content]]
+    </main>
+
+    <footer class="footer">
+      <a href="[[~[[++ae.resource.landing]]]]">Accueil</a>
+      &nbsp;·&nbsp;
+      <a href="https://livinweb.fr" target="_blank" rel="noreferrer">Livinweb</a>
+    </footer>
+
+  </div>
+</body>
+</html>

+ 36 - 0
modx/templates/AuditExpress_Results.html

@@ -0,0 +1,36 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <title>Vos résultats — Contrôle technique process</title>
+  <meta name="robots" content="noindex,nofollow">
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link rel="stylesheet" href="[[++assets_url]]components/audit_express/css/app.css">
+</head>
+<body>
+  <div class="container">
+
+    <header class="header">
+      <div>
+        <div class="brand__logo">
+          <a href="[[~[[++ae.resource.landing]]]]" style="color:inherit;text-decoration:none">Contrôle technique process</a>
+        </div>
+        <div class="brand__sub">Diagnostic self-serve · Livinweb</div>
+      </div>
+    </header>
+
+    <main id="app">
+      [[*content]]
+    </main>
+
+    <footer class="footer">
+      <a href="[[~[[++ae.resource.landing]]]]">Accueil</a>
+      &nbsp;·&nbsp;
+      <a href="https://livinweb.fr" target="_blank" rel="noreferrer">Livinweb</a>
+    </footer>
+
+  </div>
+</body>
+</html>

+ 5 - 1
public/api/_bootstrap.php

@@ -9,6 +9,8 @@ if (is_file($autoload)) {
     require $autoload;
 }
 
+require $root . '/config/config.loader.php';
+
 spl_autoload_register(function (string $class) use ($root): void {
     $prefix = 'AuditExpress\\';
     if (!str_starts_with($class, $prefix)) {
@@ -21,5 +23,7 @@ spl_autoload_register(function (string $class) use ($root): void {
     }
 });
 
-return $root;
+$config = load_config($root);
+
+return ['root' => $root, 'config' => $config];
 

+ 23 - 11
public/api/email.php

@@ -2,28 +2,35 @@
 
 declare(strict_types=1);
 
+use AuditExpress\AdminNotifier;
+use AuditExpress\Analytics;
 use AuditExpress\Engine;
 use AuditExpress\Http;
-use AuditExpress\LogMailer;
 use AuditExpress\PackRepository;
 use AuditExpress\PdfRenderer;
+use AuditExpress\RateLimiter;
 use AuditExpress\RulesRepository;
+use AuditExpress\Security;
 
-$root = require __DIR__ . '/_bootstrap.php';
+['root' => $root, 'config' => $config] = require __DIR__ . '/_bootstrap.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     Http::methodNotAllowed(['POST']);
     exit;
 }
 
-$body = Http::readJsonBody();
+Security::validateCsrf();
+(new RateLimiter($root, $config, RateLimiter::clientIp()))->check('email');
+
+$maxBody = (int) ($config['max_body_bytes'] ?? 1_048_576);
+$body = Http::readJsonBody($maxBody > 0 ? $maxBody : null);
 $packId = (string) ($body['pack_id'] ?? 'onboarding-v1');
 $answers = $body['answers'] ?? [];
 $optional = $body['optional'] ?? [];
-$email = (string) ($body['email'] ?? '');
+$userEmail = (string) ($body['email'] ?? '');
 $bookingUrl = (string) ($body['booking_url'] ?? '');
 
-if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
+if ($userEmail === '' || !filter_var($userEmail, FILTER_VALIDATE_EMAIL)) {
     Http::json(['error' => 'Email invalide'], 400);
     exit;
 }
@@ -39,21 +46,26 @@ try {
     $rules = $rulesRepo->getRules();
 
     $result = Engine::compute($pack, $answers, $optional, $rules);
+
+    (new Analytics($root))->track(Analytics::EVENT_EMAIL_CAPTURED, $packId);
+
     $pdfBytes = (new PdfRenderer($root))->renderPdfBytes($pack, $result, [
         'booking_url' => $bookingUrl,
         'date' => date('Y-m-d'),
     ]);
 
     $filename = 'controle-technique-' . ($pack['pack_id'] ?? 'resultat') . '.pdf';
-    $subject = 'Votre contrôle technique : synthèse PDF';
-    $text = "Bonjour,\n\nVoici votre synthèse PDF.\n\nCordialement,\n";
 
-    $mailer = new LogMailer($root . '/storage/outbox');
-    $mailer->sendPdf($email, $subject, $text, $filename, $pdfBytes);
+    // Notification admin via webhook (pas d'envoi aux utilisateurs finaux)
+    $webhookUrl = (string) ($config['admin_notify_webhook'] ?? '');
+    if ($webhookUrl !== '' && filter_var($webhookUrl, FILTER_VALIDATE_URL)) {
+        $ctx = ['pack_id' => $packId, 'answers' => $answers, 'optional' => $optional, 'result' => $result];
+        (new AdminNotifier($webhookUrl, $root . '/storage/outbox'))->notify('email', $ctx, $filename, $pdfBytes, $userEmail);
+    }
 
     Http::json([
-        'status' => 'stored',
-        'message' => 'V1 pseudo: email stocké dans storage/outbox (à brancher sur SMTP/API).',
+        'status' => 'ok',
+        'message' => 'PDF généré. Vous pouvez le télécharger.',
     ]);
 } catch (Throwable $e) {
     Http::json(['error' => $e->getMessage()], 400);

+ 14 - 3
public/api/notify.php

@@ -3,18 +3,29 @@
 declare(strict_types=1);
 
 use AuditExpress\Http;
+use AuditExpress\RateLimiter;
+use AuditExpress\Security;
 
-$root = require __DIR__ . '/_bootstrap.php';
+['root' => $root, 'config' => $config] = require __DIR__ . '/_bootstrap.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     Http::methodNotAllowed(['POST']);
     exit;
 }
 
-$body  = Http::readJsonBody();
+Security::validateCsrf();
+(new RateLimiter($root, $config, RateLimiter::clientIp()))->check('notify');
+
+$maxBody = (int) ($config['max_body_bytes'] ?? 1_048_576);
+$body = Http::readJsonBody($maxBody > 0 ? $maxBody : null);
 $email = (string) ($body['email'] ?? '');
-$tool  = (string) ($body['tool']  ?? 'unknown');
+$tool  = (string) ($body['tool']  ?? '');
 
+$allowedTools = (array) ($config['allowed_notify_tools'] ?? ['process-mapper']);
+if ($tool === '' || !in_array($tool, $allowedTools, true)) {
+    Http::json(['error' => 'Outil invalide ou non autorisé'], 400);
+    exit;
+}
 if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
     Http::json(['error' => 'Email invalide'], 400);
     exit;

+ 3 - 1
public/api/pack.php

@@ -2,10 +2,11 @@
 
 declare(strict_types=1);
 
+use AuditExpress\Analytics;
 use AuditExpress\Http;
 use AuditExpress\PackRepository;
 
-$root = require __DIR__ . '/_bootstrap.php';
+['root' => $root] = require __DIR__ . '/_bootstrap.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
     Http::methodNotAllowed(['GET']);
@@ -17,6 +18,7 @@ $packId = (string) ($_GET['pack'] ?? 'onboarding-v1');
 try {
     $repo = new PackRepository($root);
     $pack = $repo->getPack($packId);
+    (new Analytics($root))->track(Analytics::EVENT_DIA_INIT, $packId);
     Http::json(['pack' => $pack]);
 } catch (Throwable $e) {
     Http::json(['error' => $e->getMessage()], 404);

+ 21 - 2
public/api/pdf.php

@@ -2,20 +2,28 @@
 
 declare(strict_types=1);
 
+use AuditExpress\AdminNotifier;
+use AuditExpress\Analytics;
 use AuditExpress\Engine;
 use AuditExpress\Http;
 use AuditExpress\PackRepository;
 use AuditExpress\PdfRenderer;
+use AuditExpress\RateLimiter;
 use AuditExpress\RulesRepository;
+use AuditExpress\Security;
 
-$root = require __DIR__ . '/_bootstrap.php';
+['root' => $root, 'config' => $config] = require __DIR__ . '/_bootstrap.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     Http::methodNotAllowed(['POST']);
     exit;
 }
 
-$body = Http::readJsonBody();
+Security::validateCsrf();
+(new RateLimiter($root, $config, RateLimiter::clientIp()))->check('pdf');
+
+$maxBody = (int) ($config['max_body_bytes'] ?? 1_048_576);
+$body = Http::readJsonBody($maxBody > 0 ? $maxBody : null);
 $packId = (string) ($body['pack_id'] ?? 'onboarding-v1');
 $answers = $body['answers'] ?? [];
 $optional = $body['optional'] ?? [];
@@ -40,7 +48,18 @@ try {
         'date' => date('Y-m-d'),
     ]);
 
+    (new Analytics($root))->track(Analytics::EVENT_PDF_GENERATED, $packId);
+
     $filename = 'controle-technique-' . ($pack['pack_id'] ?? 'resultat') . '.pdf';
+
+    // Notification admin via webhook
+    $webhookUrl = (string) ($config['admin_notify_webhook'] ?? '');
+    $userEmail = (string) ($body['email'] ?? '');
+    if ($webhookUrl !== '' && filter_var($webhookUrl, FILTER_VALIDATE_URL)) {
+        $ctx = ['pack_id' => $packId, 'answers' => $answers, 'optional' => $optional, 'result' => $result];
+        (new AdminNotifier($webhookUrl, $root . '/storage/outbox'))->notify('pdf', $ctx, $filename, $pdf, $userEmail !== '' ? $userEmail : null);
+    }
+
     header('Content-Type: application/pdf');
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header('Content-Length: ' . strlen($pdf));

+ 26 - 2
public/api/score.php

@@ -2,19 +2,28 @@
 
 declare(strict_types=1);
 
+use AuditExpress\AdminNotifier;
+use AuditExpress\Analytics;
 use AuditExpress\Engine;
 use AuditExpress\Http;
 use AuditExpress\PackRepository;
+use AuditExpress\PdfRenderer;
+use AuditExpress\RateLimiter;
 use AuditExpress\RulesRepository;
+use AuditExpress\Security;
 
-$root = require __DIR__ . '/_bootstrap.php';
+['root' => $root, 'config' => $config] = require __DIR__ . '/_bootstrap.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     Http::methodNotAllowed(['POST']);
     exit;
 }
 
-$body = Http::readJsonBody();
+Security::validateCsrf();
+(new RateLimiter($root, $config, RateLimiter::clientIp()))->check('score');
+
+$maxBody = (int) ($config['max_body_bytes'] ?? 1_048_576);
+$body = Http::readJsonBody($maxBody > 0 ? $maxBody : null);
 $packId = (string) ($body['pack_id'] ?? 'onboarding-v1');
 $answers = $body['answers'] ?? [];
 $optional = $body['optional'] ?? [];
@@ -31,6 +40,21 @@ try {
     $rules = $rulesRepo->getRules();
 
     $result = Engine::compute($pack, $answers, $optional, $rules);
+
+    (new Analytics($root))->track(Analytics::EVENT_DIA_COMPLETED, $packId);
+
+    // Notification admin via webhook
+    $webhookUrl = (string) ($config['admin_notify_webhook'] ?? '');
+    if ($webhookUrl !== '' && filter_var($webhookUrl, FILTER_VALIDATE_URL)) {
+        $pdfBytes = (new PdfRenderer($root))->renderPdfBytes($pack, $result, [
+            'booking_url' => '',
+            'date' => date('Y-m-d'),
+        ]);
+        $filename = 'controle-technique-' . ($pack['pack_id'] ?? 'resultat') . '.pdf';
+        $ctx = ['pack_id' => $packId, 'answers' => $answers, 'optional' => $optional, 'result' => $result];
+        (new AdminNotifier($webhookUrl, $root . '/storage/outbox'))->notify('score', $ctx, $filename, $pdfBytes, null);
+    }
+
     Http::json(['result' => $result]);
 } catch (Throwable $e) {
     Http::json(['error' => $e->getMessage()], 400);

+ 206 - 8
public/assets/css/app.css

@@ -32,15 +32,209 @@ body {
 /* ── Layout ── */
 .container { max-width: 920px; margin: 0 auto; padding: 32px 18px 52px; }
 
-.header {
+/* ── Navbar (bandeau menu) ── */
+.navbar {
+  background: linear-gradient(180deg, var(--navy) 0%, var(--dark) 100%);
+  color: #fff;
+  box-shadow: 0 2px 8px rgba(4, 23, 61, .25);
+  position: sticky;
+  top: 0;
+  z-index: 100;
+  border-bottom: 2px solid rgba(0, 190, 243, .35);
+}
+.navbar__inner {
+  max-width: 980px;
+  margin: 0 auto;
+  padding: 0 20px;
   display: flex;
   align-items: center;
   justify-content: space-between;
+  min-height: 58px;
+  gap: 16px;
+}
+.navbar__brand {
+  display: flex;
+  flex-direction: column;
+  text-decoration: none;
+  color: inherit;
+  transition: opacity .2s;
+  padding: 2px 0;
+}
+.navbar__brand:hover { opacity: .92; }
+.navbar__logo {
+  font-size: 17px;
+  font-weight: 700;
+  letter-spacing: .35px;
+  line-height: 1.25;
+  color: #fff;
+}
+.navbar__sub {
+  font-size: 11px;
+  font-weight: 400;
+  opacity: .82;
+  margin-top: 2px;
+  letter-spacing: .2px;
+}
+.navbar__nav {
+  display: flex;
+  align-items: center;
+  gap: 6px;
+}
+.navbar__link {
+  color: rgba(255, 255, 255, .88);
+  text-decoration: none;
+  font-size: 14px;
+  font-weight: 500;
+  padding: 8px 14px;
+  border-radius: 6px;
+  transition: color .2s, background .2s;
+}
+.navbar__link:hover {
+  color: #fff;
+  background: rgba(255, 255, 255, .1);
+}
+.navbar__link--external::after {
+  content: ' ↗';
+  font-size: 10px;
+  opacity: .7;
+  vertical-align: 1px;
+}
+.navbar__link--cta {
+  background: var(--cyan);
+  color: #fff !important;
+  margin-left: 8px;
+}
+.navbar__link--cta:hover {
+  background: rgba(0, 190, 243, .85);
+  color: #fff !important;
+}
+.navbar__badge {
+  font-size: 10px;
+  font-weight: 700;
+  letter-spacing: .5px;
+  text-transform: uppercase;
+  background: var(--cyan);
+  color: #fff;
+  padding: 5px 10px;
+  border-radius: 5px;
+  margin-left: 8px;
+  box-shadow: 0 1px 3px rgba(0, 190, 243, .3);
+}
+.navbar__toggle {
+  display: none;
+  flex-direction: column;
+  gap: 5px;
+  padding: 10px;
+  background: transparent;
+  border: none;
+  cursor: pointer;
+  color: #fff;
+  border-radius: 6px;
+  transition: background .2s;
+}
+.navbar__toggle:hover { background: rgba(255, 255, 255, .1); }
+.navbar__toggle span {
+  display: block;
+  width: 20px;
+  height: 2px;
+  background: currentColor;
+  border-radius: 1px;
+  transition: transform .2s;
+}
+@media (max-width: 640px) {
+  .navbar__toggle { display: flex; }
+  .navbar__nav {
+    position: fixed;
+    top: 58px;
+    left: 0;
+    right: 0;
+    background: linear-gradient(180deg, var(--navy) 0%, var(--dark) 100%);
+    flex-direction: column;
+    padding: 16px 20px 24px;
+    gap: 4px;
+    transform: translateY(-100%);
+    opacity: 0;
+    visibility: hidden;
+    transition: transform .25s, opacity .25s, visibility .25s;
+    box-shadow: 0 8px 24px rgba(4, 23, 61, .25);
+    border-bottom: 2px solid rgba(0, 190, 243, .35);
+  }
+  body.nav-open .navbar__nav {
+    transform: translateY(0);
+    opacity: 1;
+    visibility: visible;
+  }
+  .navbar__link {
+    font-size: 15px;
+    padding: 12px 16px;
+    width: 100%;
+    text-align: left;
+    border-radius: 6px;
+  }
+}
+
+/* ── Footer ── */
+.footer {
+  margin-top: 48px;
+  padding-top: 28px;
+  border-top: 1px solid var(--border);
+  font-size: 13px;
+  color: var(--muted);
+}
+.footer__inner {
+  display: flex;
+  flex-wrap: wrap;
+  justify-content: space-between;
+  align-items: flex-start;
+  gap: 24px;
+}
+.footer__brand {
+  display: flex;
+  flex-direction: column;
+  gap: 2px;
+}
+.footer__brand strong {
+  font-size: 14px;
+  color: var(--navy);
+  font-weight: 700;
+}
+.footer__brand span {
+  font-size: 12px;
+  color: var(--muted);
+}
+.footer__links {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px 20px;
+}
+.footer__links a {
+  color: var(--muted);
+  text-decoration: none;
+  transition: color .15s;
+}
+.footer__links a:hover { color: var(--blue); }
+.footer__bottom {
+  margin-top: 20px;
+  padding-top: 16px;
+  border-top: 1px solid var(--border);
+  font-size: 12px;
+  color: var(--muted);
+  display: flex;
+  align-items: center;
   gap: 12px;
-  margin-bottom: 28px;
-  padding-bottom: 18px;
-  border-bottom: 2px solid var(--navy);
 }
+.footer__badge {
+  font-size: 10px;
+  font-weight: 700;
+  letter-spacing: .5px;
+  text-transform: uppercase;
+  background: var(--cyan);
+  color: #fff;
+  padding: 4px 8px;
+  border-radius: 4px;
+}
+
+/* Legacy brand (MODX / fallback) */
 .brand__logo { font-size: 20px; font-weight: 700; color: var(--navy); letter-spacing: .3px; }
 .brand__sub   { color: var(--muted); font-size: 13px; margin-top: 2px; font-weight: 400; }
 .brand__badge {
@@ -48,10 +242,6 @@ body {
   background: var(--cyan); color: #fff; padding: 3px 9px; border-radius: 4px;
 }
 
-.footer { margin-top: 32px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
-.footer a { color: var(--muted); text-decoration: underline; }
-.footer a:hover { color: var(--blue); }
-
 /* ── Cards ── */
 .card {
   background: var(--bg-card);
@@ -433,6 +623,14 @@ body {
 /* ── Tags outils ── */
 .tag--roi { background: #fffbe8; color: #8a5a00; border-color: #f0d090; }
 .tag--qwf { background: #e8faf6; color: #0a6a50; border-color: #90d8c0; }
+.tag--booking { background: #e8f4ff; color: #0a5a9e; border-color: #90c0f0; }
+
+.pack-card--link {
+  display: block;
+  text-decoration: none;
+  color: inherit;
+}
+.pack-card--link:hover { text-decoration: none; color: inherit; }
 
 /* ── ROI Calculator ── */
 .roi-grid { display: grid; gap: 14px; }

+ 3 - 0
public/assets/images/logo-livinweb-dark.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 28" width="120" height="28">
+  <text x="0" y="20" font-family="Arial,sans-serif" font-size="18" font-weight="700" fill="#173258">Livinweb</text>
+</svg>

+ 3 - 0
public/assets/images/logo-livinweb.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 28" width="120" height="28">
+  <text x="0" y="20" font-family="Arial,sans-serif" font-size="18" font-weight="700" fill="#fff">Livinweb</text>
+</svg>

+ 85 - 104
public/assets/js/app.js

@@ -1,9 +1,9 @@
 /* Audit Express Self — Livinweb */
 
 const appEl = document.getElementById('app');
-const API_BASE    = appEl?.dataset?.apiBase    || '/api';
-const BOOKING_URL = appEl?.dataset?.bookingUrl || '';
-const DEVIS_URL   = appEl?.dataset?.devisUrl   || '';
+const API_BASE     = appEl?.dataset?.apiBase     || '/api';
+const BOOKING_URL  = appEl?.dataset?.bookingUrl  || '';
+const DEVIS_URL    = appEl?.dataset?.devisUrl    || '';
 
 /* ── Catalogue packs ── */
 const PACK_CATALOGUE = [
@@ -32,7 +32,7 @@ const PACK_CATALOGUE = [
     id: 'process-generique-v2',
     title: 'Diagnostic d\'opportunité',
     desc: 'Évaluez sur 8 axes si ce process est prioritaire à automatiser : friction, volume, risque, données, outils, variabilité, collaboration, déploiement.',
-    tag: 'V2 — 25 questions',
+    tag: 'Diagnostic d\'opportunité',
     tagStyle: 'tag--v2',
   },
 ];
@@ -98,10 +98,17 @@ function loadProgress(packId) {
 }
 
 async function apiJson(path, { method = 'GET', body } = {}) {
+  const headers = {};
+  if (body) {
+    headers['Content-Type'] = 'application/json';
+    const csrf = appEl?.dataset?.csrfToken;
+    if (csrf) headers['X-CSRF-Token'] = csrf;
+  }
   const res = await fetch(`${API_BASE}${path}`, {
     method,
-    headers: body ? { 'Content-Type': 'application/json' } : undefined,
+    headers: Object.keys(headers).length ? headers : undefined,
     body: body ? JSON.stringify(body) : undefined,
+    credentials: 'same-origin',
   });
   const data = await res.json().catch(() => ({}));
   if (!res.ok) throw new Error(data?.error || 'Erreur API');
@@ -112,7 +119,7 @@ function setView(v) { state.view = v; render(); }
 
 function goStart() {
   Object.assign(state, { packId: null, pack: null, idx: 0, answers: {}, optional: {}, result: null, emailUnlocked: false, captureEmail: '' });
-  setView('select');
+  setView('landing');
 }
 
 async function selectPack(packId) {
@@ -134,55 +141,6 @@ function levelColor(level) {
   return { A: '#1e8a5e', B: '#1e8a5e', C: '#c07c10', D: '#b83040' }[level] || '#2F506D';
 }
 
-/* ── LANDING ── */
-function renderLanding() {
-  return h('div', { class: 'grid' }, [
-    h('div', { class: 'card' }, [
-      h('div', { style: 'margin-bottom:14px' }, [
-        h('span', { class: 'tag tag--pre', style: 'font-size:12px' }, ['Diagnostic self-serve']),
-      ]),
-      h('h1', { class: 'h1' }, ['Contrôle technique de votre process opérationnel']),
-      h('p', { class: 'lead' }, [
-        'En 7 minutes, obtenez une note sur 100, vos risques probables et 5 actions prioritaires pour fiabiliser votre process.'
-      ]),
-      h('ul', { class: 'bullets' }, [
-        h('li', {}, ['20 questions, 1 écran à la fois, langage simple']),
-        h('li', {}, ['Résultats immédiats — PDF 1 page partageable']),
-        h('li', {}, ['Données minimales, suppression sur demande']),
-      ]),
-      h('div', { class: 'btnrow' }, [
-        h('button', { class: 'btn btn--primary', onClick: goStart }, ['Lancer le contrôle technique →']),
-        BOOKING_URL
-          ? h('a', { class: 'btn btn--outline', href: '#exemple', onClick: (e) => { e.preventDefault(); showExemple(); } }, ['Voir un exemple de résultat'])
-          : null,
-      ]),
-      h('p', { class: 'hint' }, ['Aucun jargon. Aucun discours "outil". Juste un diagnostic actionnable.']),
-    ]),
-    h('div', { class: 'grid--2 grid', style: 'margin-top:0' }, [
-      ...PACK_CATALOGUE.map(p =>
-        h('div', { class: 'pack-card', style: 'cursor:default; opacity:.75' }, [
-          h('span', { class: `tag ${p.tagStyle}` }, [p.tag]),
-          h('div', { class: 'title', style: 'margin-top:8px' }, [p.title]),
-          h('div', { class: 'desc' }, [p.desc]),
-        ])
-      ),
-      ...COMING_SOON_TOOLS.map(makeComingSoonCard),
-    ]),
-    renderNotifyDialog(),
-  ]);
-}
-
-function showExemple() {
-  alert(
-    'Exemple de résultat :\n\n' +
-    'Score : 67/100 — Niveau C (Fragile)\n' +
-    '• Clarté du flux : 14/20\n• Fiabilité : 11/20\n• Traçabilité : 10/20\n' +
-    '• Résilience : 15/20\n• Coût caché : 17/20\n\n' +
-    'Risques : Statut flou → relances permanentes / Documents dispersés / Dépendance personne clé\n\n' +
-    'Quick wins : Checklist jour 1 prêt · Pré-check 48h · Tableau statut unique · Centraliser docs · Escalade simple'
-  );
-}
-
 /* ── COMING-SOON card helper ── */
 function makeComingSoonCard(tool) {
   return h('div', {
@@ -267,7 +225,65 @@ function renderNotifyDialog() {
   ]);
 }
 
-/* ── SELECT ── */
+/* ── LANDING (page d'accueil) ── */
+const DIAGNOSTIC_PROCESS_TOOL = {
+  id: 'diagnostic-process',
+  title: 'Diagnostique process',
+  desc: 'Choisissez un pack pré-configuré (onboarding, validation de facture) ou le questionnaire universel. Évaluez votre process en 7 minutes.',
+};
+
+function renderLanding() {
+  const diagnosticV2 = PACK_CATALOGUE.find(p => p.id === 'process-generique-v2');
+
+  const tools = [
+    h('div', { class: 'pack-card', onClick: () => setView('select') }, [
+      h('span', { class: 'tag tag--pre' }, ['Diagnostic']),
+      h('div', { class: 'title' }, [DIAGNOSTIC_PROCESS_TOOL.title, h('span', { class: 'arrow' }, [' →'])]),
+      h('div', { class: 'desc' }, [DIAGNOSTIC_PROCESS_TOOL.desc]),
+    ]),
+    diagnosticV2 ? h('div', { class: 'pack-card', onClick: () => selectPack(diagnosticV2.id) }, [
+      h('span', { class: `tag ${diagnosticV2.tagStyle}` }, [diagnosticV2.tag]),
+      h('div', { class: 'title' }, [diagnosticV2.title, h('span', { class: 'arrow' }, [' →'])]),
+      h('div', { class: 'desc' }, [diagnosticV2.desc]),
+    ]) : null,
+    h('div', { class: 'pack-card', onClick: () => setView('roi') }, [
+      h('span', { class: 'tag tag--roi' }, ['ROI Calculator']),
+      h('div', { class: 'title' }, ['ROI Calculator', h('span', { class: 'arrow' }, [' →'])]),
+      h('div', { class: 'desc' }, ['Transformez "ça nous coûte" en "ça vaut X €". 10 questions pour chiffrer le gain mensuel, le ROI annuel et les 2 leviers qui pèsent le plus.']),
+    ]),
+    h('div', { class: 'pack-card', onClick: () => setView('qwf') }, [
+      h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder']),
+      h('div', { class: 'title' }, ['Quick Wins Finder', h('span', { class: 'arrow' }, [' →'])]),
+      h('div', { class: 'desc' }, ['3 actions concrètes et personnalisées basées sur vos signaux — résultat attendu, effort estimé et délai typique pour chaque recommandation.']),
+    ]),
+    BOOKING_URL ? h('a', {
+      class: 'pack-card pack-card--link',
+      href: BOOKING_URL,
+      target: '_blank',
+      rel: 'noreferrer',
+    }, [
+      h('span', { class: 'tag tag--booking' }, ['Prise de décision']),
+      h('div', { class: 'title' }, ['Faisabilité d\'automatisation d\'un process', h('span', { class: 'arrow' }, [' →'])]),
+      h('div', { class: 'desc' }, ['Moins d\'une heure. Prenez rendez-vous pour évaluer ensemble si votre process est prioritaire à automatiser.']),
+    ]) : null,
+  ].filter(Boolean);
+
+  return h('div', { class: 'grid' }, [
+    h('div', { class: 'card' }, [
+      h('h1', { class: 'h1' }, ['Choisissez un outil']),
+      h('p', { class: 'lead' }, ['Diagnostiquez vos process opérationnels.']),
+
+      h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Outils disponibles']),
+      h('div', { class: 'grid grid--2' }, tools),
+
+      h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Bientôt disponible']),
+      h('div', { class: 'grid grid--2' }, COMING_SOON_TOOLS.map(makeComingSoonCard)),
+    ]),
+    renderNotifyDialog(),
+  ]);
+}
+
+/* ── SELECT (page Diagnostic process) ── */
 function renderSelect() {
   const makeCard = (p) =>
     h('div', { class: 'pack-card', onClick: () => selectPack(p.id) }, [
@@ -276,9 +292,8 @@ function renderSelect() {
       h('div', { class: 'desc' }, [p.desc]),
     ]);
 
-  const preConfigured = PACK_CATALOGUE.filter(p => p.id !== 'process-generique' && p.id !== 'process-generique-v2');
-  const generic   = PACK_CATALOGUE.find(p => p.id === 'process-generique');
-  const genericV2 = PACK_CATALOGUE.find(p => p.id === 'process-generique-v2');
+  const preConfigured = PACK_CATALOGUE.filter(p => p.tag === 'Pré-configuré');
+  const generic = PACK_CATALOGUE.find(p => p.id === 'process-generique');
 
   return h('div', { class: 'grid' }, [
     h('div', { class: 'card' }, [
@@ -289,33 +304,12 @@ function renderSelect() {
       h('div', { class: 'grid grid--2' }, preConfigured.map(makeCard)),
 
       h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Process universel']),
-      h('div', { class: 'grid grid--2' }, [
-        generic   ? makeCard(generic)   : null,
-        genericV2 ? makeCard(genericV2) : null,
-      ]),
-
-      h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Outils complémentaires']),
-      h('div', { class: 'grid grid--2' }, [
-        h('div', { class: 'pack-card', onClick: () => setView('roi') }, [
-          h('span', { class: 'tag tag--roi' }, ['ROI Calculator']),
-          h('div', { class: 'title' }, ['ROI Calculator', h('span', { class: 'arrow' }, [' →'])]),
-          h('div', { class: 'desc' }, ['Transformez "ça nous coûte" en "ça vaut X €". 10 questions pour chiffrer le gain mensuel, le ROI annuel et les 2 leviers qui pèsent le plus.']),
-        ]),
-        h('div', { class: 'pack-card', onClick: () => setView('qwf') }, [
-          h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder']),
-          h('div', { class: 'title' }, ['Quick Wins Finder', h('span', { class: 'arrow' }, [' →'])]),
-          h('div', { class: 'desc' }, ['3 actions concrètes et personnalisées basées sur vos signaux — résultat attendu, effort estimé et délai typique pour chaque recommandation.']),
-        ]),
-      ]),
-
-      h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Bientôt disponible']),
-      h('div', { class: 'grid grid--2' }, COMING_SOON_TOOLS.map(makeComingSoonCard)),
+      h('div', { class: 'grid grid--2' }, generic ? [makeCard(generic)] : []),
 
       h('div', { class: 'btnrow', style: 'margin-top:18px' }, [
         h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
       ]),
     ]),
-    renderNotifyDialog(),
   ]);
 }
 
@@ -618,12 +612,6 @@ function renderResults() {
       setTimeout(() => document.getElementById('pdfDialog')?.showModal(), 80);
     };
 
-    /* Teaser basé sur les vrais risques calculés */
-    const teaser = (r.risks_top3 || []).slice(0, 3).map(x => ({
-      title: x.title,
-      desc: x.what_happens,
-    }));
-
     return h('div', { class: 'unlock-gate' }, [
       h('div', { class: 'unlock-gate__inner' }, [
         h('div', { class: 'unlock-gate__icon' }, ['↓']),
@@ -631,17 +619,6 @@ function renderResults() {
         h('p', { class: 'lead', style: 'margin-bottom:20px' }, [
           'Entrez votre email professionnel pour accéder aux 5 actions prioritaires et télécharger votre PDF synthèse.',
         ]),
-
-        teaser.length ? h('div', { class: 'unlock-risks' }, teaser.map((t, i) =>
-          h('div', { class: 'unlock-risk' }, [
-            h('div', { class: 'unlock-risk__num' }, [String(i + 1)]),
-            h('div', { class: 'unlock-risk__body' }, [
-              h('strong', {}, [t.title]),
-              h('span', {}, [t.desc]),
-            ]),
-          ])
-        )) : null,
-
         h('form', { class: 'unlock-form', onSubmit: onUnlock }, [
           h('div', { class: 'unlock-row' }, [
             h('input', {
@@ -729,16 +706,16 @@ function renderResults() {
     /* V2 : carte diagnostic (toujours visible) */
     v2 ? renderV2Diagnostic() : null,
 
-    /* Non-V2 : risques (toujours visibles) */
-    !v2 ? h('div', { class: 'card' }, [
+    /* Non-V2 : risques (visibles uniquement après déblocage) */
+    !v2 && unlocked ? h('div', { class: 'card' }, [
       h('div', { class: 'h2' }, ['3 risques probables']),
       riskItems.length
         ? h('ol', { class: 'list' }, riskItems)
         : h('p', { class: 'muted small' }, ['Aucun risque majeur détecté.']),
     ]) : null,
 
-    /* Non-V2 : coût caché */
-    !v2 && cost ? h('div', { class: 'cost-block' }, [
+    /* Non-V2 : coût caché (visible uniquement après déblocage) */
+    !v2 && unlocked && cost ? h('div', { class: 'cost-block' }, [
       h('div', { class: 'h2' }, ['Coût caché estimé']),
       h('div', { class: 'cost-figures' }, [
         h('div', { class: 'cost-fig' }, [
@@ -753,7 +730,7 @@ function renderResults() {
       h('p', { class: 'hint' }, ['Estimation indicative, à valider par mesure réelle.']),
     ]) : null,
 
-    /* Gate ou contenu débloqué */
+    /* Gate (formulaire déblocage) ou contenu débloqué — gate visible uniquement si non débloqué */
     unlocked ? null : renderUnlockGate(),
 
     /* V2 : mini plan (débloqué) */
@@ -782,9 +759,13 @@ function renderPdfDialog() {
     const email = e.target.email.value.trim();
     if (!email) return;
     try {
+      const headers = { 'Content-Type': 'application/json' };
+      const csrf = appEl?.dataset?.csrfToken;
+      if (csrf) headers['X-CSRF-Token'] = csrf;
       const res = await fetch(`${API_BASE}/pdf.php`, {
         method: 'POST',
-        headers: { 'Content-Type': 'application/json' },
+        headers,
+        credentials: 'same-origin',
         body: JSON.stringify({
           pack_id: state.packId, answers: state.answers,
           optional: state.optional, booking_url: BOOKING_URL, email,

+ 4 - 0
public/favicon.svg

@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <rect width="32" height="32" rx="6" fill="#173258"/>
+  <text x="16" y="22" font-family="Arial,sans-serif" font-size="18" font-weight="700" fill="#00BEF3" text-anchor="middle">L</text>
+</svg>

+ 59 - 22
public/index.php

@@ -1,40 +1,77 @@
 <?php
 declare(strict_types=1);
 
-$bookingUrl = 'https://calendly.com/livinweb/diagnostic'; // TODO: remplacer par votre lien Calendly
-$devisUrl   = 'mailto:contact@livinweb.fr?subject=Demande%20de%20devis%20%E2%80%94%20Audit%20Express';  // TODO: remplacer par votre URL devis
+$root = dirname(__DIR__);
+require $root . '/config/config.loader.php';
+$config = load_config($root);
+$bookingUrl = (string) ($config['booking_url'] ?? '');
+$devisUrl   = (string) ($config['devis_url'] ?? '');
+
+// CSRF : démarre une session pour le token (côté standalone)
+if (session_status() === PHP_SESSION_NONE) {
+    session_start();
+}
+$csrfToken = $_SESSION['csrf_token'] ?? null;
+if ($csrfToken === null) {
+    $_SESSION['csrf_token'] = $csrfToken = bin2hex(random_bytes(32));
+}
 ?>
 <!doctype html>
 <html lang="fr">
   <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width,initial-scale=1" />
-    <title>Contrôle technique de votre process — Livinweb</title>
-    <meta name="description" content="En 7 minutes, obtenez une note sur 100, vos risques probables et 5 actions prioritaires pour fiabiliser votre process." />
+    <title>Contrôle technique process — Diagnostic self-serve · Livinweb</title>
+    <meta name="description" content="Choisissez le process à diagnostiquer. Packs pré-configurés, process universel, outils complémentaires (ROI Calculator, Quick Wins Finder)." />
+    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
     <link rel="preconnect" href="https://fonts.googleapis.com" />
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
     <link rel="stylesheet" href="/assets/css/app.css" />
   </head>
   <body>
-    <div class="container">
-      <header class="header">
-        <div>
-          <div class="brand__logo">Contrôle technique process</div>
-          <div class="brand__sub">Diagnostic self-serve · <a href="https://livinweb.fr" target="_blank" rel="noreferrer" style="color:inherit;text-decoration:none">Livinweb</a></div>
-        </div>
-        <span class="brand__badge">V1</span>
-      </header>
+    <header class="navbar">
+      <div class="navbar__inner">
+        <a href="/" class="navbar__brand">
+          <span class="navbar__logo">Contrôle technique process</span>
+        </a>
+        <nav class="navbar__nav">
+          <a href="/" class="navbar__link">Accueil</a>
+          <a href="https://livinweb.fr" target="_blank" rel="noreferrer" class="navbar__link navbar__link--logo">
+            <img src="/assets/images/logo-livinweb.svg" alt="Livinweb" class="navbar__logo-img" width="100" height="22" />
+          </a>
+          <a href="https://livinweb.fr/a-propos-de-livinweb/agence-web-digitale-paris-contact-form/" target="_blank" rel="noreferrer" class="navbar__link navbar__link--cta">Nous consulter</a>
+        </nav>
+        <button class="navbar__toggle" id="navToggle" aria-label="Menu" type="button">
+          <span></span><span></span><span></span>
+        </button>
+      </div>
+    </header>
 
+    <div class="container">
       <main id="app"
             data-api-base="/api"
             data-booking-url="<?= htmlspecialchars($bookingUrl, ENT_QUOTES) ?>"
-            data-devis-url="<?= htmlspecialchars($devisUrl, ENT_QUOTES) ?>">
+            data-devis-url="<?= htmlspecialchars($devisUrl, ENT_QUOTES) ?>"
+            data-csrf-token="<?= htmlspecialchars($csrfToken, ENT_QUOTES) ?>">
       </main>
 
       <footer class="footer">
-        <a href="#" id="privacyLink">Données &amp; confidentialité</a>
-        &nbsp;·&nbsp;
-        <a href="https://livinweb.fr" target="_blank" rel="noreferrer">Livinweb</a>
+        <div class="footer__inner">
+          <div class="footer__brand">
+            <strong>Contrôle technique process</strong>
+            <span>Diagnostic self-serve · <a href="https://livinweb.fr" target="_blank" rel="noreferrer" class="footer__logo-link">Livinweb</a></span>
+          </div>
+          <div class="footer__links">
+            <a href="/">Accueil</a>
+            <a href="#" id="footerPrivacyLink">Données &amp; confidentialité</a>
+            <a href="mailto:contact@livinweb.fr">Contact</a>
+            <a href="https://livinweb.fr" target="_blank" rel="noreferrer" class="footer__logo-link"><img src="/assets/images/logo-livinweb-dark.svg" alt="Livinweb" width="90" height="21" /></a>
+          </div>
+        </div>
+        <div class="footer__bottom">
+          <span>&copy; <?= date('Y') ?> <a href="https://livinweb.fr" target="_blank" rel="noreferrer" class="footer__logo-link"><img src="/assets/images/logo-livinweb-dark.svg" alt="Livinweb" width="72" height="17" class="footer__logo-img" /></a></span>
+          <span class="footer__badge">V1</span>
+        </div>
       </footer>
     </div>
 
@@ -47,7 +84,6 @@ $devisUrl   = 'mailto:contact@livinweb.fr?subject=Demande%20de%20devis%20%E2%80%
         <div class="dialog__body">
           <p><strong>Données collectées</strong> : réponses au questionnaire, et email uniquement si vous demandez le PDF.</p>
           <p><strong>Finalité</strong> : calculer un score, générer votre PDF, et vous l'envoyer.</p>
-          <p><strong>Durée</strong> : sessions sans email 7 jours ; avec email 90 jours max.</p>
           <p><strong>Droits</strong> : accès, rectification, effacement. Contact : <a href="mailto:contact@livinweb.fr">contact@livinweb.fr</a></p>
         </div>
       </div>
@@ -55,11 +91,12 @@ $devisUrl   = 'mailto:contact@livinweb.fr?subject=Demande%20de%20devis%20%E2%80%
 
     <script type="module" src="/assets/js/app.js"></script>
     <script>
-      const link = document.getElementById('privacyLink');
-      const dlg  = document.getElementById('privacyDialog');
-      const cls  = document.getElementById('closePrivacy');
-      if (link && dlg) link.addEventListener('click', (e) => { e.preventDefault(); dlg.showModal(); });
-      if (cls  && dlg) cls.addEventListener('click', () => dlg.close());
+      const dlg = document.getElementById('privacyDialog');
+      const cls = document.getElementById('closePrivacy');
+      const openPrivacy = (e) => { e.preventDefault(); dlg?.showModal(); };
+      document.getElementById('footerPrivacyLink')?.addEventListener('click', openPrivacy);
+      cls?.addEventListener('click', () => dlg?.close());
+      document.getElementById('navToggle')?.addEventListener('click', () => document.body.classList.toggle('nav-open'));
     </script>
   </body>
 </html>

+ 78 - 0
src/AdminNotifier.php

@@ -0,0 +1,78 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AuditExpress;
+
+/**
+ * Appelle un webhook à chaque soumission (données complètes + PDF en base64).
+ * Stocke aussi dans outbox pour traçabilité.
+ */
+final class AdminNotifier
+{
+    public function __construct(
+        private readonly string $webhookUrl,
+        private readonly string $outboxDir
+    ) {
+    }
+
+    /**
+     * @param array{pack_id?: string, answers?: array, optional?: array, result?: array} $context
+     */
+    public function notify(string $source, array $context, string $pdfFilename, string $pdfBytes, ?string $userEmail = null): void
+    {
+        $payload = [
+            'source' => $source,
+            'pack_id' => $context['pack_id'] ?? null,
+            'user_email' => $userEmail,
+            'date' => date('c'),
+            'answers' => $context['answers'] ?? [],
+            'optional' => $context['optional'] ?? [],
+            'result' => $context['result'] ?? [],
+            'pdf_filename' => $pdfFilename,
+            'pdf_base64' => base64_encode($pdfBytes),
+        ];
+
+        // Stockage outbox (toujours, pour traçabilité)
+        $this->storeInOutbox($source, $payload, $pdfFilename, $pdfBytes, $userEmail);
+
+        // Appel webhook
+        $this->callWebhook($payload);
+    }
+
+    private function storeInOutbox(string $source, array $payload, string $pdfFilename, string $pdfBytes, ?string $userEmail): void
+    {
+        if (!is_dir($this->outboxDir)) {
+            @mkdir($this->outboxDir, 0775, true);
+        }
+        $id = date('Ymd_His') . '_' . bin2hex(random_bytes(4));
+        $pdfPath = rtrim($this->outboxDir, '/\\') . DIRECTORY_SEPARATOR . $id . '_' . $pdfFilename;
+        file_put_contents($pdfPath, $pdfBytes);
+
+        $meta = $payload;
+        unset($meta['pdf_base64']);
+        $meta['id'] = $id;
+        $meta['type'] = 'admin_notify';
+        $meta['attachment'] = basename($pdfPath);
+        $meta['created_at'] = date(DATE_ATOM);
+
+        file_put_contents(
+            rtrim($this->outboxDir, '/\\') . DIRECTORY_SEPARATOR . $id . '_admin.json',
+            json_encode($meta, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
+        );
+    }
+
+    private function callWebhook(array $payload): void
+    {
+        $ctx = stream_context_create([
+            'http' => [
+                'method' => 'POST',
+                'header' => "Content-Type: application/json\r\n",
+                'content' => json_encode($payload, JSON_UNESCAPED_UNICODE),
+                'timeout' => 10,
+                'ignore_errors' => true,
+            ],
+        ]);
+        @file_get_contents($this->webhookUrl, false, $ctx);
+    }
+}

+ 115 - 0
src/Analytics.php

@@ -0,0 +1,115 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AuditExpress;
+
+/**
+ * Mini-analytics : incrémente des compteurs dans un fichier JSON.
+ * Utilise flock pour des écritures atomiques.
+ */
+final class Analytics
+{
+    public const EVENT_DIA_INIT = 'dia_init';
+    public const EVENT_DIA_COMPLETED = 'dia_completed';
+    public const EVENT_PDF_GENERATED = 'pdf_generated';
+    public const EVENT_EMAIL_CAPTURED = 'email_captured';
+
+    private string $file;
+
+    public function __construct(string $root)
+    {
+        $dir = $root . '/storage';
+        if (!is_dir($dir)) {
+            mkdir($dir, 0755, true);
+        }
+        $this->file = $dir . '/analytics.json';
+    }
+
+    /**
+     * Incrémente un compteur global et optionnellement par pack.
+     */
+    public function track(string $event, ?string $packId = null): void
+    {
+        $fp = fopen($this->file, 'c+');
+        if ($fp === false) {
+            return;
+        }
+
+        if (!flock($fp, LOCK_EX)) {
+            fclose($fp);
+            return;
+        }
+
+        $data = $this->readOrInit($fp);
+
+        $data['total'][$event] = ($data['total'][$event] ?? 0) + 1;
+
+        if ($packId !== null && $packId !== '') {
+            if (!isset($data['by_pack'][$packId])) {
+                $data['by_pack'][$packId] = array_fill_keys(
+                    [self::EVENT_DIA_INIT, self::EVENT_DIA_COMPLETED, self::EVENT_PDF_GENERATED, self::EVENT_EMAIL_CAPTURED],
+                    0
+                );
+            }
+            $data['by_pack'][$packId][$event] = ($data['by_pack'][$packId][$event] ?? 0) + 1;
+        }
+
+        $data['last_updated'] = date('c');
+
+        ftruncate($fp, 0);
+        rewind($fp);
+        fwrite($fp, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
+        flock($fp, LOCK_UN);
+        fclose($fp);
+    }
+
+    /**
+     * Retourne toutes les stats (lecture seule).
+     */
+    public function getStats(): array
+    {
+        $fp = fopen($this->file, 'r');
+        if ($fp === false) {
+            return $this->defaultStructure();
+        }
+
+        if (!flock($fp, LOCK_SH)) {
+            fclose($fp);
+            return $this->defaultStructure();
+        }
+
+        $data = $this->readOrInit($fp);
+        flock($fp, LOCK_UN);
+        fclose($fp);
+
+        return $data;
+    }
+
+    private function readOrInit($fp): array
+    {
+        $raw = stream_get_contents($fp);
+        if ($raw === false || trim($raw) === '') {
+            return $this->defaultStructure();
+        }
+        $decoded = json_decode($raw, true);
+        if (!is_array($decoded)) {
+            return $this->defaultStructure();
+        }
+        return array_merge($this->defaultStructure(), $decoded);
+    }
+
+    private function defaultStructure(): array
+    {
+        return [
+            'total' => [
+                self::EVENT_DIA_INIT => 0,
+                self::EVENT_DIA_COMPLETED => 0,
+                self::EVENT_PDF_GENERATED => 0,
+                self::EVENT_EMAIL_CAPTURED => 0,
+            ],
+            'by_pack' => [],
+            'last_updated' => null,
+        ];
+    }
+}

+ 20 - 2
src/Http.php

@@ -6,9 +6,27 @@ namespace AuditExpress;
 
 final class Http
 {
-    public static function readJsonBody(): array
+    /**
+     * @param positive-int|null $maxBytes Taille max du body (défaut 1 Mo). 0 = pas de limite.
+     */
+    public static function readJsonBody(?int $maxBytes = 1_048_576): array
     {
-        $raw = file_get_contents('php://input');
+        $stream = fopen('php://input', 'r');
+        if ($stream === false) {
+            return [];
+        }
+        $raw = '';
+        if ($maxBytes > 0) {
+            $raw = stream_get_contents($stream, $maxBytes + 1);
+            if ($raw !== false && strlen($raw) > $maxBytes) {
+                fclose($stream);
+                self::json(['error' => 'Body trop volumineux'], 413);
+                exit;
+            }
+        } else {
+            $raw = stream_get_contents($stream);
+        }
+        fclose($stream);
         if ($raw === false || trim($raw) === '') {
             return [];
         }

+ 1 - 1
src/PackRepository.php

@@ -22,7 +22,7 @@ final class PackRepository
         }
 
         $path = match ($packId) {
-            'onboarding-v1'         => $this->rootDir . '/config/pack-onboarding-v1.json',
+            'onboarding-v1'         => $this->rootDir . '/config/packs/pack-onboarding-v1.json',
             'validation-facture'    => $this->rootDir . '/config/packs/validation-facture.json',
             'process-generique'     => $this->rootDir . '/config/packs/process-generique.json',
             'process-generique-v2'  => $this->rootDir . '/config/packs/process-generique-v2.json',

+ 74 - 0
src/RateLimiter.php

@@ -0,0 +1,74 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AuditExpress;
+
+final class RateLimiter
+{
+    private string $storageDir;
+    private array $config;
+    private string $clientKey;
+
+    public function __construct(string $root, array $config, string $clientKey)
+    {
+        $this->storageDir = $root . '/storage/ratelimit';
+        $this->config = $config['rate_limit'] ?? [];
+        $this->clientKey = $clientKey;
+    }
+
+    public static function clientIp(): string
+    {
+        $headers = ['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'REMOTE_ADDR'];
+        foreach ($headers as $h) {
+            $v = $_SERVER[$h] ?? null;
+            if (is_string($v) && trim($v) !== '') {
+                $parts = explode(',', $v);
+                $ip = trim($parts[0]);
+                if (filter_var($ip, FILTER_VALIDATE_IP)) {
+                    return $ip;
+                }
+            }
+        }
+        return $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
+    }
+
+    /**
+     * Vérifie le rate limit. En cas de dépassement, envoie 429 et termine.
+     */
+    public function check(string $endpoint): void
+    {
+        $limits = $this->config[$endpoint] ?? null;
+        if ($limits === null) {
+            return;
+        }
+
+        $requests = (int) ($limits['requests'] ?? 30);
+        $window = (int) ($limits['window'] ?? 60);
+
+        if (!is_dir($this->storageDir)) {
+            @mkdir($this->storageDir, 0775, true);
+        }
+
+        $file = $this->storageDir . '/' . hash('sha256', $this->clientKey . ':' . $endpoint) . '.txt';
+        $now = time();
+        $lines = [];
+        if (is_file($file)) {
+            $content = file_get_contents($file);
+            foreach (explode("\n", trim($content)) as $line) {
+                $ts = (int) $line;
+                if ($ts > $now - $window) {
+                    $lines[] = $ts;
+                }
+            }
+        }
+
+        if (count($lines) >= $requests) {
+            Http::json(['error' => 'Trop de requêtes. Réessayez plus tard.'], 429);
+            exit;
+        }
+
+        $lines[] = $now;
+        file_put_contents($file, implode("\n", $lines) . "\n");
+    }
+}

+ 1 - 1
src/RulesRepository.php

@@ -13,7 +13,7 @@ final class RulesRepository
 
     public function getRules(): array
     {
-        $path = $this->rootDir . '/audit-structure.json';
+        $path = $this->rootDir . '/config/audit-structure.json';
         $raw = file_get_contents($path);
         if ($raw === false) {
             throw new \RuntimeException('Unable to read rules file');

+ 28 - 0
src/Security.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AuditExpress;
+
+final class Security
+{
+    /**
+     * Démarre la session si besoin, valide le token CSRF pour les POST.
+     * En cas d'échec : 403 et exit.
+     */
+    public static function validateCsrf(): void
+    {
+        if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+            return;
+        }
+        if (session_status() === PHP_SESSION_NONE) {
+            session_start();
+        }
+        $token = $_SESSION['csrf_token'] ?? null;
+        $header = trim((string) ($_SERVER['HTTP_X_CSRF_TOKEN'] ?? ''));
+        if ($token === null || $header === '' || !hash_equals((string) $token, trim($header))) {
+            Http::json(['error' => 'Token CSRF invalide ou manquant'], 403);
+            exit;
+        }
+    }
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor