/* ═══════════════════════════════════════════════════════════════════════════
   AMB-FLOW — Design system
   Palette relevée sur l'application Glide d'origine (screen/*.png).
   Aucun framework : tout est défini ici, les écrans se contentent d'assembler.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 1. Tokens ─────────────────────────────────────────────────────────── */

:root {
    /* Marque */
    --jaune: #fdc902;
    --jaune-fonce: #e3b402;
    --jaune-sombre: #b58f00;
    --jaune-clair: #fff6d6;
    --jaune-voile: rgba(253, 201, 2, 0.16);

    /* Surfaces */
    --fond: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #ebebee;
    --bordure: #e9e9ec;
    --bordure-forte: #d6d6dc;

    /* Texte */
    --texte: #282828;
    --texte-2: #6b6b70;
    --texte-3: #9a9aa0;
    --texte-inverse: #ffffff;
    --sur-jaune: #3a2e00;

    /* Pôles */
    --pole-commerce: #b49000;
    --pole-bureau-etudes: #1ba2bd;
    --pole-production: #935aea;
    --pole-pose: #00ae00;
    --pole-comptabilite: #d5296f;
    --pole-archives: #6b6b70;

    /* Sémantique */
    --succes: #0e9f6e;
    --alerte: #f59e0b;
    --danger: #e02424;
    --info: #1ba2bd;
    --succes-voile: rgba(14, 159, 110, 0.12);
    --alerte-voile: rgba(245, 158, 11, 0.14);
    --danger-voile: rgba(224, 36, 36, 0.1);
    --info-voile: rgba(27, 162, 189, 0.12);

    /* Rayons */
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-plein: 999px;

    /* Ombres */
    --ombre-1: 0 1px 2px rgba(16, 16, 20, 0.06);
    --ombre-2: 0 2px 8px rgba(16, 16, 20, 0.08);
    --ombre-3: 0 8px 24px rgba(16, 16, 20, 0.12);
    --ombre-4: 0 20px 48px rgba(16, 16, 20, 0.2);

    /* Espacements — échelle de 4 px */
    --e1: 4px;
    --e2: 8px;
    --e3: 12px;
    --e4: 16px;
    --e5: 20px;
    --e6: 24px;
    --e8: 32px;
    --e10: 40px;
    --e12: 48px;

    /* Typographie */
    --police: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --police-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Structure */
    --largeur-sidebar: 252px;
    --hauteur-topbar: 64px;

    /* Empilement */
    --z-sidebar: 40;
    --z-topbar: 30;
    --z-scrim: 45;
    --z-modal: 60;
    --z-flash: 70;

    --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);

    color-scheme: light;
}

[data-theme="dark"] {
    --jaune: #fdc902;
    --jaune-fonce: #ffd633;
    --jaune-sombre: #c79f00;
    --jaune-clair: #3a2f05;
    --jaune-voile: rgba(253, 201, 2, 0.14);

    --fond: #131317;
    --surface: #1b1b21;
    --surface-2: #23232b;
    --surface-3: #2c2c35;
    --bordure: #2f2f39;
    --bordure-forte: #3d3d49;

    --texte: #ececf0;
    --texte-2: #a4a4b0;
    --texte-3: #74747f;
    --texte-inverse: #131317;
    --sur-jaune: #2a2100;

    --pole-commerce: #d4ac1a;
    --pole-bureau-etudes: #3fc0da;
    --pole-production: #ab7bf5;
    --pole-pose: #35c935;
    --pole-comptabilite: #f0568f;
    --pole-archives: #9a9aa6;

    --succes: #2fc38f;
    --alerte: #fbbf3f;
    --danger: #f56565;
    --info: #3fc0da;

    --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ombre-2: 0 2px 8px rgba(0, 0, 0, 0.45);
    --ombre-3: 0 8px 24px rgba(0, 0, 0, 0.5);
    --ombre-4: 0 20px 48px rgba(0, 0, 0, 0.6);

    color-scheme: dark;
}

/* ─── 2. Réinitialisation ───────────────────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: var(--police);
    font-size: 15px;
    line-height: 1.5;
    color: var(--texte);
    background: var(--fond);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 700;
    line-height: 1.25;
    color: var(--texte);
}

h1 {
    font-size: 1.7rem;
}
h2 {
    font-size: 1.25rem;
}
h3 {
    font-size: 1.05rem;
}
h4 {
    font-size: 0.95rem;
}

p {
    margin: 0 0 var(--e3);
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    max-width: 100%;
    vertical-align: middle;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--jaune-fonce);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection {
    background: var(--jaune-voile);
}

/* Barres de défilement discrètes, y compris en thème sombre */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bordure-forte) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: var(--bordure-forte);
    border: 3px solid transparent;
    border-radius: var(--r-plein);
    background-clip: content-box;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ─── 3. Structure : sidebar + contenu ──────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    width: var(--largeur-sidebar);
    padding: var(--e4) 0 var(--e3);
    background: var(--jaune);
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: transform var(--transition);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--e3);
    padding: 0 var(--e4) var(--e5);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--sur-jaune);
    letter-spacing: -0.01em;
}

/*
   La barre latérale reste jaune dans les deux thèmes : son encre est donc
   toujours l'encre sur jaune. Le blanc pur qui servait ici ne donnait que
   1,55:1 — les quinze intitulés du menu se lisaient à la forme du mot, sur
   les vingt écrans de l'application.
*/

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--sur-jaune);
    background: #fff;
    border-radius: var(--r-md);
    box-shadow: var(--ombre-1);
    flex: none;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--e3);
}

.nav-section {
    padding: var(--e4) var(--e3) var(--e2);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(58, 46, 0, 0.78);
}

.nav-separateur {
    height: 1px;
    margin: var(--e3) var(--e3);
    background: rgba(58, 46, 0, 0.22);
    border: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--e3);
    min-height: 40px;
    padding: var(--e2) var(--e3);
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--sur-jaune);
    border-radius: var(--r-md);
    transition: background var(--transition);
}

.nav-item:hover {
    background: rgba(58, 46, 0, 0.10);
}

.nav-item.active {
    background: #fff;
    box-shadow: var(--ombre-1);
}

.nav-item .icone {
    width: 1.25em;
    text-align: center;
    flex: none;
}

