:root {
    --bg-color: #f0f2f5;
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    --primary-color: #4e54c8;
    --primary-hover: #3f44a0;
    --secondary-color: #95a5a6;
    --danger-color: #ff6b6b;
    --border-color: #e1e4e8;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --primary-color: #767bfa;
    --primary-hover: #5b60d6;
    --border-color: #333;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-main); }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-bottom: 50px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] header {
    background-color: rgba(30, 30, 30, 0.85);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Buttons & Inputs */
.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary { 
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover)); 
    color: white; 
}
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-danger { background-color: var(--danger-color); color: white; font-size: 0.8rem; padding: 0.4rem 0.8rem; }
.btn-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: #f8f9fa;
    color: var(--text-color);
    margin-top: 0.3rem;
    transition: all 0.2s;
    font-size: 0.95rem;
}

[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
    background-color: #2d2d2d;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(78, 84, 200, 0.15);
}

/* Form Section */
.card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

#create-form, #edit-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    align-items: end;
}

.form-group { display: flex; flex-direction: column; }
.full-width { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
.required { color: var(--danger-color); }

/* Controls */
.controls-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}
.filters input, .filters select { width: auto; margin-top: 0; }

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.baraude-card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    animation: fadeIn 0.4s ease-out;
    border-left: 5px solid var(--primary-color);
    border: 1px solid var(--border-color);
    border-left-width: 5px;
}

.baraude-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-title { font-size: 1.2rem; font-weight: bold; }
.card-priority {
    background-color: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-bottom: 0.8rem;
    display: flex;
    gap: 10px;
}

.card-desc {
    flex-grow: 1;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.8rem;
}

.empty-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
    font-size: 1.2rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.hidden { display: none !important; }
.modal-content {
    width: 90%;
    max-width: 600px;
    animation: slideDown 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    #create-form, #edit-form {
        grid-template-columns: 1fr;
    }
    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }
    .filters {
        flex-direction: column;
    }
    .filters input, .filters select {
        width: 100%;
    }
}

/* Login Page Specifics */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding-bottom: 0;
}

.login-card {
    width: 100%;
    max-width: 400px;
    margin: 0;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }

/* Password Strength */
.password-strength {
    height: 4px;
    background-color: #e0e0e0;
    margin-top: 5px;
    border-radius: 2px;
    overflow: hidden;
}
.password-strength-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}
.strength-text {
    font-size: 0.75rem;
    text-align: right;
    margin-top: 2px;
    min-height: 1.2em;
    font-weight: 600;
}

