/* ============================================
   Variables CSS – InSpec Design System
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary:        #16a34a;
    --primary-dark:   #15803d;
    --primary-light:  #dcfce7;
    --primary-rgb:    22, 163, 74;

    --success:        #059669;
    --success-light:  #d1fae5;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --danger:         #dc2626;
    --danger-light:   #fee2e2;
    --info:           #0284c7;
    --info-light:     #e0f2fe;

    --bg:             #f1f5f9;
    --bg-card:        #ffffff;
    --text:           #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;
    --border:         #e2e8f0;
    --border-dark:    #cbd5e1;

    --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
    --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --shadow:    0 4px 6px -1px rgba(15,23,42,.07), 0 2px 4px -2px rgba(15,23,42,.04);
    --shadow-md: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.03);
    --shadow-lg: 0 20px 25px -5px rgba(15,23,42,.1), 0 8px 10px -6px rgba(15,23,42,.04);

    --sidebar-bg:        #052e16;
    --sidebar-surface:   #14532d;
    --sidebar-hover:     rgba(255,255,255,.06);
    --sidebar-active-bg: rgba(22,163,74,.18);
    --sidebar-text:      #94a3b8;
    --sidebar-text-active: #f8fafc;
    --sidebar-border:    rgba(255,255,255,.07);
    --sidebar-width:     260px;
    --header-height:     60px;

    --radius-sm:  6px;
    --radius:     10px;
    --radius-lg:  14px;
    --radius-xl:  20px;
    --radius-full: 9999px;

    --font: 'Outfit', 'Segoe UI', -apple-system, sans-serif;
    --transition: all .18s ease;
    --transition-med: all .28s ease;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

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

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 40;
    backdrop-filter: blur(2px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.sidebar-overlay.active { display: block; }

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(80,70,229,.25);
}

.sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: .3px;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-surface) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-surface); border-radius: 4px; }

.nav-section { padding: 8px 0; }

.nav-section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 6px 20px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 20px;
    color: var(--sidebar-text);
    font-size: .88rem;
    font-weight: 400;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    transition: transform .18s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 99px;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .18);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: .75;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
    opacity: 1;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: var(--radius);
    margin-bottom: 4px;
    background: var(--sidebar-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-details { min-width: 0; }

.user-name {
    font-size: .83rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .72rem;
    color: #64748b;
    font-weight: 400;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.top-bar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-xs);
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.hamburger:hover { background: var(--bg); color: var(--text); }

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-content {
    flex: 1;
    padding: 24px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
}

.card-body { padding: 20px; }

.mt-3 { margin-top: 20px; }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
.mb-1 { margin-bottom: 8px; }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: .85rem;
    font-weight: 500;
    font-family: var(--font);
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1;
    letter-spacing: .1px;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), .35);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-dark);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-dark);
}

.btn-secondary { background: var(--bg); color: var(--text-secondary); border-color: var(--border-dark); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card); color: var(--text); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #047857; border-color: #047857; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: #b45309; border-color: #b45309; }

.btn-sm { padding: 5px 11px; font-size: .8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 24px; font-size: .95rem; }

.btn-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success  { background: var(--success-light); color: #065f46; }
.badge-danger   { background: var(--danger-light);  color: #991b1b; }
.badge-warning  { background: var(--warning-light); color: #92400e; }
.badge-info     { background: var(--info-light);    color: #075985; }
.badge-secondary{ background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }

/* Status labels */
.badge-ADMIN       { background: #fef3c7; color: #92400e; }
.badge-SUPERVISEUR { background: #ede9fe; color: #4c1d95; }
.badge-COMMERCIAL  { background: #d1fae5; color: #065f46; }

/* ============================================
   Forms
   ============================================ */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    font-size: .88rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius);
    transition: var(--transition);
    outline: none;
    line-height: 1.5;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.form-control:hover:not(:focus) { border-color: #b0b7c3; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-text {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: .85rem;
    font-weight: 500;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.required { color: var(--danger); }

/* ============================================
   Filters Bar
   ============================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filters-bar .form-control {
    background: var(--bg-card);
    font-size: .83rem;
    padding: 7px 12px;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-wrapper svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.search-wrapper input {
    padding-left: 34px !important;
}

.filter-select {
    width: auto;
    min-width: 140px;
}

.filter-date {
    width: auto;
    min-width: 130px;
}

.filters-bar label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

thead { background: var(--bg); }

thead th {
    padding: 11px 14px;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .12s ease;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

tbody td {
    padding: 11px 14px;
    color: var(--text);
    vertical-align: middle;
}

.text-muted { color: var(--text-muted); }

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
    animation: fadeIn .18s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .22s cubic-bezier(.4,0,.2,1);
    border: 1px solid var(--border);
}

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

/* Body scrollable autonome (utilisé dans le modal détail) */
.modal-body-scroll {
    overflow-y: auto;
    max-height: calc(90vh - 130px);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: .95rem;
    font-weight: 600;
}

.modal-close {
    background: var(--bg);
    border: 1px solid var(--border);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    line-height: 1;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: #fca5a5; }

.modal-body {
    overflow-y: auto;
    padding: 22px;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    font-weight: 500;
    pointer-events: all;
    min-width: 280px;
    max-width: 400px;
    animation: toastIn .22s cubic-bezier(.4,0,.2,1);
    border: 1px solid transparent;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast.removing { animation: toastOut .3s ease forwards; }

@keyframes toastOut {
    to { opacity: 0; transform: translateX(30px); }
}

.toast-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.toast-error   { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.toast-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.toast-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: .5;
    color: inherit;
    transition: opacity .15s;
    line-height: 1;
    flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination button {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: .82rem;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:disabled { opacity: .35; cursor: not-allowed; }

.pagination-info {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: .85rem;
}

/* ============================================
   Loading
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--text-muted);
    gap: 10px;
    font-size: .88rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
}

.empty-icon {
    font-size: 2.2rem;
    opacity: .45;
    margin-bottom: 4px;
}

.empty-state h4 {
    font-size: .92rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: .82rem;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}

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

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #d1fae5; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.cyan   { background: #cffafe; }
.stat-icon.red    { background: #fee2e2; }
.stat-icon.purple { background: #ede9fe; }

.stat-info h4 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-info p {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 400;
}

/* ============================================
   Recap / Detail Sections
   ============================================ */
.recap-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.recap-section:last-child { border-bottom: none; margin-bottom: 0; }

.recap-section-reject {
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 20px;
}
.recap-section-reject h4 { color: #991b1b; }
.reject-motif { color: #7f1d1d; font-size: .88rem; line-height: 1.6; white-space: pre-wrap; }
.reject-meta  { font-size: .75rem; color: #b91c1c; margin-top: 6px; }

.recap-section h4 {
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.recap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.recap-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.recap-item .label {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.recap-item .value {
    font-size: .88rem;
    color: var(--text);
    font-weight: 500;
}

/* ============================================
   Bulk Bar
   ============================================ */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--primary-light);
    border: 1px solid rgba(var(--primary-rgb), .2);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--primary-dark);
    flex-wrap: wrap;
    /* Reste visible pendant le défilement d'une longue liste */
    position: sticky;
    top: 8px;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.bulk-scope {
    font-weight: 400;
    opacity: .75;
}

/* Action secondaire présentée comme un lien dans la barre d'actions */
.btn-link {
    background: none;
    border: none;
    padding: 0 4px;
    color: var(--primary-dark);
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
}

.btn-link:hover { opacity: .75; }

.bulk-spacer { flex: 1; }

/* Ligne cochée : repère visuel dans la liste */
tr.row-selected > td {
    background: var(--primary-light);
}

tr[data-pdv] { cursor: default; }
tr[data-pdv][onclick] { cursor: pointer; }

/* Récapitulatif de la sélection dans la fenêtre d'affectation */
.bulk-preview {
    margin: 8px 0 0;
    padding-left: 18px;
    max-height: 160px;
    overflow-y: auto;
    font-size: .85rem;
    font-weight: 400;
}

.bulk-preview li { margin-bottom: 2px; }
.bulk-preview .muted { opacity: .6; font-style: italic; }

/* ============================================
   Product Tags / Checkbox Grid
   ============================================ */
.products-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.product-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-full);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    background: var(--bg-card);
}

.product-tag input { display: none; }

.product-tag:hover { border-color: var(--primary); color: var(--primary); }

.product-tag.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* ============================================
   Inspection Form – Steps Progress Bar
   ============================================ */
.steps-progress {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: 16px 16px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-height);
    z-index: 20;
}
.steps-progress::-webkit-scrollbar { display: none; }

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 72px;
    max-width: 110px;
}

/* Connector line between steps */
.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: calc(50% + 16px);
    right: calc(-50% + 16px);
    height: 2px;
    background: var(--border-dark);
    z-index: 0;
    transition: background .3s;
}
.step-item.completed:not(:last-child)::after {
    background: var(--primary);
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-dark);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: border-color .3s, background .3s, color .3s;
}

.step-item.active   .step-circle {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.step-item.completed .step-circle {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.step-item.completed .step-circle::after {
    content: '✓';
    font-size: .75rem;
}
.step-item.completed .step-circle { font-size: 0; }

.step-label {
    font-size: .68rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: center;
    line-height: 1.3;
    transition: color .3s;
}
.step-item.active    .step-label { color: var(--primary); font-weight: 600; }
.step-item.completed .step-label { color: var(--primary-dark); }

/* ============================================
   Inspection Form – Step Content
   ============================================ */
.step-content {
    display: none;
}
.step-content.active {
    display: block;
    animation: stepIn .22s ease;
}

@keyframes stepIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.step-content h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-content h4 {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 20px 0 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ============================================
   Inspection Form – Eval Buttons (Oui/Non, Bon/Mauvais…)
   ============================================ */
.eval-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.eval-btn {
    padding: 8px 20px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-dark);
    background: var(--bg-card);
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    outline: none;
    white-space: nowrap;
}

.eval-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Positive = green when selected */
.eval-btn.bon.selected {
    background: #dcfce7;
    border-color: #16a34a;
    color: #15803d;
}

/* Negative = red when selected */
.eval-btn.mauvais.selected {
    background: #fee2e2;
    border-color: #dc2626;
    color: #991b1b;
}

/* Neutral = amber when selected */
.eval-btn.moyen.selected {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
}

/* ============================================
   Inspection Form – Star Rating
   ============================================ */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 6px;
}

.star-rating input[type="radio"] {
    display: none;
}

.star-rating label {
    font-size: 1.8rem;
    color: #d1d5db;
    cursor: pointer;
    transition: color .15s;
    line-height: 1;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: #f59e0b;
}

/* ============================================
   Inspection Form – Geo Status Banner
   ============================================ */
.geo-status {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .82rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.geo-status.pending {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.geo-status.valid {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.geo-status.invalid {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

/* ============================================
   Inspection Form – Step Actions (nav bar)
   ============================================ */
.step-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid var(--border);
}

/* ============================================
   Login Page
   ============================================ */
body.login-page {
    background:
        radial-gradient(ellipse at 50% -10%, #166534 0%, transparent 55%),
        linear-gradient(160deg, #052e16 0%, #064e2b 48%, #03220f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

/* Grille topographique subtile, estompée vers les bords */
body.login-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, transparent 75%);
            mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, transparent 75%);
    pointer-events: none;
}

/* Halo lumineux vivant */
body.login-page::after {
    content: '';
    position: fixed;
    width: 620px;
    height: 620px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34,197,94,.22) 0%, transparent 70%);
    top: -220px;
    right: -160px;
    filter: blur(8px);
    pointer-events: none;
    animation: loginGlow 9s ease-in-out infinite alternate;
}

@keyframes loginGlow {
    from { transform: translate(0, 0) scale(1);          opacity: .8; }
    to   { transform: translate(-50px, 60px) scale(1.12); opacity: 1; }
}

/* ---- Carte de connexion centrée ---- */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 44px 40px;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.55),
                0 0 0 1px rgba(255,255,255,.05);
    animation: loginRise .6s cubic-bezier(.22,1,.36,1) both;
}

@keyframes loginRise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-form-header {
    margin-bottom: 30px;
    text-align: center;
}

.login-form-header .logo-sm {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #22c55e, #15803d);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff;
    margin: 0 auto 22px;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), .28);
}

.login-form-header p {
    font-size: .9rem;
    color: var(--text-muted);
}

.login-form { width: 100%; }

.login-form .form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: .83rem;
}

.login-form .form-control { padding-top: 11px; padding-bottom: 11px; }

.input-with-icon {
    position: relative;
}

.input-with-icon svg {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 1.75;
    pointer-events: none;
    transition: stroke .18s ease;
}

.input-with-icon:focus-within svg { stroke: var(--primary); }

.input-with-icon .form-control { padding-left: 42px; }

.input-with-icon .toggle-password {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.input-with-icon .toggle-password:hover { color: var(--primary); background: var(--primary-light); }
.input-with-icon .toggle-password svg { position: static; transform: none; stroke: currentColor; }

.login-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .2px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 26px;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), .28);
}