.nav-item .compteur {
    margin-left: auto;
    padding: 1px 7px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--sur-jaune);
    background: #fff;
    border-radius: var(--r-plein);
}

.sidebar .spacer {
    flex: 1 1 auto;
    min-height: var(--e6);
}

.theme-toggle {
    margin: 0 var(--e4) var(--e3);
    padding: var(--e2) var(--e3);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--texte-inverse);
    text-align: left;
    background: rgba(255, 255, 255, 0.2);
    border: 0;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--transition);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.32);
}

.user-box {
    display: flex;
    align-items: center;
    gap: var(--e3);
    margin: 0 var(--e3);
    padding: var(--e3);
    font-size: 0.85rem;
    color: var(--sur-jaune);
    background: rgba(255, 255, 255, 0.55);
    border-radius: var(--r-md);
}

.user-box strong {
    display: block;
    font-size: 0.9rem;
}

.user-box a {
    font-size: 0.78rem;
    text-decoration: underline;
    opacity: 0.85;
}

.content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--largeur-sidebar);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
    display: flex;
    align-items: center;
    gap: var(--e4);
    min-height: var(--hauteur-topbar);
    padding: var(--e3) var(--e6);
    background: color-mix(in srgb, var(--fond) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--bordure);
}

.topbar .breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--e2);
    min-width: 0;
    font-size: 0.85rem;
    color: var(--texte-2);
}

.topbar .breadcrumb .courant {
    font-weight: 600;
    color: var(--texte);
}

.topbar .actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2);
    margin-left: auto;
}

.hamburger {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-md);
    cursor: pointer;
    flex: none;
}

.page-body {
    flex: 1 1 auto;
    padding: var(--e6);
    min-width: 0;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e4);
    margin-bottom: var(--e5);
}

.page-head .titre {
    min-width: 0;
}

.page-head .surtitre {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--jaune-sombre);
}

.page-head .sous-titre {
    margin: var(--e1) 0 0;
    color: var(--texte-2);
}

.page-head .outils {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2);
    margin-left: auto;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: var(--z-scrim);
    background: rgba(16, 16, 20, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

body.tiroir-ouvert .scrim {
    opacity: 1;
    visibility: visible;
}

/* ─── 4. Cartes et statistiques ─────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    box-shadow: var(--ombre-1);
}

.card + .card {
    margin-top: var(--e4);
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e3);
    padding: var(--e4) var(--e5);
    border-bottom: 1px solid var(--bordure);
}

.card-head h2,
.card-head h3 {
    margin: 0;
}

.card-head .outils {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2);
    margin-left: auto;
}

.card-body {
    padding: var(--e5);
}

.card-body.serre {
    padding: var(--e3);
}

.card-body.plat {
    padding: 0;
}

.grille {
    display: grid;
    gap: var(--e4);
}

.grille-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grille-3 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--e4);
    margin-bottom: var(--e5);
}

.stat-card {
    position: relative;
    padding: var(--e4) var(--e5);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    box-shadow: var(--ombre-1);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent, var(--jaune));
}

.stat-card .libelle {
    display: flex;
    align-items: center;
    gap: var(--e2);
    font-size: 0.9rem;
    font-weight: 700;
}

.stat-card .valeur {
    margin-top: var(--e1);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-card .detail {
    font-size: 0.85rem;
    color: var(--texte-2);
}

/* ─── 5. Boutons ────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--e2);
    min-height: 40px;
    padding: var(--e2) var(--e4);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--texte);
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.btn:hover {
    background: var(--surface-2);
}

.btn:active {
    transform: translateY(1px);
}

.btn[disabled],
.btn.desactive {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    color: var(--sur-jaune);
    background: var(--jaune);
    border-color: var(--jaune);
    box-shadow: var(--ombre-1);
}

.btn-primary:hover {
    background: var(--jaune-fonce);
    border-color: var(--jaune-fonce);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--texte-2);
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--texte);
}

.btn-danger {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    background: var(--danger-voile);
}

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

.btn-succes {
    color: var(--succes);
    border-color: color-mix(in srgb, var(--succes) 35%, transparent);
    background: var(--succes-voile);
}

.btn-succes:hover {
    color: #fff;
    background: var(--succes);
    border-color: var(--succes);
}

.btn-sm {
    min-height: 32px;
    padding: var(--e1) var(--e3);
    font-size: 0.82rem;
}

.btn-lg {
    min-height: 48px;
    padding: var(--e3) var(--e6);
    font-size: 1rem;
}

.btn-bloc {
    width: 100%;
}

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 40px;
    min-height: 40px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    min-height: 32px;
}

.btn-groupe {
    display: inline-flex;
    gap: var(--e1);
    padding: 3px;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.btn-groupe .btn {
    min-height: 32px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.btn-groupe .btn.actif {
    background: var(--surface);
    box-shadow: var(--ombre-1);
}

/* ─── 6. Barre d'outils, recherche, filtres ─────────────────────────────── */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e2);
    margin-bottom: var(--e4);
}

.toolbar .grandit {
    flex: 1 1 220px;
    min-width: 0;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 260px;
    min-width: 0;
}

.search .icone {
    position: absolute;
    left: var(--e3);
    color: var(--texte-3);
    pointer-events: none;
}

.search input {
    width: 100%;
    min-height: 40px;
    padding: var(--e2) var(--e4) var(--e2) var(--e8);
    font-size: 16px; /* évite le zoom automatique iOS */
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    transition: background var(--transition), border-color var(--transition);
}

.search input::placeholder {
    color: var(--texte-3);
}

.search input:focus {
    background: var(--surface);
    border-color: var(--bordure-forte);
}

.filtres {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2);
    align-items: center;
}

.filtres select,
.filtres input {
    min-height: 40px;
    padding: var(--e2) var(--e3);
    font-size: 0.9rem;
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
}

/* ─── 7. Tableaux ───────────────────────────────────────────────────────── */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--e3) var(--e4);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--texte-2);
    text-align: left;
    white-space: nowrap;
    background: var(--surface);
    border-bottom: 1px solid var(--bordure);
}

.table td {
    padding: var(--e3) var(--e4);
    border-bottom: 1px solid var(--bordure);
    vertical-align: middle;
}

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

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

.table tbody tr:hover {
    background: var(--surface-2);
}