/* Password Toggle (Eye icon) */
.password-wrapper {
    position: relative;
    margin-top: 0.3rem;
}
.password-wrapper input {
    margin-top: 0;
    padding-right: 40px; /* Espace pour l'icône */
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Checkbox "Se souvenir de moi" */
.checkbox-group {
    flex-direction: row !important; /* Force l'alignement horizontal */
    align-items: center;
    margin-top: 0.5rem;
}
.checkbox-group input {
    width: auto; /* Annule le width: 100% des inputs classiques */
    margin-top: 0;
    margin-right: 0.5rem;
}

/* Dashboard Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

.profile-card {
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background-color: var(--primary-color);
    color: white;
    font-size: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.profile-meta {
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
```

### 3. script.js
This file contains all the logic: state management, DOM manipulation, event listeners, and `localStorage` persistence.

```diff
/**
 * Script principal pour Baraude Manager
 * Gère la logique, le stockage et l'UI
 */

// --- État de l'application ---
let baraudes = [];
const STORAGE_KEY = 'baraudes_data';
const THEME_KEY = 'baraudes_theme';

// --- Sélecteurs DOM ---
const createForm = document.getElementById('create-form');
const gridContainer = document.getElementById('baraude-grid');
const searchInput = document.getElementById('search-input');
const filterCategory = document.getElementById('filter-category');
const sortPriority = document.getElementById('sort-priority');
const statsCounter = document.getElementById('stats-counter');
const themeToggle = document.getElementById('theme-toggle');

// Modal Elements
const editModal = document.getElementById('edit-modal');
const editForm = document.getElementById('edit-form');
const cancelEditBtn = document.getElementById('cancel-edit');

// --- Initialisation ---
document.addEventListener('DOMContentLoaded', () => {
    loadFromStorage();
    loadTheme();
    renderBaraudes();
    setupEventListeners();
});

function setupEventListeners() {
    // Création
    createForm.addEventListener('submit', handleCreate);
    
    // Filtres et Tri
    searchInput.addEventListener('input', renderBaraudes);
    filterCategory.addEventListener('change', renderBaraudes);
    sortPriority.addEventListener('change', renderBaraudes);
    
    // Thème
    themeToggle.addEventListener('click', toggleTheme);

    // Edition
    cancelEditBtn.addEventListener('click', closeEditModal);
    editForm.addEventListener('submit', handleUpdate);
    
    // Fermer modal si clic en dehors
    editModal.addEventListener('click', (e) => {
        if (e.target === editModal) closeEditModal();
    });
}

// --- Gestion des Baraudes (CRUD) ---

function addBaraude(title, category, priority, description) {
    const newBaraude = {
        id: Date.now(), // ID unique basé sur timestamp
        title,
        category,
        priority: parseInt(priority),
        description,
        date: new Date().toISOString()
    };

    baraudes.push(newBaraude);
    saveToStorage();
    renderBaraudes();
}

function deleteBaraude(id) {
    if(confirm('Voulez-vous vraiment supprimer cette baraude ?')) {
        baraudes = baraudes.filter(b => b.id !== id);
        saveToStorage();
        renderBaraudes();
    }
}

function updateBaraude(id, updatedData) {
    const index = baraudes.findIndex(b => b.id === id);
    if (index !== -1) {
        baraudes[index] = { ...baraudes[index], ...updatedData };
        saveToStorage();
        renderBaraudes();
    }
}

// --- Gestion des Événements ---

function handleCreate(e) {
    e.preventDefault();
    const title = document.getElementById('title').value.trim();
    const category = document.getElementById('category').value;
    const priority = document.getElementById('priority').value;
    const description = document.getElementById('description').value.trim();

    if (!title) {
        alert("Le titre est obligatoire !");
        return;
    }

    addBaraude(title, category, priority, description);
    createForm.reset();
}

function handleUpdate(e) {
    e.preventDefault();
    const id = parseInt(document.getElementById('edit-id').value);
    const title = document.getElementById('edit-title').value.trim();
    const category = document.getElementById('edit-category').value;
    const priority = parseInt(document.getElementById('edit-priority').value);
    const description = document.getElementById('edit-description').value.trim();

    if (!title) return alert("Titre obligatoire");

    updateBaraude(id, { title, category, priority, description });
    closeEditModal();
}

// --- UI & Rendu ---

function renderBaraudes() {
    // 1. Filtrage
    const searchText = searchInput.value.toLowerCase();
    const catFilter = filterCategory.value;
    const sortOrder = sortPriority.value;

    let filtered = baraudes.filter(b => {
        const matchesSearch = b.title.toLowerCase().includes(searchText) || 
                              b.description.toLowerCase().includes(searchText);
        const matchesCat = catFilter === '' || b.category === catFilter;
        return matchesSearch && matchesCat;
    });

    // 2. Tri
    filtered.sort((a, b) => {
        if (sortOrder === 'desc') return b.priority - a.priority;
        return a.priority - b.priority;
    });

    // 3. Affichage
    gridContainer.innerHTML = '';
    
    if (filtered.length === 0) {
        gridContainer.innerHTML = '<div class="empty-message">Aucune baraude trouvée 🍃</div>';
    } else {
        filtered.forEach(b => {
            const card = createCardElement(b);
            gridContainer.appendChild(card);
        });
    }

    // Mise à jour compteur
    statsCounter.textContent = `${filtered.length} baraude${filtered.length > 1 ? 's' : ''}`;
}

function createCardElement(baraude) {
    const dateFormatted = new Date(baraude.date).toLocaleDateString('fr-FR', {
        day: 'numeric', month: 'short', year: 'numeric'
    });

    const div = document.createElement('div');
    div.className = 'baraude-card';
    div.innerHTML = `
        <div class="card-header">
            <span class="card-title">${escapeHtml(baraude.title)}</span>
            <span class="card-priority" title="Priorité">P${baraude.priority}</span>
        </div>
        <div class="card-meta">
            <span class="badge">${baraude.category}</span>
            <span>• ${dateFormatted}</span>
        </div>
        <div class="card-desc">${escapeHtml(baraude.description || '')}</div>
        <div class="card-actions">
            <button class="btn btn-secondary" onclick="openEditModal(${baraude.id})">Modifier</button>
            <button class="btn btn-danger" onclick="deleteBaraude(${baraude.id})">Supprimer</button>
        </div>
    `;
    return div;
}

// --- Modal Functions ---
window.openEditModal = function(id) {
    const baraude = baraudes.find(b => b.id === id);
    if (!baraude) return;

    document.getElementById('edit-id').value = baraude.id;
    document.getElementById('edit-title').value = baraude.title;
    document.getElementById('edit-category').value = baraude.category;
    document.getElementById('edit-priority').value = baraude.priority;
    document.getElementById('edit-description').value = baraude.description;

    editModal.classList.remove('hidden');
};

function closeEditModal() {
    editModal.classList.add('hidden');
}

// --- Persistance & Utilitaires ---

function saveToStorage() {
    localStorage.setItem(STORAGE_KEY, JSON.stringify(baraudes));
}

function loadFromStorage() {
    const data = localStorage.getItem(STORAGE_KEY);
    if (data) baraudes = JSON.parse(data);
}

function toggleTheme() {
    const isDark = document.body.getAttribute('data-theme') === 'dark';
    const newTheme = isDark ? 'light' : 'dark';
    document.body.setAttribute('data-theme', newTheme);
    localStorage.setItem(THEME_KEY, newTheme);
}

function loadTheme() {
    const savedTheme = localStorage.getItem(THEME_KEY);
    if (savedTheme) document.body.setAttribute('data-theme', savedTheme);
}

function escapeHtml(text) {
    if (!text) return '';
    return text
        .replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&#039;");
}
