/* ─── Inter (self-hosted, variable) ─────────────────────────────────────── */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../assets/fonts/inter/InterVariable.woff2') format('woff2-variations'),
         url('../assets/fonts/inter/InterVariable.woff2') format('woff2');
    font-feature-settings: 'cv11', 'ss01', 'ss03';
}
@font-face {
    font-family: 'Inter';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('../assets/fonts/inter/InterVariable-Italic.woff2') format('woff2-variations'),
         url('../assets/fonts/inter/InterVariable-Italic.woff2') format('woff2');
    font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

:root {
    /* Primaire */
    --primary:         #0b5cff;
    --primary-dark:    #0847c5;
    --primary-light:   #e6efff;
    --primary-rgb:     11, 92, 255;

    /* États */
    --success:         #16a34a;
    --warning:         #d97706;
    --danger:          #dc2626;
    --info:            #0891b2;

    /* Gris recalibrés (ton légèrement chaud, lisibles sur fond #f5f5f7) */
    --gray-50:         #fafafc;
    --gray-100:        #f2f2f5;
    --gray-200:        #e5e5ea;
    --gray-300:        #d1d1d6;
    --gray-400:        #a1a1a6;
    --gray-500:        #86868b;
    --gray-600:        #515154;
    --gray-700:        #3a3a3c;
    --gray-800:        #1d1d1f;
    --gray-900:        #000000;

    /* Alias sémantiques de texte */
    --text-primary:    var(--gray-800);
    --text-secondary:  var(--gray-600);
    --text-tertiary:   var(--gray-400);

    /* Fonds et surfaces */
    --bg-app:          #f5f5f7;
    --surface:         #ffffff;
    --surface-alt:     #fafafc;
    --surface-inset:   #f0f0f3;

    /* Layout */
    --topbar-height:   62px;

    /* Rayons */
    --radius:          10px;
    --radius-lg:       14px;
    --radius-xl:       20px;
    --radius-pill:     999px;

    /* Ombres (fond clair, deux couches) */
    --shadow-xs:       0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm:       0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md:       0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg:       0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.05);
    --shadow-xl:       0 24px 48px rgba(0, 0, 0, 0.10), 0 8px 16px rgba(0, 0, 0, 0.06);
    --shadow-focus:    0 0 0 4px rgba(11, 92, 255, 0.15);

    /* Compat : --shadow utilisée dans plusieurs endroits → alias vers --shadow-sm */
    --shadow:          var(--shadow-sm);

    /* Durées */
    --dur-fast:        150ms;
    --dur:             220ms;
    --dur-slow:        320ms;

    /* DatePicker — tokens sémantiques (alias sur palette existante) */
    --weekend-bg:      var(--gray-100);
    --holiday-accent:  var(--warning);

    /* Courbes (Apple iOS / macOS style) */
    --ease-out:        cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-ios:        cubic-bezier(0.32, 0.72, 0, 1);
    --ease-back:       cubic-bezier(0.2, 0.9, 0.3, 1.25);

    /* Compat : --transition (utilisée partout dans l'existant) → on l'aligne */
    --transition:      var(--dur) var(--ease-out);

    /* Échelle typographique */
    --fs-xs:           0.75rem;
    --fs-sm:           0.8125rem;
    --fs-base:         0.95rem;
    --fs-md:           1.0625rem;
    --fs-lg:           1.25rem;
    --fs-xl:           1.625rem;
    --fs-2xl:          2.125rem;

    /* Accents sections admin (inchangés) */
    --accent-modeles:  #5c4fa0;
    --accent-societe:  #0d7c8a;
    --accent-rgpd:     #c2600a;
    --accent-nf525:    #1a7a3a;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    letter-spacing: -0.003em;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ─── Marque iatko (logo carré, inline à côté du texte) ─────────────────── */
.iatko-mark {
    display: inline-block;
    height: 1.4em;
    width: auto;
    vertical-align: -0.4em;
    margin-right: 0.3em;
}

/* ─── Wordmark Vethys (lettres extraites du logo, inline) ─────────────────
   Le viewBox du SVG (55 22 445 128) contient :
     - top des lettres   ≈ y=25 (≈0.02em depuis le top du svg)
     - baseline interne  ≈ y=113 (≈0.71em depuis le top → 0.29em depuis le bas)
     - descender du Y    ≈ y=145 (≈0.96em depuis le top)
   Avec height: 1em et vertical-align: -0.29em la baseline interne s'aligne
   pile sur la baseline du texte parent, et la cap-height (0.69em) tombe
   très proche de celle d'Inter et Georgia. */
.vethys-mark {
    display: inline-block;
    height: 1em;
    width: auto;
    vertical-align: -0.29em;
    fill: currentColor;
    color: inherit;
    line-height: 1;
}

/* ─── Responsive visibility helpers ─────────────────────────────────────── */
.mobile-only { display: none; }
.mobile-client { font-size: 0.8rem; color: var(--gray-500); }
@media (max-width: 768px) {
    .mobile-only { display: inline; }
    br.mobile-only { display: block; }
    .desktop-only { display: none !important; }
}

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

.login-layout {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    min-height: 100vh;
    background: transparent;
}
.login-layout > .container {
    padding: 0;
    padding-bottom: 0;
    flex: 1;
    display: flex;
}

/* ─── Couleurs par module ───────────────────────────────────────────────── */
:root {
    --module-color:     #1d1d1f;
    --module-dark:      #000000;
    --module-light:     var(--gray-200);
    --module-color-rgb: 29, 29, 31;
}
.module-clients          { --module-color: #e11d48; --module-dark: #be123c; --module-light: #ffe4ea; --module-color-rgb: 225, 29, 72; }
.module-interventions    { --module-color: #ea580c; --module-dark: #c2410c; --module-light: #ffedd5; --module-color-rgb: 234, 88, 12; }
.module-documents        { --module-color: #7c3aed; --module-dark: #5b21b6; --module-light: #ede9fe; --module-color-rgb: 124, 58, 237; }
.module-contrats         { --module-color: #059669; --module-dark: #047857; --module-light: #d1fae5; --module-color-rgb: 5, 150, 105; }
.module-articles         { --module-color: #2563eb; --module-dark: #1d4ed8; --module-light: #dbeafe; --module-color-rgb: 37, 99, 235; }
.module-equipements      { --module-color: #2563eb; --module-dark: #1d4ed8; --module-light: #dbeafe; --module-color-rgb: 37, 99, 235; }
.module-encaissements    { --module-color: #7c3aed; --module-dark: #5b21b6; --module-light: #ede9fe; --module-color-rgb: 124, 58, 237; }
.module-admin            { --module-color: #3a3a3c; --module-dark: #1d1d1f; --module-light: #e5e5ea; --module-color-rgb: 58, 58, 60; }
.module-commandes_pieces { --module-color: #d97706; --module-dark: #b45309; --module-light: #fef3c7; --module-color-rgb: 217, 119, 6; }
.module-mises_en_service { --module-color: #0891b2; --module-dark: #0e7490; --module-light: #cffafe; --module-color-rgb: 8, 145, 178; }
.module-camion           { --module-color: #ea580c; --module-dark: #c2410c; --module-light: #ffedd5; --module-color-rgb: 234, 88, 12; }
.module-heures           { --module-color: #4f46e5; --module-dark: #4338ca; --module-light: #e0e7ff; --module-color-rgb: 79, 70, 229; }

/* ─── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
    background: #0C1727;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    box-shadow: 0 1px 0 rgba(255,255,255,0.05), 0 6px 24px rgba(0,0,0,0.55);
    border-bottom: 3px solid var(--module-color);
}

.topbar-brand {
    padding: 0 1.4rem;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    align-items: center;
}
.topbar-brand a {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.topbar-brand img,
.topbar-brand svg {
    height: 38px;
    width: auto;
    color: var(--gray-900);
    transition: transform 0.2s ease;
    transform-origin: center;
}
.topbar-brand a:hover img,
.topbar-brand a:hover svg {
    transform: scale(1.05);
}

.topbar-nav {
    display: flex;
    align-items: center;
    flex: 1;
    height: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 0.25rem;
}
.topbar-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: color var(--transition), background var(--transition);
    letter-spacing: 0.01em;
}
.nav-item:hover {
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.07);
    text-decoration: none;
}
.nav-item.active {
    color: #fff;
    background: var(--module-color);
    animation: activemenu 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 0.4rem;
    background: #dc2626;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 10px;
    line-height: 1;
}

@keyframes activemenu {
    0% {
        opacity: 0;
        transform: translateY(14px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.4rem;
    flex-shrink: 0;
    border-left: 1px solid rgba(255,255,255,0.08);
    height: 100%;
}

.topbar-username {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: -0.005em;
    transition: color var(--dur) var(--ease-out);
}
.topbar-username:hover {
    color: #fff;
    text-decoration: none;
}

.topbar-role {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.topbar-logout {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition);
    font-weight: 500;
}
.topbar-logout:hover {
    color: #f87171;
    text-decoration: none;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: rgba(255,255,255,0.6);
    padding: 0 1rem;
    height: 100%;
    transition: color var(--transition);
}
.nav-toggle:hover {
    color: #fff;
}

/* ─── Main content ──────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.75rem;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-xs);
    animation: pageHeaderIn var(--dur-slow) var(--ease-ios);
}
@keyframes pageHeaderIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.container {
    padding: 1.5rem;
    padding-bottom: 4rem;
    flex: 1;
}

/* ─── Sections de formulaire ────────────────────────────────────────────── */
/* Approche éditoriale : numérotation italique sérif + filet vertical color-coded
   (l'ancien badge emoji est neutralisé, le contenu reste compatible) */
form, .form-sections, body { counter-reset: form-section; }

.form-section {
    counter-increment: form-section;
    position: relative;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: visible;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    max-width: 90%;
    margin: 1.25rem auto;
    transition: box-shadow var(--dur) var(--ease-out),
                border-color var(--dur) var(--ease-out);
}
.form-section:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.form-section-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem 0.85rem 1.4rem;
    background: linear-gradient(180deg,
        var(--surface) 0%,
        var(--surface-alt) 100%);
    border-bottom: 1px solid var(--gray-200);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    user-select: none;
}

/* Numéro éditorial : "01", "02"... en italique sérif, devant le titre */
.form-section-header::before {
    content: counter(form-section, decimal-leading-zero);
    font-family: 'Georgia', 'Cormorant Garamond', 'Times New Roman', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--text-tertiary);
    letter-spacing: 0.01em;
    min-width: 1.6rem;
    flex-shrink: 0;
    transition: color var(--dur) var(--ease-out);
}
.form-section:hover .form-section-header::before {
    color: var(--text-secondary);
}

/* L'ancien carré coloré devient un filet vertical fin, color-coded.
   L'emoji passé en contenu est masqué visuellement (rendu OS aléatoire). */
.form-section-icon {
    width: 2px;
    height: 18px;
    border-radius: 1px;
    background: var(--gray-300);
    color: transparent;
    font-size: 0;
    line-height: 0;
    text-indent: -9999px;
    box-shadow: none;
    flex-shrink: 0;
    overflow: hidden;
    align-self: center;
}
.form-section-icon.icon-blue   { background: var(--primary); }
.form-section-icon.icon-amber  { background: var(--warning); }
.form-section-icon.icon-green  { background: var(--success); }
.form-section-icon.icon-purple { background: #7c3aed; }
.form-section-icon.icon-teal   { background: var(--info); }
.form-section-icon.icon-gray   { background: var(--gray-400); }

.form-section-title {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-primary);
}

.form-section-body {
    padding: 1.4rem 1.4rem 1.1rem;
    max-width: 800px;
    margin: 0 auto;
}

.form-section-body > .form-row:last-child,
.form-section-body > .form-group:last-child {
    margin-bottom: 0;
}

.form-section-danger .form-section-header {
    background: linear-gradient(180deg, #fff5f7 0%, #ffe4ea 100%);
    border-bottom-color: #e11d48;
}
.form-section-danger .form-section-header::before {
    color: #be123c;
}
.form-section-danger .form-section-title {
    color: #9f1239;
}
.form-section-danger .form-section-icon {
    background: #e11d48;
}

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--gray-200);
    transition: box-shadow var(--dur) var(--ease-out),
                transform var(--dur) var(--ease-out);
}
.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.card.module .card-header {
    border-bottom-color: var(--module-color);
    border-bottom-width: 2px;
}

.card.module .card-title {
    color: var(--module-color);
}

.card.module .btn-primary {
    background: var(--module-color);
    border-color: var(--module-color);
}

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

@media (hover: none) {
    .card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* ─── Badges suivis ──────────────────────────────────────────────────────── */
.suivi-badge {
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.suivi-badge-rouge  { background: #fff1f2; color: #be123c; }
.suivi-badge-violet { background: #f5f3ff; color: #6d28d9; }
.suivi-badge-noir   { background: #f1f5f9; color: #334155; }

/* ─── Liste rouge ────────────────────────────────────────────────────────── */
.row-liste-rouge td {
    background: #fff1f2;
    color: #9f1239;
}

.row-liste-rouge:hover td {
    background: #ffe4e8;
}

/* ─── Checkboxes & Radios ───────────────────────────────────────────────── */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out);
}
input[type="checkbox"]:hover,
input[type="radio"]:hover {
    transform: scale(1.05);
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: var(--fs-base);
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Contexte "liste rouge" : accent en rose */
.form-section-danger .checkbox-label input[type="checkbox"],
.checkbox-label.is-danger input[type="checkbox"] {
    accent-color: #e11d48;
}

/* ─── Dashboard ────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--dur) var(--ease-out),
                transform var(--dur) var(--ease-out);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent, var(--primary));
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.stat-card--wide {
    grid-column: span 4;
    padding: 1rem 1.15rem;
}

.stat-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.stat-card__header .stat-label {
    margin-top: 0;
}

.stat-value {
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-top: 0.4rem;
}

.stat-value--lg {
    font-size: var(--fs-2xl);
    margin-top: 0;
}

.stat-label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    margin-top: 0.35rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-sublabel {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

@media (hover: none) {
    .stat-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* ─── Admin Page ──────────────────────────────────────────────────────── */
.admin-page {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.admin-section {
    --section-accent: var(--primary);
    margin-bottom: 2rem;
}

/* Section accent colors via data-group */
.admin-section[data-group="config"]  { --section-accent: var(--primary); }
.admin-section[data-group="modeles"] { --section-accent: var(--accent-modeles); }
.admin-section[data-group="societe"] { --section-accent: var(--accent-societe); }
.admin-section[data-group="rgpd"]    { --section-accent: var(--accent-rgpd); }
.admin-section[data-group="nf525"]   { --section-accent: var(--accent-nf525); }

.admin-section-title {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-bottom: 0.55rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--section-accent) 20%, transparent);
    color: var(--section-accent);
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.admin-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--gray-200);
    border-bottom: 4px solid var(--section-accent);
    transition: box-shadow var(--dur) var(--ease-out),
                transform var(--dur) var(--ease-out);
}
.admin-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    border-bottom-width: 6px;
    border-bottom-color: #0c1727;
}
.admin-card:hover .admin-card-title {
    color: #0c1727;
}
.admin-card:hover .admin-card-label,
.admin-card:hover .admin-card-title {
    text-decoration: none;
}

.admin-card-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.admin-card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.25rem;
    letter-spacing: -0.01em;
}

@media (hover: none) {
    .admin-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* Toggle group */
.toggle-group {
    display: inline-flex;
    background: var(--surface-inset);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
}

.toggle-btn {
    border: none;
    background: transparent;
    padding: 0.4rem 0.95rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease-ios),
                color var(--dur) var(--ease-ios),
                box-shadow var(--dur) var(--ease-ios),
                transform var(--dur-fast) var(--ease-ios);
    font-family: inherit;
    position: relative;
}
.toggle-btn:hover {
    color: var(--text-primary);
}
.toggle-btn:active {
    transform: scale(0.96);
}
.toggle-btn--active {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

/* Devis stats row */
.devis-stats {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.devis-stat {
    display: flex;
    flex-direction: column;
}
.devis-stat .stat-value {
    font-size: 1.5rem;
}
.devis-stat .stat-sublabel {
    margin-top: 0.15rem;
}

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}

thead th {
    background: var(--surface-alt);
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
    vertical-align: middle;
}

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

tbody tr {
    transition: background var(--dur) var(--ease-out),
                box-shadow var(--dur) var(--ease-out);
}

tbody tr:hover {
    background: var(--surface-alt);
    box-shadow: inset 3px 0 0 var(--module-color, var(--primary));
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--dur) var(--ease-out),
                box-shadow var(--dur) var(--ease-out),
                background-color var(--dur) var(--ease-out),
                border-color var(--dur) var(--ease-out);
    line-height: 1.4;
    letter-spacing: -0.005em;
    user-select: none;
    box-shadow: var(--shadow-xs);
}
.btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
    transition-duration: var(--dur-fast);
}
.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}
.btn:disabled,
.btn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-xs);
}

.btn-primary {
    background: var(--module-color, var(--primary));
    color: #fff;
    border-color: var(--module-color, var(--primary));
    box-shadow:
        0 1px 2px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.3),
        0 2px 6px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.15);
}
.btn-primary:hover {
    background: var(--module-dark, var(--primary-dark));
    border-color: var(--module-dark, var(--primary-dark));
    box-shadow:
        0 2px 4px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.35),
        0 6px 16px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.22);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    box-shadow: 0 1px 2px rgba(22, 163, 74, 0.3), 0 2px 6px rgba(22, 163, 74, 0.15);
}
.btn-success:hover:not(:disabled) {
    background: #15803d;
    border-color: #15803d;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.35), 0 6px 16px rgba(22, 163, 74, 0.22);
}
.btn-success:disabled {
    background: var(--gray-400);
    border-color: var(--gray-400);
    color: #fff;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.3), 0 2px 6px rgba(220, 38, 38, 0.15);
}
.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.35), 0 6px 16px rgba(220, 38, 38, 0.22);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.3), 0 2px 6px rgba(217, 119, 6, 0.15);
}
.btn-warning:hover {
    background: #b45309;
    border-color: #b45309;
    box-shadow: 0 2px 4px rgba(217, 119, 6, 0.35), 0 6px 16px rgba(217, 119, 6, 0.22);
}