/* En-têtes triables : le curseur et la flèche disent que la colonne réagit. */
.table th[data-tri] {
    cursor: pointer;
    user-select: none;
}

.table th[data-tri]:hover {
    color: var(--texte);
    background: var(--surface-2);
}

.table th[data-tri]::after {
    content: "↕";
    margin-left: var(--e1);
    opacity: 0.35;
}

.table th[aria-sort="ascending"]::after {
    content: "↑";
    opacity: 1;
    color: var(--jaune-sombre);
}

.table th[aria-sort="descending"]::after {
    content: "↓";
    opacity: 1;
    color: var(--jaune-sombre);
}

/* La croix native du champ de recherche doublonne avec nos boutons de fermeture. */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* Valeur copiable d'un clic : téléphone, adresse e-mail, référence. */
.copiable {
    display: inline-flex;
    align-items: center;
    gap: var(--e1);
    padding: 1px var(--e1);
    margin: -1px calc(var(--e1) * -1);
    border-radius: var(--r-xs);
    cursor: copy;
    transition: background var(--transition);
}

.copiable:hover {
    background: var(--jaune-clair);
}

.copiable::after {
    content: "⧉";
    font-size: 0.8em;
    color: var(--texte-3);
}

.copiable:hover::after {
    color: var(--jaune-sombre);
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    /* Sans cela « 1 216,36 » et « € » se séparaient sur deux lignes : la colonne
       se désalignait et un millier isolé se relisait comme un autre nombre. */
    white-space: nowrap;
    min-width: 9ch;
}

.table .actions-cellule {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.row-link {
    cursor: pointer;
}

/* Liste type Glide : surtitre de statut, titre, sous-titre, actions, chevron */
.liste {
    display: flex;
    flex-direction: column;
}

.liste-ligne {
    display: flex;
    align-items: center;
    gap: var(--e4);
    padding: var(--e3) var(--e5);
    border-bottom: 1px solid var(--bordure);
    transition: background var(--transition);
}

.liste-ligne:last-child {
    border-bottom: 0;
}

.liste-ligne:hover {
    background: var(--surface-2);
}

.liste-ligne .corps {
    flex: 1 1 auto;
    min-width: 0;
}

.liste-ligne .surtitre {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    /* Le statut portait toujours le même olive alors que chaque statut a déjà
       sa couleur côté serveur : « Devis perdu » et « Facturée » se lisaient
       pareil sur quarante lignes. La teinte est fournie par le gabarit. */
    color: color-mix(in srgb, var(--teinte, var(--jaune-sombre)) 68%, var(--texte));
}

.liste-ligne .titre {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.liste-ligne .sous-titre {
    font-size: 0.85rem;
    color: var(--texte-2);
}

.liste-ligne .actions {
    display: flex;
    align-items: center;
    gap: var(--e2);
    flex: none;
}

.chevron {
    color: var(--texte-3);
    flex: none;
}

/* ─── 8. Badges et pastilles ────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--e1);
    padding: 2px var(--e2);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    border-radius: var(--r-plein);
    background: var(--surface-2);
    color: var(--texte-2);
}

.badge-point::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Un badge coloré : la teinte vient d'une variable posée en ligne ou par classe */
.badge-teinte {
    /* La teinte pure sur son propre voile plafonnait à 2:1 en 12 px gras. En la
       mêlant au texte courant, l'encre fonce en thème clair et s'éclaircit en
       thème sombre : la couleur reste porteuse de sens et redevient lisible. */
    color: color-mix(in srgb, var(--teinte) 64%, var(--texte));
    background: color-mix(in srgb, var(--teinte) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--teinte) 32%, transparent);
}

.badge-pole-commerce { --teinte: var(--pole-commerce); }
.badge-pole-bureau-etudes { --teinte: var(--pole-bureau-etudes); }
.badge-pole-production { --teinte: var(--pole-production); }
.badge-pole-pose { --teinte: var(--pole-pose); }
.badge-pole-comptabilite { --teinte: var(--pole-comptabilite); }
.badge-pole-archives { --teinte: var(--pole-archives); }

.badge-priorite-prioritaire { --teinte: var(--danger); }
.badge-priorite-secondaire { --teinte: var(--texte-2); }
.badge-priorite-a-regrouper { --teinte: var(--info); }

.badge-statut-deposee { --teinte: var(--alerte); }
.badge-statut-validee { --teinte: var(--succes); }
.badge-statut-refusee { --teinte: var(--danger); }

.badge-ndf-en-cours { --teinte: var(--alerte); }
.badge-ndf-acceptee { --teinte: var(--info); }
.badge-ndf-refusee { --teinte: var(--danger); }
.badge-ndf-remboursee { --teinte: var(--succes); }

.badge-evenement-a-planifier { --teinte: var(--alerte); }
.badge-evenement-planifie { --teinte: var(--succes); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
    padding: var(--e1) var(--e3);
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--bordure);
    border-radius: var(--r-plein);
}

.chip button {
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--texte-3);
    background: none;
    border: 0;
    cursor: pointer;
}

.pastille {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teinte, var(--jaune));
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--jaune-sombre);
    background: var(--jaune-clair);
    border-radius: var(--r-plein);
    object-fit: cover;
    flex: none;
    overflow: hidden;
}

.avatar-sm {
    width: 26px;
    height: 26px;
    font-size: 0.68rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
}

.avatar-groupe {
    display: inline-flex;
}

.avatar-groupe .avatar + .avatar {
    margin-left: -10px;
    border: 2px solid var(--surface);
}

/* ─── 9. Kanban ─────────────────────────────────────────────────────────── */

