/* ============================================
   FÊTE MÉDIÉVALE — Identité visuelle
   Parchemin, bordeaux, or et encre
   ============================================ */

:root {
    --primary: #7A1F2B;
    --primary-dark: #4A121A;
    --primary-light: #A23B45;
    --secondary: #C9A24B;
    --accent: #9A7429;
    --bg: #F5EFE3;
    --bg-card: #FFFCF5;
    --ink: #1C1512;
    --ink-soft: #2C211B;
    --text: #241A14;
    --text-light: #66564A;
    --border: #E2D5BD;
    --success: #2F6B47;
    --warning: #B8690F;
    --danger: #A92B2B;
    --info: #2A5B85;
    --shadow: 0 1px 2px rgba(36,26,20,.06), 0 4px 14px rgba(36,26,20,.06);
    --shadow-lg: 0 2px 6px rgba(36,26,20,.08), 0 14px 34px rgba(36,26,20,.14);
    --radius: 8px;
    --radius-lg: 14px;
    --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M22 0l22 22-22 22L0 22z' fill='none' stroke='%23C9A24B' stroke-opacity='.16'/%3E%3Ccircle cx='22' cy='22' r='1.4' fill='%23C9A24B' fill-opacity='.28'/%3E%3C/svg%3E");
    --crenel: repeating-linear-gradient(90deg, currentColor 0 16px, transparent 16px 26px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 1.25;
}

a { color: var(--primary); }

:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

/* ---- CONNEXION ---- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lattice), radial-gradient(120% 90% at 50% 0%, #5B1721 0%, #2A1013 55%, var(--ink) 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 38px 36px 30px;
    box-shadow: 0 24px 60px rgba(0,0,0,.45);
    border: 1px solid var(--secondary);
    outline: 1px solid rgba(201,162,75,.35);
    outline-offset: 5px;
}

.login-header { text-align: center; margin-bottom: 26px; }
.login-crest { color: var(--primary); margin-bottom: 8px; }
.login-header h2 { color: var(--primary-dark); font-size: 1.6rem; }
.login-header p {
    color: var(--accent);
    font-size: .78rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    margin-top: 4px;
}

/* ---- STRUCTURE ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--lattice), linear-gradient(180deg, var(--ink) 0%, #2B1417 100%);
    color: #EFE6D6;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px 18px;
    text-align: center;
}

.sidebar-crest { color: var(--secondary); display: inline-flex; margin-bottom: 6px; }
.sidebar-header h2 { font-size: 1.08rem; color: #F4E7C8; }
.sidebar-header small {
    display: block;
    color: var(--secondary);
    font-size: .74rem;
    letter-spacing: .14em;
    margin-top: 2px;
}

.sidebar-user {
    margin: 0 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(201,162,75,.2);
    border-radius: var(--radius);
    font-size: .85rem;
}

.sidebar-user .user-avatar { font-size: 1.35rem; line-height: 1; }
.sidebar-user .user-name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.sidebar-user .user-role { color: var(--secondary); font-size: .72rem; text-transform: capitalize; }

.sidebar-nav { padding: 8px 0 16px; flex: 1; }

.nav-section {
    padding: 16px 22px 5px;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: rgba(239,230,214,.5);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 1px 10px;
    padding: 8px 12px;
    color: rgba(239,230,214,.82);
    text-decoration: none;
    border-radius: 7px;
    font-size: .9rem;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }

.nav-link.active {
    background: linear-gradient(90deg, rgba(201,162,75,.24), rgba(201,162,75,.06));
    color: #F7E9C4;
    box-shadow: inset 2px 0 0 var(--secondary);
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 0 7px;
    font-size: .72rem;
    font-weight: 600;
}

.sidebar-backdrop { display: none; }

.main-content {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
}

.top-bar {
    background: rgba(255,252,245,.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 10px 30px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-user { color: var(--text-light); font-size: .88rem; }
.top-bar-date { margin-left: auto; font-size: .82rem; color: var(--text-light); }
#menu-toggle { display: none; }

.page-content { padding: 28px 30px 44px; max-width: 1500px; margin: 0 auto; }

/* ---- COMPOSANTS ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.75rem;
    color: var(--primary-dark);
}

.page-header h1::after {
    content: '';
    display: block;
    width: 72px;
    height: 7px;
    margin-top: 7px;
    color: var(--secondary);
    background: var(--crenel);
    opacity: .85;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font: 500 .88rem/1.3 var(--font-body);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    text-decoration: none;
    color: var(--text);
    background: #EFE6D6;
}

.btn:hover { background: #E6DAC4; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #EFE6D6; color: var(--text); }
.btn-secondary:hover { background: #E6DAC4; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(169,43,43,.4); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border-color: var(--secondary); color: var(--primary-dark); }
.btn-outline:hover { background: rgba(201,162,75,.14); }
.btn.btn-edit { background: transparent; color: var(--primary); border-color: var(--border); }
.btn.btn-edit:hover { background: rgba(122,31,43,.08); }
.btn-sm { padding: 4px 10px; font-size: .79rem; }
.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }

/* Formulaires */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; color: var(--text-light); font-size: .85rem; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #D6C7AB;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: 400 .94rem/1.4 var(--font-body);
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(201,162,75,.25);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-full { grid-column: 1 / -1; }

/* Alertes */
.alert { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px; font-size: .92rem; }
.alert-error { background: #FBEDEA; border: 1px solid #EBC3BC; color: var(--danger); }
.alert-success { background: #EAF3EC; border: 1px solid #BFDAC7; color: var(--success); }
.alert-info { background: #FBF3DF; border: 1px solid #EBD9AC; color: #6E5417; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-urgente { background: #FBE6E3; color: #952222; }
.badge-haute { background: #FCEBD8; color: #9A520C; }
.badge-normale { background: #FBF3DF; color: #7D5D12; }
.badge-basse { background: #E6F1E9; color: var(--success); }
.badge-confirme { background: #E6F1E9; color: var(--success); }
.badge-en_attente { background: #FCEBD8; color: #9A520C; }
.badge-decline { background: #FBE6E3; color: #952222; }
.badge-retard { background: var(--danger); color: #fff; animation: pulse 1.6s infinite; }
.badge-type { background: rgba(122,31,43,.08); color: var(--primary); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }

/* Tableaux */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.data-table th {
    background: var(--ink-soft);
    color: #F1E6CF;
    padding: 11px 14px;
    text-align: left;
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #EEE4D2;
    font-size: .9rem;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(201,162,75,.08); }
.data-table tr:last-child td { border-bottom: none; }

.text-center { text-align: center; }

.toggle-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Filtres */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-form, .filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-form input, .filter-form select, .search-form select {
    padding: 7px 11px;
    border: 1px solid #D6C7AB;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: 400 .88rem/1.4 var(--font-body);
}

/* Compteurs */
.mini-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mini-stat {
    flex: 1 1 110px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 11px 14px;
    text-align: center;
    box-shadow: var(--shadow);
}

.ms-number {
    display: block;
    font: 600 1.6rem/1.2 var(--font-display);
    color: var(--primary);
}

.ms-label { font-size: .73rem; color: var(--text-light); }
.ms-green .ms-number { color: var(--success); }
.ms-orange .ms-number { color: var(--warning); }
.ms-red .ms-number { color: var(--danger); }

/* Tableau de bord */
.countdown-banner {
    position: relative;
    overflow: hidden;
    background: var(--lattice), linear-gradient(120deg, var(--ink) 0%, var(--primary-dark) 55%, var(--primary) 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 26px 30px 30px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-lg);
}

.countdown-banner::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    height: 8px;
    color: var(--bg);
    background: var(--crenel);
}

.countdown-content { display: flex; align-items: center; gap: 20px; }
.countdown-content > div { flex: 1; }
.countdown-icon { font-size: 2.2rem; }
.countdown-content h2 { color: #F4E0AC; font-size: 1.45rem; }
.countdown-content p { color: rgba(255,255,255,.88); margin-top: 3px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(201,162,75,.16);
}

.stat-blue .stat-icon { background: rgba(42,91,133,.12); }
.stat-green .stat-icon { background: rgba(47,107,71,.13); }
.stat-red .stat-icon { background: rgba(169,43,43,.11); }
.stat-orange .stat-icon { background: rgba(184,105,15,.13); }

.stat-info h3 { font-size: 1.6rem; color: var(--primary-dark); }
.stat-info p { font-size: .8rem; color: var(--text-light); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.dashboard-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    min-width: 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 { color: var(--primary-dark); font-size: 1.04rem; }

/* Annonces */
.annonce-item {
    padding: 11px 13px;
    border-radius: var(--radius);
    margin-bottom: 9px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--secondary);
    background: #fff;
}

.annonce-info { border-left-color: var(--info); }
.annonce-important { border-left-color: var(--warning); }
.annonce-urgent { border-left-color: var(--danger); }

.annonce-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: .74rem;
    color: var(--text-light);
    margin-bottom: 3px;
}

/* Tâches */
.todos-list { display: flex; flex-direction: column; gap: 13px; }

.todo-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
}

.todo-priorite-urgente { border-left-color: var(--danger); }
.todo-priorite-haute { border-left-color: var(--warning); }
.todo-priorite-normale { border-left-color: var(--secondary); }
.todo-priorite-basse { border-left-color: var(--success); }
.todo-done { opacity: .62; }
.todo-retard { background: #FDF3EF; }

.todo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.todo-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.todo-titre { font-size: 1.02rem; margin-bottom: 6px; }
.todo-desc { color: var(--text-light); font-size: .9rem; margin-bottom: 8px; }
.todo-meta-bar { display: flex; gap: 14px; font-size: .84rem; color: var(--text-light); flex-wrap: wrap; margin-bottom: 8px; }

.statut-select {
    padding: 4px 8px;
    border: 1px solid #D6C7AB;
    border-radius: var(--radius);
    font-size: .8rem;
    background: #fff;
    color: var(--text);
}

/* Commentaires */
.todo-comments { border-top: 1px solid var(--border); padding-top: 10px; margin-bottom: 10px; }
.comment { padding: 8px 10px; background: rgba(201,162,75,.1); border-radius: var(--radius); margin-bottom: 6px; }
.comment-author { font-weight: 600; font-size: .84rem; }
.comment-date { font-size: .74rem; color: var(--text-light); margin-left: 8px; }
.comment p { font-size: .9rem; margin-top: 3px; }

.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid #D6C7AB; border-radius: var(--radius); }

/* Programme */
.timeline { position: relative; padding: 14px 0; }

.timeline::before {
    content: '';
    position: absolute;
    left: 139px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--secondary), var(--primary-light));
}

.timeline-item { display: flex; gap: 20px; margin-bottom: 20px; position: relative; }
.timeline-time { width: 100px; text-align: right; flex-shrink: 0; padding-top: 6px; }
.time-start { display: block; font: 600 1.06rem/1.2 var(--font-display); color: var(--primary); }
.time-end { display: block; font-size: .78rem; color: var(--text-light); }

.timeline-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    z-index: 1;
    box-shadow: var(--shadow);
}

.timeline-active .timeline-dot { background: var(--secondary); animation: pulse 2s infinite; }
.timeline-done .timeline-dot { background: #E6F1E9; border-color: var(--success); }

.timeline-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 13px 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.timeline-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.timeline-header h3 { color: var(--primary-dark); font-size: 1.02rem; }
.timeline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline-meta { display: flex; gap: 14px; font-size: .84rem; color: var(--text-light); flex-wrap: wrap; margin-bottom: 4px; }
.timeline-notes { margin-top: 8px; padding: 8px 10px; background: rgba(201,162,75,.12); border-radius: var(--radius); font-size: .88rem; }
.statut-select-sm { padding: 3px 6px; border: 1px solid #D6C7AB; border-radius: var(--radius); font-size: .78rem; background: #fff; }

/* Fenêtres */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28,21,18,.62);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open { display: flex; }

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--secondary);
}

.modal-large { max-width: 820px; }

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 22px;
    background: var(--lattice), linear-gradient(120deg, var(--ink), var(--primary-dark));
    color: #fff;
}

.modal-header h3 { color: #F4E0AC; font-size: 1.1rem; }
.modal-close { background: none; border: none; color: #fff; font-size: 1.15rem; cursor: pointer; padding: 2px 6px; }

.modal-content form { padding: 22px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.checkbox-group { display: flex; gap: 8px 20px; flex-wrap: wrap; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--text); }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* États vides */
.empty-state { text-align: center; color: var(--text-light); padding: 18px; font-style: italic; }
.empty-state-large { text-align: center; padding: 56px 20px; color: var(--text-light); font-size: 1.05rem; }

/* Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    max-width: calc(100vw - 40px);
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 11px 17px;
    border-radius: var(--radius);
    color: #fff;
    font-size: .9rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn .25s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--ink-soft); }

@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } }

/* Petits écrans */
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    body { font-size: 14.5px; }
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }

    .sidebar.open + .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(28,21,18,.5);
        z-index: 90;
    }

    .main-content { margin-left: 0; }
    #menu-toggle { display: inline-flex; }
    .top-bar { padding: 8px 16px; }
    .top-bar-date { display: none; }
    .page-content { padding: 18px 16px 32px; }
    .page-header h1 { font-size: 1.45rem; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
    .countdown-banner { padding: 20px 18px 24px; }
    .countdown-icon { display: none; }
    .timeline::before { left: 99px; }
    .timeline-item { gap: 10px; }
    .timeline-time { width: 70px; }
    .modal { padding: 10px; }
    .modal-content form { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    body { background: #fff; font-size: 12px; }
    .sidebar, .sidebar-backdrop, .top-bar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0; max-width: none; }
}

/* ---- CHOSES À RAMENER ---- */
.aff-progress { min-width: 200px; }
.aff-progress-text { font-size: .88rem; color: var(--text-light); margin-bottom: 5px; text-align: right; }
.aff-progress-text strong { color: var(--success); font-size: 1.05rem; }
.aff-progress-bar { height: 8px; border-radius: 8px; background: #EAE0CC; overflow: hidden; }
.aff-progress-bar span { display: block; height: 100%; width: 0; background: var(--success); border-radius: 8px; transition: width .35s ease; }

.aff-add {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 12px; margin-bottom: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.aff-add input, .aff-add select, .aff-edit input, .aff-edit select {
    padding: 9px 12px; border: 1px solid #D6C7AB; border-radius: var(--radius);
    background: #fff; color: var(--text); font: 400 .94rem/1.4 var(--font-body); min-width: 0;
}
.aff-add input:focus, .aff-add select:focus, .aff-edit input:focus, .aff-edit select:focus {
    outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(201,162,75,.25);
}
.aff-add #aff-add-nom { flex: 1 1 260px; font-size: 1rem; }
.aff-add-qte { width: 80px; }
.aff-add .btn { padding-left: 20px; padding-right: 20px; }

.aff-idees { margin-bottom: 16px; }
.aff-idees-toggle {
    background: none; border: none; padding: 4px 2px; cursor: pointer;
    color: var(--accent); font: 500 .86rem var(--font-body);
}
.aff-idees-toggle:hover { text-decoration: underline; }
.aff-idees-liste[hidden] { display: none; }
.aff-idees-liste { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.aff-idee {
    border: 1px dashed var(--secondary); background: rgba(201,162,75,.08); color: var(--primary-dark);
    border-radius: 20px; padding: 4px 11px; font: 500 .8rem var(--font-body); cursor: pointer;
}
.aff-idee:hover { background: rgba(201,162,75,.22); border-style: solid; }
.aff-idee:disabled { opacity: .4; }

.aff-filtres { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.aff-filtre {
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-light);
    border-radius: 20px; padding: 6px 14px; font: 500 .85rem var(--font-body); cursor: pointer;
}
.aff-filtre:hover { border-color: var(--secondary); color: var(--text); }
.aff-filtre.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.aff-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.aff-groupe {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
.aff-groupe-titre {
    display: flex; align-items: center; gap: 8px; margin: 0;
    padding: 11px 16px; border-bottom: 1px solid var(--border);
    font: 600 .98rem var(--font-display); color: var(--primary-dark); background: rgba(201,162,75,.08);
}
.aff-groupe-compte { margin-left: auto; font: 500 .8rem var(--font-body); color: var(--text-light); }
.aff-items { list-style: none; margin: 0; padding: 0; }
.aff-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px 8px 16px; border-bottom: 1px solid #EFE6D6;
    transition: background .15s;
}
.aff-item:last-child { border-bottom: none; }
.aff-item:hover { background: rgba(201,162,75,.06); }
.aff-nouveau { animation: affFlash 1.2s ease; }
@keyframes affFlash { from { background: rgba(201,162,75,.35); } }

.aff-coche { width: 22px; height: 22px; flex: none; accent-color: var(--success); cursor: pointer; }
.aff-coche:disabled { cursor: default; }
.aff-corps { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.aff-nom {
    background: none; border: none; padding: 2px 0; text-align: left; cursor: text;
    font: 500 .95rem/1.35 var(--font-body); color: var(--text); overflow-wrap: anywhere;
}
button.aff-nom:hover { color: var(--primary); text-decoration: underline dotted; }
.aff-qte { font-size: .78rem; font-weight: 600; color: var(--accent); background: rgba(201,162,75,.15); padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.aff-pret .aff-nom { color: var(--text-light); text-decoration: line-through; text-decoration-color: rgba(47,107,71,.6); }
.aff-pret .aff-qte { opacity: .6; }

.aff-qui {
    flex: none; max-width: 140px; padding: 4px 6px; border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--text); font: 400 .84rem var(--font-body); cursor: pointer;
}
.aff-qui:hover:not(:disabled), .aff-qui:focus { border-color: var(--border); background: #fff; outline: none; }
.aff-qui.aff-qui-vide { color: var(--warning); font-style: italic; }
.aff-qui:disabled { cursor: default; opacity: 1; appearance: none; }

.aff-sup {
    flex: none; width: 28px; height: 28px; border: none; border-radius: 50%; background: none;
    color: var(--text-light); cursor: pointer; font-size: .85rem; opacity: .45;
}
.aff-item:hover .aff-sup, .aff-sup:focus { opacity: 1; }
.aff-sup:hover { background: #FBE6E3; color: var(--danger); }

.aff-edit { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.aff-edit input:first-child { flex: 1 1 160px; }
.aff-edit .aff-add-qte { width: 70px; }
.aff-edit input, .aff-edit select { padding: 5px 8px; font-size: .88rem; }

.aff-vide { grid-column: 1 / -1; text-align: center; padding: 48px 20px; color: var(--text-light); font-size: 1.02rem; }
.aff-annuler-btn {
    background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: var(--radius);
    padding: 3px 10px; font: 600 .82rem var(--font-body); cursor: pointer;
}
.aff-annuler-btn:hover { background: rgba(255,255,255,.15); }

@media (max-width: 768px) {
    .aff-progress { width: 100%; }
    .aff-progress-text { text-align: left; }
    .aff-liste { grid-template-columns: 1fr; }
    .aff-add select { flex: 1 1 40%; }
    .aff-add .btn { flex: 1 1 100%; justify-content: center; }
    .aff-item { flex-wrap: wrap; padding: 10px 12px; }
    .aff-corps { flex: 1 1 calc(100% - 80px); }
    .aff-qui { margin-left: 32px; max-width: none; }
    .aff-sup { opacity: .7; margin-left: auto; }
}

@media print {
    .aff-add, .aff-idees, .aff-filtres, .aff-sup { display: none !important; }
    .aff-liste { display: block; }
    .aff-groupe { box-shadow: none; margin-bottom: 12px; break-inside: avoid; }
    .aff-qui { appearance: none; border: none; }
}