.btn-purple {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
    box-shadow: 0 1px 2px rgba(124, 58, 237, 0.3), 0 2px 6px rgba(124, 58, 237, 0.15);
}
.btn-purple:hover {
    background: #5b21b6;
    border-color: #5b21b6;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.35), 0 6px 16px rgba(124, 58, 237, 0.22);
}

.btn-success-light {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.btn-danger-light {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 0.4rem;
}

@media (hover: none) {
    .btn:hover {
        transform: none;
        box-shadow: var(--shadow-xs);
    }
    .btn-primary:hover {
        background: var(--module-color, var(--primary));
        border-color: var(--module-color, var(--primary));
        box-shadow:
            0 1px 2px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.3),
            0 2px 6px rgba(var(--module-color-rgb, var(--primary-rgb)), 0.15);
    }
}

/* ─── Dropdown action ────────────────────────────────────────────────────── */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle::after {
    content: ' ▾';
    font-size: 0.7em;
    opacity: 0.7;
    display: inline-block;
    transition: transform var(--dur) var(--ease-out);
}
.dropdown.open .dropdown-toggle::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: fixed;
    z-index: 200;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    overflow-x: hidden;
    overflow-y: auto;
    transform-origin: top center;
}

.dropdown-menu a {
    display: block;
    padding: 0.55rem 0.85rem;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 8px;
    transition: background var(--dur-fast) var(--ease-out);
}

