:root {
    /* Palette inspirée de l'identité réelle de Brevo (échantillonnée sur brevo.com),
       vérifiée avec le validateur de contraste/CVD du skill dataviz : fond blanc,
       vert signature comme couleur de texte/lien/action, violet en accent secondaire.
       #006a43 sert de couleur de TEXTE/lien/bouton (6.68:1 sur blanc).
       #0b996e est réservé aux usages décoratifs (traits de graphique, dégradés) : 3.62:1 seulement. */
    --bg: #ffffff;
    --bg-page: #fbfcfa;
    --surface: #ffffff;
    --surface-alt: #f3f8f1;
    --border: #e5e8e2;
    --border-strong: #d7dbd2;

    --accent: #006a43;
    --accent-dark: #004228;
    --accent-bright: #0b996e;
    --accent-soft: #e8fedf;
    --accent-lime: #c0ffa5;

    --violet: #6358de;
    --violet-soft: #efedfc;

    --success: #006a43;
    --success-soft: #e8fedf;
    --warning: #92600a;
    --warning-soft: #fef4df;
    --danger: #b42318;
    --danger-soft: #f8e4e4;

    --text: #17191a;
    --text-muted: #667069;
    --text-faint: #7d857e;

    /* Rampe ordinale (une teinte, claire→foncée) pour visualiser la progression du pipeline */
    --pipeline-1: #5fb84a;
    --pipeline-2: #0b996e;
    --pipeline-3: #006a43;
    --pipeline-4: #004228;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.07);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
    --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

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

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-dark);
}

h1, h2, h3, h4 {
    margin: 0 0 0.5em;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text);
}

p {
    margin: 0 0 0.75em;
    color: var(--text-muted);
}

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.25); }
    100% { box-shadow: 0 0 0 6px rgba(180, 35, 24, 0); }
}

/* ---------- Layout ---------- */

.app-shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}

.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .page-title {
    font-size: 15px;
    font-weight: 700;
}

.topbar .user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.sidebar {
    grid-area: sidebar;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 0 22px 18px;
    font-size: 15.5px;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar .brand .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    flex-shrink: 0;
}

.sidebar .brand .brand-text span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
}

.sidebar nav a {
    padding: 9px 22px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar nav a:hover {
    color: var(--text);
    background: var(--surface-alt);
}

.sidebar nav a.active {
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-left-color: var(--accent);
    font-weight: 700;
}

.sidebar nav .nav-group {
    margin-top: 18px;
    padding: 0 22px 6px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
}

main.content {
    grid-area: main;
    padding: 26px 28px 40px;
    overflow-x: hidden;
    animation: fadeInUp 0.35s ease both;
}

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

.page-header h1 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Grid helpers ---------- */

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.grid > * {
    animation: fadeInUp 0.4s ease both;
}
.grid > *:nth-child(1) { animation-delay: 0ms; }
.grid > *:nth-child(2) { animation-delay: 40ms; }
.grid > *:nth-child(3) { animation-delay: 80ms; }
.grid > *:nth-child(4) { animation-delay: 120ms; }
.grid > *:nth-child(n+5) { animation-delay: 150ms; }

@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .sidebar { display: none; }
}

/* ---------- Components ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

a.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.stat-card .stat-value {
    font-size: 27px;
    font-weight: 800;
    margin-bottom: 3px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    font-size: 11.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    font-weight: 700;
    background: var(--surface-alt);
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: var(--surface-alt);
}

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

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background var(--transition), color var(--transition);
}

.badge-neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { background: var(--violet-soft); color: var(--violet); }
.badge-success { background: var(--success-soft); color: var(--accent-dark); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-danger.badge-pulse { animation: pulseRing 1.6s ease-out infinite; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 17px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:hover {
    border-color: var(--accent);
    background: var(--surface-alt);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

form .field {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-muted);
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], input[type="file"],
select, textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.flash {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
    animation: slideDown 0.25s ease both;
}

.flash-success { background: var(--success-soft); color: var(--accent-dark); border-color: #bdeecf; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f6cfca; }
.flash-info { background: var(--violet-soft); color: var(--violet); border-color: #dad4f9; }

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--accent-dark); }

.empty-state {
    padding: 44px 20px;
    text-align: center;
    color: var(--text-faint);
    font-size: 13.5px;
}

.progress-bar {
    height: 7px;
    background: var(--surface-alt);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dark) 100%);
    transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters-bar select, .filters-bar input {
    width: auto;
    min-width: 160px;
}

/* ---------- Tableau de bord : raccourcis, alertes, classement ---------- */

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.alerts-card h3 {
    margin-bottom: 12px;
}

.alert-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
    background: var(--surface-alt);
    color: var(--text);
    font-size: 13px;
    margin-bottom: 8px;
    transition: background var(--transition), transform var(--transition);
}

a.alert-row:hover {
    transform: translateX(2px);
}

.alert-row:last-child {
    margin-bottom: 0;
}

.alert-row.alert-ok {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.alert-row.alert-critical {
    border-left-color: var(--danger);
    background: var(--danger-soft);
}

.alert-row.alert-warning {
    border-left-color: var(--warning);
    background: var(--warning-soft);
}

.alert-row.alert-info {
    border-left-color: var(--violet);
    background: var(--violet-soft);
}

.alert-badge {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.6);
}

.rank-cell {
    font-weight: 800;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    width: 22px;
}

tr.rank-first {
    background: var(--accent-soft);
}

tr.rank-first .rank-cell {
    color: var(--accent-dark);
}

/* ---------- Pipeline (funnel visuel) ---------- */

.pipeline {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.pipeline-step {
    background: var(--surface);
    padding: 20px 10px 18px;
    text-align: center;
    position: relative;
    animation: fadeInUp 0.45s ease both;
    border-top: 3px solid var(--border);
}

.pipeline-step:nth-child(1) { animation-delay: 0ms; border-top-color: var(--pipeline-1); }
.pipeline-step:nth-child(2) { animation-delay: 60ms; border-top-color: var(--pipeline-2); }
.pipeline-step:nth-child(3) { animation-delay: 120ms; border-top-color: var(--pipeline-3); }
.pipeline-step:nth-child(4) { animation-delay: 180ms; border-top-color: var(--pipeline-4); }
.pipeline-step:nth-child(5) { animation-delay: 240ms; }
.pipeline-step.is-danger { border-top-color: var(--danger); }

.pipeline-step:not(:last-child)::after {
    content: '\2192';
    position: absolute;
    right: -11px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-faint);
    font-size: 12px;
    z-index: 2;
}

.pipeline-step .pipeline-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.pipeline-step .pipeline-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 3px;
}

.pipeline-step .pipeline-pct {
    font-size: 11px;
    color: var(--accent-dark);
    margin-top: 4px;
    font-weight: 600;
}

.pipeline-step.is-danger .pipeline-value { color: var(--danger); }

@media (max-width: 900px) {
    .pipeline { grid-auto-flow: row; }
    .pipeline-step:not(:last-child)::after { content: '\2193'; right: 50%; top: auto; bottom: -11px; transform: translateX(50%); }
}

/* ---------- Auth page ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    background-image: radial-gradient(circle at 15% 15%, var(--accent-soft) 0%, transparent 45%),
                       radial-gradient(circle at 85% 85%, var(--violet-soft) 0%, transparent 45%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 34px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.4s ease both;
}

.auth-card h1 {
    font-size: 18px;
    margin-bottom: 4px;
}

.auth-card p {
    font-size: 13px;
    margin-bottom: 22px;
}