.kanban {
    display: flex;
    gap: var(--e4);
    padding-bottom: var(--e4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.kanban-col {
    display: flex;
    flex-direction: column;
    /* Largeur fixe, la dernière colonne se retrouvait tranchée en plein milieu
       des cartes sur la tablette d'atelier. */
    flex: 0 0 clamp(15rem, 78vw, 19rem);
    min-width: 0;
    max-height: calc(100dvh - var(--hauteur-topbar) - var(--e12) * 2);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    scroll-snap-align: start;
    transition: border-color var(--transition), background var(--transition);
}

.kanban-col.survol {
    border-color: var(--jaune);
    background: var(--jaune-clair);
}

.kanban-col.refus {
    border-color: var(--danger);
    background: var(--danger-voile);
}

.kanban-col-head {
    display: flex;
    align-items: center;
    gap: var(--e2);
    padding: var(--e3) var(--e4);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--texte-2);
    border-bottom: 1px solid var(--bordure);
    position: sticky;
    top: 0;
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    z-index: 1;
}

.kanban-col-head .compteur {
    margin-left: auto;
    padding: 1px 7px;
    font-size: 0.72rem;
    background: var(--surface-2);
    border-radius: var(--r-plein);
}

.kanban-col-body {
    display: flex;
    flex-direction: column;
    gap: var(--e3);
    padding: var(--e3);
    overflow-y: auto;
    min-height: 120px;
}

.kanban-card {
    display: block;
    padding: var(--e3) var(--e4);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-left: 3px solid var(--teinte, var(--bordure-forte));
    border-radius: var(--r-md);
    box-shadow: var(--ombre-1);
    cursor: grab;
    transition: box-shadow var(--transition), transform var(--transition), opacity var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--ombre-2);
    transform: translateY(-1px);
}

.kanban-card.deplacement {
    opacity: 0.45;
    cursor: grabbing;
}

.kanban-card .titre {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.kanban-card .prescripteur {
    font-size: 0.82rem;
    color: var(--texte-2);
    overflow-wrap: anywhere;
}

.kanban-card .valeur {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.kanban-card .pied {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e2);
    margin-top: var(--e2);
}

/* ─── 10. Formulaires ───────────────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--e4);
}

.form-grid .pleine-largeur {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--e1);
    min-width: 0;
}

/* `.field` est une <label> qui enveloppe son champ : seul l'intitulé doit
   afficher le curseur de sélection, pas la zone de saisie elle-même. */
label.field {
    cursor: default;
}

label.field > .field-label {
    cursor: pointer;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--texte);
}

.field-label .requis {
    color: var(--danger);
}

.field-aide {
    font-size: 0.8rem;
    color: var(--texte-2);
}

.field-input,
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="url"],
.field input[type="number"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="datetime-local"],
.field select,
.field textarea {
    width: 100%;
    min-height: 42px;
    padding: var(--e2) var(--e3);
    font-size: 16px; /* évite le zoom automatique iOS */
    color: var(--texte);
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.field textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--jaune);
    box-shadow: 0 0 0 3px var(--jaune-voile);
    outline: none;
}

.field input[readonly],
.field input[disabled],
.field select[disabled],
.field textarea[disabled] {
    background: var(--surface-2);
    color: var(--texte-2);
    cursor: not-allowed;
}

.field.erreur input,
.field.erreur select,
.field.erreur textarea {
    border-color: var(--danger);
}

.field-error {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--danger);
}

.field-statique {
    padding: var(--e2) 0;
    font-weight: 600;
}

/* Interrupteur « Afficher/Cacher » de la fiche affaire */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: none;
    width: 48px;
    height: 28px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch .piste {
    width: 100%;
    height: 100%;
    background: var(--bordure-forte);
    border-radius: var(--r-plein);
    transition: background var(--transition);
}

.switch .curseur {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--ombre-1);
    transition: transform var(--transition);
}

.switch input:checked ~ .piste {
    background: var(--jaune);
}

.switch input:checked ~ .curseur {
    transform: translateX(20px);
}

.switch input:focus-visible ~ .piste {
    outline: 2px solid var(--jaune-fonce);
    outline-offset: 2px;
}

.case-a-cocher {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
    min-height: 40px;
    cursor: pointer;
}

.case-a-cocher input {
    width: 18px;
    height: 18px;
    accent-color: var(--jaune-sombre);
}

.radio-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--e2);
}

.radio-carte {
    display: flex;
    align-items: center;
    gap: var(--e2);
    padding: var(--e3);
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.radio-carte:has(input:checked) {
    border-color: var(--jaune);
    background: var(--jaune-clair);
}


/* ─── 10 bis. Choix directs : segments, cartes et boutons de décision ────── */

/*
   Un choix parmi deux à quatre valeurs se prend d'un geste, pas en dépliant
   une liste. Ces trois composants remplacent les <select> courts.
*/

.choix-segmente {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--bordure);
    border-radius: var(--r-md);
}

.choix-segmente label {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--e2);
    flex: 1 1 auto;
    min-width: 0;
    min-height: 36px;
    padding: var(--e1) var(--e3);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--texte-2);
    text-align: center;
    white-space: nowrap;
    border-radius: calc(var(--r-md) - 3px);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.choix-segmente label:hover {
    color: var(--texte);
}

.choix-segmente input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.choix-segmente label:has(input:checked) {
    color: var(--teinte, var(--texte));
    background: var(--surface);
    box-shadow: var(--ombre-1);
}

.choix-segmente label:has(input:focus-visible) {
    outline: 2px solid var(--jaune-fonce);
    outline-offset: 1px;
}

.choix-segmente label:has(input:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Variantes colorées : contrôle qualité, décisions. */
.choix-segmente .oui { --teinte: var(--succes); }
.choix-segmente .non { --teinte: var(--danger); }
.choix-segmente .neutre { --teinte: var(--texte-2); }

/* Cartes de choix : une valeur, une explication. */
.choix-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--e2);
}

.choix-carte {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--e3);
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.choix-carte:hover {
    border-color: var(--teinte, var(--jaune));
}

.choix-carte input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.choix-carte .intitule {
    font-weight: 700;
    font-size: 0.9rem;
}

.choix-carte .mention {
    font-size: 0.8rem;
    color: var(--texte-2);
}

.choix-carte:has(input:checked) {
    border-color: var(--teinte, var(--jaune));
    background: color-mix(in srgb, var(--teinte, var(--jaune)) 10%, var(--surface));
    box-shadow: inset 0 0 0 1px var(--teinte, var(--jaune));
}

.choix-carte:has(input:focus-visible) {
    outline: 2px solid var(--jaune-fonce);
    outline-offset: 2px;
}

/* Boutons de décision : une action par bouton, pleine largeur. */
.boutons-decision {
    display: grid;
    gap: var(--e2);
}

.boutons-decision .btn {
    justify-content: flex-start;
    min-height: 52px;
    padding: var(--e3) var(--e4);
    text-align: left;
}