.dropdown-menu a:hover {
    background: var(--gray-100);
    color: var(--text-primary);
    text-decoration: none;
}

.dropdown-menu a.is-active,
.dropdown-menu a[aria-current="true"] {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-menu .dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.35rem 0;
}

.dropdown.open .dropdown-menu,
.dropdown-menu.open {
    display: block;
    animation: dropdownIn var(--dur) var(--ease-out) both;
}
@keyframes dropdownIn {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Dropdown statut inline ─────────────────────────────────────────────── */
.statut-dropdown {
    position: relative;
    display: inline-block;
}

.statut-dropdown-toggle {
    cursor: pointer;
}

.statut-dropdown-toggle:hover {
    opacity: 0.85;
}

.statut-dropdown-menu {
    display: none;
    position: fixed;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    min-width: 150px;
    overflow: hidden;
    transform-origin: top center;
}

.statut-dropdown-menu .statut-option {
    display: block;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: var(--fs-sm);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
    border-radius: 8px;
    transition: background var(--dur-fast) var(--ease-out);
}

.statut-dropdown-menu .statut-option:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.statut-dropdown.open .statut-dropdown-menu,
.statut-dropdown-menu.is-open {
    display: block;
    animation: dropdownIn var(--dur) var(--ease-out) both;
}

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.35rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: var(--fs-base);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color var(--dur) var(--ease-out),
                box-shadow var(--dur) var(--ease-out);
    line-height: 1.5;
}
.form-control:hover {
    border-color: var(--gray-300);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04), var(--shadow-focus);
}
.form-control:disabled,
.form-control[readonly] {
    background: var(--gray-100);
    color: var(--text-tertiary);
    cursor: not-allowed;
    box-shadow: none;
}
.form-control::placeholder {
    color: var(--text-tertiary);
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-color: var(--surface);
    padding-right: 2.4rem;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease-out),
                box-shadow var(--dur) var(--ease-out);
}
select.form-control:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%230b5cff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="date"].form-control,
input[type="time"].form-control {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

textarea.form-control {
    resize: vertical;
    min-height: 96px;
    padding: 0.75rem 0.9rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.form-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

/* ─── Toolbar (search + actions above table) ────────────────────────────── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-form .form-control {
    width: auto;
    min-width: 280px;
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.85rem center;
    box-shadow: var(--shadow-xs);
}
.search-form .form-control:focus {
    box-shadow: var(--shadow-xs), var(--shadow-focus);
}

.search-form .form-control::placeholder {
    color: var(--text-tertiary);
}

/* Les inputs non-search de la toolbar (date, select) gardent le style standard */
.search-form select.form-control {
    padding: 0.65rem 0.9rem;
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position: right 0.85rem center;
    border-radius: var(--radius);
    min-width: 0;
    width: auto;
}
.search-form input[type="date"].form-control,
.search-form input[type="time"].form-control {
    padding: 0.65rem 0.9rem;
    background-image: none;
    border-radius: var(--radius);
    min-width: 0;
    width: auto;
}

/* ─── Filter bar (search + chips actifs + popover) ─────────────────────── */
.filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "search actions"
        "chips chips";
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
    padding: 0.4rem 0;
}

.filter-bar-search {
    grid-area: search;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex-wrap: nowrap;
}
.filter-bar-search > input.form-control {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.65rem 1rem 0.65rem 2.6rem;
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.95rem center;
    box-shadow: var(--shadow-xs);
    font-size: var(--fs-base);
}

.filter-bar-chips {
    grid-area: chips;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    min-width: 0;
}
.filter-bar-chips:empty {
    display: none;
}

/* Chip : pill arrondie représentant un filtre actif */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.35rem 0.3rem 0.75rem;
    border-radius: var(--radius-pill);
    background: var(--primary-light);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    color: var(--primary);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    animation: chipIn var(--dur) var(--ease-spring);
}
.filter-chip:hover {
    background: color-mix(in srgb, var(--primary) 18%, transparent);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
}
.filter-chip-label {
    color: color-mix(in srgb, var(--primary) 75%, var(--text-secondary));
    font-weight: 500;
}
.filter-chip-value {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.005em;
}
.filter-chip-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 22%, transparent);
    color: var(--primary);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.15rem;
    transition: background var(--dur-fast) var(--ease-out);
}
.filter-chip:hover .filter-chip-close {
    background: var(--primary);
    color: #fff;
}
@keyframes chipIn {
    0%   { opacity: 0; transform: scale(0.8); }
    70%  { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Chip interactive : body cliquable (ouvre popover) + × séparé ────────── */
.filter-chip--interactive {
    position: relative;
    padding: 0;
    gap: 0;
}
.filter-chip--interactive .filter-chip__body {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.45rem 0.3rem 0.75rem;
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    border-radius: var(--radius-pill) 0 0 var(--radius-pill);
    transition: background var(--dur-fast) var(--ease-out);
}
.filter-chip--interactive .filter-chip__body:hover {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
}
.filter-chip--interactive .filter-chip__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 22%, transparent);
    color: var(--primary);
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip--interactive .filter-chip__close:hover {
    background: var(--danger);
    color: #fff;
    text-decoration: none;
}
/* Le hover global .filter-chip:hover ne doit pas se propager à la chip interactive
   (sinon le body + close bougent ensemble). On désactive. */
.filter-chip--interactive:hover {
    background: var(--primary-light);
    transform: none;
    box-shadow: none;
}

/* Popover d'options affiché sous la chip interactive */
.filter-chip__popover {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.3rem;
    z-index: 100;
    animation: chipPopoverIn 180ms cubic-bezier(0.32, 0.72, 0, 1);
}
.filter-chip__popover[hidden] {
    display: none;
}
@keyframes chipPopoverIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.filter-chip__option {
    display: block;
    padding: 0.55rem 0.85rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: -0.005em;
    transition: background var(--dur-fast) var(--ease-out);
}
.filter-chip__option:hover {
    background: var(--gray-100);
    text-decoration: none;
}
.filter-chip__option--active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Bouton "Effacer tous les filtres" (plus discret) */
.filter-chip-clear {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-decoration: none;
    border: 1px dashed var(--gray-300);
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip-clear:hover {
    color: var(--danger);
    border-color: var(--danger);
    text-decoration: none;
}

/* Wrapper du bouton "+ Filtrer" avec popover
   Par défaut dans la zone search (collé à la search pill) */
.filter-add {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.filter-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--dur) var(--ease-out);
}
.filter-add-btn::before {
    content: "+";
    font-size: 1.1em;
    line-height: 1;
    font-weight: 600;
}
.filter-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    border-style: solid;
    background: var(--primary-light);
}
.filter-add.open .filter-add-btn {
    border-color: var(--primary);
    color: var(--primary);
    border-style: solid;
    background: var(--primary-light);
}

