/* ========================================================
   BOOST CRM — DESIGN SYSTEM
   Version 1.0

   Ce fichier remplace et étend global.css.
   Il centralise tous les tokens visuels, composants et layouts.
   ======================================================== */

/* ----------------------------------------
   1. DESIGN TOKENS (Variables CSS)
   ---------------------------------------- */
:root {
    /* === COULEURS BRAND === */
    --color-brand-50:  #f8f6f0;
    --color-brand-100: #efe9d8;
    --color-brand-200: #e2d8b8;
    --color-brand-300: #d5c898;
    --color-brand-400: #c1b581;  /* Couleur principale */
    --color-brand-500: #ada16d;
    --color-brand-600: #8f8455;
    --color-brand-700: #716840;
    --color-brand-800: #534c2e;
    --color-brand-900: #35311d;

    /* Alias principaux (rétro-compatible avec l'ancien --primary-color) */
    --primary-color: var(--color-brand-400);
    --primary-hover: var(--color-brand-500);
    --primary-light: var(--color-brand-100);

    /* === COULEURS SÉMANTIQUES === */
    --color-success-50:  #ecfdf5;
    --color-success-100: #d1fae5;
    --color-success-500: #22c55e;
    --color-success-600: #16a34a;
    --color-success-700: #15803d;

    --color-error-50:  #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-500: #ef4444;
    --color-error-600: #dc2626;
    --color-error-700: #b91c1c;

    --color-warning-50:  #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;

    --color-info-50:  #eff6ff;
    --color-info-100: #dbeafe;
    --color-info-500: #3b82f6;
    --color-info-600: #2563eb;

    /* Rétro-compatibilité */
    --success-color: var(--color-success-500);
    --success-hover: var(--color-success-700);
    --error-color: var(--color-error-500);
    --error-hover: var(--color-error-700);
    --warning-color: var(--color-warning-500);
    --info-color: var(--color-info-500);
    --secondary-color: var(--color-info-500);
    --secondary-hover: var(--color-info-600);

    /* === NEUTRES === */
    --color-gray-50:  #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;

    /* Alias backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: var(--color-gray-50);
    --bg-tertiary: var(--color-gray-100);
    --bg-input: #ffffff;
    --bg-sidebar: var(--color-gray-900);

    /* Alias texte */
    --text-primary: var(--color-gray-800);
    --text-secondary: var(--color-gray-500);
    --text-muted: var(--color-gray-400);
    --text-light: var(--color-gray-400);
    --text-inverse: #ffffff;

    /* === BORDURES === */
    --border-color: var(--color-gray-200);
    --border-light: var(--color-gray-100);
    --border-radius-sm: 4px;
    --border-radius: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --border-radius-full: 9999px;

    /* Rétro-compatibilité */
    --border-radius-large: var(--border-radius-md);

    /* === ESPACEMENT (4px base) === */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 1rem;      /* 16px */
    --spacing-lg: 1.5rem;    /* 24px */
    --spacing-xl: 2rem;      /* 32px */
    --spacing-2xl: 3rem;     /* 48px */

    /* === OMBRES === */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Rétro-compatibilité */
    --shadow-light: var(--shadow-sm);
    --shadow-medium: var(--shadow-md);
    --shadow-heavy: var(--shadow-lg);

    /* === TRANSITIONS === */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* === TYPOGRAPHIE === */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.875rem;    /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.25rem;     /* 20px */
    --text-2xl: 1.5rem;     /* 24px */
    --text-3xl: 1.875rem;   /* 30px */

    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* === LAYOUT === */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --header-height: 56px;
    --content-max-width: 1400px;

    /* === Z-INDEX === */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 300;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* ----------------------------------------
   2. RESET & BASE
   ---------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
}

a {
    color: var(--color-brand-500);
    text-decoration: none;
}
a:hover {
    color: var(--color-brand-600);
    text-decoration: underline;
}

img { max-width: 100%; height: auto; }

/* ----------------------------------------
   3. LAYOUT — SIDEBAR + HEADER + CONTENT
   ---------------------------------------- */

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

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sticky);
    transition: width var(--transition-normal);
    overflow-x: hidden;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--text-inverse);
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.sidebar-brand:hover {
    color: var(--text-inverse);
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md) 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-md);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-gray-300);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-inverse);
    text-decoration: none;
}
.sidebar-link.active {
    background: rgba(255,255,255,0.12);
    color: var(--text-inverse);
    border-left-color: var(--color-brand-400);
}