.boutons-decision .btn .intitule {
    font-weight: 700;
}

.boutons-decision .btn .mention {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.75;
}

.boutons-decision .btn .icone {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    background: color-mix(in srgb, currentColor 14%, transparent);
    border-radius: var(--r-plein);
    flex: none;
}

/* Bouton en cours de soumission : on empêche le double envoi. */
.btn[aria-busy="true"] {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--sur-jaune);
    animation: rotation 700ms linear infinite;
}

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

/* Champ de filtrage d'une longue liste (référentiel matières). */
.liste-filtrable {
    display: flex;
    flex-direction: column;
    gap: var(--e2);
}

.liste-filtrable select {
    min-height: 220px;
    font-family: var(--police-mono);
    font-size: 0.85rem;
}

.liste-filtrable .decompte {
    font-size: 0.8rem;
    color: var(--texte-2);
}

/* ─── 11. Modals ────────────────────────────────────────────────────────── */

dialog.modal {
    width: min(680px, calc(100vw - var(--e8)));
    max-width: none;
    max-height: 90dvh;
    padding: 0;
    color: var(--texte);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-xl);
    box-shadow: var(--ombre-4);
    overflow: hidden;
}

dialog.modal.large {
    width: min(960px, calc(100vw - var(--e8)));
}

dialog.modal.etroite {
    width: min(460px, calc(100vw - var(--e8)));
}

dialog.modal::backdrop {
    background: rgba(16, 16, 20, 0.5);
    backdrop-filter: blur(2px);
}

dialog.modal[open] {
    display: flex;
    flex-direction: column;
    animation: modal-entree 180ms cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes modal-entree {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

.modal-form {
    display: contents;
}

.modal-head {
    display: flex;
    align-items: center;
    gap: var(--e3);
    padding: var(--e4) var(--e5);
    border-bottom: 1px solid var(--bordure);
    flex: none;
}

.modal-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.modal-head .fermer {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    color: var(--texte-2);
    background: transparent;
    border: 0;
    border-radius: var(--r-md);
    cursor: pointer;
    flex: none;
}

.modal-head .fermer:hover {
    background: var(--surface-2);
    color: var(--texte);
}

.modal-body {
    flex: 1 1 auto;
    padding: var(--e5);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--e2);
    padding: var(--e4) var(--e5);
    background: var(--surface-2);
    border-top: 1px solid var(--bordure);
    flex: none;
}

.modal-foot .a-gauche {
    margin-right: auto;
}

/* Clic sur le fond alors qu'une saisie est en cours : la fenêtre le signale
   au lieu de se fermer et de faire perdre le travail. */
dialog.modal.saisie-en-cours {
    animation: modal-refus 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes modal-refus {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

dialog.modal-danger .modal-head {
    color: var(--danger);
}

.modal-message {
    display: flex;
    gap: var(--e4);
    align-items: flex-start;
}

.modal-message .icone {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    background: var(--danger-voile);
    border-radius: var(--r-plein);
    flex: none;
}

/* ─── 11 bis. Palette de recherche globale (Ctrl + K) ───────────────────── */

.raccourci-recherche {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
    min-height: 36px;
    margin-left: var(--e4);
    padding: var(--e1) var(--e3);
    font-size: 0.85rem;
    color: var(--texte-2);
    background: var(--surface-2);
    border: 1px solid var(--bordure);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.raccourci-recherche:hover {
    background: var(--surface);
    color: var(--texte);
}

kbd {
    padding: 1px 5px;
    font-family: var(--police);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--texte-2);
    background: var(--surface);
    border: 1px solid var(--bordure-forte);
    border-bottom-width: 2px;
    border-radius: var(--r-xs);
}

dialog.palette {
    width: min(620px, calc(100vw - var(--e8)));
    max-height: 70dvh;
    padding: 0;
    margin-top: 10dvh;
    color: var(--texte);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-xl);
    box-shadow: var(--ombre-4);
    overflow: hidden;
}

dialog.palette[open] {
    display: flex;
    flex-direction: column;
    animation: modal-entree 160ms cubic-bezier(0.2, 0, 0.2, 1);
}

dialog.palette::backdrop {
    background: rgba(16, 16, 20, 0.5);
    backdrop-filter: blur(2px);
}

.palette-saisie {
    display: flex;
    align-items: center;
    gap: var(--e3);
    padding: var(--e3) var(--e4);
    border-bottom: 1px solid var(--bordure);
    flex: none;
}

.palette-saisie .icone {
    color: var(--texte-3);
    font-size: 1.1rem;
}

.palette-saisie input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    font-size: 16px;
    background: none;
    border: 0;
    outline: none;
}

.palette-saisie .fermer {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: var(--texte-3);
    background: none;
    border: 0;
    border-radius: var(--r-md);
    cursor: pointer;
    flex: none;
}

.palette-saisie .fermer:hover {
    background: var(--surface-2);
    color: var(--texte);
}

.palette-corps {
    flex: 1 1 auto;
    padding: var(--e2);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.palette-etat:empty {
    display: none;
}

.palette-etat {
    margin: 0;
    padding: var(--e5) var(--e3);
    font-size: 0.88rem;
    color: var(--texte-2);
    text-align: center;
}

.palette-titre {
    padding: var(--e3) var(--e3) var(--e1);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--texte-3);
}

.palette-resultat {
    display: flex;
    align-items: center;
    gap: var(--e3);
    padding: var(--e2) var(--e3);
    border-radius: var(--r-md);
    cursor: pointer;
}

.palette-resultat .corps {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.palette-resultat .titre {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.palette-resultat .mention {
    font-size: 0.8rem;
    color: var(--texte-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.palette-resultat:hover,
.palette-resultat.actif {
    background: var(--jaune-clair);
}

.palette-pied {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e3);
    padding: var(--e2) var(--e4);
    font-size: 0.75rem;
    color: var(--texte-3);
    background: var(--surface-2);
    border-top: 1px solid var(--bordure);
    flex: none;
}

.palette-pied .a-droite {
    margin-left: auto;
}

@media (max-width: 640px) {
    .raccourci-recherche .libelle,
    .raccourci-recherche kbd {
        display: none;
    }

    .raccourci-recherche {
        margin-left: auto;
    }

    dialog.palette {
        width: 100vw;
        max-width: none;
        max-height: 100dvh;
        height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .palette-pied {
        display: none;
    }
}

/* ─── 12. Onglets ───────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: var(--e1);
    margin-bottom: var(--e5);
    overflow-x: auto;
    border-bottom: 1px solid var(--bordure);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
    padding: var(--e3) var(--e4);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--texte-2);
    white-space: nowrap;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.tab:hover {
    color: var(--texte);
}

.tab-active {
    color: var(--texte);
    border-bottom-color: var(--jaune);
}

.tab .compteur {
    padding: 0 6px;
    font-size: 0.72rem;
    color: var(--sur-jaune);
    background: var(--jaune-clair);
    border-radius: var(--r-plein);
}

.tab-panneau[hidden] {
    display: none !important;
}

/* ─── 13. Sections repliables (fiche affaire) ───────────────────────────── */

.section-repliable {
    border-bottom: 1px solid var(--bordure);
}

.section-repliable:last-child {
    border-bottom: 0;
}

.section-entete {
    display: flex;
    align-items: center;
    gap: var(--e3);
    width: 100%;
    padding: var(--e4) var(--e5);
    background: none;
    border: 0;
    cursor: pointer;
    text-align: left;
}

.section-entete h2 {
    font-size: 1.15rem;
}

.section-entete .mention {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--texte-2);
}

.section-corps {
    padding: 0 var(--e5) var(--e5);
}

.section-corps[hidden] {
    display: none !important;
}

/* Barre d'actions collante en pied de fiche */
.barre-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: var(--e3);
    padding: var(--e4) var(--e5);
    margin-top: var(--e6);
    background: #3d3100;
    border-radius: var(--r-lg);
    box-shadow: var(--ombre-3);
}

.barre-actions .btn {
    flex: 1 1 220px;
}

.barre-actions .btn:not(.btn-primary) {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.barre-actions .btn:not(.btn-primary):hover {
    background: rgba(255, 255, 255, 0.16);
}

/* ─── 14. Définitions (en-tête de fiche) ────────────────────────────────── */

.definitions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--e8);
}

.definition {
    display: flex;
    align-items: center;
    gap: var(--e3);
    padding: var(--e3) 0;
    border-bottom: 1px solid var(--bordure);
}

.definition dt {
    font-size: 0.9rem;
    color: var(--texte-2);
}

.definition dd {
    margin: 0 0 0 auto;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

/* ─── 15. Planning ──────────────────────────────────────────────────────── */

.planning {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--e4);
    align-items: start;
}

.cal {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.cal-entete {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e3);
    padding: var(--e3) var(--e4);
    border-bottom: 1px solid var(--bordure);
}

.cal-entete .periode {
    font-weight: 800;
}

.cal-entete .semaine {
    font-size: 0.8rem;
    color: var(--texte-2);
}

.cal-entete .navigation {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2);
    margin-left: auto;
}

.cal-entete .btn-groupe {
    flex-wrap: wrap;
}

.cal-mois {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-mois .jour-entete {
    padding: var(--e2);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--texte-2);
    text-align: center;
    border-bottom: 1px solid var(--bordure);
}

.cal-jour {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 110px;
    padding: var(--e2);
    border-right: 1px solid var(--bordure);
    border-bottom: 1px solid var(--bordure);
}

.cal-jour:nth-child(7n) {
    border-right: 0;
}

.cal-jour .numero {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--texte-2);
    text-align: right;
}