/* Popover contenant les filtres */
.filter-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    z-index: 300;
    min-width: 320px;
    max-width: min(400px, calc(100vw - 2rem));
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1rem;
    transform-origin: top right;
}
.filter-add.open .filter-popover {
    display: block;
    animation: filterPopoverIn var(--dur) var(--ease-out);
}
@keyframes filterPopoverIn {
    from { opacity: 0; transform: scale(0.95) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.filter-popover-title {
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.85rem;
}
.filter-popover-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}
.filter-popover-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.filter-popover-field label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.filter-popover-field .form-control {
    padding: 0.55rem 0.85rem;
    font-size: var(--fs-sm);
    width: 100%;
    box-sizing: border-box;
}
.filter-popover-field select.form-control {
    padding-right: 2.4rem;
    background-position: right 0.85rem center;
}
.filter-popover-field input[type="date"].form-control,
.filter-popover-field input[type="time"].form-control {
    padding-right: 0.85rem;
    min-height: 38px;
    line-height: 1.4;
}
.filter-popover-field input[type="date"].form-control::-webkit-calendar-picker-indicator,
.filter-popover-field input[type="time"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    padding: 2px;
    filter: invert(40%);
    transition: opacity var(--dur-fast);
}
.filter-popover-field input[type="date"].form-control::-webkit-calendar-picker-indicator:hover,
.filter-popover-field input[type="time"].form-control::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}
.filter-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--gray-100);
}

/* Actions à droite (boutons primaires de la toolbar) */
.filter-bar-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Résumé "X résultats" (optionnel) */
.filter-bar-count {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Responsive : mobile */
@media (max-width: 768px) {
    .filter-bar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "search"
            "chips"
            "actions";
        gap: 0.6rem;
    }
    .filter-bar-actions {
        justify-content: stretch;
    }
    .filter-bar-actions .btn {
        flex: 1;
        justify-content: center;
    }
    .filter-popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 0;
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1.25rem 1rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
    }
    .filter-add.open .filter-popover {
        animation: filterPopoverSheetIn var(--dur-slow) var(--ease-out);
    }
    @keyframes filterPopoverSheetIn {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .filter-popover-grid {
        gap: 1rem;
    }
    .filter-popover-field .form-control {
        padding: 0.65rem 0.85rem;
        font-size: 16px;
        min-height: 44px;
    }
}

/* Backdrop mobile quand le popover est ouvert */
@media (max-width: 768px) {
    .filter-add.open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 299;
        animation: overlayIn var(--dur) var(--ease-out);
    }
}

/* ─── Badges (statuts) ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
    transition: background-color var(--dur) var(--ease-out),
                color var(--dur) var(--ease-out);
}
.badge::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

.badge-a_faire {
    background: #fef9ec;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-en_cours {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-termine {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-annule {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.badge-brouillon {
    background-color: #95a5a6;
    color: #fff;
}

.badge-envoye {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.badge-paye {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-signe {
    background: #f0fdfa;
    color: #0f766e;
    border: 1px solid #99f6e4;
}

.badge-actif {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-contrat-attention {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.badge-suspendu {
    background: #fef9ec;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-resilie {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.badge-expire {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.badge-en_recherche {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.badge-commande {
    background: #fef9ec;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-recu {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-entretien-ok { background: #f0fdf4; color: #166534; }
.badge-entretien-ok::before { background: #16a34a; }
.badge-entretien-bientot { background: #fff7ed; color: #9a3412; }
.badge-entretien-bientot::before { background: #ea580c; }
.badge-entretien-retard { background: #fff1f2; color: #9f1239; }
.badge-entretien-retard::before { background: #e11d48; }
.badge-entretien-aucun { background: var(--gray-100); color: var(--gray-600); }
.badge-entretien-aucun::before { background: var(--gray-400); }

.badge-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-danger {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.badge-obsolete { background: var(--gray-100); color: var(--gray-500); }
.badge-obsolete::before { background: var(--gray-400); }

.row-obsolete { background: var(--gray-100); font-style: italic; }
.row-obsolete td { color: var(--gray-500); }

/* ─── Flash messages ────────────────────────────────────────────────────── */
.flash-message {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: opacity var(--dur-slow);
    border: 1px solid transparent;
    border-left-width: 4px;
    box-shadow: var(--shadow-xs);
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
    border-left-color: #22c55e;
}

.flash-error {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fecdd3;
    border-left-color: #ef4444;
}

.flash-warning {
    background: #fef9ec;
    color: #92400e;
    border-color: #fde68a;
    border-left-color: #f59e0b;
}

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
    border-left-color: #3b82f6;
}

/* ─── Form Readonly (facture payée) ──────────────────────────────────────── */
.form-readonly input,
.form-readonly select,
.form-readonly textarea {
    pointer-events: none;
    opacity: 0.7;
    background-color: var(--gray-100, #f3f4f6);
}
.form-readonly .btn-remove-ligne,
.form-readonly .btn-danger {
    display: none;
}

.alert-inline {
    padding: 0.8rem 1rem 0.8rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-left-width: 4px;
}

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.pagination-dots {
    padding: 0 0.3rem;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login-container {
    flex: 1;
    min-height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse at top left, #eef2ff 0%, transparent 45%),
        radial-gradient(ellipse at bottom right, #f0f9ff 0%, transparent 45%),
        linear-gradient(180deg, #fafbfc 0%, #f5f5f7 100%);
}

/* Aurora orbs animés en arrière-plan */
.login-container::before,
.login-container::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}
.login-container::before {
    width: 520px;
    height: 520px;
    top: -20%;
    left: -10%;
    background: radial-gradient(circle, rgba(11, 92, 255, 0.35) 0%, rgba(11, 92, 255, 0) 70%);
    animation: loginOrbFloat1 18s ease-in-out infinite;
}
.login-container::after {
    width: 560px;
    height: 560px;
    bottom: -25%;
    right: -15%;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.28) 0%, rgba(124, 58, 237, 0) 70%);
    animation: loginOrbFloat2 22s ease-in-out infinite;
}
@keyframes loginOrbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, 30px) scale(1.08); }
    66%      { transform: translate(-20px, 50px) scale(0.95); }
}
@keyframes loginOrbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-30px, -40px) scale(1.05); }
    66%      { transform: translate(40px, -20px) scale(0.92); }
}

.login-box {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(32px) saturate(1.3);
    -webkit-backdrop-filter: blur(32px) saturate(1.3);

    padding: 2.75rem 2.5rem 2.5rem;
    border-radius: 22px;

    border: 1px solid rgba(255, 255, 255, 0.6);

    box-shadow:
        0 0 0 1px rgba(11, 92, 255, 0.04),
        0 20px 50px -10px rgba(11, 30, 80, 0.18),
        0 10px 30px -5px rgba(11, 30, 80, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);

    width: 100%;
    max-width: 440px;

    transition: box-shadow var(--dur-slow) var(--ease-out),
                transform var(--dur-slow) var(--ease-out);

    animation: loginBoxIn 600ms var(--ease-ios) both;
}
@keyframes loginBoxIn {
    0%   { opacity: 0; transform: translateY(20px) scale(0.96); filter: blur(8px); }
    100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.login-box:hover {
    transform: translateY(-4px);
    box-shadow:
        0 0 0 1px rgba(11, 92, 255, 0.08),
        0 28px 60px -10px rgba(11, 30, 80, 0.22),
        0 14px 36px -6px rgba(11, 30, 80, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.login-box > * {
    position: relative;
    z-index: 1;
}

.login-box img.login-logo {
    display: block;
    margin: 0 auto 1.75rem auto;
    width: 200px;
    height: auto;
    transform: translateY(-8px);
    color: var(--primary);
    animation: loginLogoIn 700ms 150ms var(--ease-ios) both;
    filter: drop-shadow(0 2px 8px rgba(11, 92, 255, 0.12));
}
@keyframes loginLogoIn {
    0%   { opacity: 0; transform: translateY(-18px) scale(0.92); }
    100% { opacity: 1; transform: translateY(-8px) scale(1); }
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.45rem;
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--gray-900);
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 400;
    margin-bottom: 2rem;
}

/* Animation en cascade des éléments du form */
.login-box .form-group,
.login-box .form-actions,
.login-box .login-error {
    animation: loginFieldIn 500ms var(--ease-ios) both;
}
.login-box .login-error              { animation-delay: 200ms; animation-name: loginFieldInShake; }
.login-box form .form-group:nth-of-type(1) { animation-delay: 260ms; }
.login-box form .form-group:nth-of-type(2) { animation-delay: 320ms; }
.login-box form .form-actions        { animation-delay: 380ms; }
@keyframes loginFieldIn {
    0%   { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes loginFieldInShake {
    0%   { opacity: 0; transform: translateX(0); }
    20%  { opacity: 1; transform: translateX(-6px); }
    40%  { transform: translateX(6px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

/* Inputs sur le login : look encore plus premium */
.login-box .form-control {
    padding: 0.85rem 1rem;
    font-size: var(--fs-base);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--gray-200);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all var(--dur) var(--ease-out);
}
.login-box .form-control:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--gray-300);
}
.login-box .form-control:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03), var(--shadow-focus);
}

.login-box .form-group label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    font-weight: 700;
}

/* Bouton login premium : gradient + shimmer subtil au hover */
.login-box .btn-primary {
    padding: 0.85rem 1.1rem;
    font-size: var(--fs-base);
    font-weight: 600;
    letter-spacing: -0.005em;
    background: linear-gradient(180deg, #1d6dff 0%, #0b5cff 100%);
    border: 1px solid #0847c5;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4) inset,
        0 2px 6px rgba(11, 92, 255, 0.35),
        0 8px 20px rgba(11, 92, 255, 0.25);
    position: relative;
    overflow: hidden;
}
.login-box .btn-primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.25) 50%,
        transparent 100%
    );
    transition: left 600ms var(--ease-out);
}
.login-box .btn-primary:hover {
    background: linear-gradient(180deg, #2d7aff 0%, #0b5cff 100%);
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5) inset,
        0 4px 10px rgba(11, 92, 255, 0.45),
        0 14px 30px rgba(11, 92, 255, 0.32);
}
.login-box .btn-primary:hover::after {
    left: 100%;
}
.login-box .btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.login-error {
    background: rgba(255, 241, 242, 0.9);
    border: 1px solid rgba(252, 165, 165, 0.6);
    border-left: 3px solid #ef4444;
    color: #9f1239;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

/* Subtle inner glow (gradient doux en diagonale) */
.login-box::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(255, 255, 255, 0.02) 50%,
        rgba(11, 92, 255, 0.04) 100%
    );
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
}