.sidebar-link-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: var(--text-base);
}

/* --- Main content area --- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

/* --- Top header bar --- */
.topbar {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.topbar-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
}
.sidebar-toggle:hover {
    background: var(--bg-tertiary);
}

/* --- Page content --- */
.page-content {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* ----------------------------------------
   3b. LEGACY LAYOUT (rétro-compatibilité)
   Header/footer pour les pages non migrées
   ---------------------------------------- */
header {
    background-color: var(--color-brand-400);
    color: var(--text-inverse);
    padding: var(--spacing-sm) var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.header-brand:hover { text-decoration: none; }

.header-logo {
    height: 255px;
    width: auto;
    margin: -85px -35px -85px -15px;
}

/* User courant + badges (à droite du logo, avant le bouton Retour) */
.header-user-badges {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    margin-right: 12px;
    font-size: var(--text-sm);
    color: var(--text-inverse, #fff);
}
.header-user-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.header-user-avatar {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.5);
}
.header-user-avatar--neutral {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.5);
}
.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.15);
    color: inherit;
    padding: 4px 10px;
    border-radius: 12px;
    text-decoration: none;
    font-size: var(--text-xs);
    font-weight: 600;
}
.header-badge:hover { background: rgba(255,255,255,0.3); }
.header-badge--active {
    background: rgba(255,255,255,0.55);
    color: var(--text-primary, #1a1a1a);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.4) inset;
}
.header-badge--active:hover { background: rgba(255,255,255,0.7); }
.header-badge--active .header-badge-count {
    background: var(--text-primary, #1a1a1a);
    color: var(--text-inverse, #fff);
}
.header-badge-count {
    background: var(--color-danger-500, #d32f2f);
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

/* Assignee badge (pattern statut/priorité) */
.assignee-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.4;
}
.assignee-clickable { cursor: pointer; user-select: none; }
.assignee-clickable:hover { opacity: 0.85; }

/* Note équipe (gmail_user_notes) — distinguée par bordure brand olive */
.conv-team-note {
    border-left: 4px solid var(--color-brand-500, #ada16d) !important;
    background: var(--color-brand-50, #f9f6ed) !important;
}
.conv-team-note .conv-header span:first-child { color: var(--color-brand-700, #5a5230); }

/* Notes équipe (gmail_user_notes) dans la vue ticket — legacy section (supprimée) */
.user-notes-section {
    background: var(--bg-secondary, #fafafa);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
}
.user-note-item {
    background: white;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-left: 3px solid var(--border-light, #ccc);
}
.user-note-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.user-note-avatar {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.user-note-date { margin-left: auto; }
.user-note-body { font-size: var(--text-sm); margin-top: 4px; }

.app-title, .app-title-link {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-inverse);
    text-decoration: none;
}
.app-title-link:hover { color: var(--text-inverse); text-decoration: none; }

.back-button, .home-link {
    background-color: rgba(255,255,255,0.9);
    color: var(--color-brand-600);
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-block;
}
.back-button:hover, .home-link:hover {
    background-color: #ffffff;
}

footer {
    background-color: var(--bg-tertiary);
    padding: var(--spacing-md);
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.page-title {
    padding: var(--spacing-lg) var(--spacing-xl);
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
}

main {
    flex: 1;
    padding: var(--spacing-xl);
    background: var(--bg-secondary);
}

/* ----------------------------------------
   4. BOUTONS
   ---------------------------------------- */
.btn, button:not(.unstyled):not(.sidebar-toggle) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: var(--leading-tight);
    white-space: nowrap;
}

/* Primary */
.btn-primary, .submit-btn, .add-btn, .send-button {
    background-color: var(--color-brand-400);
    color: var(--text-inverse);
    border-color: var(--color-brand-400);
}
.btn-primary:hover, .submit-btn:hover, .add-btn:hover, .send-button:hover {
    background-color: var(--color-brand-500);
    border-color: var(--color-brand-500);
}

/* Secondary / Outline */
.btn-secondary, .button-secondary {
    background-color: transparent;
    color: var(--color-brand-500);
    border-color: var(--color-brand-300);
}
.btn-secondary:hover, .button-secondary:hover {
    background-color: var(--color-brand-50);
    border-color: var(--color-brand-400);
}

/* Success */
.btn-success, .button-success, .btn-save {
    background-color: var(--color-success-500);
    color: var(--text-inverse);
    border-color: var(--color-success-500);
}
.btn-success:hover, .button-success:hover, .btn-save:hover {
    background-color: var(--color-success-600);
    border-color: var(--color-success-600);
}

/* Edit */
.btn-edit {
    background-color: var(--color-brand-400);
    color: var(--text-inverse);
    border-color: var(--color-brand-400);
    padding: 0.375rem 0.75rem;
    font-size: var(--text-xs);
}
.btn-edit:hover {
    background-color: var(--color-brand-500);
    border-color: var(--color-brand-500);
}

/* Danger / Delete */
.btn-delete, .delete-btn, .btn-danger {
    background-color: var(--color-error-500);
    color: var(--text-inverse);
    border-color: var(--color-error-500);
}
.btn-delete:hover, .delete-btn:hover, .btn-danger:hover {
    background-color: var(--color-error-600);
    border-color: var(--color-error-600);
}

/* Cancel / Ghost */
.btn-cancel, .btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-cancel:hover, .btn-ghost:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Disabled */
button:disabled, .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Button sizes */
.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: var(--text-base); }

/* Icon-only button */
.btn-icon {
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}
.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ----------------------------------------
   5. FORMULAIRES
   ---------------------------------------- */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label, .form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.form-control, input:not([type="checkbox"]):not([type="radio"]):not(.unstyled),
select, textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: var(--leading-normal);
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-brand-400);
    box-shadow: 0 0 0 3px var(--color-brand-100);
}

.form-control::placeholder, input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

textarea { resize: vertical; min-height: 100px; }
select { cursor: pointer; }

.form-row {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.form-col {
    flex: 1;
    min-width: 250px;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--color-error-500);
    margin-top: var(--spacing-xs);
}

/* ----------------------------------------
   6. CARTES
   ---------------------------------------- */
.card, .client-card, .deal-card, .tool-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.card:hover, .client-card:hover, .deal-card:hover, .tool-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--spacing-md);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-content {
    padding: var(--spacing-md);
}

.card-actions {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ----------------------------------------
   7. TABLEAUX
   ---------------------------------------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.table, .orders-table, .tasks-table, .installation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th, .orders-table th, .tasks-table th, .installation-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: var(--font-semibold);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.table th:hover, .orders-table th:hover, .tasks-table th:hover {
    background-color: var(--bg-tertiary);
}

.table td, .orders-table td, .tasks-table td, .installation-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:hover, .orders-table tbody tr:hover,
.tasks-table tbody tr:hover, .installation-table tbody tr:hover {
    background-color: var(--color-brand-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ----------------------------------------
   8. BADGES & STATUTS
   ---------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--border-radius-full);
    white-space: nowrap;
    line-height: 1.4;
}

.badge-primary   { background: var(--color-brand-100); color: var(--color-brand-700); }
.badge-success   { background: var(--color-success-100); color: var(--color-success-700); }
.badge-error,
.badge-danger    { background: var(--color-error-100); color: var(--color-error-700); }
.badge-warning   { background: var(--color-warning-100); color: var(--color-warning-600); }
.badge-info      { background: var(--color-info-100); color: var(--color-info-600); }
.badge-neutral   { background: var(--color-gray-100); color: var(--color-gray-600); }

/* Rétro-compatibilité : status badges existants */
.order-status-new, .task-status-new     { background: var(--color-info-100); color: var(--color-info-600); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.order-status-progress, .task-status-progress { background: var(--color-warning-100); color: var(--color-warning-600); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.order-status-done, .task-status-done   { background: var(--color-success-100); color: var(--color-success-700); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.task-status-wait   { background: var(--color-error-100); color: var(--color-error-700); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.status-planifier   { background: var(--color-info-100); color: var(--color-info-600); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.status-planifie    { background: var(--color-warning-100); color: var(--color-warning-600); padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.status-technique   { background: #f3e8ff; color: #7c3aed; padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }

/* SAV badge */
.sav-status {
    background: var(--color-error-500);
    color: var(--text-inverse);
    padding: 0.2rem 0.6rem;
    border-radius: var(--border-radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
}

/* Payment indicator dot */
.payment-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.payment-status.paid    { background: var(--color-success-500); }
.payment-status.unpaid  { background: var(--color-error-500); }

/* Deal status */
.deal-status          { padding: 0.2rem 0.6rem; border-radius: var(--border-radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.status-won           { background: var(--color-success-100); color: var(--color-success-700); }
.status-lost          { background: var(--color-error-100); color: var(--color-error-700); }
.status-open          { background: var(--color-info-100); color: var(--color-info-600); }

/* ----------------------------------------
   9. MODALES
   ---------------------------------------- */
.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-primary);
    margin: 3% auto;
    padding: 0;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--border-light);
}

.modal-body {
    padding: var(--spacing-xl);
}

/* Formulaire directement dans modal-content (sans modal-body wrapper) */
.modal-content > form {
    padding: var(--spacing-xl) var(--spacing-2xl) var(--spacing-2xl);
}

.modal-content > form .form-group {
    margin-bottom: var(--spacing-md);
}

.modal-content > form .submit-btn,
.modal-content > form button[type="submit"],
.modal-content > form button[type="button"].submit-btn {
    margin-top: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg) var(--spacing-xl);
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.close, .modal-close {
    color: var(--text-muted);
    font-size: 24px;
    font-weight: var(--font-bold);
    cursor: pointer;
    background: none;
    border: none;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    line-height: 1;
    transition: all var(--transition-fast);
}
.close:hover, .modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* ----------------------------------------
   10. TOOLBAR
   ---------------------------------------- */
.toolbar {
    background-color: var(--bg-primary);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-lg);
}

.toolbar .search-container {
    flex: 1;
    max-width: 400px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ----------------------------------------
   11. NOTIFICATIONS / ALERTS
   ---------------------------------------- */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    font-size: var(--text-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.alert-success, .success, .success-message {
    background-color: var(--color-success-50);
    color: var(--color-success-700);
    border: 1px solid var(--color-success-100);
}

.alert-error, .error, .error-message {
    background-color: var(--color-error-50);
    color: var(--color-error-700);
    border: 1px solid var(--color-error-100);
}

.alert-warning {
    background-color: var(--color-warning-50);
    color: var(--color-warning-600);
    border: 1px solid var(--color-warning-100);
}

.alert-info, .info {
    background-color: var(--color-info-50);
    color: var(--color-info-600);
    border: 1px solid var(--color-info-100);
}

/* Toast (notification fixe) */
.notification, .success-message {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: var(--z-toast);
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ----------------------------------------
   12. RECHERCHE & DROPDOWNS
   ---------------------------------------- */
.search-container {
    position: relative;
}

.search-input, .chat-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    padding-left: 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 0.75rem center;
}
.search-input:not(:placeholder-shown) {
    background-image: none;
    padding-left: 0.75rem;
}
select.search-input {
    background-image: none;
    padding-left: 0.75rem;
}
.search-input:focus, .chat-input:focus {
    outline: none;
    border-color: var(--color-brand-400);
    box-shadow: 0 0 0 3px var(--color-brand-100);
}

.search-results, .contact-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    z-index: var(--z-dropdown);
    display: none;
    box-shadow: var(--shadow-lg);
}

.search-result-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--text-sm);
    transition: background-color var(--transition-fast);
}
.search-result-item:hover {
    background-color: var(--color-brand-50);
}
.search-result-item:last-child {
    border-bottom: none;
}

/* ----------------------------------------
   13. TABS
   ---------------------------------------- */
.tab-navigation {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--spacing-lg);
}

.tab-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.tab-button:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}
.tab-button.active {
    color: var(--color-brand-500);
    border-bottom-color: var(--color-brand-400);
    font-weight: var(--font-semibold);
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* ----------------------------------------
   14. PAGINATION
   ---------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-lg);
}

.pagination button, .pagination a {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pagination button:hover, .pagination a:hover {
    background: var(--bg-tertiary);
    border-color: var(--color-brand-300);
}
.pagination button.active, .pagination a.active {
    background: var(--color-brand-400);
    color: var(--text-inverse);
    border-color: var(--color-brand-400);
}

/* ----------------------------------------
   15. GRILLES & LAYOUTS
   ---------------------------------------- */
.grid-container, .cards-container, .tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.menu-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    width: 100%;
    max-width: 1000px;
}

/* ----------------------------------------
   16. LOADING & ÉTATS VIDES
   ---------------------------------------- */
.loading {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--color-gray-200);
    border-top: 3px solid var(--color-brand-400);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-xl);
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    border-radius: var(--border-radius-md);
    border: 2px dashed var(--border-color);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state-text {
    font-size: var(--text-lg);
    font-weight: var(--font-medium);
    margin-bottom: var(--spacing-xs);
}

.empty-state-hint {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ----------------------------------------
   17. UTILITAIRES
   ---------------------------------------- */

/* Display */
.hidden     { display: none !important; }
.sr-only    { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* Text alignment */
.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* Font weight */
.font-normal    { font-weight: var(--font-normal); }
.font-medium    { font-weight: var(--font-medium); }
.font-semibold  { font-weight: var(--font-semibold); }
.font-bold      { font-weight: var(--font-bold); }

/* Text size */
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.text-lg  { font-size: var(--text-lg); }

/* Text color */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--color-success-600); }
.text-error     { color: var(--color-error-600); }

/* Spacing - margin */
.m-0  { margin: 0; }
.mt-0 { margin-top: 0; }           .mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); } .mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); } .mt-5 { margin-top: var(--spacing-xl); }
.mb-0 { margin-bottom: 0; }           .mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); } .mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); } .mb-5 { margin-bottom: var(--spacing-xl); }