.cal-jour.hors-mois {
    background: var(--surface-2);
}

.cal-jour.hors-mois .numero {
    color: var(--texte-3);
}

.cal-jour.aujourdhui {
    background: var(--jaune-clair);
}

.cal-jour.aujourdhui .numero {
    color: var(--jaune-sombre);
}

.cal-semaine {
    display: grid;
    grid-template-columns: 64px repeat(7, minmax(96px, 1fr));
    max-height: 70dvh;
    overflow: auto;
}

.cal-semaine .coin,
.cal-semaine .jour-entete {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: var(--e2);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    background: var(--surface);
    border-bottom: 1px solid var(--bordure);
}

.cal-semaine .heure {
    position: sticky;
    left: 0;
    z-index: 1;
    padding: var(--e1) var(--e2);
    font-size: 0.72rem;
    color: var(--texte-3);
    text-align: right;
    background: var(--surface);
    border-right: 1px solid var(--bordure);
    border-bottom: 1px solid var(--bordure);
}

.cal-creneau {
    min-height: 44px;
    padding: 2px;
    border-right: 1px solid var(--bordure);
    border-bottom: 1px solid var(--bordure);
    cursor: pointer;
}

.cal-creneau:hover {
    background: var(--jaune-clair);
}

.cal-creneau.week-end {
    background: var(--surface-2);
}