.login-btn svg { transition: transform .2s ease; }

.login-btn:hover:not(:disabled) {
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), .42);
    transform: translateY(-2px);
}

.login-btn:hover:not(:disabled) svg { transform: translateX(3px); }
.login-btn:active:not(:disabled) { transform: translateY(0); }
.login-btn:disabled { opacity: .65; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
    body.login-page::after,
    .login-card { animation: none; }
}

/* ============================================
   Dashboard Progress Bar
   ============================================ */
.progress-bar {
    background: var(--border);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), #818cf8);
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ============================================
   Utilities
   ============================================ */
.d-flex          { display: flex; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.text-sm         { font-size: .82rem; }
.font-semibold   { font-weight: 600; }
.text-primary    { color: var(--primary); }
.text-success    { color: var(--success); }
.text-danger     { color: var(--danger); }
.w-full          { width: 100%; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .login-card { padding: 34px 24px; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .hamburger { display: flex; }
    .page-content { padding: 16px; }
    .filters-bar { padding: 10px 12px; }
    .steps-progress { padding: 12px 8px 10px; top: var(--header-height); }
    .eval-btn { padding: 8px 14px; font-size: .8rem; }
}

@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .step-label { display: none; }
    .step-item { min-width: 32px; }
    .step-item:not(:last-child)::after { left: calc(50% + 12px); right: calc(-50% + 12px); }
}

/* ============================================
   Import CSV
   ============================================ */
.import-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.import-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: none;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
    border-radius: var(--radius) var(--radius) 0 0;
}