/* Spacing - padding */
.p-0  { padding: 0; }
.p-1  { padding: var(--spacing-xs); }  .p-2 { padding: var(--spacing-sm); }
.p-3  { padding: var(--spacing-md); }  .p-4 { padding: var(--spacing-lg); }
.p-5  { padding: var(--spacing-xl); }

/* Flex utilities */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }
.gap-4 { gap: var(--spacing-lg); }

/* Truncate */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--spacing-lg) 0;
}

/* ----------------------------------------
   18. RESPONSIVE
   ---------------------------------------- */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --spacing-xl: 1.5rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-container {
        max-width: 100%;
    }

    .form-row {
        flex-direction: column;
    }
    .form-col {
        min-width: auto;
    }

    .grid-container, .cards-container, .tools-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 2% auto;
    }

    main, .page-content {
        padding: var(--spacing-md);
    }

    .page-title {
        padding: var(--spacing-md);
        font-size: var(--text-xl);
    }

    .topbar {
        padding: 0 var(--spacing-md);
    }

    .tab-navigation {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .tab-button {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .menu-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* ----------------------------------------
   19. PRINT
   ---------------------------------------- */
@media print {
    .sidebar, .topbar, .toolbar, footer, header,
    .btn, button, .pagination, .modal { display: none !important; }
    .main-wrapper { margin-left: 0; }
    body { background: white; }
}

/* ============================================================
   TR-CRM — compléments au design system hérité.
   Ajoutés à la fin pour que la mise à jour du socle reste triviale.
   ============================================================ */

.header-brand { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none; }
.header-wordmark {
    font-weight: 700; font-size: 1.35rem; letter-spacing: -0.02em;
    color: var(--color-brand-600);
}
.header-wordmark-sub { font-size: .8rem; color: var(--text-secondary); letter-spacing: .04em; }
.header-user-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; display: inline-block; }

/* --- Tuiles de l'accueil --- */
.tile-grid {
    display: grid; gap: var(--spacing-md);
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.tile {
    display: flex; flex-direction: column; gap: 6px;
    padding: var(--spacing-lg); background: #fff; text-decoration: none;
    border: 1px solid var(--border-light); border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-xs); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-brand-300); }