.cal-event {
    display: block;
    padding: 3px var(--e2);
    margin-bottom: 2px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--teinte, var(--texte));
    background: color-mix(in srgb, var(--teinte, var(--jaune)) 14%, transparent);
    border-left: 3px solid var(--teinte, var(--jaune));
    border-radius: var(--r-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.cal-event:hover {
    background: color-mix(in srgb, var(--teinte, var(--jaune)) 24%, transparent);
}

.file-planifier {
    position: sticky;
    top: calc(var(--hauteur-topbar) + var(--e4));
    max-height: calc(100dvh - var(--hauteur-topbar) - var(--e8));
    display: flex;
    flex-direction: column;
}

.file-planifier .card-body {
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: flex-start;
    gap: var(--e3);
    padding: var(--e3) var(--e4);
    border-bottom: 1px solid var(--bordure);
}

.file-item:last-child {
    border-bottom: 0;
}

.file-item .corps {
    flex: 1 1 auto;
    min-width: 0;
}

.file-item .type {
    font-weight: 700;
    font-size: 0.88rem;
}

.file-item .contexte {
    font-size: 0.8rem;
    color: var(--texte-2);
    overflow-wrap: anywhere;
}

/* ─── 16. Graphiques (SVG maison, sans librairie) ───────────────────────── */

.graphique {
    display: flex;
    flex-direction: column;
    gap: var(--e4);
}

.graphique svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.graphique .legende {
    display: flex;
    flex-wrap: wrap;
    gap: var(--e2) var(--e4);
    font-size: 0.82rem;
}

.graphique .legende span {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
}

.graphique .grille-axe {
    stroke: var(--bordure);
    stroke-width: 1;
}

.graphique .etiquette-axe {
    fill: var(--texte-3);
    font-size: 11px;
}

.graphique .barre {
    transition: opacity var(--transition);
}

.graphique .barre:hover,
.graphique .arc:hover {
    opacity: 0.8;
}

.graphique .valeur-centre {
    fill: var(--texte);
    font-size: 22px;
    font-weight: 800;
    text-anchor: middle;
}

.graphique .libelle-centre {
    fill: var(--texte-2);
    font-size: 11px;
    text-anchor: middle;
}

/* ─── 17. Messages, états vides, pagination ─────────────────────────────── */

.flashes {
    position: fixed;
    top: var(--e4);
    right: var(--e4);
    z-index: var(--z-flash);
    display: flex;
    flex-direction: column;
    gap: var(--e2);
    width: min(400px, calc(100vw - var(--e8)));
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: var(--e3);
    padding: var(--e3) var(--e4);
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-left: 4px solid var(--teinte, var(--jaune));
    border-radius: var(--r-md);
    box-shadow: var(--ombre-3);
    animation: flash-entree 200ms ease-out;
}

@keyframes flash-entree {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
}

.flash-success { --teinte: var(--succes); }
.flash-error,
.flash-danger { --teinte: var(--danger); }
.flash-warning { --teinte: var(--alerte); }
.flash-info { --teinte: var(--info); }

.flash .fermer {
    margin-left: auto;
    color: var(--texte-3);
    background: none;
    border: 0;
    cursor: pointer;
}

.encart {
    display: flex;
    gap: var(--e3);
    padding: var(--e3) var(--e4);
    font-size: 0.9rem;
    background: color-mix(in srgb, var(--teinte, var(--info)) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--teinte, var(--info)) 26%, transparent);
    border-radius: var(--r-md);
}

.encart-alerte { --teinte: var(--alerte); }
.encart-danger { --teinte: var(--danger); }
.encart-succes { --teinte: var(--succes); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--e2);
    padding: var(--e12) var(--e5);
    text-align: center;
    color: var(--texte-2);
}

.empty-state .illustration {
    font-size: 2.4rem;
    opacity: 0.55;
}

.empty-state .titre {
    font-size: 1rem;
    font-weight: 700;
    color: var(--texte);
}

.empty-state p {
    max-width: 44ch;
    margin: 0;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--e2);
    padding: var(--e4);
}

.pager .info {
    margin-right: auto;
    font-size: 0.85rem;
    color: var(--texte-2);
}

.progression {
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--r-plein);
    overflow: hidden;
}

.progression span {
    display: block;
    height: 100%;
    background: var(--teinte, var(--jaune));
    border-radius: inherit;
    transition: width var(--transition);
}

/* ─── 18. Divers ────────────────────────────────────────────────────────── */

.pile {
    display: flex;
    flex-direction: column;
    gap: var(--e4);
}

.rangee {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e3);
}

.rangee-fin {
    justify-content: flex-end;
}

.muet {
    color: var(--texte-2);
}

.petit {
    font-size: 0.85rem;
}

.mono {
    font-family: var(--police-mono);
    font-variant-numeric: tabular-nums;
}

.gras {
    font-weight: 700;
}

.tronque {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.carte-localisation {
    width: 100%;
    height: 260px;
    border: 0;
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.photo-vignette {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--bordure);
    border-radius: var(--r-md);
}

.galerie {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--e3);
}

.horloge {
    font-family: var(--police-mono);
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* Écran de connexion (gabarit autonome, sans sidebar) */
.ecran-connexion {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: var(--e5);
    background: linear-gradient(160deg, var(--jaune) 0%, var(--jaune-fonce) 46%, var(--fond) 46%);
}

.carte-connexion {
    width: min(420px, 100%);
    padding: var(--e8);
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--ombre-4);
}

/* ─── 19. Responsive ────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
    .planning {
        grid-template-columns: minmax(0, 1fr);
    }

    .file-planifier {
        position: static;
        max-height: none;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--ombre-4);
    }

    body.tiroir-ouvert .sidebar {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .hamburger {
        display: grid;
    }

    .page-body {
        padding: var(--e4);
    }

    .topbar {
        padding: var(--e3) var(--e4);
    }
}

@media (max-width: 768px) {
    .form-grid,
    .definitions {
        grid-template-columns: minmax(0, 1fr);
    }

    .card-body {
        padding: var(--e4);
    }

    .barre-actions {
        margin-left: calc(var(--e4) * -1);
        margin-right: calc(var(--e4) * -1);
        border-radius: 0;
    }

    /* Le voile suit la fenêtre, jamais la largeur du document. */
    .scrim {
        width: 100vw;
        max-width: 100%;
    }
}

/* Les tableaux se replient en cartes dès la tablette d'atelier : à 820 px ils
   restaient en colonnes serrées, illisibles au doigt, alors que les data-label
   nécessaires étaient déjà posés dans les gabarits. */