.import-tab:hover  { color: var(--primary); }
.import-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.import-desc {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: .83rem;
    line-height: 1.6;
}

.import-desc code {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: .8rem;
    color: var(--primary-dark);
}

.import-upload-bar {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.import-dropzone {
    flex: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: .85rem;
    transition: border-color .2s, background .2s;
    text-align: center;
}

.import-dropzone:hover,
.import-dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.import-dropzone.has-file {
    border-color: var(--primary);
    background: var(--primary-light);
}

.import-file-name {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: .85rem;
}

.import-summary-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.import-total { font-size: .82rem; color: var(--text-muted); margin-left: auto; }

.badge-import {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-create { background: #dcfce7; color: #166534; }
.badge-update { background: #dbeafe; color: #1e40af; }
.badge-ok     { background: #dcfce7; color: #166534; }
.badge-err    { background: #fee2e2; color: #991b1b; }
.badge-warn   { background: #fef3c7; color: #92400e; }

/* Row coloring in preview table */
tr.row-create td:first-child { border-left: 3px solid var(--success); }
tr.row-update td:first-child { border-left: 3px solid #3b82f6; }
tr.row-error  td:first-child { border-left: 3px solid var(--danger); }
tr.row-error  { background: #fff5f5; }

/* ── Alertes : indicateur de gravité ────────────────────────── */
.alert-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.alert-summary:empty { display: none; }

.alert-sev-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 11px; border-radius: 99px;
    font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.alert-sev-pill::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}
.alert-sev-pill.sev-critique { background: #fee2e2; color: #b91c1c; }
.alert-sev-pill.sev-eleve    { background: #ffedd5; color: #c2410c; }
.alert-sev-pill.sev-modere   { background: #fef9c3; color: #a16207; }

.alert-sev-tag {
    display: inline-block; margin-left: 6px; padding: 2px 8px;
    border-radius: 99px; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em;
    background: #7f1d1d; color: #fff;
}

/* Bande de gravité en tête de ligne */
tr.alert-row.sev-critique td:first-child { border-left: 3px solid #b91c1c; }
tr.alert-row.sev-eleve    td:first-child { border-left: 3px solid #ea580c; }
tr.alert-row.sev-modere   td:first-child { border-left: 3px solid #ca8a04; }
tr.alert-row.sev-critique { background: #fef2f2; }

.import-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-top: 12px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .modal { border-radius: var(--radius-lg); }
}

/* ═══════════════════════════════════════════════════════════════
   CARTE INTERACTIVE
   ═══════════════════════════════════════════════════════════════ */

.map-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin: -24px;
    overflow: hidden;
}

/* ── Sidebar ── */
.map-sidebar {
    width: 290px;
    min-width: 290px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

.map-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.map-stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.map-stats-visible {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.map-stats-detail {
    font-size: .78rem;
    color: var(--text-muted);
}

.map-center-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: .76rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.map-center-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.map-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

/* ── Sections ── */
.map-section { margin-bottom: 4px; }

.map-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
}

.map-section-title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.map-section-actions { display: flex; gap: 4px; }

.map-section-actions button {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: .73rem;
    cursor: pointer;
}

.map-section-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   Dashboard – Charts & Stats
   ============================================ */

.charts-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-card-header h3 {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
}

.chart-subtitle {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.chart-wrap {
    position: relative;
    height: 220px;
}

.chart-wrap-sm { height: 180px; }
.chart-wrap-md { height: 260px; }

/* Trend badge on KPI cards */
.stat-trend {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

.stat-trend.up {
    color: var(--success);
    background: var(--success-light);
}

.stat-trend.down {
    color: var(--danger);
    background: var(--danger-light);
}

.stat-trend.neutral {
    color: var(--text-muted);
    background: var(--bg);
}

/* Progress bar */
.progress-bar-track {
    background: var(--border);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar-fill {
    background: var(--primary);
    height: 100%;
    border-radius: var(--radius-full);
    transition: width .5s ease;
}

/* Chart legend dots */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 12px;
    font-size: .78rem;
    color: var(--text-secondary);
}

.chart-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* ── Agence items ── */
.agence-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    cursor: pointer;
    transition: background .15s;
}

.agence-item:hover { background: var(--bg); }

.agence-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.agence-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agence-name {
    flex: 1;
    font-size: .82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agence-count {
    font-size: .75rem;
    color: var(--text-muted);
    background: var(--bg);
    border-radius: 99px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.agence-focus-btn {
    background: none;
    border: none;
    padding: 3px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s, color .15s;
}

.agence-item:hover .agence-focus-btn { opacity: 1; }
.agence-focus-btn:hover { color: var(--primary); }

.map-empty {
    padding: 12px 16px;
    font-size: .82rem;
    color: var(--text-muted);
}

/* ── Unlocated section ── */
.map-unlocated-badge {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 99px;
    padding: 0 7px;
    font-size: .7rem;
    font-weight: 700;
}

.map-unlocated-list {
    max-height: 180px;
    overflow-y: auto;
}

.unlocated-item {
    padding: 6px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.unlocated-item:last-child { border-bottom: none; }

.unlocated-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.unlocated-meta {
    font-size: .74rem;
    color: var(--text-muted);
}

/* ── Map container ── */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map { width: 100%; height: 100%; }

/* ── Loading overlay ── */
.map-overlay-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 1000;
    font-size: .875rem;
    color: var(--text-secondary);
}

/* ── Custom markers ── */
.map-marker {
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.85);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.map-cluster {
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: .78rem;
    text-align: center;
    border: 2px solid rgba(255,255,255,.8);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Popup ── */
.map-popup-wrapper .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    padding: 0;
}

.map-popup-wrapper .leaflet-popup-content { margin: 0; }

.map-popup {
    padding: 12px 14px;
    min-width: 180px;
}

.map-popup-name {
    font-weight: 700;
    font-size: .875rem;
    color: #0f172a;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.map-popup-type {
    font-size: .68rem;
    font-weight: 600;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 4px;
    padding: 1px 5px;
}

.map-popup-code {
    font-size: .75rem;
    color: #64748b;
    margin-bottom: 6px;
    font-family: monospace;
}

.map-popup-agence {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    color: #334155;
    margin-bottom: 3px;
}

.map-popup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.map-popup-ville {
    font-size: .75rem;
    color: #64748b;
    margin-bottom: 8px;
}

.map-popup-link {
    display: inline-block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    margin-top: 4px;
}

.map-popup-link:hover { text-decoration: underline; }

/* ── Tooltip survol ── */
.map-tooltip {
    padding: 8px 10px;
    min-width: 150px;
}

.map-tooltip-name {
    font-weight: 700;
    font-size: .82rem;
    color: #0f172a;
    margin-bottom: 4px;
    white-space: nowrap;
}

.map-tooltip-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    color: #334155;
}

.map-tooltip-ville {
    font-size: .72rem;
    color: #64748b;
    margin-top: 2px;
}

.map-tooltip-hint {
    font-size: .68rem;
    color: #94a3b8;
    margin-top: 5px;
    font-style: italic;
}

@media (max-width: 1024px) {
    .map-layout { flex-direction: column; }
    .map-sidebar {
        width: 100%;
        min-width: unset;
        height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .map-container { flex: 1; }
}

/* ============================================
   Dashboard « Résultats & conformité » (v1.5)
   ============================================ */

.dsh-context { font-size: .85rem; color: var(--text-muted); margin: 0 0 14px; }

.dsh-section-title {
    font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-muted); margin: 24px 0 12px; display: flex; align-items: center; gap: 10px;
}
.dsh-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.dsh-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.dsh-col { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .dsh-row2 { grid-template-columns: 1fr; } }

.dsh-csub { font-size: .8rem; color: var(--text-muted); font-weight: 400; }

/* KPI tiles */
.dsh-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.dsh-tile {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow-xs);
    display: flex; flex-direction: column; gap: 3px;
}
.dsh-tile.dsh-accent-crit { border-left: 3px solid var(--danger); }
.dsh-tile.dsh-accent-warn { border-left: 3px solid var(--warning); }
.dsh-tl { font-size: .74rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.dsh-tv { font-size: 1.7rem; font-weight: 700; line-height: 1.15; color: var(--text); }
.dsh-tv small { font-size: .95rem; font-weight: 600; color: var(--text-muted); }
.dsh-tctx { font-size: .78rem; color: var(--text-muted); }
.dsh-delta { font-size: .8rem; font-weight: 600; }
.dsh-delta.up { color: var(--success); }
.dsh-delta.down { color: var(--danger); }
.dsh-delta.flat { color: var(--text-muted); }
.dsh-link { font-size: .8rem; font-weight: 600; color: var(--primary-dark); text-decoration: none; }
.dsh-link:hover { text-decoration: underline; }
.dsh-meter { margin-top: 7px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.dsh-meter i { display: block; height: 100%; border-radius: 3px; background: var(--primary); }

/* Histogramme distribution */
.dsh-hist { display: flex; align-items: flex-end; gap: 5px; height: 140px; padding-top: 8px; }
.dsh-hb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.dsh-hb i { display: block; border-radius: 4px 4px 0 0; min-height: 3px; }
.dsh-hb:hover i { filter: brightness(1.12); }
.dsh-hist-x { display: flex; gap: 5px; margin-top: 6px; }
.dsh-hist-x span { flex: 1; text-align: center; font-size: .68rem; color: var(--text-muted); }
.dsh-hlegend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: .8rem; color: var(--text-secondary); }
.dsh-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* Barres non-conformités */

/* Barres groupées comparaison */
.dsh-gbars { display: flex; gap: 14px; align-items: flex-end; height: 180px; padding-top: 22px; }
.dsh-gcol { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.dsh-gpair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.dsh-gpair i { display: block; width: 24px; border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.dsh-gpair .prev { background: var(--text-muted); opacity: .45; }
.dsh-gpair .curr { background: var(--primary); }
.dsh-gpair .val { position: absolute; top: -19px; left: 50%; transform: translateX(-50%); font-size: .74rem; font-weight: 700; color: var(--primary-dark); }
.dsh-gx { font-size: .72rem; color: var(--text-muted); margin-top: 8px; text-align: center; line-height: 1.25; }
.dsh-glegend { display: flex; gap: 16px; margin-top: 14px; font-size: .8rem; color: var(--text-secondary); flex-wrap: wrap; }

/* Listes actionnables */
.dsh-pdv { font-weight: 600; font-size: .88rem; }
.dsh-pdv small { display: block; font-weight: 400; color: var(--text-muted); font-size: .76rem; }
.dsh-scorebar { display: inline-flex; align-items: center; gap: 8px; }
.dsh-scorebar .tr { width: 48px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; display: inline-block; }
.dsh-scorebar .tr i { display: block; height: 100%; border-radius: 3px; }
.dsh-age { font-weight: 700; white-space: nowrap; }
.dsh-age.old { color: var(--warning); }