/* ─── Footer de l'application (pages connectées) ───────────────────────── */
.app-footer {
    padding: 1.25rem 1rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--gray-200);
    margin-top: 2rem;
    background: var(--surface-alt);
}

.app-footer-links {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-bottom: 0.55rem;
}

.app-footer-links a {
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    display: inline-block;
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
}
.app-footer-links a:hover {
    color: var(--primary);
}

.app-footer-sep {
    color: var(--gray-300);
}

.app-footer-credit {
    margin: 0;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
    /* iatko + version groupés à droite */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0 1.25rem;
}
.app-footer-credit .app-footer-version {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* iatko link dans le footer : couleur foncée plate (pas de gradient),
   soulignement uniquement sur le mot "iatko" pas sur le logo */
.app-footer-credit .login-credit-link {
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
    -webkit-text-fill-color: #0C1727 !important;
    color: #0C1727 !important;
    animation: none !important;
}
.app-footer-credit .login-credit-link::after {
    display: none;
}
.app-footer-credit .iatko-text {
    position: relative;
    display: inline-block;
}
.app-footer-credit .iatko-text::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background: #0C1727;
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.app-footer-credit .login-credit-link:hover .iatko-text::after {
    transform: scaleX(1);
}

/* Sur mobile : footer padding compact + safe-area pour iPhone notch */
@media (max-width: 640px) {
    .app-footer {
        padding: 1rem 0.75rem 1.25rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
    .app-footer-links {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.25rem;
        flex-wrap: wrap;
    }
}

/* Stack vertical : login-box + footer credit en dessous */
.login-stack {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    width: 100%;
    max-width: 440px;
}

/* Footer de credit sous l'encart de connexion */
.login-credit {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    margin: 0;
    letter-spacing: 0.01em;
    animation: loginFieldIn 500ms 500ms var(--ease-ios) both;
}

.login-credit-link {
    position: relative;
    display: inline-block;
    font-weight: 800;
    font-size: 1em;
    text-decoration: none;
    padding: 0.1em 0.25em;
    background: linear-gradient(
        135deg,
        #0b5cff 0%,
        #7c3aed 50%,
        #e11d48 100%
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    letter-spacing: 0;
    animation: iatkoGradientShift 6s ease-in-out infinite;
    transition: transform var(--dur) var(--ease-spring);
}

.login-credit-link::after {
    content: "";
    position: absolute;
    left: 0.25em;
    right: 0.25em;
    bottom: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        #0b5cff 0%,
        #7c3aed 50%,
        #e11d48 100%
    );
    background-size: 200% 100%;
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform var(--dur-slow) var(--ease-ios);
    animation: iatkoGradientShiftBar 6s ease-in-out infinite;
}

.login-credit-link:hover {
    transform: translateY(-1px) scale(1.05);
    text-decoration: none;
}
.login-credit-link:hover::after {
    transform: scaleX(1);
}

@keyframes iatkoGradientShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}
@keyframes iatkoGradientShiftBar {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* Respect reduced motion : pas d'aurora floating */
@media (prefers-reduced-motion: reduce) {
    .login-container::before,
    .login-container::after {
        animation: none;
    }
    .login-credit-link,
    .login-credit-link::after {
        animation: none;
    }
}

/* ─── Tabs (dossier client) ─────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.7rem 1.4rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    text-decoration: none;
    transition: color var(--dur) var(--ease-out),
                border-color var(--dur) var(--ease-out),
                background-color var(--dur) var(--ease-out);
    white-space: nowrap;
    letter-spacing: -0.005em;
    border-radius: 8px 8px 0 0;
}
.tab:hover {
    color: var(--text-primary);
    text-decoration: none;
    background: var(--gray-50);
}
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    border-bottom-width: 2px;
    font-weight: 600;
}

.tab-panel {
    display: none;
}
.tab-panel-active {
    display: block;
    animation: tabFadeIn var(--dur-slow) var(--ease-out);
}
@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Couleurs de lignes par statut d'intervention ─────────────────────── */
tr.row-statut-a_faire  td { color: #111827; }
tr.row-statut-en_cours td { color: #1d4ed8; font-weight: 500; }
tr.row-statut-termine  td { color: #15803d; }
tr.row-statut-annule   td { color: #e87c7c; }
tr.row-statut-annule   td:last-child { color: inherit; }

tr.row-statut-a_faire:hover  { background: var(--gray-50); }
tr.row-statut-en_cours:hover { background: #eff6ff; }
tr.row-statut-termine:hover  { background: #f0fdf4; }
tr.row-statut-annule:hover   { background: #fff1f2; }

/* ─── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--text-tertiary);
}

.empty-state p {
    font-size: var(--fs-base);
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ─── Modals (convention standardisée) ──────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(6px) saturate(1.1);
    backdrop-filter: blur(6px) saturate(1.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: overlayIn var(--dur) var(--ease-out);
}
.modal-overlay.is-closing {
    animation: overlayOut var(--dur-fast) var(--ease-out) forwards;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: min(560px, 92vw);
    width: 100%;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn var(--dur-slow) var(--ease-spring);
}
.modal-overlay.is-closing .modal {
    animation: modalOut var(--dur-fast) var(--ease-out) forwards;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: background var(--dur-fast), color var(--dur-fast);
}
.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.4rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--gray-200);
    background: var(--surface-alt);
}

/* ─── Liste des doublons d'adresse (client_form) ─────────────────────────── */
.doublon-liste {
    list-style: none;
    padding: 0;
    margin: 0;
}
.doublon-liste li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-200);
}
.doublon-liste li:last-child {
    border-bottom: none;
}
.doublon-liste .doublon-infos {
    flex: 1;
    min-width: 0;
}
.doublon-liste .doublon-code {
    font-weight: 600;
    color: var(--text-primary);
}
.doublon-liste .doublon-adresse,
.doublon-liste .doublon-tel {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes overlayOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes modalOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.96); }
}

/* ─── Animations universelles pour n'importe quel modal (is-opening / is-closing)
   Appliquées par le helper JS sur tout élément fermé via data-modal-close.
   Style Apple-esque : cubic-bezier long out, scale subtil, opacity. ─────── */

@keyframes genericModalIn {
    0%   { opacity: 0; transform: scale(0.92) translateY(12px); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes genericModalOut {
    0%   { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.94) translateY(6px); }
}
@keyframes genericBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes genericBackdropOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* Animation générique universelle, appliquée par JS à tout modal ouvert/fermé via data-modal-* */
.is-opening {
    animation: genericBackdropIn var(--dur-slow) var(--ease-out) both;
}
.is-opening > :first-child {
    animation: genericModalIn var(--dur-slow) var(--ease-spring) both;
}
.is-closing {
    animation: genericBackdropOut 200ms var(--ease-out) both;
    pointer-events: none;
}
.is-closing > :first-child {
    animation: genericModalOut 200ms var(--ease-out) both;
}

/* Si le modal utilise la nouvelle convention .modal-overlay, on utilise ses propres keyframes */
.modal-overlay.is-opening {
    animation: overlayIn var(--dur) var(--ease-out) both;
}
.modal-overlay.is-opening > :first-child {
    animation: modalIn var(--dur-slow) var(--ease-spring) both;
}
.modal-overlay.is-closing {
    animation: overlayOut 200ms var(--ease-out) both;
    pointer-events: none;
}
.modal-overlay.is-closing > :first-child {
    animation: modalOut 200ms var(--ease-out) both;
}

@media (max-width: 640px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: modalSheetIn var(--dur-slow) var(--ease-out);
    }
    .modal-overlay.is-closing .modal {
        animation: modalSheetOut var(--dur-fast) var(--ease-out) forwards;
    }
    @keyframes modalSheetIn {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    @keyframes modalSheetOut {
        from { transform: translateY(0); }
        to   { transform: translateY(100%); }
    }
}

/* ─── Toasts (notifications) ────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.toast {
    --toast-accent: var(--primary);
    min-width: 280px;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-left: 3px solid var(--toast-accent);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    pointer-events: auto;
    animation: toastIn var(--dur-slow) var(--ease-spring);
}
.toast.is-closing {
    animation: toastOut var(--dur-fast) var(--ease-out) forwards;
}

.toast--success { --toast-accent: var(--success); }
.toast--error   { --toast-accent: var(--danger); }
.toast--warning { --toast-accent: var(--warning); }
.toast--info    { --toast-accent: var(--info); }

.toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--toast-accent);
    margin-top: 1px;
}

.toast-content {
    flex: 1;
    line-height: 1.45;
}

.toast-close {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.25rem;
    transition: color var(--dur-fast);
}
.toast-close:hover {
    color: var(--text-primary);
}

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

@media (max-width: 640px) {
    .toast-container {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
    }
    .toast {
        min-width: 0;
        max-width: 100%;
        animation: toastInMobile var(--dur-slow) var(--ease-spring);
    }
    .toast.is-closing {
        animation: toastOutMobile var(--dur-fast) var(--ease-out) forwards;
    }
    @keyframes toastInMobile {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes toastOutMobile {
        from { opacity: 1; transform: translateY(0); }
        to   { opacity: 0; transform: translateY(100%); }
    }
}

/* ─── Skeleton loaders ──────────────────────────────────────────────────── */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg,
        var(--gray-100) 0%,
        var(--gray-200) 50%,
        var(--gray-100) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
    color: transparent;
    user-select: none;
    pointer-events: none;
}

.skeleton--text {
    display: inline-block;
    width: 100%;
    height: 0.9em;
    margin-top: 0.25em;
}

.skeleton--title {
    display: block;
    width: 60%;
    height: 1.4em;
    margin-bottom: 0.6em;
}

.skeleton--avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton--row {
    display: block;
    width: 100%;
    height: 3rem;
    margin-bottom: 0.4rem;
    border-radius: var(--radius);
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Système d'animation global ────────────────────────────────────────── */

/* Entrée de page : fade-in + translate discret sur le .container principal */
.container {
    animation: pageIn var(--dur-slow) var(--ease-out);
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stagger d'apparition sur les enfants directs de grilles et listes
   (CSS pur via nth-child, cap à 10 enfants pour ne pas retarder les grandes listes) */

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

.dashboard-grid > .stat-card,
.admin-grid > .admin-card,
tbody > tr {
    animation: staggerIn var(--dur-slow) var(--ease-out) both;
}
.dashboard-grid > .stat-card:nth-child(1),
.admin-grid > .admin-card:nth-child(1),
tbody > tr:nth-child(1)  { animation-delay: 0ms; }
.dashboard-grid > .stat-card:nth-child(2),
.admin-grid > .admin-card:nth-child(2),
tbody > tr:nth-child(2)  { animation-delay: 30ms; }
.dashboard-grid > .stat-card:nth-child(3),
.admin-grid > .admin-card:nth-child(3),
tbody > tr:nth-child(3)  { animation-delay: 60ms; }
.dashboard-grid > .stat-card:nth-child(4),
.admin-grid > .admin-card:nth-child(4),
tbody > tr:nth-child(4)  { animation-delay: 90ms; }
.dashboard-grid > .stat-card:nth-child(5),
.admin-grid > .admin-card:nth-child(5),
tbody > tr:nth-child(5)  { animation-delay: 120ms; }
.dashboard-grid > .stat-card:nth-child(6),
.admin-grid > .admin-card:nth-child(6),
tbody > tr:nth-child(6)  { animation-delay: 150ms; }
.dashboard-grid > .stat-card:nth-child(7),
.admin-grid > .admin-card:nth-child(7),
tbody > tr:nth-child(7)  { animation-delay: 180ms; }
.dashboard-grid > .stat-card:nth-child(8),
.admin-grid > .admin-card:nth-child(8),
tbody > tr:nth-child(8)  { animation-delay: 210ms; }
.dashboard-grid > .stat-card:nth-child(9),
.admin-grid > .admin-card:nth-child(9),
tbody > tr:nth-child(9)  { animation-delay: 240ms; }
.dashboard-grid > .stat-card:nth-child(10),
.admin-grid > .admin-card:nth-child(10),
tbody > tr:nth-child(10) { animation-delay: 270ms; }
/* Au-delà du 10e enfant, apparition immédiate */
.dashboard-grid > .stat-card:nth-child(n+11),
.admin-grid > .admin-card:nth-child(n+11),
tbody > tr:nth-child(n+11) {
    animation: none;
    opacity: 1;
    transform: none;
}

/* Désactiver le stagger sur les tables marquées "dense" */
.table-dense tbody > tr {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Badge qui change d'état : pulse léger */
.badge.is-changing {
    animation: badgePulse var(--dur-slow) var(--ease-spring);
}
@keyframes badgePulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Flash messages : slide-in depuis le haut à l'apparition */
.flash-message {
    animation: flashSlideIn var(--dur-slow) var(--ease-out);
}
@keyframes flashSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Row highlight bref (ajouter la classe .row-flash sur un <tr> ou un div pour surligner) */
.row-flash {
    animation: rowFlash 1.4s var(--ease-out);
}
@keyframes rowFlash {
    0%   { background-color: var(--primary-light); box-shadow: inset 3px 0 0 var(--primary); }
    100% { background-color: transparent; box-shadow: inset 3px 0 0 transparent; }
}

/* Highlight sur cellule qui vient d'être mise à jour */
.cell-flash {
    animation: cellFlash 1.2s var(--ease-out);
}
@keyframes cellFlash {
    0%   { background-color: var(--primary-light); }
    100% { background-color: transparent; }
}

/* Icônes qui pivotent au hover (classe .icon-spin-hover sur un parent) */
.icon-spin-hover .spin-target {
    transition: transform var(--dur) var(--ease-spring);
}
.icon-spin-hover:hover .spin-target {
    transform: rotate(90deg);
}

/* Shake subtil pour signaler une erreur (classe .shake temporaire) */
.shake {
    animation: shake 0.45s var(--ease-out);
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(3px); }
}

/* Bounce in (pour les éléments qui apparaissent avec du caractère) */
.bounce-in {
    animation: bounceIn var(--dur-slow) var(--ease-back);
}
@keyframes bounceIn {
    0%   { opacity: 0; transform: scale(0.85); }
    70%  { opacity: 1; transform: scale(1.03); }
    100% { opacity: 1; transform: scale(1); }
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .topbar-nav,
    .topbar-user {
        display: none;
    }
    .topbar-brand {
        padding: 0 0.5rem;
    }
    .nav-toggle {
        display: flex;
        align-items: center;
        margin-left: auto;
    }

    .topbar-nav.open {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        background: var(--module-color);
        z-index: 999;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
        overflow-y: auto;
        overflow-x: hidden;
        max-height: calc(100dvh - var(--topbar-height));
        transform-origin: top center;
    }
    .topbar-nav.open .nav-item {
        height: auto;
        padding: 1rem 1.35rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        border-left: 3px solid transparent;
        font-size: 0.95rem;
        border-radius: 0;
        transform: none;
    }
    .topbar-nav.open .nav-item.active {
        border-left-color: rgba(255, 255, 255, 0.9);
        background: rgba(0, 0, 0, 0.2);
    }

    /* Backdrop derrière le menu mobile (animé via Motion ; transition CSS = fallback)
       z-index 99 : sous le stacking context de .topbar (z-index 100) pour ne pas masquer le menu. */
    .topbar-backdrop {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        backdrop-filter: blur(0);
        -webkit-backdrop-filter: blur(0);
        transition: opacity 80ms ease-out;
        pointer-events: none;
    }
    .topbar-backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Rotation du hamburger quand le menu est ouvert */
    .nav-toggle {
        transition: transform var(--dur) var(--ease-spring),
                    color var(--dur) var(--ease-out);
    }
    .topbar:has(.topbar-nav.open) .nav-toggle {
        transform: rotate(90deg);
    }

    .topbar-user.in-menu {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        height: auto;
        padding: 1rem 1.35rem;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        background: var(--module-dark);
    }
    .topbar-user.in-menu .topbar-username,
    .topbar-user.in-menu .topbar-logout {
        color: rgba(255,255,255,0.75);
        font-size: 0.85rem;
    }
    .topbar-user.in-menu .topbar-logout:hover {
        color: #fff;
    }

    .page-header {
        padding: 0.65rem 1rem;
    }
    .container {
        padding: 1rem;
        overflow-x: hidden;
    }

    .form-control,
    select.form-control,
    textarea.form-control {
        font-size: 16px;
        min-height: 44px;
    }

    .form-group label {
        text-transform: none;
        letter-spacing: 0;
        font-size: var(--fs-sm);
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 900px) {
    .search-form .form-control,
    .toolbar .form-control {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-card--wide {
        grid-column: span 2;
    }
    .devis-stats {
        gap: 1.5rem;
    }

    .card {
        padding: 1rem;
        border-left: none;
    }
    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
    .form-actions {
        flex-wrap: wrap;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-form {
        flex-direction: column;
    }
    .search-form .form-control,
    .search-form input[type="date"] {
        display: block;
        min-width: 0;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    .search-form .btn {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .btn-group {
        flex-wrap: wrap;
    }

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

@media (max-width: 400px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .stat-card--wide {
        grid-column: span 1;
    }
    .devis-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

/* Indicateurs d'encaissement dans la liste documents */
.encaiss-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 1rem;
    vertical-align: middle;
}
.encaiss-indicator.encaiss-solde {
    color: var(--success);
}
.encaiss-indicator.encaiss-partiel {
    color: var(--warning);
}
/* Badge statut impayes */
.badge-impayes {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* Badge statut litige */
.badge-litige {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #dc2626;
}

/* ─── Mobile enhancements ──��───────────────────────────────────────────── */

/* Safe area for notched phones (iPhone X+) */
@supports (padding: env(safe-area-inset-bottom)) {
    .topbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ─── Generic table→card mobile transformation ────────────────────────── */
/* Only activates on tables that contain td[data-label] elements          */
@media (max-width: 768px) {
    .table-responsive:has(td[data-label]) {
        overflow: visible;
    }
    .table-responsive:has(td[data-label]) table thead {
        display: none;
    }
    .table-responsive:has(td[data-label]) table,
    .table-responsive:has(td[data-label]) table tbody {
        display: block;
        width: 100%;
    }
    .table-responsive:has(td[data-label]) table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--gray-200);
        border-left: none;
        border-radius: var(--radius);
        margin-bottom: 0.6rem;
        padding: 0.5rem 0;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .table-responsive:has(td[data-label]) table tbody tr:nth-child(even) {
        background: var(--gray-50, #f5f6f8);
    }
    .table-responsive:has(td[data-label]) table tbody tr:last-child {
        margin-bottom: 0;
    }
    .table-responsive:has(td[data-label]) table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0.85rem;
        border-bottom: none;
        text-align: right;
        font-size: 0.85rem;
        gap: 0.5rem;
    }
    .table-responsive:has(td[data-label]) table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--gray-500);
        text-align: left;
        flex-shrink: 0;
        white-space: nowrap;
    }
    .table-responsive:has(td[data-label]) table tbody td[data-label=""]::before,
    .table-responsive:has(td[data-label]) table tbody td:not([data-label])::before {
        display: none;
    }
    /* Hide checkbox-only cells on mobile */
    .table-responsive:has(td[data-label]) table tbody td[data-label=""]:has(input[type="checkbox"]:only-child) {
        display: none;
    }
    .table-responsive:has(td[data-label]) table tbody td:has(.btn-group) {
        justify-content: flex-end;
        padding-top: 0.45rem;
        border-top: 1px solid var(--gray-100);
        margin-top: 0.15rem;
    }
    .table-responsive:has(td[data-label]) table tbody td:has(.btn-group) .btn-group {
        width: 100%;
        justify-content: stretch;
    }
    .table-responsive:has(td[data-label]) table tbody td:has(.btn-group) .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
    .table-responsive:has(td[data-label]) table tbody td:has(.dropdown) {
        display: block;
        padding-top: 0.45rem;
        border-top: 1px solid var(--gray-100);
        margin-top: 0.15rem;
    }
    /* Dropdown inline dans les cards (pas de position:fixed) */
    .table-responsive:has(td[data-label]) .dropdown {
        display: block;
        width: 100%;
    }
    .table-responsive:has(td[data-label]) .dropdown-toggle {
        width: 100%;
        justify-content: center;
    }
    .table-responsive:has(td[data-label]) .dropdown-menu {
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        display: none;
        width: 100%;
        box-shadow: none;
        border: 1px solid var(--gray-200);
        border-radius: 0 0 var(--radius) var(--radius);
        margin-top: -1px;
    }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu {
        display: block;
        transform-origin: top center;
        animation: dropdownInMobile 0.28s var(--ease-out) both;
    }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > a,
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > button {
        animation: dropdownItemInMobile 0.32s var(--ease-out) both;
    }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(1) { animation-delay: 0.04s; }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(2) { animation-delay: 0.08s; }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(3) { animation-delay: 0.12s; }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(4) { animation-delay: 0.16s; }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(5) { animation-delay: 0.20s; }
    .table-responsive:has(td[data-label]) .dropdown.open .dropdown-menu > *:nth-child(n+6) { animation-delay: 0.22s; }
    @keyframes dropdownInMobile {
        from {
            opacity: 0;
            clip-path: inset(0 0 100% 0);
            transform: translateY(-4px);
        }
        to {
            opacity: 1;
            clip-path: inset(0 0 0 0);
            transform: translateY(0);
        }
    }
    @keyframes dropdownItemInMobile {
        from { opacity: 0; transform: translateX(-10px); }
        to   { opacity: 1; transform: translateX(0); }
    }
    /* Statut dropdown inline aussi */
    .table-responsive:has(td[data-label]) .statut-dropdown-menu {
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        display: none;
        width: 100%;
        box-shadow: none;
        border: 1px solid var(--gray-200);
        border-radius: 0 0 var(--radius) var(--radius);
        margin-top: 0.25rem;
    }
    .table-responsive:has(td[data-label]) .statut-dropdown.open .statut-dropdown-menu {
        display: block;
    }

    /* Empty state rows: full width */
    .table-responsive:has(td[data-label]) table tbody tr:has(.empty-state) {
        display: block;
        text-align: center;
        border: 1px dashed var(--gray-300);
    }
    .table-responsive:has(td[data-label]) table tbody td.empty-state {
        display: block;
        padding: 2rem 1rem;
        text-align: center;
    }
    .table-responsive:has(td[data-label]) table tbody td.empty-state::before {
        display: none;
    }

    /* ─── Clients list: compact card layout ─────────────────────────────── */
    .table-clients tbody tr {
        display: grid !important;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto;
        padding: 0.7rem 0.85rem !important;
        gap: 0.1rem 0.5rem;
    }
    .table-clients tbody tr.row-liste-rouge {
        border-left: 3px solid #e11d48;
    }
    .table-clients tbody td {
        display: block !important;
        text-align: left !important;
        padding: 0 !important;
    }
    .table-clients tbody td::before {
        display: none !important;
    }
    /* Code client: top-left, discret */
    .table-clients tbody td[data-label="Code"] {
        grid-column: 1;
        grid-row: 1;
        font-size: 0.72rem;
        color: var(--gray-400);
        letter-spacing: 0.03em;
    }
    .table-clients tbody td[data-label="Code"] strong {
        font-weight: 500;
    }
    /* Badge contrat: top-right */
    .table-clients tbody td[data-label="Contrat"] {
        grid-column: 2;
        grid-row: 1;
        text-align: right !important;
        align-self: center;
    }
    /* Nom: row 2, pleine largeur, mis en avant */
    .table-clients tbody td[data-label="Nom"] {
        grid-column: 1 / -1;
        grid-row: 2;
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--gray-900);
        margin-top: 0.05rem;
    }
    /* Adresse: row 3, discret */
    .table-clients tbody td[data-label="Adresse"] {
        grid-column: 1 / -1;
        grid-row: 3;
        color: var(--gray-500);
        font-size: 0.8rem;
        margin-top: 0.15rem;
        line-height: 1.3;
    }
    /* Téléphone: row 4, lien cliquable */
    .table-clients tbody td[data-label="Téléphone"] {
        grid-column: 1 / -1;
        grid-row: 4;
        margin-top: 0.2rem;
        font-size: 0.82rem;
    }
    .table-clients tbody td[data-label="Téléphone"] a {
        color: var(--primary);
        font-weight: 500;
    }
    /* Boutons actions: row 5, pleine largeur */
    .table-clients tbody td[data-label="Actions"] {
        grid-column: 1 / -1;
        grid-row: 5;
        border-top: 1px solid var(--gray-100);
        margin-top: 0.45rem;
        padding-top: 0.45rem !important;
    }
    .table-clients tbody td[data-label="Actions"] .btn-group {
        display: flex;
        width: 100%;
    }
    .table-clients tbody td[data-label="Actions"] .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
        font-size: 0.82rem;
        padding: 0.4rem 0.5rem;
    }

    /* Strip outer .card wrapper when it contains clients table */
    .card:has(.table-clients) {
        padding: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }
    .card:has(.table-clients) > #pagination {
        padding: 0.5rem 0.25rem 0;
    }
}


@media (max-width: 900px) {
    /* Bigger hamburger touch target */
    .nav-toggle {
        font-size: 1.5rem;
        min-width: 48px;
        min-height: 48px;
        justify-content: center;
    }

    /* Active tap feedback on nav items */
    .topbar-nav.open .nav-item:active {
        background: rgba(255,255,255,0.15);
    }

    /* Form section full-width on mobile */
    .form-section {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    /* Container tighter padding on small screens */
    .container {
        padding: 0.75rem;
        padding-bottom: 3rem;
    }

    /* Touch-friendly buttons */
    .btn {
        min-height: 44px;
    }

    /* Stagger cappé à 6 enfants sur mobile (perception plus rapide) */
    .dashboard-grid > .stat-card:nth-child(n+7),
    .admin-grid > .admin-card:nth-child(n+7),
    tbody > tr:nth-child(n+7) {
        animation: none;
        opacity: 1;
        transform: none;
    }

    /* Form actions full-width buttons */
    .form-actions {
        flex-direction: column;
    }
    .form-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
    }

    /* Touch-friendly pagination */
    .pagination a,
    .pagination span {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        border-radius: var(--radius);
    }

    /* Toggle group mobile sizing */
    .toggle-group {
        width: 100%;
    }
    .toggle-btn {
        flex: 1;
        padding: 0.5rem 0.5rem;
        font-size: 0.82rem;
        text-align: center;
    }

    /* Better badge visibility on mobile */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.55rem;
    }

    /* Dropdown menus wider on mobile */
    .dropdown-menu {
        min-width: 180px;
    }
    .dropdown-menu a {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Statut dropdown touch-friendly */
    .statut-dropdown-menu .statut-option {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Flash messages mobile */
    .flash-message {
        font-size: 0.82rem;
        padding: 0.7rem 0.85rem;
    }

    /* Empty state compact on mobile */
    .empty-state {
        padding: 2rem 1rem;
    }

    /* Login box mobile */
    .login-box {
        padding: 2rem 1.5rem;
        margin: 0.75rem;
        border-radius: 16px;
    }
    .login-box h1 {
        font-size: 1.3rem;
    }
    .login-box .subtitle {
        font-size: 0.82rem;
        margin-bottom: 1.5rem;
    }

    /* Active tap feedback on buttons */
    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* Active tap feedback on cards */
    .card:active {
        transform: scale(0.99);
    }

    /* Admin cards 1 column earlier */
    .admin-card {
        padding: 1rem;
    }
    .admin-card-title {
        font-size: 0.95rem;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 0.5rem;
        padding-bottom: 2.5rem;
    }

    /* Even tighter card padding */
    .card {
        padding: 0.75rem;
        border-radius: var(--radius);
    }

    /* Login box very small screens */
    .login-box {
        padding: 1.5rem 1.2rem;
        margin: 0.5rem;
        border-radius: 12px;
    }
    .login-box img.login-logo {
        width: 160px;
        margin-bottom: 1rem;
    }
    .login-box h1 {
        font-size: 1.15rem;
    }

    /* Buttons full-width on very small screens */
    .toolbar .btn {
        width: 100%;
        justify-content: center;
    }

    /* Stat values smaller */
    .stat-value {
        font-size: 1.25rem;
    }
    .stat-value--lg {
        font-size: 1.4rem;
    }

    /* Form section body tighter */
    .form-section-body {
        padding: 0.85rem;
    }
}

/* Badges relance (suivi) */
.suivi-badge-bleu { background: #eff6ff; color: #1e40af; }

/* Badges relance (documents) */
.badge-relance { display: inline-block; padding: 0.12rem 0.4rem; border-radius: 4px; font-size: 0.68rem; font-weight: 700; margin-left: 0.3rem; vertical-align: middle; letter-spacing: 0.02em; }
.badge-relance-1 { background: #fef3c7; color: #92400e; }
.badge-relance-2 { background: #ffedd5; color: #9a3412; }
.badge-relance-3 { background: #fee2e2; color: #991b1b; }
.badge-relance-md { background: #450a0a; color: #fecaca; }
.badge-relance-due { background: transparent; border: 1.5px dashed; }
.badge-relance-due.badge-relance-1 { border-color: #f59e0b; color: #92400e; }
.badge-relance-due.badge-relance-2 { border-color: #f97316; color: #9a3412; }
.badge-relance-due.badge-relance-3 { border-color: #ef4444; color: #991b1b; }

/* ─── Accessibilité : reduced-motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .skeleton {
        animation: none;
        background: var(--gray-100);
    }
    .container {
        animation: none;
    }
    .dashboard-grid > .stat-card,
    .admin-grid > .admin-card,
    tbody > tr {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* Badge « chèque en main » — signale qu'un chèque physique doit être récupéré au bureau */
.badge-cheque {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    margin-left: 0.4rem;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

/* Documentation intégration Mitel — admin */
.mitel-doc-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.mitel-doc-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}
.mitel-doc-card h4 {
    margin-bottom: 0.4rem;
}
.mitel-doc-card code {
    background: var(--gray-100, #f3f4f6);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.9em;
}
.mitel-code {
    background: #1f2937;
    color: #e5e7eb;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0.4rem 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Page d'accueil appel entrant Mitel */
.appel-entrant-card {
    max-width: 720px;
    margin: 1.5rem auto;
}
.appel-entrant-numero {
    font-size: var(--fs-base);
    margin-bottom: 1rem;
}
.appel-entrant-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.appel-entrant-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}
.appel-entrant-list li {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.appel-entrant-list li:last-child {
    border-bottom: none;
}
.appel-entrant-list a {
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}
.appel-entrant-list a:hover {
    color: var(--primary);
}
.appel-entrant-meta {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
}

/* Lien d'appel Mitel (callto:) — desktop uniquement, masqué sur mobile */
.tel-call-link {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    vertical-align: middle;
    line-height: 1;
    transition: color 0.15s ease;
}
.tel-call-link:hover {
    color: var(--primary-dark);
}
@media (max-width: 768px) {
    .tel-call-link { display: none; }
}

/* ─── Stagger d'apparition des lignes de listings ─────────────────────────────
   Pattern CSS pur, identique à celui des `.kpi-card` du dashboard :
   `animation-fill-mode: both` impose `opacity: 0` AVANT le délai et pendant
   l'animation, sync au paint via le CSS render-blocking — donc aucun flash
   visible→caché possible. Au-delà de 18 lignes : pas d'animation.

   Cible : les listings paginés (`tbody#list-content`) et tout tbody opt-in
   (`tbody[data-stagger]`). À chaque update AJAX live-search, le tbody est
   remplacé via innerHTML : les nouvelles `<tr>` rejouent automatiquement
   l'animation, sans code JS ad-hoc. */
@keyframes rowFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

tbody#list-content > tr,
tbody[data-stagger] > tr {
    animation: rowFadeIn 1.4s cubic-bezier(0.32, 0.72, 0, 1) both;
}

tbody#list-content > tr:nth-child(1),
tbody[data-stagger] > tr:nth-child(1)  { animation-delay: 0.20s; }
tbody#list-content > tr:nth-child(2),
tbody[data-stagger] > tr:nth-child(2)  { animation-delay: 0.33s; }
tbody#list-content > tr:nth-child(3),
tbody[data-stagger] > tr:nth-child(3)  { animation-delay: 0.46s; }
tbody#list-content > tr:nth-child(4),
tbody[data-stagger] > tr:nth-child(4)  { animation-delay: 0.59s; }
tbody#list-content > tr:nth-child(5),
tbody[data-stagger] > tr:nth-child(5)  { animation-delay: 0.72s; }
tbody#list-content > tr:nth-child(6),
tbody[data-stagger] > tr:nth-child(6)  { animation-delay: 0.85s; }
tbody#list-content > tr:nth-child(7),
tbody[data-stagger] > tr:nth-child(7)  { animation-delay: 0.98s; }
tbody#list-content > tr:nth-child(8),
tbody[data-stagger] > tr:nth-child(8)  { animation-delay: 1.11s; }
tbody#list-content > tr:nth-child(9),
tbody[data-stagger] > tr:nth-child(9)  { animation-delay: 1.24s; }
tbody#list-content > tr:nth-child(10),
tbody[data-stagger] > tr:nth-child(10) { animation-delay: 1.37s; }
tbody#list-content > tr:nth-child(11),
tbody[data-stagger] > tr:nth-child(11) { animation-delay: 1.50s; }
tbody#list-content > tr:nth-child(12),
tbody[data-stagger] > tr:nth-child(12) { animation-delay: 1.63s; }
tbody#list-content > tr:nth-child(13),
tbody[data-stagger] > tr:nth-child(13) { animation-delay: 1.76s; }
tbody#list-content > tr:nth-child(14),
tbody[data-stagger] > tr:nth-child(14) { animation-delay: 1.89s; }
tbody#list-content > tr:nth-child(15),
tbody[data-stagger] > tr:nth-child(15) { animation-delay: 2.02s; }
tbody#list-content > tr:nth-child(16),
tbody[data-stagger] > tr:nth-child(16) { animation-delay: 2.15s; }
tbody#list-content > tr:nth-child(17),
tbody[data-stagger] > tr:nth-child(17) { animation-delay: 2.28s; }
tbody#list-content > tr:nth-child(18),
tbody[data-stagger] > tr:nth-child(18) { animation-delay: 2.41s; }

tbody#list-content > tr:nth-child(n+19),
tbody[data-stagger] > tr:nth-child(n+19) {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    tbody#list-content > tr,
    tbody[data-stagger] > tr {
        animation: none;
    }
}