@media (max-width: 1024px) {
    body {
        font-size: 14.5px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .page-body {
        padding: var(--e3);
    }

    .stat-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--e3);
    }

    .topbar .actions .btn span.libelle {
        display: none;
    }

    .topbar .actions .btn {
        padding: var(--e2) var(--e3);
    }

    /* Tableaux : passage en cartes empilées, sans dupliquer le balisage */
    .table.cartes-mobile thead {
        display: none;
    }

    .table.cartes-mobile,
    .table.cartes-mobile tbody,
    .table.cartes-mobile tr,
    .table.cartes-mobile td {
        display: block;
        width: 100%;
    }

    .table.cartes-mobile tr {
        margin-bottom: var(--e3);
        background: var(--surface);
        border: 1px solid var(--bordure);
        border-radius: var(--r-md);
        overflow: hidden;
    }

    .table.cartes-mobile td {
        display: flex;
        align-items: center;
        gap: var(--e3);
        padding: var(--e2) var(--e3);
        border-bottom: 1px solid var(--bordure);
        text-align: left;
    }

    .table.cartes-mobile td:last-child {
        border-bottom: 0;
    }

    .table.cartes-mobile td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--texte-2);
    }

    .table.cartes-mobile td:empty {
        display: none;
    }

    .table.cartes-mobile .actions-cellule {
        justify-content: flex-end;
        width: auto;
        background: var(--surface-2);
    }

    .table.cartes-mobile .actions-cellule::before {
        content: none;
    }

    /* Fenêtres en plein écran : c'est `inset: 0` qui fixe les dimensions,
       et non 100vw — cette unité inclut la barre de défilement et laissait
       deux pixels de marge sur le côté. */
    dialog.modal,
    dialog.modal.large,
    dialog.modal.etroite {
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    dialog.modal[open] {
        position: fixed;
        inset: 0;
        /* En plein écran, la fenêtre glisse depuis le bas : une mise à l'échelle
           donnerait l'impression qu'elle se décolle des bords de l'écran. */
        animation: modal-glissement 200ms cubic-bezier(0.2, 0, 0.2, 1);
    }

    @keyframes modal-glissement {
        from {
            opacity: 0;
            transform: translateY(24px);
        }
    }

    .modal-foot {
        position: sticky;
        bottom: 0;
        flex-direction: column-reverse;
    }

    .modal-foot .btn {
        width: 100%;
    }

    .modal-foot .a-gauche {
        margin-right: 0;
    }

    /* Kanban : colonnes plein écran, aimantées */
    .kanban-col {
        flex-basis: 84vw;
        min-width: 84vw;
        max-height: none;
    }

    /* Planning : la vue mois devient une liste par jour */
    .cal-semaine {
        grid-template-columns: 52px repeat(7, minmax(72px, 1fr));
    }

    .cal-jour {
        min-height: 76px;
    }

    .liste-ligne {
        flex-wrap: wrap;
        padding: var(--e3);
    }

    .liste-ligne .actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* La ligne entière est cliquable : le chevron n'apporte rien et occupait une ligne. */
    .liste-ligne .chevron {
        display: none;
    }

    .flashes {
        top: auto;
        right: var(--e3);
        bottom: var(--e3);
        left: var(--e3);
        width: auto;
    }

    .barre-actions {
        flex-direction: column;
        padding: var(--e3);
        /* .page-body passe à --e3 sous 640px : la marge négative doit suivre. */
        margin-left: calc(var(--e3) * -1);
        margin-right: calc(var(--e3) * -1);
    }

    .cal-entete .navigation {
        width: 100%;
        margin-left: 0;
    }

    .barre-actions .btn {
        flex: 1 1 auto;
        width: 100%;
    }

    .tabs {
        margin-left: calc(var(--e3) * -1);
        margin-right: calc(var(--e3) * -1);
        padding: 0 var(--e3);
    }

    .choix-segmente label {
        flex: 1 1 100%;
    }

    .choix-cartes {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ─── 20. Accessibilité et impression ───────────────────────────────────── */

@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;
    }
}

@media print {
    .sidebar,
    .topbar,
    .barre-actions,
    .flashes,
    .toolbar,
    .pager,
    .btn,
    .scrim,
    dialog.modal {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }

    .content {
        margin-left: 0;
    }

    .page-body {
        padding: 0;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
    }

    .section-corps[hidden] {
        display: block !important;
    }

    .table th {
        position: static;
    }

    a[href]::after {
        content: "";
    }
}

/* Aperçu du décompte de jours, annoncé pendant la saisie d'une demande. */
.apercu-decompte {
    margin: var(--e3) 0 0;
    padding: var(--e2) var(--e3);
    font-size: 0.88rem;
    font-weight: 600;
    background: var(--surface-2);
    border-left: 3px solid var(--bordure-forte);
    border-radius: var(--r-sm);
}

.apercu-decompte[data-ton="succes"] {
    color: var(--succes);
    background: var(--succes-voile);
    border-left-color: var(--succes);
}

.apercu-decompte[data-ton="erreur"] {
    color: var(--danger);
    background: var(--danger-voile);
    border-left-color: var(--danger);
}

.apercu-decompte[data-ton="muet"] {
    color: var(--texte-2);
}

/* ─── Barre de filtre d'un tableau en fenêtre ─────────────────────────────
   Les historiques (congés, modulations) se parcouraient à l'œil ; la barre
   les rend cherchables sans aller-retour serveur. */
.barre-filtre {
    display: flex;
    align-items: center;
    gap: var(--e3);
    flex-wrap: wrap;
    padding: 0 0 var(--e3);
}

.barre-filtre .search {
    flex: 1 1 16rem;
    margin: 0;
}

.barre-filtre .petit {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .barre-filtre .petit { flex-basis: 100%; }
}

/* Motif de décision restitué au salarié : la fenêtre de refus promet qu'il
   sera informé « du refus et de son motif » — encore faut-il le lui montrer. */
.motif-decision {
    margin-top: var(--e2);
    padding: var(--e2) var(--e3);
    border-left: 3px solid var(--alerte);
    background: color-mix(in srgb, var(--alerte) 8%, transparent);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: .85rem;
    color: var(--texte-2);
}

.motif-decision .intitule {
    display: block;
    font-weight: 600;
    color: var(--texte);
}

/* ─── Cibles tactiles ────────────────────────────────────────────────────
   L'atelier travaille debout, sur tablette, au doigt. Les boutons d'icône
   mesuraient 31,5 px : au-dessus du minimum d'accessibilité, mais bien en
   dessous du confort. On ne les agrandit que là où le pointeur est un doigt,
   pour ne pas alourdir l'interface à la souris. */
@media (pointer: coarse) {
    .btn-icon,
    .btn-sm.btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    .liste-ligne .actions .btn,
    .table .btn-sm {
        min-height: 40px;
    }

    /* Les cases de la vue mensuelle du planning restent atteignables. */
    .cal-jour,
    .cal-creneau {
        min-height: 56px;
    }
}

/* ─── Bornes de période ──────────────────────────────────────────────────
   Deux champs de date jumeaux ne disent pas lequel est le début : sur l'écran
   qui sert à contrôler les heures avant la paie, une période à l'envers passe
   inaperçue et se lit comme « ce salarié n'a pas pointé ». */
.borne-periode {
    display: inline-flex;
    align-items: center;
    gap: var(--e2);
}

.borne-periode > span {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--texte-2);
}