.tile-icon { font-size: 1.6rem; color: var(--color-brand-500); }
.tile-title { font-weight: 600; color: var(--text-primary); }
.tile-sub { font-size: .82rem; color: var(--text-secondary); }
.tile-count {
    align-self: flex-start; margin-top: 4px; padding: 1px 8px; border-radius: 999px;
    background: var(--color-brand-100); color: var(--color-brand-700);
    font-size: .75rem; font-weight: 600;
}

/* --- Indicateurs --- */
.kpi-grid {
    display: grid; gap: var(--spacing-sm);
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    margin-bottom: var(--spacing-lg);
}
.kpi {
    padding: var(--spacing-md); background: #fff; border: 1px solid var(--border-light);
    border-radius: var(--border-radius); text-decoration: none; display: block;
}
.kpi:hover { border-color: var(--color-brand-300); }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: var(--text-primary); }
.kpi-label { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.kpi--alert .kpi-value { color: var(--color-error-600); }
.kpi--hero { grid-column: span 2; background: var(--color-brand-50); border-color: var(--color-brand-200); }
.kpi--hero .kpi-value { font-size: 2.4rem; color: var(--color-brand-700); }

/* --- Pastilles de statut d'acquisition --- */
.st {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: .74rem; font-weight: 600; white-space: nowrap;
    color: #fff;
}
.st--ghost { background: transparent; border: 1px dashed var(--border-medium); color: var(--text-muted); }

/* --- Matrice de couverture --- */
.matrix-table td.cell { text-align: center; padding: 4px; }
/* Porte `unstyled` dans le HTML : la règle générique des boutons est PLUS
   SPÉCIFIQUE que cette classe (`button:not(.unstyled):not(.sidebar-toggle)`),
   et imposait sinon sa taille de police et son remplissage — la cellule faisait
   36 px de haut au lieu de 24, sans que rien ici ne le laisse deviner. */
.matrix-cell {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 3px 8px; margin: 0; border: none; border-radius: var(--border-radius-sm);
    font-family: inherit; font-size: .74rem; font-weight: 600; line-height: 1.35;
    color: #fff; cursor: pointer; white-space: nowrap; text-align: left;
}
/* Le statut EN TOUTES LETTRES à côté de la version : la couleur repère, le mot
   renseigne. Une couleur seule obligerait à retenir une légende.
   Sur la même ligne et à la même taille — l'empiler rendait le texte illisible
   et allongeait chaque ligne du tableau sans rien apporter. */
.matrix-cell .cell-statut { font-weight: 400; opacity: .95; }
.matrix-cell:hover { outline: 2px solid var(--color-brand-400); outline-offset: 1px; }
.coverage-bar { height: 6px; border-radius: 3px; background: var(--color-gray-200, #e5e7eb); overflow: hidden; min-width: 70px; }
.coverage-bar > span { display: block; height: 100%; background: var(--color-success-500); }

/* --- Tableaux de type kanban --- */
.board { display: grid; gap: var(--spacing-md); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.board-col { background: var(--bg-tertiary); border-radius: var(--border-radius); padding: var(--spacing-sm); }
.board-col h3 {
    margin: 0 0 var(--spacing-sm); font-size: .82rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-secondary);
}
.board-card {
    background: #fff; border: 1px solid var(--border-light); border-radius: var(--border-radius-sm);
    padding: 10px 12px; margin-bottom: 8px; display: block; text-decoration: none; color: inherit;
}
.board-card:hover { border-color: var(--color-brand-300); }
.board-card-title { font-weight: 600; font-size: .88rem; }
.board-card-meta { font-size: .76rem; color: var(--text-secondary); margin-top: 3px; }
.board-empty { font-size: .8rem; color: var(--text-muted); padding: 8px 4px; }

/* --- Toast --- */
#toast-zone { position: fixed; right: 16px; bottom: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 10px 16px; border-radius: var(--border-radius); color: #fff;
    box-shadow: var(--shadow-md); font-size: .88rem; max-width: 380px;
    animation: toast-in .18s ease-out;
}
.toast--ok { background: var(--color-success-600); }
.toast--err { background: var(--color-error-600); }
.toast--info { background: var(--color-brand-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- Divers --- */
.page-actions { display: flex; gap: var(--spacing-sm); align-items: center; flex-wrap: wrap; margin-bottom: var(--spacing-md); }
.page-actions .grow { flex: 1 1 auto; }
.section-title { font-size: 1rem; font-weight: 600; margin: var(--spacing-lg) 0 var(--spacing-sm); }
.muted-row td { color: var(--text-muted); font-style: italic; }
.two-col { display: grid; gap: var(--spacing-lg); grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .kpi--hero { grid-column: span 2; } }

/* Anomalie : un catalogue devrait toujours porter au moins une version.
   Signalé plutôt que masqué — un catalogue vide sort de tous les décomptes
   de couverture sans que rien ne l'indique. */
.matrix-cell--anomalie {
    background: transparent;
    border: 1px dashed var(--color-error-500);
    color: var(--color-error-600);
}
