@import url('https://fonts.googleapis.com/css2?family=Blinker:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ---- Thème sombre chaud + verre --------------------------------------
     Base : #262626, le gris sombre institutionnel du manuel de marque,
     réchauffé et RELEVÉ en luminosité. Un fond quasi noir écrase le verre —
     il faut un fond suffisamment clair pour que les panneaux translucides
     s'en détachent et se lisent réellement comme du verre posé dessus.

     Les surfaces sont volontairement TRANSLUCIDES : combinées au
     backdrop-filter et aux halos diffus posés derrière la page (voir
     body::before), elles produisent l'effet de verre dépoli. Toute surface
     qui ne peut pas être translucide (le trou du donut, qui doit masquer le
     conic-gradient sous lui) utilise --surface-solid. */
  --bg: #2B2725;
  --bg-2: #35302E;
  --surface: rgba(255, 255, 255, 0.095);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.14);
  --surface-solid: #3A3533;
  --sidebar-bg: rgba(255, 255, 255, 0.10);
  --sidebar-bg-2: rgba(255, 255, 255, 0.06);
  /* Les infobulles débordent la barre latérale et se posent PAR-DESSUS le
     contenu : il leur faut une couleur pleine. Elles réutilisaient
     --sidebar-bg, devenu un blanc quasi transparent avec le thème verre —
     le texte se retrouvait à flotter sur la vignette qu'il recouvrait. */
  --tooltip-bg: rgba(62, 56, 54, 0.72);
  --border: rgba(255, 255, 255, 0.155);
  --border-strong: rgba(255, 255, 255, 0.24);
  /* Liseré clair sur l'arête haute : c'est ce reflet qui fait qu'un panneau
     se lit comme une plaque de verre et non comme un rectangle gris. */
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  --orange: #FF5002;
  --orange-soft: rgba(255, 122, 61, 0.18);
  --orange-dark: #FF8A52;
  --navy: #262626;
  --text: #F4F1EE;
  --text-muted: #ABA49F;
  /* #7C7570 avant : contraste 3,3 sur le fond, illisible en plein soleil sur
     un chantier. #A09993 garde la même teinte et passe 4,5 (minimum WCAG AA)
     sur le fond ET sur les cartes, tout en restant plus discret que
     --text-muted. */
  --text-soft: #A09993;
  /* Teintes d'état remontées en luminosité : les versions claires du thème
     précédent (#1FAE6E, #E5484D…) passent sous le seuil de lisibilité sur
     fond sombre. Les variantes "-soft" deviennent des voiles translucides
     de la même teinte plutôt que des pastels opaques. */
  --green: #4ECF95;
  --green-soft: rgba(78, 207, 149, 0.17);
  --red: #FF7A7A;
  --red-soft: rgba(255, 122, 122, 0.17);
  --amber: #F0C25C;
  --amber-soft: rgba(240, 194, 92, 0.17);
  --purple: #B49CFF;
  --purple-soft: rgba(180, 156, 255, 0.19);
  --purple-dark: #C7B5FF;
  --radius: 24px;
  --radius-sm: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 10px 28px rgba(0, 0, 0, 0.3);
  --glass-blur: saturate(165%) blur(28px);
}

* { box-sizing: border-box; }

/* L'attribut `hidden` du HTML doit gagner sur nos propres règles. Sans ça,
   tout élément à qui une classe donne un `display` (flex, grid…) reste
   VISIBLE malgré `hidden` : la règle du navigateur a une spécificité nulle et
   se fait écraser par la moindre classe. Bug silencieux et déroutant. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  /* Tells the browser to render its OWN chrome in dark mode: date pickers,
     the native <select> popup, scrollbars, autofill. Without it a date field
     keeps a white calendar icon and a light popup that clash badly with the
     rest of the interface. */
  color-scheme: dark;
}

/* The base colour lives on <html>, NOT on <body>: a background set on body is
   propagated to the root canvas and painted in front of negative-z-index
   children, which would bury the ambient halos below under an opaque fill. */
html { background: var(--bg); }

body {
  background-color: transparent;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Halos très diffus, fixes derrière toute la page. Sans eux le verre n'a
   rien à filtrer et les panneaux translucides se lisent comme de simples
   gris plats. Volontairement faibles (8-10 % d'opacité) : on doit les sentir
   plus que les voir. pointer-events:none pour ne jamais gêner un clic. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(50rem 34rem at 14% -10%, rgba(255, 110, 40, 0.26), transparent 62%),
    radial-gradient(40rem 28rem at 96% 0%, rgba(255, 255, 255, 0.10), transparent 58%),
    radial-gradient(56rem 38rem at 78% 108%, rgba(255, 130, 70, 0.15), transparent 62%),
    radial-gradient(70rem 50rem at 50% 40%, rgba(255, 255, 255, 0.035), transparent 70%);
}

h1, h2, h3, h4 {
  font-family: 'Blinker', sans-serif;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0 0 8px 0;
  color: var(--text);
}

a { color: var(--orange); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  margin: 18px 0 18px 18px;
  transition: width .16s ease;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--glass-edge);
  /* Le backdrop-filter des cartes crée un contexte d'empilement par carte ;
     comme elles arrivent APRÈS la barre latérale dans le DOM, elles passaient
     devant, et l'infobulle d'un icône de nav (pourtant en z-index 40 dans son
     propre contexte) se retrouvait cachée derrière la première vignette.
     Poser un z-index sur la barre elle-même remonte tout son contexte
     au-dessus du contenu — en restant sous les fenêtres modales (50) et la
     notification d'alerte (60). */
  position: relative;
  z-index: 30;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  padding: 4px 6px 18px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
  width: 100%;
}
.sidebar .brand img.brand-logo { height: 30px; width: 30px; object-fit: contain; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  margin-bottom: 4px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-link svg, .logout-btn svg, .barre-replier svg { flex: 0 0 auto; }
.nav-liste { width: 100%; display: flex; flex-direction: column; }
/* Le nom de l'entreprise à côté du symbole, quand la barre est dépliée. */
.sidebar .brand-nom { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 14px;
  letter-spacing: .04em; color: #fff; }
/* REPLIÉE : on revient aux icônes seules, et les noms disparaissent. */
.sidebar.icon-only { width: 78px; padding: 22px 14px; align-items: center; }
.sidebar.icon-only .nav-nom, .sidebar.icon-only .brand-nom { display: none; }
.sidebar.icon-only .brand { justify-content: center; padding: 4px 0 20px 0; }
.sidebar.icon-only .nav-link { width: 46px; min-height: 46px; justify-content: center;
  padding: 0; gap: 0; margin-bottom: 6px; }
.sidebar.icon-only .logout-btn { width: 46px; min-height: 46px; justify-content: center;
  padding: 0; gap: 0; }
.sidebar.icon-only .barre-replier { width: 46px; justify-content: center; padding: 0; gap: 0; }
.barre-replier {
  background: none; border: 0; color: rgba(255,255,255,0.45); cursor: pointer;
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px;
  padding: 0 11px; border-radius: var(--radius-sm); font: 500 12.5px 'Inter', sans-serif;
  margin-top: 4px;
}
.barre-replier:hover { background: rgba(255,255,255,0.06); color: #fff; }
.barre-replier.retournee svg { transform: rotate(180deg); }
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--surface-3); color: var(--orange-dark); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ---- Les cinq espaces ------------------------------------------------
   Un espace qui se déplie montre ses pages ; les autres restent fermés.
   Le trait vertical à gauche des sous-entrées dit qu'elles appartiennent
   à l'espace au-dessus, sans avoir à les décaler beaucoup. */
.nav-groupe { width: 100%; }
.nav-chef { background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }
.nav-chef .nav-chevron { margin-left: auto; opacity: .5; transition: transform .16s ease; }
.nav-groupe.ouvert > .nav-chef .nav-chevron { transform: rotate(180deg); }
.nav-sous {
  display: none;
  flex-direction: column;
  margin: 0 0 6px 21px;
  padding-left: 11px;
  border-left: 1px solid rgba(255,255,255,0.12);
}
.nav-groupe.ouvert > .nav-sous { display: flex; }
.nav-sous-lien {
  display: flex; align-items: center; min-height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm); color: rgba(255,255,255,0.58);
  text-decoration: none; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.nav-sous-lien:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-sous-lien.active { color: var(--orange-dark); background: var(--surface-3); }
/* Repliée, il n'y a pas la place : le clic sur un espace rouvre la barre. */
.sidebar.icon-only .nav-sous { display: none; }
.sidebar.icon-only .nav-chef .nav-chevron { display: none; }
.nav-separateur {
  width: 100%; height: 1px; background: rgba(255,255,255,0.08); margin: 10px 0;
}
/* Parc automobile et Réglages : atteignables, mais pas au même rang que
   les cinq espaces. */
.nav-link.secondaire { font-size: 12.5px; color: rgba(255,255,255,0.5); min-height: 38px; }
.nav-link.secondaire:hover { color: #fff; }

/* Tooltip shown on hover for icon-only nav items */
.sidebar.icon-only [data-tooltip] { position: relative; }
.sidebar.icon-only [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  /* Verre, comme le reste de l'interface : fond translucide + flou du fond,
     ce qui laisse deviner ce qui se trouve derrière au lieu de le masquer. */
  background: var(--tooltip-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
  z-index: 40;
}
.sidebar.icon-only [data-tooltip]:hover::after { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.sidebar.icon-only .sidebar-footer { align-items: center; }
/* La version de l'app, discrète, tout en bas de la barre. Elle doit se lire
   sans attirer l'œil : on la cherche quand on en a besoin, elle ne doit
   jamais concurrencer la navigation. En chiffres à chasse fixe pour qu'on
   puisse la recopier ou la comparer d'un coup d'œil. */
.version-app {
  margin-top: 10px;
  padding: 0 4px;
  font-size: 10.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.28);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  user-select: all;
}
.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.55);
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  gap: 11px;
  font: 500 13px 'Inter', sans-serif;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-family: 'Inter', sans-serif;
}
.logout-btn:hover { color: #fff; border-color: rgba(255,255,255,0.35); }

main {
  flex: 1;
  min-width: 0; /* flex items default to min-width:auto, which lets a wide
    table force the whole page wider instead of scrolling within its own
    .table-scroll container — this is what made buttons like "Suppr." look
    like they were spilling outside the card. */
  padding: 30px 34px 44px 34px;
  /* Plafond relevé : à 1280px, un écran 1920 laissait un large vide à droite
     pendant que les tableaux (11 colonnes sur les achats) étaient comprimés
     et défilaient horizontalement pour rien. */
  max-width: 1680px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.topbar p { color: var(--text-muted); margin: 4px 0 0 0; font-size: 14px; }

.btn {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  box-shadow: none;
  text-decoration: none;
  display: inline-block;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: var(--orange-dark); }
.btn.secondary {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
.btn.secondary:hover { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
.btn.danger { background: rgba(255, 107, 107, 0.16); border: 1px solid rgba(255, 107, 107, 0.4); color: var(--red); box-shadow: none; }
.btn.danger:hover { background: rgba(255, 107, 107, 0.26); }
/* A row action repeated on every line shouldn't paint the column red — it
   stays neutral like its neighbours and only shows its intent on hover. */
.btn.danger.small { background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); }
.btn.danger.small:hover { background: rgba(255, 107, 107, 0.18); border-color: rgba(255, 107, 107, 0.45); color: var(--red); }
.btn.small { padding: 7px 12px; font-size: 13px; box-shadow: none; }
.btn.icon-only { padding: 7px 8px; line-height: 0; }

.grid { display: grid; gap: 22px; }
/* Un enfant de grille vaut min-width:auto par défaut : un champ dont la
   largeur INTRINSÈQUE dépasse la colonne (input[type=time], select à long
   libellé) élargit alors la colonne au lieu de se comprimer, et toute la
   carte déborde vers la droite. Sur téléphone c'est le débordement le plus
   fréquent — et le plus invisible en test sur grand écran. */
.grid > * { min-width: 0; }
/* Sans `appearance: none`, Safari iOS impose au champ sa taille native et
   ignore la largeur qu'on lui donne. C'est la cause du débordement observé
   sur iPhone alors que Chrome affichait tout correctement. */
input[type="time"], input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  /* Et sans hauteur minimale, le même `appearance: none` provoque l'autre
     défaut vu sur iPhone : un champ ENCORE VIDE n'a plus rien à afficher,
     donc plus rien pour le tenir ouvert, et il s'écrase en une bande fine à
     côté des champs voisins. « Jour », lui, était déjà rempli et gardait sa
     hauteur — d'où l'impression que seuls « Arrivée » et « Départ » étaient
     ratés. On fixe la hauteur en em pour qu'elle suive la taille du texte
     du contexte (14 px au bureau, 16 px sur le téléphone). */
  min-height: 2.8em;
}
/* Le contenu d'un champ heure sur iOS vit dans cette pièce interne. Elle
   aussi doit garder une hauteur quand elle est vide, sinon la précédente ne
   sert à rien. */
input[type="time"]::-webkit-date-and-time-value,
input[type="date"]::-webkit-date-and-time-value {
  min-height: 1.2em;
  text-align: inherit;
}
select { min-width: 0; max-width: 100%; }
/* minmax(0, 1fr) et non 1fr : « 1fr » vaut « minmax(auto, 1fr) », et cet
   « auto » autorise une colonne à s'élargir jusqu'à la largeur INTRINSÈQUE
   de son contenu. Un champ d'heure natif a une largeur intrinsèque imposée
   par le navigateur, plus grande sur Safari iOS que sur Chrome : les deux
   colonnes gonflaient alors au-delà de la carte et se chevauchaient sur
   iPhone, alors que tout tenait sur ordinateur. minmax(0, …) interdit
   cette croissance, sur tous les moteurs. */
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }

  /* LES TROIS MONTANTS DE L'ACCUEIL, DÈS QUE L'ÉCRAN RÉTRÉCIT.
     Sur deux colonnes, le troisième restait seul sur sa ligne, à moitié
     large : ça ressemble à un oubli de mise en page. Trois lignes pleines,
     le libellé et le montant à gauche, le périmètre à droite : ça se lit
     d'un coup d'œil, et les urgences remontent dans l'écran. */
  #hero-cards.grid.cols-3 { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #hero-cards .hero-card {
    min-height: 0; padding: 14px 16px;
    flex-direction: row; align-items: center; gap: 12px;
  }
  #hero-cards .hero-card > div:first-child { flex: 1 1 auto; min-width: 0; }
  #hero-cards .hero-card .hc-value { font-size: 23px; margin-top: 2px; }
  #hero-cards .hero-card .hc-sub {
    flex: 0 0 auto; margin-top: 0; flex-direction: column; align-items: flex-end;
    text-align: right; font-size: 11.5px; line-height: 1.5;
  }
}

/* Pas de backdrop-filter ici, volontairement. Une carte est le seul bloc de
   la page qui peut devenir très haut (le rapport des dépenses dépasse les
   900 px), et Chromium/Brave ne repeint alors qu'une partie du flou pendant
   le défilement : une bande entière de la carte reste blanche à l'écran alors
   que le contenu est bien là. Mesuré avant de trancher : sur le fond quasi
   uni de l'app, le flou ne change l'image que de 1,4 niveau en moyenne
   (12 au pire) — invisible. On le garde là où les blocs restent courts et où
   il sert vraiment (barre latérale, en-tête, fenêtres, champs). */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow-sm), var(--glass-edge);
}
/* Un titre de carte doit se détacher de ce qu'il annonce. Collé, il se lit
   comme une première ligne de contenu. */
.card > h3 { margin-bottom: 10px; }
.card > h3 + p { margin-top: 0; }

.stat-card .label { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; font-weight: 500; }
.stat-card .value { font-family: 'Blinker', sans-serif; font-size: 27px; font-weight: 700; color: var(--text); }
.stat-card .value.orange { color: var(--orange); }
.stat-card .value.red { color: var(--red); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.amber { color: var(--amber); }
.stat-card .value.purple { color: var(--purple-dark); }

/* Hero "bank card" style summary widgets (dashboard) */
.hero-card {
  border-radius: var(--radius);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm), var(--glass-edge);
  padding: 24px 26px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hero-card.hc-orange { background: linear-gradient(135deg, rgba(255,105,35,0.62) 0%, rgba(255,80,2,0.34) 100%); border: 1px solid rgba(255,140,90,0.42); }
/* La troisième carte : les retards clients. Rouge, parce que c'est de
   l'argent échu, pas de l'argent attendu. */
.hero-card.hc-rouge { background: linear-gradient(135deg, rgba(229,72,77,0.42) 0%, rgba(229,72,77,0.16) 100%); border: 1px solid rgba(229,72,77,0.42); }
/* Les trois cartes mènent à la liste correspondante : elles se comportent
   donc comme des liens, sans en prendre l'apparence. */
a.hero-card { text-decoration: none; color: inherit; transition: transform .12s ease; }
a.hero-card:hover { transform: translateY(-2px); }

/* ---- À TRAITER, en haut de l'accueil --------------------------------- */
.bloc-traiter { margin-bottom: 18px; }
.bloc-traiter:last-child { margin-bottom: 0; }
.bt-tete { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.bt-tete h4 { margin: 0; font-size: 13px; font-weight: 600; }
.bt-compte { font-size: 11.5px; font-weight: 700; background: var(--surface-3);
  color: var(--text-muted); border-radius: 999px; padding: 1px 8px; }
.bt-tout { font-size: 12.5px; white-space: nowrap; }
.bt-vide { color: var(--text-muted); font-size: 13px; margin: 0; }
.rien-a-faire { color: var(--text-muted); font-size: 13.5px; margin: 0; }
.ligne-traiter {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  min-height: 48px;
}
.ligne-traiter:hover { background: rgba(255,255,255,0.045); border-color: var(--border); }
.lt-point { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.ligne-traiter.urgente .lt-point { background: var(--red); }
.lt-quoi { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.lt-quoi b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.lt-quoi i { font-style: normal; font-size: 12px; color: var(--text-muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.lt-montant { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 13px;
  font-weight: 600; white-space: nowrap; }

/* ---- Les listes de suggestions ---------------------------------------
   Remplacent le menu que le navigateur dessinait lui-même pour un
   <datalist> : un bloc noir sans rapport avec le reste de l'écran, et
   impossible à styler. Mêmes couleurs, même rayon et même ombre que le menu
   « Ajouter » ci-dessous, pour qu'une liste reste une liste partout.
   En `position: fixed` parce que ces champs vivent souvent dans une fenêtre
   qui défile, où un panneau absolu serait coupé par le bord. */
.liste-suggestions {
  position: fixed; z-index: 60;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.liste-suggestions.hidden { display: none; }
.liste-option {
  text-align: left; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 13.5px; font-weight: 500; line-height: 1.35;
}
.liste-option:hover, .liste-option.actif { background: var(--surface-3); }

/* ---- Le bouton Ajouter, et ses quatre choix --------------------------
   Un seul point d'entrée pour créer, au lieu de trois pavés qui prenaient
   un tiers de l'écran d'accueil. Le menu ne crée rien lui-même : chaque
   choix ouvre le formulaire de sa page. */
.menu-ajouter { position: relative; flex: 0 0 auto; }
.choix-ajouter {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 45;
  min-width: 232px; padding: 6px;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px;
}
.choix-ajouter[hidden] { display: none; }
.choix-ajouter a {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 46px; justify-content: center;
  padding: 8px 11px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 600;
}
.choix-ajouter a i { font-style: normal; font-size: 12px; font-weight: 400; color: var(--text-muted); }
.choix-ajouter a:hover, .choix-ajouter a:focus-visible { background: var(--surface-3); }

/* ---- Les détails de l'activité, repliés ------------------------------ */
.detail-activite { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); margin-bottom: 22px; }
.detail-activite > summary { list-style: none; cursor: pointer; padding: 15px 18px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-height: 52px; }
.detail-activite > summary::-webkit-details-marker { display: none; }
.detail-activite > summary span { font-size: 14px; font-weight: 600; }
.detail-activite > summary i { font-style: normal; font-size: 12.5px; color: var(--text-muted); }
.detail-activite > summary::after { content: "▾"; margin-left: auto; color: var(--text-muted); }
.detail-activite[open] > summary::after { content: "▴"; }
.detail-activite[open] > summary { border-bottom: 1px solid var(--border); }
.detail-corps { padding: 18px; }

.hero-card.hc-navy { background: linear-gradient(135deg, rgba(255,255,255,0.13) 0%, rgba(255,255,255,0.05) 100%); border: 1px solid var(--border); }
.hero-card .hc-label { font-size: 13px; opacity: 0.85; font-weight: 500; }
.hero-card .hc-value { font-family: 'Blinker', sans-serif; font-size: 30px; font-weight: 700; margin-top: 6px; }
.hero-card .hc-sub { font-size: 12.5px; opacity: 0.8; margin-top: 14px; display: flex; justify-content: space-between; }
.hero-card::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  pointer-events: none;
}

/* Wraps a <table> inside a .card so that if the table content is wider than
   the card (long status labels, many columns, action buttons), it scrolls
   horizontally within the rounded card instead of overflowing past its edge
   (which used to make buttons like "Suppr." appear to spill outside the box). */
.table-scroll { overflow-x: auto; }

/* A sticky last column was tried here to keep row actions always visible,
   but on rows with many columns it pins an opaque cell over whatever data
   column happens to sit at that same screen position at the default scroll
   offset (e.g. it painted right over the Statut badge, making it look like
   the status had vanished) — worse than just scrolling. Actions now scroll
   with the rest of the row like every other column; the buttons themselves
   are compact icons (see .icon-only) to keep how far you need to scroll to
   a minimum. */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .sort-arrow { opacity: 0.5; font-size: 10px; margin-left: 3px; }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { border-left: 3px solid transparent; }
tbody tr:hover { background: rgba(255,255,255,0.045); }
tbody tr.row-payee { border-left-color: var(--green); }
tbody tr.row-en_retard { border-left-color: var(--red); }
tbody tr.row-en_attente { border-left-color: var(--amber); }
tbody tr.row-annulee { border-left-color: var(--text-soft); }
/* Le liseré de gauche dit la même chose que la pastille, en un coup d'œil sur
   toute la colonne : gris, orange, rouge. */
tbody tr.row-ok { border-left-color: var(--border); }
tbody tr.row-bientot { border-left-color: var(--orange-dark); }
tbody tr.row-echeance_aujourdhui { border-left-color: var(--orange); }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.payee { background: var(--green-soft); color: var(--green); }
.badge.en_attente { background: var(--amber-soft); color: var(--amber); }
.badge.en_retard { background: var(--red-soft); color: var(--red); }
.badge.annulee { background: var(--surface-2); color: var(--text-muted); }
.badge.partiel { background: var(--orange-soft); color: var(--orange-dark); }
.badge.trop_percu { background: var(--purple-soft); color: var(--purple-dark); }
/* Trois feux, et un seul message par couleur :
     gris   — rien à faire aujourd'hui
     orange — l'échéance approche, prépare le paiement
     rouge  — c'est dépassé
   Le jour même reste orange, mais plein plutôt que teinté : c'est la dernière
   marche avant le rouge, elle doit se voir sans être une alarme. */
.badge.ok { background: var(--surface-2); color: var(--text-muted); }
.badge.bientot { background: var(--orange-soft); color: var(--orange-dark); }
/* Teinté comme les autres, juste plus dense : l'orange plein tapait trop
   l'œil pour une information qui n'est pas une alarme. */
.badge.echeance_aujourdhui {
  background: rgba(255, 122, 61, 0.34);
  color: var(--orange-dark);
  font-weight: 700;
}

/* Same pill look as .badge, but an actual <select> — lets the status be
   changed (e.g. "En retard" → "Payée") right from the table, no modal needed. */
.status-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  border: none; border-radius: 14px; padding: 4px 22px 4px 10px;
  font-size: 12px; font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer;
  background-repeat: no-repeat; background-position: right 7px center; background-size: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239A9A9E' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  /* Long labels ("Échéance dans 7 j", "En retard (33 j)") wrap onto two
     lines within this max-width instead of forcing the whole column wide —
     keeps the status readable without pushing other columns off-screen. */
  display: inline-block; width: auto; max-width: 96px; white-space: normal;
  line-height: 1.3; text-align: left; vertical-align: middle;
}
.status-select:hover { filter: brightness(0.97); }
.status-select.payee { background-color: var(--green-soft); color: var(--green); }
.status-select.en_attente { background-color: var(--amber-soft); color: var(--amber); }
.status-select.en_retard { background-color: var(--red-soft); color: var(--red); }
.status-select.annulee { background-color: var(--surface-2); color: var(--text-muted); }
/* Les trois feux de l'échéance, sur le bouton de statut du tableau — mêmes
   couleurs que les pastilles .badge correspondantes, pour qu'un même état ne
   change jamais de couleur d'un écran à l'autre. */
.status-select.ok { background-color: var(--surface-2); color: var(--text-muted); }
.status-select.bientot { background-color: var(--orange-soft); color: var(--orange-dark); }
/* Le jour même : le même orange que « bientôt », en plus dense. On reste dans
   la famille teintée du reste de l'app — la flèche grise du menu redevient
   donc lisible sans traitement particulier. */
.status-select.echeance_aujourdhui {
  background-color: rgba(255, 122, 61, 0.34);
  color: var(--orange-dark);
  font-weight: 700;
}
/* Distinct from both "en_attente" (amber) and "en_retard" (red) — a partial
   payment is neither "nothing received" nor "fully overdue with nothing
   done", it needs its own color so it doesn't get lost among either. Wider
   than the default pill since its label ("Partiel — En retard (49 j)") runs
   longer than the others. */
.status-select.partiel { background-color: var(--orange-soft); color: var(--orange-dark); max-width: 132px; }
/* A "trop-perçu" (overpaid) invoice needs its own look too — it's still
   technically "payée" (montantPaye covers the total) but with an EXCESS on
   top, which usually means a refund or credit note is owed. Purple keeps it
   visually distinct from every other state (green=payée, red=en retard,
   orange=partiel, amber=en attente) so it can't be mistaken for a normal
   "Payée" at a glance. Wide like .partiel since its label includes the
   excess amount. */
.status-select.trop_percu { background-color: var(--purple-soft); color: var(--purple-dark); max-width: 150px; }

.status-dd { position: relative; display: inline-block; }
.status-menu {
  /* Fixe, et positionné en JS depuis la position du bouton (voir
     toggleStatusMenu) : en absolu il était rogné par le .table-scroll du
     tableau, qui a un overflow — le menu se retrouvait coupé net au bord de
     la carte dès que la ligne était proche du bas. */
  /* top/left par défaut : sans eux, le menu fraîchement rattaché au <body>
     se place un instant à sa position statique — tout en bas du document —
     ce qui déclenchait un scroll parasite, aussitôt intercepté par le
     gestionnaire qui referme les menus au défilement. Il se rouvrait donc
     et se refermait dans la même milliseconde. */
  position: fixed; top: 0; left: 0; z-index: 45;
  background: rgba(52, 47, 46, 0.94);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 4px; min-width: 150px;
}
.status-menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  font-family: 'Inter', sans-serif; cursor: pointer; color: var(--text);
}
.status-menu-item:hover { background: var(--surface-3); color: var(--text); }
.status-menu-item.active { background: var(--surface-3); }
.status-menu-item.payee { color: var(--green); }
.status-menu-item.payee:hover { background: var(--green-soft); color: var(--green); }
.status-menu-item.en_attente { color: var(--amber); }
.status-menu-item.en_attente:hover { background: var(--amber-soft); color: var(--amber); }
.status-menu-item.en_retard { color: var(--red); }
.status-menu-item.en_retard:hover { background: var(--red-soft); color: var(--red); }
.status-menu-item.annulee { color: var(--text-muted); }
.status-menu-item.annulee:hover { background: var(--surface-3); color: var(--text); }
/* Idem dans le menu ouvert : la ligne « pas encore payée » prend la couleur de
   l'échéance réelle de la facture. */
.status-menu-item.ok { color: var(--text-muted); }
.status-menu-item.ok:hover { background: var(--surface-3); color: var(--text); }
.status-menu-item.bientot,
.status-menu-item.echeance_aujourdhui { color: var(--orange-dark); }
.status-menu-item.bientot:hover,
.status-menu-item.echeance_aujourdhui:hover { background: var(--orange-soft); color: var(--orange-dark); }

.avatar-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--orange);
  flex-shrink: 0;
}

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  background: var(--surface-2);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { outline: none; border-color: rgba(255,122,61,0.55); box-shadow: 0 0 0 3px rgba(255,80,2,0.14); }
input::placeholder, textarea::placeholder { color: var(--text-soft); }
select option { background: var(--surface-solid); color: var(--text); }
/* Cases à cocher : contrôle natif, juste teinté aux couleurs de la marque
   et dimensionné correctement — pas de cadre autour. */
input[type="checkbox"], input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--orange);
  cursor: pointer;
  vertical-align: middle;
  margin: 0;
}

label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 14px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
/* La règle générique des champs porte `width: 100%` avec une specificité de
   (0,3,1) — plus forte que `.toolbar input` (0,1,1). Résultat : chaque champ
   d'une barre d'outils occupait toute la largeur et poussait le suivant à la
   ligne, ce qui rendait « du [date] au [date] » illisible. On aligne la
   specificité pour que la barre reprenne la main. */
.toolbar input:not([type="checkbox"]):not([type="radio"]), .toolbar select { width: auto; min-width: 170px; }
/* Une date n'a pas besoin de 170px, et les garder courtes permet de lire
   « du … au … » d'un seul tenant. */
.toolbar input[type="date"] { min-width: 0; width: 150px; }
.spacer { flex: 1; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal {
  /* UNE seule mesure pour le rembourrage de la fenêtre ET pour les marges
     négatives des deux barres collantes. Elles doivent se correspondre au
     pixel près : sur téléphone le rembourrage tombait à 16px pendant que les
     barres gardaient -28px, elles dépassaient donc de 12px de chaque côté et
     la fenêtre se mettait à défiler de côté. Avec une variable, changer le
     rembourrage suffit, et l'écart ne peut plus revenir. */
  --modal-pad: 28px;
  background: rgba(52, 47, 46, 0.82);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--modal-pad);
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  /* Ceinture et bretelles : la cause du débordement latéral est réglée par
     --modal-pad ci-dessus, mais un contenu trop large ajouté un jour (un
     tableau, une longue référence) ne doit jamais remettre la fenêtre à
     défiler de côté. Il sera coupé, pas promené. */
  overflow-x: hidden;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 18px; }

/* ---- L'EN-TÊTE ET LE PIED NE DOIVENT JAMAIS SORTIR DE L'ÉCRAN ---------
   Le contenu d'une fenêtre dépasse souvent sa hauteur : elle défile, et
   les boutons Annuler et Enregistrer se retrouvaient SOUS le bord de
   l'écran. Mesuré sur un écran de 900 px de haut : boutons à 876 px,
   bas à 915 px, donc inatteignables sans deviner qu'il faut faire défiler
   l'intérieur de la fenêtre. On reste bloqué dedans.

   L'en-tête et la barre d'actions sont donc collés en haut et en bas de
   la partie visible. Les marges négatives les font déborder sur le
   rembourrage de la fenêtre, pour qu'ils aillent d'un bord à l'autre. */
.modal > h3:first-of-type {
  position: sticky;
  top: 0;
  z-index: 2;
  /* La marge du bas vaut 18px d'espace VOULU + les 28px que la marge
     négative du haut retire au flux. Sans cette compensation, tout ce qui
     suit l'en-tête remonte de 28px et passe DESSOUS : mesuré, la première
     ligne de texte était recouverte de 10px dans chaque fenêtre de l'app.
     Ça ne se voyait que sur les fenêtres dont le premier élément est du
     texte, d'où le temps qu'il a fallu pour le remarquer. */
  margin: calc(-1 * var(--modal-pad)) calc(-1 * var(--modal-pad)) calc(18px + var(--modal-pad));
  padding: 22px 56px 14px var(--modal-pad);   /* place à droite pour la croix */
  background: var(--surface-solid, rgba(52, 47, 46, 0.97));
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  /* Même compensation qu'en haut, et pour la même raison : la marge
     négative du bas retire 28px au flux, donc le contenu qui précède
     remonte de 28px et passe SOUS la barre d'actions. Mesuré : 8px du
     dernier élément restaient cachés dans toutes les fenêtres, à toutes
     les largeurs, même après avoir fait défiler jusqu'en bas.
     20px d'espace voulu + 28px de compensation = 48px. */
  margin: calc(20px + var(--modal-pad)) calc(-1 * var(--modal-pad)) calc(-1 * var(--modal-pad));
  padding: 16px var(--modal-pad);
  background: var(--surface-solid, rgba(52, 47, 46, 0.97));
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
/* La croix de fermeture, posée dans l'en-tête. */
.modal-fermer {
  position: absolute;
  top: 18px; right: 18px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  z-index: 3;
}
.modal-fermer:hover { background: var(--surface-3); border-color: var(--border-strong); }
.modal { position: relative; }
/* Sur grand écran, une colonne de 480 px pour une facture, c'est étroit :
   les libellés et les dates se coupent. */
@media (min-width: 1100px) {
  .modal:not(.preview-modal):not(.has-preview) { width: 620px; }
}
/* Le fond ne défile plus tant qu'une fenêtre est ouverte. */
body.fenetre-ouverte { overflow: hidden; }

.preview-modal { width: 760px; padding: 20px; }
.preview-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.preview-modal-header h3 { margin: 0; font-size: 15px; word-break: break-all; }
.preview-modal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.preview-modal-body { min-height: 200px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.28); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.preview-modal-body img { max-width: 100%; max-height: 74vh; display: block; }
.preview-modal-body iframe { width: 100%; height: 74vh; border: 0; }
.preview-unavailable { color: var(--text-muted); font-size: 13.5px; text-align: center; padding: 50px 24px; }
.preview-loading { color: var(--text-muted); font-size: 13.5px; text-align: center; padding: 50px 24px; }
.preview-xml-summary { width: 100%; padding: 28px; }
.preview-xml-note { color: var(--text-muted); font-size: 12px; margin: 0 0 20px 0; }
.preview-xml-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.preview-xml-grid > div { display: flex; flex-direction: column; gap: 4px; }
.preview-xml-grid label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.preview-xml-grid span { font-size: 14.5px; font-weight: 600; color: var(--text); }

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.montrer-fiche { display: none; }

.category-tag {
  /* inline-block, et pas inline : sur un élément en ligne, un texte qui passe
     à la ligne coupe la bordure et les coins arrondis en deux morceaux —
     « Véhicules (location/leasing) » débordait de sa pastille. En bloc en
     ligne, la boîte enveloppe les deux lignes. */
  display: inline-block;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  /* Sur une seule ligne, coupée par des points de suspension : « Véhicules
     (location/leasing) » sur deux lignes faisait grandir TOUTES les lignes du
     tableau. Le nom complet reste lisible au survol (attribut title). */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}


/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 24% 12%, rgba(255,110,40,0.28) 0%, transparent 58%), radial-gradient(circle at 78% 92%, rgba(255,130,70,0.16) 0%, transparent 58%), var(--bg);
}
.login-card {
  background: rgba(255, 255, 255, 0.095);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 42px 38px;
  width: 380px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-card img.login-logo { height: 42px; margin-bottom: 24px; }
.login-card p.sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }
.login-error { color: var(--red); font-size: 13.5px; margin-top: 10px; min-height: 16px; }
.login-notice { color: var(--amber); font-size: 13px; margin-bottom: 16px; text-align: left; background: var(--amber-soft); padding: 10px 12px; border-radius: var(--radius-sm); }

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 18px;
  background: var(--surface-2);
}
.dropzone.drag { border-color: rgba(255,122,61,0.5); color: var(--orange-dark); background: var(--orange-soft); }

/* Segmented control (vente / achat) */
/* La barre d'onglets fait 664 px à six onglets. Sur une tablette de 768 px,
   une fois la barre latérale déduite, elle débordait de 124 px et élargissait
   TOUTE la page : le tableau des factures passait sous le bord droit, et les
   dernières colonnes devenaient inaccessibles.
   Elle défile donc sur elle-même plutôt que de pousser la page. `max-width`
   avec `min-width: 0` est ce qui l'autorise à rétrécir : un élément flex
   refuse par défaut de descendre sous la taille de son contenu. */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 22px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;           /* la barre de défilement elle-même est inutile ici */
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 0 0 auto; }  /* sinon les onglets se compriment au lieu de défiler */
.segmented button {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 9px 22px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

.attach-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-2);
}
.attach-pill:hover { border-color: var(--border-strong); color: var(--text); }

.bar-row { margin-bottom: 14px; }
.bar-row .bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--text);
}
.bar-track {
  background: var(--surface-2);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--orange); border-radius: 6px; opacity: 0.55; }
.bar-fill.top { background: var(--orange); opacity: 1; }

.section-title {
  font-family: 'Blinker', sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.warn-banner {
  background: var(--amber-soft);
  border: 1px solid rgba(233, 185, 73, 0.34);
  color: var(--amber);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* Donut chart (pure CSS conic-gradient, no external lib) */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.donut {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.donut-hole {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  /* Opaque, contrairement aux autres surfaces : ce disque doit masquer le
     conic-gradient du donut placé dessous, ce qu'un fond translucide ne
     ferait pas. */
  background: var(--surface-solid);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
.donut-hole .dh-value { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 18px; color: var(--text); }
.donut-hole .dh-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.legend-list { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-item .legend-value { margin-left: auto; font-weight: 600; color: var(--text); }

/* Batch import queue (Factures — Achats) */
.dropzone.small { padding: 16px; margin-bottom: 0; }
.dropzone.dragover { border-color: rgba(255,122,61,0.5); color: var(--orange-dark); background: var(--orange-soft); }
.batch-card { margin-bottom: 22px; }
.batch-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.batch-header h3 { font-size: 15px; margin: 0; }
.batch-count { background: var(--orange-soft); color: var(--orange-dark); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.batch-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.batch-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.batch-row.dup { border-color: var(--red); background: var(--red-soft); }
.batch-row .bi-main { display: flex; align-items: center; gap: 12px; }
.batch-row .bi-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-row .bi-size { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.batch-row .bi-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 4px 6px; flex-shrink: 0; }
.batch-row .bi-remove:hover { color: var(--red); }
.batch-row .bi-dup-warning { color: var(--red); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 5px; }

/* Inline duplicate-number warning inside the invoice modal itself */
.dup-note { background: var(--red-soft); border: 1px solid rgba(255,107,107,0.3); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }

/* Folder-style cards (Sous-traitants) */
.folder-card { background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; font-family: 'Inter', sans-serif; }
.folder-card:hover { border-color: var(--border-strong); background: var(--surface-3); }
.folder-card .folder-name { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; color: var(--text); }
.folder-card .folder-count { color: var(--text-muted); font-size: 12px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.doc-card { background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow-sm); display: block; text-decoration: none; color: inherit; font-family: 'Inter', sans-serif; }
a.doc-card:hover { border-color: var(--border-strong); background: var(--surface-3); }
.doc-card .doc-name { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.doc-card .doc-meta { color: var(--text-muted); font-size: 12px; }

/* Alert toast (bottom-right) — pops up when a NEW alert appears (see
   checkForNewAlerts in app.js). Present on every page via renderSidebar. */
.alert-toast {
  /* The toast floats over the bottom-right corner, which on the invoice and
     rapprochement screens is exactly where row action buttons sit. It never
     swallows a click meant for the page underneath: the card itself is
     click-through, and only its own controls (re-enabled below) are
     interactive. Combined with the 12s auto-hide, it can never trap the UI. */
  pointer-events: none;
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 330px; max-width: calc(100vw - 44px);
  background: rgba(52, 47, 46, 0.88);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 15px 17px 15px 16px;
  animation: alert-toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.alert-toast.leaving { animation: alert-toast-out 0.2s ease forwards; }
@keyframes alert-toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes alert-toast-out { to { opacity: 0; transform: translateY(10px); } }
.alert-toast-title { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); padding-right: 20px; }
.alert-toast-body { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin-top: 3px; }
.alert-toast-actions { display: flex; gap: 8px; margin-top: 12px; pointer-events: auto; }
.alert-toast-actions .btn { text-decoration: none; }
.alert-toast-close {
  pointer-events: auto;
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--text-soft);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 5px;
}
.alert-toast-close:hover { color: var(--text); }
@media (max-width: 640px) { .alert-toast { right: 12px; left: 12px; bottom: 12px; width: auto; } }


/* ==========================================================================
   RESPONSIVE — ordinateur / tablette / téléphone
   ==========================================================================
   L'app est faite de tableaux denses (jusqu'à 11 colonnes sur les achats).
   Le parti pris est donc : on NE casse PAS les tableaux en cartes empilées
   — sur un suivi comptable, comparer deux lignes côte à côte est justement
   ce qu'on vient y faire — mais on rend tout le reste de l'interface
   confortable au doigt, et les tableaux défilent horizontalement dans leur
   carte, avec un rappel visuel qu'ils défilent.
   ========================================================================== */

/* ---- Tablette (≤ 1024px) ---- */
@media (max-width: 1024px) {
  main { padding: 22px 20px 40px 20px; }
  .sidebar { margin: 12px 0 12px 12px; padding: 18px 10px; width: 196px; }
  .sidebar.icon-only { width: 68px; padding: 18px 10px; }
  .sidebar.icon-only .nav-link { width: 42px; min-height: 42px; }
  h1 { font-size: 26px; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .card { padding: 18px 18px; }
  .grid { gap: 14px; }
}

/* ---- Téléphone (≤ 720px) ----------------------------------------------
   La barre latérale verticale devient une barre horizontale FIXE EN BAS :
   c'est la zone atteignable au pouce, et ça rend les 78px de largeur au
   contenu, ce qui compte quand l'écran fait 390px de large. */
/* ---- La navigation sur téléphone -------------------------------------
   La barre latérale se transformait en une rangée de DIX icônes sans nom,
   qui débordait par la droite : on ne savait ni où on allait, ni ce qui se
   cachait au-delà du bord. Elle laisse la place à une barre de quatre
   onglets nommés + « Plus ». La barre latérale complète reste, elle, la
   navigation de l'ordinateur, où la place ne manque pas. */
.nav-mobile { display: none; }

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .nav-mobile { display: block; }

  .nav-mobile {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 46;
  }
  .barre-mobile {
    position: relative;
    z-index: 2;
    display: flex;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)) 6px;
    background: rgba(46, 42, 40, 0.96);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  }
  .onglet-mobile {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    /* 48 px de haut : la cible d'un doigt, pas d'un curseur. */
    min-height: 48px;
    padding: 6px 2px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }
  .onglet-mobile.actif { color: var(--orange-dark); background: var(--surface-2); }
  .onglet-mobile:active { background: var(--surface-3); }

  /* Le voile s'arrête AU-DESSUS de la barre : les quatre onglets restent
     lisibles et cliquables pendant que le panneau est ouvert. */
  /* Ancré au conteneur de la barre : « bottom: 100% » veut dire « juste
     au-dessus d'elle », quelle que soit sa hauteur réelle. Un nombre écrit
     en dur (62 px) chevauchait la barre dès que les libellés la faisaient
     grandir. */
  .voile-mobile {
    position: absolute;
    bottom: 100%;
    left: 0; right: 0;
    height: 100vh;
    z-index: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .voile-mobile.ouvert { opacity: 1; pointer-events: auto; }

  .tiroir-mobile {
    position: absolute;
    bottom: 100%;
    left: 0; right: 0;
    z-index: 1;
    background: var(--surface-solid);
    border-top: 1px solid var(--border-strong);
    border-radius: 22px 22px 0 0;
    padding: 8px 14px 18px;
    transform: translateY(105%);
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  }
  .tiroir-mobile.ouvert { transform: translateY(0); }
  .poignee-mobile {
    width: 38px; height: 4px; border-radius: 99px;
    background: var(--border-strong);
    margin: 2px auto 14px;
  }
  /* Le panneau contient maintenant toutes les pages des espaces, rangées
     sous le nom de leur espace. Il peut dépasser la hauteur de l'écran :
     il défile, et s'arrête avant de recouvrir la barre du bas. */
  .tiroir-corps { max-height: 68vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .tiroir-titre {
    margin: 12px 2px 7px; font-size: 11px; font-weight: 700;
    letter-spacing: .09em; text-transform: uppercase; color: var(--text-muted);
  }
  .tiroir-corps > .tiroir-grille + .tiroir-grille { margin-top: 8px; }
  .tiroir-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tiroir-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 7px;
    min-height: 76px;
    padding: 12px 4px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 11.5px; font-weight: 600;
    text-align: center; text-decoration: none;
    cursor: pointer;
  }
  .tiroir-item.actif { color: var(--orange-dark); border-color: var(--border-strong); }
  .tiroir-item:active { background: var(--surface-3); }

  main {
    max-width: none;
    padding: 18px 14px 112px 14px;  /* dégagement pour la barre du bas, libellés compris */
  }

  h1 { font-size: 23px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 18px; }
  .topbar p { font-size: 13px; }
  /* Les boutons d'action se partagent la largeur sur une même rangée (et
     passent à la ligne s'il y en a trop) plutôt qu'un par ligne : trois
     boutons pleine largeur repoussaient tout le contenu utile sous la
     ligne de flottaison. */
  .topbar > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar > div:last-child .btn { flex: 1 1 auto; min-width: 130px; text-align: center; }

  /* Contrôles confortables au doigt : 44px de haut, la cible tactile
     minimale recommandée. */
  .btn { padding: 12px 16px; }
  .btn.small { padding: 9px 12px; }
  input, select, textarea { padding: 12px 13px; font-size: 16px; }  /* 16px = pas de zoom auto sur iOS */

  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .spacer { display: none; }

  /* Le sélecteur d'onglets défile horizontalement au lieu de passer à la
     ligne et de casser la hiérarchie de la page. */
  .segmented {
    display: flex;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 16px;
  }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex: 0 0 auto; padding: 10px 16px; font-size: 13.5px; }

  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 21px; }
  .stat-card .label { font-size: 12px; }
  .hero-card { min-height: 120px; padding: 18px 18px; }
  .hero-card .hc-value { font-size: 25px; }

  .card { padding: 16px 14px; border-radius: 18px; }

  /* Tableaux : défilement horizontal dans la carte, avec une amorce de
     défilement fluide et des cellules resserrées pour qu'un maximum de
     colonnes tienne à l'écran. */
  .table-scroll { -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }
  thead th { padding: 10px 10px; font-size: 11px; }
  tbody td { padding: 10px 10px; }

  /* Sur téléphone la fenêtre colle aux bords : on change la MESURE, et les
     deux barres collantes suivent toutes seules. */
  /* La fenêtre reste au MILIEU de l'écran sur téléphone, comme ailleurs.
     Elle était collée en bas, à la manière d'un tiroir : le regard devait
     descendre pour lire ce qu'on venait d'ouvrir, et le titre se retrouvait
     loin du contenu qu'on regardait juste avant.
     Les coins sont donc arrondis des quatre côtés, et une petite marge
     latérale l'empêche de toucher les bords. */
  .modal { --modal-pad: 16px; width: 100%; max-width: calc(100% - 20px); border-radius: 18px; max-height: 88vh; }
  .modal-overlay { align-items: center; padding: 10px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .grid.cols-3 .field, .grid.cols-2 .field { margin-bottom: 10px; }

  .preview-modal { width: 100%; }
  .preview-modal-body iframe, .preview-modal-body img { max-height: 60vh; }

  .donut-wrap { gap: 18px; justify-content: center; }
  .donut { width: 140px; height: 140px; }
  .donut-hole { width: 92px; height: 92px; }

  /* La notification d'alerte remonte au-dessus de la barre du bas. */
  .alert-toast { left: 10px; right: 10px; bottom: 84px; width: auto; }

  .login-card { padding: 32px 22px; }
}

/* ---- Petit téléphone (≤ 400px) ---- */
@media (max-width: 360px) {
  main { padding: 14px 10px 92px 10px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .grid.stat-grid { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 21px; }
  .topbar > div:last-child .btn { flex: 1 1 100%; }
}

/* ---- Impression : ni barre de navigation ni notification ---- */
@media print {
  .sidebar, .alert-toast, .topbar .btn, .toolbar { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* Fenêtre d'encodage en deux colonnes : champs à gauche, aperçu du document
   joint à droite. La colonne d'aperçu n'apparaît que s'il y a un document —
   sans elle la fenêtre garde sa largeur d'origine. */
.modal-split { display: block; }
.modal-form-col { min-width: 0; }
/* Avec un document à côté, la fenêtre prend presque tout l'écran : à ce
   moment-là c'est la LECTURE de la facture qui compte, pas la fenêtre.
   Trois zones fixes : le titre en haut, le corps au milieu (seul à défiler),
   les boutons en bas. Avant, toute la fenêtre défilait d'un bloc : les
   boutons partaient au ras du bord et l'aperçu se réduisait à un timbre. */
.modal.has-preview {
  width: min(1560px, 96vw);
  max-width: 96vw;
  height: min(940px, 94vh);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px 28px 0 28px;
}
.modal.has-preview > h3 { flex: 0 0 auto; margin-bottom: 16px; }
.modal.has-preview > .warn-banner { flex: 0 0 auto; }
.modal.has-preview .modal-split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  /* La colonne des champs garde une largeur de lecture confortable ; tout le
     reste de la fenêtre va au document. */
  grid-template-columns: minmax(420px, 560px) minmax(0, 1fr);
  gap: 26px;
  align-items: stretch;
  overflow: hidden;
}
/* Seuls les champs défilent, et leur barre de défilement ne touche pas le
   texte : 12 px la séparent. */
.modal.has-preview .modal-form-col {
  overflow-y: auto;
  min-height: 0;
  padding-right: 12px;
}
.modal.has-preview .modal-preview-col { position: static; height: 100%; max-height: none; }
/* Le pied de page reste visible pendant qu'on remplit, et il est décollé du
   bord : un filet le sépare des champs, puis 22 px d'air en dessous. */
.modal.has-preview .modal-error,
.modal.has-preview .login-error { flex: 0 0 auto; }
.modal.has-preview .modal-actions {
  flex: 0 0 auto;
  margin: 0 -28px;
  padding: 16px 28px 22px 28px;
  border-top: 1px solid var(--border);
  background: rgba(38, 34, 33, 0.55);
}
.modal-preview-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Se cale sur la hauteur de la fenêtre : le document reste visible pendant
     qu'on fait défiler les champs. */
  position: sticky;
  top: 0;
  height: 80vh;
  max-height: 80vh;
}
.preview-col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
/* min-height: 0 est indispensable : sans lui, un enfant flex refuse de
   rétrécir sous la taille de son contenu et le `flex: 1` ne remplit rien. */
.preview-col-body { flex: 1; overflow: auto; min-height: 0; }
.preview-col-body iframe { width: 100%; height: 100%; min-height: 0; border: 0; background: #fff; }
.preview-col-body img { width: 100%; display: block; background: #fff; }
.preview-col-body .preview-loading,
.preview-col-body .preview-unavailable { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Lecture d'une facture électronique (UBL) : rendu lisible plutôt que du XML brut. */
.ubl-preview { padding: 14px 14px 18px 14px; font-size: 12.5px; color: var(--text); }
.ubl-preview h4 { font-size: 13.5px; margin: 0 0 2px 0; }
.ubl-preview .ubl-sub { color: var(--text-muted); font-size: 11.5px; margin-bottom: 12px; }
.ubl-preview table { font-size: 11.5px; }
.ubl-preview thead th { padding: 6px 6px; font-size: 10px; }
.ubl-preview tbody td { padding: 6px 6px; }
.ubl-preview .ubl-total { display: flex; justify-content: space-between; gap: 12px; padding: 4px 6px; }
.ubl-preview .ubl-total.strong { font-weight: 700; font-size: 13.5px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* Sur téléphone et petite tablette la colonne passe SOUS les champs, et la
   fenêtre redevient un bloc qui défile normalement. */
@media (max-width: 900px) {
  .modal.has-preview {
    width: 100%;
    height: auto;
    max-height: 92vh;
    display: block;
    overflow-y: auto;
    padding: 22px 18px;
  }
  .modal.has-preview .modal-split { display: block; overflow: visible; }
  .modal.has-preview .modal-form-col { overflow: visible; padding-right: 0; }
  .modal.has-preview .modal-actions {
    margin: 18px 0 0 0;
    padding: 14px 0 0 0;
    background: none;
  }
  .modal-preview-col { position: static; height: 62vh; max-height: 62vh; margin-top: 14px; }
  .modal.has-preview .modal-preview-col { height: 62vh; max-height: 62vh; }
}

/* Pagination partagée (voir paginate/paginationHTML dans app.js) */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-top: 14px; flex-wrap: wrap;
}
.pagination-info { font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 720px) {
  .pagination { gap: 10px; }
  .pagination .btn { flex: 1 1 auto; }
  .pagination-info { order: -1; flex: 1 1 100%; text-align: center; }
}

/* ====================================================================
   Panneau de paiement : la carte bancaire
   --------------------------------------------------------------------
   Quand des factures sont cochées, un panneau s'ouvre à droite avec la
   somme, la liste, et le bouton qui fabrique le fichier pour la banque.
   Le geste « je coche, je vois le montant, je paie » tient alors dans un
   seul endroit au lieu d'être éparpillé dans une barre d'outils.
   ==================================================================== */
.pay-panel {
  position: fixed;
  top: 88px;
  right: 20px;
  width: min(346px, calc(100vw - 40px));
  max-height: calc(100vh - 116px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  /* Sous les modales (50) : quand la fenêtre de paiement s'ouvre, elle doit
     passer devant le panneau qui l'a déclenchée. */
  z-index: 44;
  overflow: hidden;
  /* L'ouverture glisse depuis la droite : on comprend d'où vient le
     panneau, et il ne surgit pas au milieu de la lecture. */
  animation: pay-panel-in 0.22s ease-out;
}
@keyframes pay-panel-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}
.pay-panel-head { display: flex; align-items: center; gap: 8px; }
.pay-panel-head h3 { margin: 0; font-size: 15px; }
.pay-close {
  background: none; border: 0; color: var(--text-muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.pay-close:hover { color: var(--text); }

/* ---- Les deux cartes qui dépassent derrière ---- */
.pay-stack { position: relative; padding-top: 36px; }
.pay-ghost {
  position: absolute; left: 8px; right: 8px;
  height: 44px; border-radius: 16px 16px 10px 10px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; font-size: 10.5px; letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.55); text-transform: uppercase;
}
.pay-ghost-1 { top: 0; background: linear-gradient(180deg, #5A3B29, #4A3124); }
.pay-ghost-2 { top: 17px; left: 4px; right: 4px; background: linear-gradient(180deg, #6B452F, #55372a); }

/* ---- La carte principale ---- */
.pay-card {
  position: relative;
  border-radius: 18px;
  padding: 16px 18px 18px 18px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(255, 122, 61, 0.30), transparent 60%),
    linear-gradient(160deg, #3B3330 0%, #241F1D 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
}
.pay-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pay-card-marque { font-size: 13px; font-weight: 800; letter-spacing: 1.6px; }
.pay-card-banque { font-size: 10.5px; color: rgba(255, 255, 255, 0.6); margin-top: 2px; letter-spacing: 0.4px; }
/* La puce est dessinée en CSS : aucune image à charger, aucun logo de
   banque détourné. */
.pay-chip {
  width: 40px; height: 30px; border-radius: 6px;
  background: linear-gradient(135deg, #E6C88A, #B8965A);
  position: relative; flex: none;
}
.pay-chip::before, .pay-chip::after {
  content: ""; position: absolute; left: 5px; right: 5px;
  height: 1px; background: rgba(0, 0, 0, 0.28);
}
.pay-chip::before { top: 10px; }
.pay-chip::after { top: 19px; }
.pay-label { font-size: 11px; color: rgba(255, 255, 255, 0.62); margin: 18px 0 2px 0; }
.pay-montant { font-size: 27px; font-weight: 800; letter-spacing: -0.5px; }
.pay-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
  background: var(--green-soft); color: var(--green);
}
.pay-pill.warn { background: var(--amber-soft); color: var(--amber); }
.pay-iban {
  font-family: ui-monospace, monospace; font-size: 11.5px;
  color: rgba(255, 255, 255, 0.55); margin-top: 10px; letter-spacing: 1px;
}
/* Trois boutons dans une carte étroite : on laisse la rangée passer à la
   ligne plutôt que de couper un libellé en deux mots empilés. */
.pay-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pay-actions .btn { flex: 1 1 auto; justify-content: center; white-space: nowrap; padding-left: 12px; padding-right: 12px; }

/* ---- La liste des factures retenues ---- */
.pay-liste { overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.pay-ligne {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.pay-ligne:last-child { border-bottom: 0; }
.pay-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, var(--orange), #A33200);
}
.pay-ligne-nom { font-size: 13px; font-weight: 600; line-height: 1.25; }
.pay-ligne-sub { font-size: 11.5px; color: var(--text-muted); }
.pay-ligne-montant { margin-left: auto; font-size: 13px; font-weight: 700; white-space: nowrap; }

/* Sur un écran étroit, le panneau devient un tiroir en bas : à droite, il
   couvrirait le tableau qu'on est justement en train de lire. */
@media (max-width: 1150px) {
  .pay-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    width: auto; max-height: 62vh;
    border-radius: var(--radius) var(--radius) 0 0;
    animation: pay-sheet-in 0.22s ease-out;
  }
  @keyframes pay-sheet-in {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
  /* Replié par défaut sur petit écran : un tiroir qui recouvre le tableau
     empêche justement de cocher la facture suivante. On ne garde que le
     montant et le bouton, et on déplie à la demande. */
  .pay-panel.replie .pay-stack,
  .pay-panel.replie .pay-liste,
  .pay-panel.replie .pay-panel-sous { display: none; }
  .pay-compact { display: flex; }
}
.pay-compact { display: none; align-items: center; gap: 10px; flex-wrap: wrap; }
.pay-compact .pay-montant { font-size: 20px; }
.pay-deplier {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; cursor: pointer;
}

/* ====================================================================
   Bandeau de synthèse : un compteur, trois chiffres
   --------------------------------------------------------------------
   Remplace une phrase de trois lignes. Une part contre un total se lit
   comme une jauge, pas comme du texte. La barre non remplie est un ton
   plus clair de la MÊME couleur que la barre remplie : l'état se lit sur
   toute la longueur, pas seulement sur la partie colorée.
   Les montants restent en encre normale ; c'est la pastille à côté du
   libellé qui porte la couleur. Un chiffre vert au milieu d'une phrase se
   confond avec un lien, et la couleur seule ne dit rien à qui ne la
   distingue pas.
   ==================================================================== */
.total-strip {
  margin-bottom: 14px; padding: 14px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.total-strip-haut {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.total-strip-titre { font-size: 12px; color: var(--text-muted); }
.total-strip-total { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.meter {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--green-soft);
  display: flex;
}
.meter-fill { background: var(--green); border-radius: 999px; transition: width 0.35s ease; }
.total-strip-bas { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 12px; }
.kpi { display: flex; align-items: flex-start; gap: 8px; }
.kpi-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.kpi-label { font-size: 11.5px; color: var(--text-muted); }
.kpi-valeur { font-size: 15px; font-weight: 700; }

/* ====================================================================
   Menu « Exporter » : une porte au lieu de six boutons
   --------------------------------------------------------------------
   Six actions alignées se ressemblent toutes et se lisent une par une.
   Groupées derrière un bouton, avec une icône chacune, on retrouve la
   bonne du premier coup d'œil.
   ==================================================================== */
.menu-wrap { position: relative; display: inline-block; }
/* La carte qui contient le menu forme son propre plan d'empilement (elle a
   un flou d'arrière-plan). Sans z-index sur elle, le menu se dessine bien
   mais passe DERRIÈRE le tableau : visible, et pourtant pas cliquable. */
/* Valeur volontairement BASSE : il suffit de passer devant le tableau, pas
   devant les fenêtres (les modales sont en 50). Un z-index trop haut ici
   rendait le bouton « Annuler » d'une modale impossible à cliquer. */
#selection-bar { position: relative; z-index: 5; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 240px; padding: 6px;
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font-family: inherit;
  font-size: 13px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { flex: none; opacity: 0.75; }
.menu-item small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.menu-item.danger { color: var(--red); }
.menu-item.danger svg { opacity: 0.9; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-chevron { transition: transform 0.18s ease; }
[aria-expanded="true"] .menu-chevron { transform: rotate(180deg); }

/* Pastille du montant sélectionné : le chiffre qui décide de l'action
   suivante, pas noyé dans une phrase. */
.chip-montant {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--orange-soft); color: var(--orange-dark);
  font-size: 14px; font-weight: 700;
}
.chip-montant span { font-size: 11px; font-weight: 600; opacity: 0.85; }

/* ====================================================================
   Badges de maîtrise
   ==================================================================== */
.badge-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.badge-svg { flex: none; display: block; }
.badge-img { flex: none; display: block; object-fit: contain; }
/* Pas encore de badge : un cercle sobre, pas un badge éteint. Un badge grisé
   se lit comme une sanction alors qu'il n'a simplement pas commencé. */
.badge-vide {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border-strong); border-radius: 50%;
}
.badge-vide span { width: 26%; height: 26%; border-radius: 50%; background: var(--text-soft); }
.badge-carte {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.badge-jauge { height: 6px; border-radius: 999px; background: var(--orange-soft); overflow: hidden; margin-top: 7px; }
.badge-jauge span { display: block; height: 100%; background: var(--orange); border-radius: 999px; transition: width 0.4s ease; }

/* La remise du badge. Elle doit se voir une fois, franchement, puis se
   laisser fermer : une animation qu'on ne peut pas passer devient une
   corvée dès la deuxième fois. */
.badge-fete {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 28px; text-align: center;
  /* Pas de backdrop-filter ici. Sur iPhone, un enfant animé au-dessus d'un
     fond flouté est promu sur sa propre couche, et Safari laisse alors une
     couture rectangulaire à l'emplacement exact de cet enfant. C'était l'une
     des deux causes possibles du halo carré vu autour du badge. Un fond un
     peu plus dense fait le même travail sans ce risque. */
  background: rgba(20, 17, 16, 0.96);
  /* Les halos des derniers paliers sont plus larges que l'écran d'un
     téléphone. Sans cette ligne, ils feraient apparaître une barre de
     défilement horizontale au moment de la remise. */
  overflow: hidden;
  animation: fete-fond 0.3s ease-out;
}

/* La lumière d'ambiance : la teinte du palier envahit tout l'écran, comme si
   le badge éclairait la pièce. Nulle au Bronze, franche au Diamant — c'est
   la source de lumière qui se voit le moins et qui change le plus la
   sensation. */
.fete-ambiance {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 42% at 50% 38%, var(--teinte-douce), transparent 72%);
  animation: fete-ambiance 1.3s ease-out both;
}
@keyframes fete-ambiance { from { opacity: 0; } to { opacity: var(--ambiance, 0); } }

/* L'éclair : au moment précis où le badge se pose, la lumière saute. C'est
   ce qui donne le sentiment d'un aboutissement plutôt que d'une apparition. */
.fete-flash {
  position: absolute; width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.75) 0%,
    var(--teinte-douce) 38%, transparent 70%);
  pointer-events: none;
  animation: fete-flash 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) var(--flash-retard, 0.38s) both;
}
.fete-flash.second { animation-delay: 0.95s; }
@keyframes fete-flash {
  0% { transform: scale(0.3); opacity: 0; }
  16% { opacity: 1; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* La poussière de lumière : des particules lentes qui montent après la
   gerbe et restent en suspension. C'est ce qui fait durer l'impression une
   fois que le gros de l'animation est passé. */
.poussiere {
  position: absolute; border-radius: 50%;
  width: var(--p-taille, 3px); height: var(--p-taille, 3px);
  background: var(--teinte); box-shadow: 0 0 6px var(--teinte);
  pointer-events: none;
  animation: poussiere-flotte var(--p-duree, 3s) ease-out var(--p-retard, 0s) both;
}
@keyframes poussiere-flotte {
  0% { transform: rotate(var(--angle)) translateY(-30px) scale(0.3); opacity: 0; }
  22% { opacity: 0.85; }
  70% { opacity: 0.5; }
  100% { transform: rotate(var(--angle)) translateY(calc(var(--p-distance, 220px) * -1)) scale(1); opacity: 0; }
}
@keyframes fete-fond { from { opacity: 0; } to { opacity: 1; } }
/* La scène : sa boîte est exactement celle du badge, et tous les effets qui
   la peuplent sont positionnés en absolu SANS décalage. Leur position par
   défaut dans un conteneur centré est donc le centre du badge — et non le
   centre de l'écran, qui tombait plus bas puisque le texte sous le badge
   pousse l'ensemble vers le haut. */
.fete-scene { position: relative; display: flex; align-items: center; justify-content: center; }
/* Le badge de la remise ne porte AUCUN filtre.
   `filter: drop-shadow()` était censé poser une lueur épousant l'hexagone.
   Il le fait dans Chrome, mais Safari calcule la lueur d'une image en
   `object-fit: contain` sur sa BOÎTE et non sur les pixels réellement
   dessinés : le badge, carré de 148 px avec l'hexagone au milieu, recevait
   donc un halo carré. La lueur est maintenant un élément à part, en dessous
   (voir .badge-lueur), et la boîte de l'image épouse enfin le badge grâce à
   `height: auto` — plus de bandes vides à gauche et à droite. */
.badge-fete .badge-svg, .badge-fete .badge-img {
  animation: fete-badge 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  height: auto;
}
.badge-lueur {
  position: absolute;
  width: var(--lueur-taille, 250px); height: var(--lueur-taille, 250px);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 122, 61, 0.32) 0%, rgba(255, 122, 61, 0.14) 44%, transparent 70%);
  pointer-events: none;
  animation: fete-lueur var(--lueur-duree, 0.9s) ease-out both;
}
@keyframes fete-lueur { from { opacity: 0; transform: scale(0.7); } to { opacity: var(--lueur-force, 1); transform: none; } }

/* L'onde : un anneau qui se propage à partir du badge. Réservé aux deux
   derniers paliers — c'est ce qui doit faire sentir qu'on n'est plus dans la
   même catégorie. */
.badge-onde {
  position: absolute; width: 130px; height: 130px; border-radius: 50%;
  border: 2px solid var(--teinte, var(--orange));
  pointer-events: none;
  animation: fete-onde 1.7s cubic-bezier(0.2, 0.7, 0.3, 1) var(--onde-retard, 0.15s) both;
}
/* L'anneau s'éteint AVANT d'atteindre le texte : un cercle net qui traverse
   « Novo nível » ressemble à un défaut d'affichage, pas à une onde. */
@keyframes fete-onde {
  0% { transform: scale(0.5); opacity: 0.75; }
  50% { opacity: 0.28; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes fete-badge {
  0% { transform: scale(0.2) rotate(-25deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* Les rayons derrière le badge : ils tournent lentement, une seule fois. */
.badge-rayons {
  position: absolute;
  width: var(--rayons-taille, 260px); height: var(--rayons-taille, 260px);
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255,122,61,0.30), transparent 22%, rgba(255,122,61,0.30) 44%, transparent 66%, rgba(255,122,61,0.30) 88%, transparent);
  animation: fete-rayons var(--rayons-duree, 2.4s) ease-out both;
  pointer-events: none;
}
@keyframes fete-rayons {
  from { transform: rotate(0) scale(0.6); opacity: 0; }
  35% { opacity: var(--rayons-force, 0.9); }
  to { transform: rotate(var(--rayons-tour, 160deg)) scale(1.15); opacity: 0; }
}
/* Une deuxième couche de rayons, tournant en sens inverse. Deux rotations
   contraires donnent une image qui bouge sans jamais paraître mécanique. */
.badge-rayons.contre {
  width: calc(var(--rayons-taille, 260px) * 0.62);
  height: calc(var(--rayons-taille, 260px) * 0.62);
  animation-duration: calc(var(--rayons-duree, 2.4s) * 1.25);
  --rayons-tour: calc(var(--rayons-tour-contre, -190deg));
}
.badge-fete h2 { font-size: 24px; margin: 6px 0 0 0; }
.badge-fete p { color: var(--text-muted); font-size: 14px; margin: 0; max-width: 320px; }
@media (prefers-reduced-motion: reduce) {
  .badge-fete, .badge-fete .badge-svg, .badge-fete .badge-img,
  .badge-rayons, .badge-lueur, .badge-onde, .fete-ambiance,
  .fete-flash, .poussiere { animation: none; }
  .badge-rayons, .badge-onde, .fete-flash, .poussiere { display: none; }
}
.serie-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--orange-soft); color: var(--orange-dark);
  font-size: 11.5px; font-weight: 700;
}

/* ====================================================================
   Barre de progression vers le palier suivant
   --------------------------------------------------------------------
   Segmentée plutôt que lisse : des cases se comptent du regard, une
   barre continue ne se lit qu'en pourcentage. Le badge visé est posé à
   l'autre bout, en sourdine : c'est la destination, pas encore un acquis.
   ==================================================================== */
.eco-wrap { width: 100%; }
.eco-rail { display: flex; align-items: center; justify-content: center; gap: 14px; }
.eco-bout { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px; flex: none; }
.eco-bout-nom { font-size: 10.5px; color: var(--text-muted); text-align: center; line-height: 1.2; }
/* Le palier pas encore atteint : éteint, mais visible. Il doit donner
   envie sans faire croire qu'il est gagné. */
.eco-bout.futur .badge-img { filter: grayscale(0.85) brightness(0.7); opacity: 0.55; }
.eco-bout.futur .eco-bout-nom { color: var(--text-soft); }

/* Sur un grand écran, 18 segments étirés sur toute la largeur ne se lisent
   plus comme une jauge mais comme une frise. On borne la largeur. */
.eco-milieu { flex: 1; min-width: 0; max-width: 560px; }
.eco-bar { display: flex; gap: 3px; height: 16px; }
.eco-seg {
  flex: 1; border-radius: 3px;
  background: var(--orange-soft);
  transition: background 0.3s ease, opacity 0.3s ease;
}
.eco-seg:first-child { border-radius: 8px 3px 3px 8px; }
.eco-seg:last-child { border-radius: 3px 8px 8px 3px; }
.eco-seg.on { background: var(--orange); }
.eco-chiffres {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.eco-phrase { font-size: 13px; color: var(--text-muted); margin-top: 10px; text-align: center; }
.eco-phrase strong { color: var(--text); }

/* La route des cinq paliers */
.route-paliers { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.route-etape { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; min-width: 0; }
.route-etape .badge-img { filter: grayscale(0.9) brightness(0.55); opacity: 0.4; transition: all 0.3s ease; }
.route-etape.atteint .badge-img { filter: none; opacity: 1; }
.route-etape.vise .badge-img { filter: grayscale(0.5) brightness(0.85); opacity: 0.8; }
.route-seuil { font-size: 10px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.route-etape.atteint .route-seuil { color: var(--orange-dark); font-weight: 700; }

@media (max-width: 520px) {
  .eco-bout { width: 58px; }
  .eco-bout-nom { font-size: 9.5px; }
  .eco-bar { height: 14px; gap: 2px; }
}

/* ====================================================================
   Le badge à côté du nom
   --------------------------------------------------------------------
   Un éclat le traverse UNE fois au chargement. Objectif : que l'œil s'y
   pose en ouvrant l'app. Une animation en boucle deviendrait un tic
   visuel qu'on finit par ne plus voir, ou pire, qui agace.
   ==================================================================== */
/* L'éclat suit la SILHOUETTE du badge : le pseudo-élément est masqué par
   l'image du badge elle-même, donc la lumière ne passe que là où le PNG est
   opaque. Sans ce masque, on voyait un rectangle lumineux traverser le vide
   autour de l'hexagone. */
.badge-brille { position: relative; display: inline-flex; }
.badge-brille::after { content: none; }

@supports ((-webkit-mask-image: url("")) or (mask-image: url(""))) {
  .badge-brille::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(105deg,
      transparent 38%, rgba(255, 255, 255, 0.30) 46%,
      rgba(255, 255, 255, 0.85) 50%,
      rgba(255, 255, 255, 0.30) 54%, transparent 62%);
    background-size: 260% 100%;
    background-repeat: no-repeat;
    -webkit-mask-image: var(--badge-src);
    mask-image: var(--badge-src);
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    animation: badge-eclat var(--eclat-duree, 1.4s) ease-out var(--eclat-retard, 0.45s) var(--eclat-nb, 1) both;
    pointer-events: none;
  }
}
/* On anime la POSITION du dégradé, pas une translation du bloc : le masque
   doit rester calé sur le badge pendant tout le passage de la lumière. */
@keyframes badge-eclat {
  from { background-position: 190% 0; }
  to { background-position: -90% 0; }
}

/* Les étincelles de la remise du badge : elles partent du centre en
   étoile, chacune avec un léger décalage pour éviter l'effet mécanique. */
.etincelle {
  position: absolute;
  width: var(--etincelle-taille, 7px); height: var(--etincelle-taille, 7px);
  border-radius: 50%;
  background: var(--orange-dark);
  box-shadow: 0 0 10px rgba(255, 138, 82, 0.9);
  animation: etincelle-vol var(--etincelle-duree, 1.1s)
    cubic-bezier(0.15, 0.8, 0.3, 1) var(--retard, 0ms) both;
  pointer-events: none;
}
@keyframes etincelle-vol {
  from { transform: rotate(var(--angle)) translateY(0) scale(0.4); opacity: 0; }
  25% { opacity: 1; }
  to { transform: rotate(var(--angle)) translateY(calc(var(--etincelle-distance, 160px) * -1)) scale(0.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .badge-brille::after, .etincelle { display: none; animation: none; }
}

/* ====================================================================
   La carte d'identité de l'ouvrier
   --------------------------------------------------------------------
   Le badge avait d'abord été posé à côté du prénom dans l'en-tête. Il s'y
   cognait au logo de l'entreprise : deux emblèmes voisins, aucun des deux
   ne se lit, et l'en-tête perdait son calme. Ici, le badge a de l'espace,
   il appartient clairement à la personne, et le logo reste seul en haut.
   ==================================================================== */
.carte-identite { padding: 18px; }
.identite-haut { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.identite-nom { font-size: 17px; font-weight: 700; line-height: 1.2; }
.identite-niveau { font-size: 13px; color: var(--orange-dark); font-weight: 600; margin-top: 1px; }
.identite-points { font-size: 22px; font-weight: 800; margin-top: 6px; letter-spacing: -0.4px; }
.identite-points span { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; }

/* Le barème ne s'impose pas : il se déplie quand la question se pose. */
.identite-plus { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.identite-plus summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-muted);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.identite-plus summary::-webkit-details-marker { display: none; }
.identite-plus summary::before {
  content: "+"; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border-strong); font-size: 13px; line-height: 1;
}
.identite-plus[open] summary::before { content: "–"; }

/* Les onglets de la page Heures. Le panneau caché ne doit pas seulement
   être invisible : il ne doit pas non plus laisser de place vide. */
.onglet-panneau.hidden { display: none !important; }
@media (max-width: 760px) {
  /* Sur téléphone, la barre d'onglets défile horizontalement plutôt que de
     passer à la ligne : six onglets empilés mangeraient tout l'écran. */
  .segmented { display: flex; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .segmented button { white-space: nowrap; padding: 9px 14px; font-size: 13px; }
}

/* ====================================================================
   La carte prend la couleur du badge
   --------------------------------------------------------------------
   Ce qui change : le halo derrière le badge, le nom du niveau, le liseré
   de la carte. Ce qui NE change PAS : la barre de progression, qui reste
   orange. Elle veut dire la même chose du bronze au diamant ; lui donner
   cinq couleurs, ce serait dire cinq choses différentes.
   ==================================================================== */
.carte-teintee {
  border-color: var(--teinte-douce);
  background-image: radial-gradient(120% 70% at 18% 0%, var(--teinte-douce), transparent 62%);
}
.carte-teintee .identite-niveau { color: var(--teinte); }
/* Le halo : une lueur douce derrière le badge, dans son propre métal. */
.halo-badge { position: relative; display: inline-flex; flex: none; }
.halo-badge::before {
  content: ""; position: absolute; inset: -22%;
  border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--teinte-douce), transparent 68%);
}
.badge-fete .badge-rayons {
  background: conic-gradient(from 0deg, var(--teinte-douce), transparent 22%,
    var(--teinte-douce) 44%, transparent 66%, var(--teinte-douce) 88%, transparent);
}
/* Ici aussi la lueur passe par l'élément du dessous et non par un filtre sur
   l'image : voir le commentaire de `.badge-fete .badge-img` plus haut. Elle
   prend le métal du niveau, comme avant. */
.badge-fete .badge-lueur {
  background: radial-gradient(circle, var(--teinte-douce) 0%,
    color-mix(in srgb, var(--teinte-douce) 45%, transparent) 44%, transparent 70%);
}
.badge-fete .etincelle { background: var(--teinte); box-shadow: 0 0 10px var(--teinte-douce); }

/* ====================================================================
   Cinq remises, cinq ambiances
   --------------------------------------------------------------------
   Une seule animation rejouée à l'identique cinq fois, c'est cinq fois la
   même récompense : la deuxième fait déjà moins d'effet que la première, et
   la cinquième n'en fait plus aucun. Chaque palier a donc sa lumière, sa
   matière et son rythme, et ils montent en intensité.

   Le geste reste le même — le badge arrive, la lumière part du centre — mais
   la MATIÈRE change : le cuivre est chaud et lent, l'argent est net et
   froid, l'or rayonne, le platine s'ouvre large, le diamant se décompose en
   couleurs.
   ==================================================================== */

/* Bronze : le cuivre. Peu d'étincelles, larges, lentes, comme des braises. */
.fete-1 .etincelle { box-shadow: 0 0 14px var(--teinte); }
.fete-1 .badge-rayons { filter: blur(1px); }

/* Argent : le métal froid. Étincelles fines et rapides, arêtes nettes. */
.fete-2 .etincelle { border-radius: 1px; box-shadow: 0 0 9px #FFFFFF; }
.fete-2 .badge-lueur {
  background: radial-gradient(circle, rgba(226, 232, 236, 0.26) 0%,
    rgba(207, 211, 214, 0.12) 44%, transparent 70%);
}

/* Or : le rayonnement. C'est le palier le plus lumineux du milieu, celui où
   l'on doit sentir qu'on a franchi quelque chose. */
.fete-3 .etincelle { box-shadow: 0 0 16px #FFD98A, 0 0 30px rgba(242, 194, 90, 0.5); }
.fete-3 .badge-lueur {
  background: radial-gradient(circle, rgba(242, 194, 90, 0.34) 0%,
    rgba(255, 216, 130, 0.16) 40%, transparent 72%);
}

/* Platine : l'ampleur. Étincelles en losange, onde qui s'ouvre largement,
   rien de tapageur — le prestige est dans l'espace occupé, pas dans le
   nombre. */
.fete-4 .etincelle {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  box-shadow: 0 0 14px rgba(214, 232, 245, 0.95);
}
.fete-4 .badge-onde { border-color: rgba(196, 221, 240, 0.85); }
.fete-4 .badge-lueur {
  background: radial-gradient(circle, rgba(159, 187, 212, 0.30) 0%,
    rgba(214, 232, 245, 0.14) 46%, transparent 74%);
}

/* Diamant : la décomposition de la lumière. Étincelles en étoile à quatre
   branches, et surtout PRISMATIQUES : trois teintes qui alternent, comme un
   éclat qui se sépare. Deux anneaux, deux couches de rayons contraires. */
.fete-5 .etincelle {
  border-radius: 0;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
}
.fete-5 .etincelle:nth-child(3n)   { background: #8FD6FF; box-shadow: 0 0 16px #8FD6FF; }
.fete-5 .etincelle:nth-child(3n+1) { background: #FFFFFF; box-shadow: 0 0 16px #DFF6FF; }
.fete-5 .etincelle:nth-child(3n+2) { background: #C9B8FF; box-shadow: 0 0 16px #C9B8FF; }
.fete-5 .badge-onde { border-color: rgba(143, 214, 255, 0.9); }
.fete-5 .badge-lueur {
  background: radial-gradient(circle, rgba(143, 214, 255, 0.34) 0%,
    rgba(201, 184, 255, 0.16) 42%, transparent 74%);
}
/* Le badge du dernier palier prend son temps : il arrive de plus loin et
   s'installe. */
.fete-5 .badge-img { animation-duration: 1.15s; }


/* ======================================================================
   TÉLÉPHONE : les filtres se replient, les tableaux deviennent des fiches
   ====================================================================== */

/* Le bouton « Filtrer » ne sert que sur téléphone (sur ordinateur les
   filtres sont déjà tous visibles), mais le menu « ⋯ » qui l'accompagne,
   lui, doit rester atteignable PARTOUT : c'est le seul accès à la remise à
   zéro des paiements. En masquant toute la barre sur ordinateur, l'action
   avait purement et simplement disparu de l'écran. */
.barre-filtres-mobile { display: flex; justify-content: flex-end; margin-bottom: 12px; }
#btn-filtres { display: none; }
.compte-filtres[hidden] { display: none !important; }
.compte-filtres {
  display: inline-grid; place-items: center;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--orange-soft); color: var(--orange-dark);
  font-size: 11px; font-weight: 700; margin-left: 6px;
}

@media (max-width: 720px) {
  .barre-filtres-mobile { align-items: center; gap: 8px; justify-content: stretch; }
  #btn-filtres { display: inline-flex; flex: 1; justify-content: center; }

  /* Repliés par défaut. On traversait tout un écran de filtres avant
     d'atteindre la première facture. */
  .zone-filtres { display: none; }
  .zone-filtres.ouverte { display: block; }
  .zone-filtres .toolbar { flex-direction: column; align-items: stretch; }
  .zone-filtres .toolbar > input,
  .zone-filtres .toolbar > select { width: 100%; min-width: 0; }
  .zone-filtres .spacer { display: none; }

  /* ---- Un tableau ne tient pas dans 390 px ----------------------------
     Trois colonnes finissaient hors écran, dont « Reste à recevoir » — le
     chiffre même qu'on vient chercher. Chaque ligne devient une fiche :
     l'en-tête disparaît, et chaque cellule porte le nom de sa colonne. */
  table.en-fiches thead { display: none; }
  table.en-fiches, table.en-fiches tbody, table.en-fiches tr, table.en-fiches td { display: block; width: 100%; }
  table.en-fiches tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  /* En fiche, la place ne manque pas : on rend le nom de catégorie entier. */
  table.en-fiches .category-tag {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  table.en-fiches td {
    border: 0;
    padding: 3px 0;
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    flex-wrap: wrap;
    text-align: right;
  }
  /* Une précision sous une valeur (« déjà reçu : … sur … ») prend sa propre
     ligne : côte à côte, les deux se disputaient la largeur et le montant
     principal se cassait en deux. */
  table.en-fiches td[data-col] > div { flex: 1 0 100%; text-align: right; }
  /* Le nom de la colonne, à gauche de la valeur. */
  table.en-fiches td::before {
    content: attr(data-col);
    flex: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
  }
  /* Une cellule sans nom de colonne (la première, les actions) occupe toute
     la largeur : c'est le titre de la fiche, ou sa rangée de boutons. */
  table.en-fiches td:not([data-col]) { display: block; text-align: left; }
  table.en-fiches td:not([data-col])::before { content: none; }
  table.en-fiches td.titre-fiche {
    font-size: 14.5px; font-weight: 600;
    padding-bottom: 8px; margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  table.en-fiches td.actions-fiche {
    padding-top: 10px; margin-top: 6px;
    border-top: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 6px;
  }
  /* Une cellule vide n'a rien à dire : elle disparaît au lieu de laisser
     une ligne « Contact  - » qui n'apprend rien. Idem pour une valeur déjà
     reprise dans le titre de la fiche. */
  table.en-fiches td.vide,
  table.en-fiches td.masquer-fiche { display: none; }
  /* Le pendant : ce qui n'a de sens QUE dans la fiche. Sur ordinateur, le nom
     du tiers a sa propre colonne juste à côté — le répéter dans le titre
     forçait le numéro à passer sur trois lignes, et toutes les lignes du
     tableau à grandir avec lui. */
  table.en-fiches .montrer-fiche { display: inline; }
  /* La case à cocher se pose en haut à droite de la fiche, hors du flux :
     une ligne « [ ] » toute seule ne veut rien dire. */
  table.en-fiches tr { position: relative; }
  table.en-fiches td.case-fiche {
    position: absolute; top: 12px; right: 14px; width: auto; padding: 0;
  }
  table.en-fiches td.titre-fiche { padding-right: 34px; }
  /* Le tableau n'a plus besoin de défiler horizontalement. */
  .table-scroll:has(table.en-fiches) { overflow-x: visible; }
}


/* ---- Les explications repliées derrière un « ? » ----------------------
   Les pavés d'explication (TVA, anomalies, import groupé) disaient des
   choses justes mais occupaient l'écran en permanence, y compris la
   centième fois. Ils passent derrière un « ? » : rien n'est perdu, et ce
   qu'on vient faire redevient visible du premier coup d'oeil. */
.aide-bouton {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  border-radius: 999px; padding: 5px 12px;
  font: 600 12.5px 'Inter', sans-serif; cursor: pointer;
}
.aide-bouton:hover { color: var(--text); border-color: var(--border-strong); }
.aide-bouton .rond {
  width: 16px; height: 16px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.aide-contenu { display: none; margin-top: 12px; }
.aide-contenu.ouverte { display: block; }
.aide-encadre {
  border: 1px solid rgba(240, 194, 92, 0.45);
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 13px; color: var(--text-muted); line-height: 1.55;
}
.aide-encadre p { margin: 0 0 10px; }
.aide-encadre p:last-child { margin: 0; }
.aide-encadre strong { color: var(--text); }

/* La carte d'import ne se replie que sur téléphone : sur ordinateur, elle
   est le point d'entrée du travail à la chaîne et doit rester ouverte. */
#batch-toggle { display: none; }
@media (max-width: 720px) {
  #batch-toggle { display: inline-flex; }
  #batch-corps { display: none; }
  #batch-corps.ouvert { display: block; }
}

/* Les anomalies : une ligne, le détail au clic. */
.anomalie:last-child { border-bottom: 0 !important; }
.anomalie > summary::-webkit-details-marker { display: none; }
.anomalie > summary:hover { color: #fff; }


/* ---- De l'air ---------------------------------------------------------
   Deux cartes qui se touchent se lisent comme une seule ; un tableau collé
   à son cadre fatigue à la longue. Rien de spectaculaire ici, mais c'est ce
   qui change le plus à l'usage. */
.card + .card { margin-top: 20px; }
.card table { border-collapse: collapse; }
.card thead th { padding-top: 14px; padding-bottom: 12px; }
.card tbody td { padding-top: 13px; padding-bottom: 13px; }
/* Les lignes d'un tableau se séparent par un trait discret plutôt que par un
   cadre autour de chaque cellule. */
.card tbody tr + tr td { border-top: 1px solid var(--border); }

@media (max-width: 720px) {
  /* Sur téléphone, l'air se prend en hauteur : la largeur, elle, est
     comptée — le contenu ne doit jamais coller au bord de l'écran. */
  .card { padding: 18px 16px; }
  .grid { gap: 16px; }
  .card + .card { margin-top: 16px; }
}

/* ===================================================================
   Rapports — la vue d'ensemble
   -------------------------------------------------------------------
   Quatre indicateurs en haut, chacun avec son petit dessin, puis un
   panneau « liste + détail » : on choisit une facture à gauche, on la
   lit en entier à droite, sans quitter la page ni ouvrir de fenêtre.
   Palette, typographie et matière de verre : celles de l'app.
   =================================================================== */

/* ---- La rangée d'indicateurs ---------------------------------------- */
.kpi-rangee {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.3fr;
  gap: 16px;
  margin-bottom: 18px;
  align-items: stretch;
}
.kpi-rangee .card + .card { margin-top: 0; }
.kpi { padding: 20px 20px 18px 20px; display: flex; flex-direction: column; }
.kpi-tete { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.kpi-lib { font-size: 12.5px; color: var(--text-muted); font-weight: 500; line-height: 1.35; }
.kpi-icone {
  margin-left: auto; width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.kpi-icone.rouge { background: var(--red-soft); border-color: rgba(255,122,122,0.34); color: var(--red); }
.kpi-icone.ambre { background: var(--amber-soft); border-color: rgba(240,194,92,0.34); color: var(--amber); }
.kpi-icone.vert  { background: var(--green-soft); border-color: rgba(78,207,149,0.34); color: var(--green); }
/* Pastille d'information, posée en haut à droite d'une carte. */
.chip-periode {
  margin-left: auto; flex-shrink: 0; max-width: 55%;
  font-family: 'Inter', sans-serif; font-size: 10.5px; line-height: 1.35; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; text-align: center;
}
.kpi-valeur {
  font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 27px; line-height: 1.05;
  color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.3px;
}
.kpi-valeur .kpi-unite { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.kpi-sous { font-size: 11.5px; color: var(--text-muted); margin-top: 7px; line-height: 1.45; }
.kpi-sous .fleche { font-weight: 700; }
.kpi-sous .hausse { color: var(--red); }
.kpi-sous .baisse { color: var(--green); }
.kpi-dessin { margin-top: auto; padding-top: 16px; }

/* Mini barres verticales, dans une tuile d'indicateur. */
.mini-bars { display: flex; align-items: flex-end; gap: 5px; height: 54px; }
.mini-bar { flex: 1; min-width: 0; border-radius: 5px 5px 3px 3px; background: rgba(255,138,82,0.34); }
.mini-bar.max { background: linear-gradient(180deg, #FF9A66, var(--orange)); }
.mini-legende { display: flex; gap: 5px; margin-top: 6px; }
.mini-legende span { flex: 1; min-width: 0; text-align: center; font-size: 8.5px; letter-spacing: .2px; text-transform: uppercase; color: var(--text-soft); white-space: nowrap; overflow: hidden; }

/* Mini courbe à points, dans une tuile d'indicateur. */
.mini-courbe svg { display: block; width: 100%; height: 58px; overflow: visible; }

/* Les trois pastilles de la quatrième tuile : la même somme, répartie par
   urgence. C'est la répartition, pas le total, qui dit s'il faut agir. */
/* margin-top:auto : les pastilles se posent en bas de la tuile, à la même
   hauteur que les graphiques des trois autres. */
.kpi-tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; padding-top: 16px; }
.kpi-tuile {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 11px; min-width: 0;
}
.kpi-tuile.forte { background: linear-gradient(160deg, rgba(255,122,61,0.30), rgba(255,80,2,0.16)); border-color: rgba(255,138,82,0.45); }
.kpi-tuile-lib { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-tuile.forte .kpi-tuile-lib { color: rgba(255,255,255,0.72); }
.kpi-tuile-val { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 14.5px; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1240px) { .kpi-rangee { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .kpi-rangee { grid-template-columns: 1fr; } }

/* ---- Le panneau « liste + détail » ---------------------------------- */
.panneau-factures {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm), var(--glass-edge);
  overflow: hidden; margin-bottom: 20px;
}
.pf-gauche { padding: 20px 18px; border-right: 1px solid var(--border); min-width: 0; }
.pf-droite { padding: 22px 24px; min-width: 0; background: rgba(255,255,255,0.028); }
@media (max-width: 980px) {
  .panneau-factures { grid-template-columns: minmax(0, 1fr); }
  .pf-gauche { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ====================================================================
   Bons de facturation : ce qui est accepté mais pas encore facturé
   --------------------------------------------------------------------
   Ce bloc ouvre l'onglet parce qu'il porte de l'argent invisible ailleurs :
   le sous-traitant a donné son accord, le montant est figé, mais tant qu'il
   n'a pas facturé, la dépense n'existe dans aucun autre écran de l'app.
   D'où le liseré orange : ce n'est pas une alerte, c'est un engagement.
   ==================================================================== */
/* L'avertissement du bon en régie : visible sans être un message d'erreur.
   Il ne bloque rien, il prévient, donc il est ambre et pas rouge. */
.bc-avert {
  border: 1px solid var(--amber);
  background: rgba(240, 170, 60, 0.10);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 12px 0;
  font-size: 12.8px;
  line-height: 1.55;
  color: var(--text-muted);
}
.bc-avert strong { color: var(--text); }
.bc-avert.hidden { display: none; }

.bc-attente {
  border: 1px solid rgba(255, 138, 82, 0.32);
  background: var(--orange-soft);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.bc-attente-tete { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.bc-attente-lib {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--orange-dark); font-weight: 700;
}
.bc-attente-sous {
  margin: 6px 0 0 0; font-size: 12.5px; line-height: 1.5;
  color: var(--text-muted); max-width: 62ch;
}
.bc-attente-total { margin-left: auto; text-align: right; }
.bc-attente-total span {
  display: block; font-family: 'Blinker', sans-serif; font-weight: 700;
  font-size: 24px; font-variant-numeric: tabular-nums;
}
.bc-attente-total small { color: var(--text-muted); font-size: 11.5px; }
.bc-attente-liste { list-style: none; margin: 14px 0 0 0; padding: 0; }
.bc-attente-liste li {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 8px 0; border-top: 1px solid rgba(255, 138, 82, 0.22);
  font-size: 13px;
}
.bc-a-num { font-weight: 700; white-space: nowrap; }
.bc-a-nom { flex: 1 1 140px; min-width: 0; }
.bc-a-quand { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.bc-a-mt {
  margin-left: auto; font-family: 'Blinker', sans-serif; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bc-attente-vide { color: var(--text-muted); font-size: 12.5px; margin: 0; }

/* L'annonce d'un accord qui vient d'arriver. Verte et non orange : ce n'est
   pas une alerte, c'est une bonne nouvelle. Elle se ferme d'un clic, et ne
   revient que pour un accord réellement nouveau. */
.bc-nouveaute {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--green-soft);
  border: 1px solid rgba(78, 207, 149, 0.34);
  font-size: 13.5px;
}
.bc-nouveaute > div:first-child { flex: 1 1 260px; min-width: 0; }
.bc-nouveaute-sous { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }

/* Le lien à coller, offert juste après l'envoi. Le nouvel Outlook ne rend
   pas cliquable une adresse posée dans un brouillon : c'est son défaut, et
   ce bouton est le seul contournement qui marche à tous les coups. */
/* ---- Déductions d'un bon ------------------------------------------- */
.bc-deductions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.bc-deduction {
  display: grid; grid-template-columns: 1fr 16px 140px 34px;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.bc-deduction input { font-size: 13px; padding: 9px 10px; }
/* Le signe devant la case : il se lit avant le chiffre, comme sur le papier. */
.bc-moins { color: var(--red); font-weight: 700; text-align: center; font-size: 16px; }
.bc-deductions-aide { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; line-height: 1.45; max-width: 70ch; }
.bc-recap-net {
  margin: 12px 0 0 auto; max-width: 340px; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.bc-recap-net > div { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.bc-recap-net > div > span:first-child { color: var(--text-muted); }
.bc-recap-net .bc-net {
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 7px;
  font-weight: 700; font-size: 14px;
}
.bc-recap-net .bc-net > span:first-child { color: var(--text); }
.bc-recap-net .bc-net-ko > span:last-child { color: var(--red); }
@media (max-width: 640px) { .bc-deduction { grid-template-columns: 1fr 16px 110px 34px; } }

/* La note sur la répartition des prix, repliée : une ligne cliquable au lieu
   d'un grand champ vide sur chaque bon. */
.bc-note-prix { margin-top: 16px; }
.bc-note-prix > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted);
  list-style: none; padding: 6px 0;
}
.bc-note-prix > summary::-webkit-details-marker { display: none; }
.bc-note-prix > summary::before { content: "+ "; color: var(--orange); font-weight: 700; }
.bc-note-prix[open] > summary::before { content: "− "; }
.bc-note-prix > summary span { font-weight: 400; font-size: 12px; margin-left: 6px; opacity: .8; }
.bc-note-prix > summary:hover { color: var(--text); }

/* Deux champs par ligne dans le formulaire de contrat, et un seul dès que
   l'écran se resserre : un champ de date à 140 px ne se remplit pas. */
.bc-grille {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px;
}
@media (max-width: 640px) { .bc-grille { grid-template-columns: 1fr; } }

.bc-lien-envoi {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--orange-soft);
  border: 1px solid rgba(255, 138, 82, 0.32);
  font-size: 13px;
}
.bc-lien-envoi > div:first-child { flex: 1 1 320px; min-width: 0; }
.bc-lien-url {
  margin-top: 6px; font-size: 12px; color: var(--text-muted);
  word-break: break-all; user-select: all;
}
/* La manoeuvre du collage en couleur : deux touches à faire dans le bon
   ordre. Écrite plus petite que le reste du panneau, parce qu'on ne la lit
   qu'une fois, la première. */
.bc-lien-astuce {
  margin-top: 8px; font-size: 12px; color: var(--text-muted);
  line-height: 1.45; max-width: 52ch;
}
/* Quatre boutons par ligne : sans nowrap ils se cassent en escalier dès que
   le tableau se resserre. Et surtout, la colonne reste COLLÉE à droite quand
   le tableau déborde : sans ça, « Annuler » sortait de l'écran et il fallait
   faire défiler horizontalement pour atteindre l'action la plus engageante
   de la ligne. Le reste du tableau glisse dessous. */
.bc-actions-cell { text-align: right; }
.bc-actions-cell .bc-actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px; min-width: 168px;
}
.bc-actions-cell .btn { margin: 0; width: 100%; }
/* L'objet porte maintenant le chantier en dessous : deux colonnes disaient
   la même chose. Bornées, sinon une adresse longue repousse les boutons. */
.bc-td-objet { max-width: 220px; }
.bc-td-chantier {
  font-size: 11px; color: var(--text-soft); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 620px) {
  .bc-attente-total { margin-left: 0; text-align: left; }
  .bc-a-mt { margin-left: 0; }
}

/* Les onglets de la liste. */
.pf-onglets { display: flex; gap: 6px; margin: 12px 0 8px 0; flex-wrap: wrap; }
.pf-onglet {
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
}
.pf-onglet:hover { border-color: var(--border-strong); color: var(--text); }
.pf-onglet[aria-selected="true"] { background: var(--orange); border-color: var(--orange); color: #fff; }
.pf-onglet .pf-compte { opacity: .75; margin-left: 4px; font-weight: 700; }

/* La liste elle-même : elle défile DANS le panneau, la page ne s'allonge pas. */
.pf-liste { max-height: 396px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.pf-ligne {
  width: 100%; text-align: left; font-family: 'Inter', sans-serif; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-bottom: 4px;
  background: transparent; border: 1px solid transparent; border-radius: 14px; color: inherit;
}
.pf-ligne:hover { background: var(--surface-2); border-color: var(--border); }
.pf-ligne[aria-current="true"] {
  background: linear-gradient(120deg, var(--orange) 0%, #E14700 100%);
  border-color: rgba(255,255,255,0.24);
  box-shadow: 0 8px 22px rgba(255,80,2,0.32);
}
.pf-ligne[aria-current="true"] .pf-num,
.pf-ligne[aria-current="true"] .pf-montant { color: #fff; }
.pf-ligne[aria-current="true"] .pf-quand { color: rgba(255,255,255,0.8); }
.pf-ligne[aria-current="true"] .pf-init { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.4); color: #fff; }
.pf-ligne[aria-current="true"] .badge { background: rgba(255,255,255,0.25); color: #fff; }
.pf-init {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 12px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
}
.pf-ident { flex: 1; min-width: 0; }
/* display:block indispensable : sur un <span> inline, ni overflow ni
   text-overflow ne s'appliquent — le nom débordait sous la pastille. */
.pf-num { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-quand { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-soft); margin-top: 3px; }
.pf-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-ligne .badge { flex-shrink: 0; font-size: 10px; padding: 2px 7px; }
.pf-montant { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 13px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.pf-vide { color: var(--text-muted); font-size: 13px; padding: 18px 4px; }

/* Le détail, à droite. */
.pf-det-tete { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pf-det-num { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 26px; line-height: 1.1; }
.pf-det-lib { font-size: 11.5px; color: var(--text-muted); }
.pf-det-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.pf-det-bloc-lib { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft); }
.pf-det-bloc-val { font-size: 14px; font-weight: 600; margin-top: 4px; }
.pf-montants { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; margin-top: 20px; }
.pf-mtile {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 14px; min-width: 0;
}
.pf-mtile.accent { background: linear-gradient(150deg, rgba(255,122,61,0.26), rgba(255,80,2,0.12)); border-color: rgba(255,138,82,0.42); }
.pf-mtile-lib { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft); }
.pf-mtile.accent .pf-mtile-lib { color: rgba(255,255,255,0.75); }
.pf-mtile-val { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 18px; margin-top: 5px; font-variant-numeric: tabular-nums; }
.pf-pied {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}
.pf-pied-item { min-width: 0; }
.pf-note { font-size: 12px; color: var(--text-muted); margin: 16px 0 0 0; line-height: 1.5; }
.pf-note.perso { background: var(--purple-soft); border: 1px solid rgba(180,156,255,0.32); color: var(--purple-dark); border-radius: var(--radius-sm); padding: 10px 13px; }

/* Le bloc « tout ce que ce tiers doit », sous le détail. */
.pf-tiers { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.pf-tiers-total { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 21px; margin-top: 5px; display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.pf-tiers-nb { font-family: 'Inter', sans-serif; font-weight: 400; font-size: 11.5px; color: var(--text-muted); }
.pf-tiers-liste { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.pf-tiers-ligne {
  display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12px; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  padding: 7px 9px; text-align: left;
}
.pf-tiers-ligne:hover { background: var(--surface-2); border-color: var(--border); }
.pf-tiers-num { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-tiers-date { color: var(--text-soft); font-size: 11px; }
.pf-tiers-ligne .badge { font-size: 10px; padding: 2px 7px; flex-shrink: 0; }
.pf-tiers-mt { margin-left: auto; font-family: 'Blinker', sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ---- Rapports : ajustements de lisibilité ---------------------------- */
/* La pastille d'horizon, sous le libellé de chaque indicateur. Deux tuiles
   suivent la période choisie en haut, deux ont un horizon fixe : sans cette
   ligne, impossible de savoir laquelle est laquelle. */
.chip-horizon {
  display: inline-block; margin-bottom: 9px;
  font-size: 10px; letter-spacing: .2px; color: var(--text-soft);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-horizon.fixe { color: var(--text-soft); opacity: .85; }
.mini-note { font-size: 11px; color: var(--text-muted); margin: 9px 0 0 0; line-height: 1.45; }
.mini-note .hausse { color: var(--red); font-weight: 600; }
.mini-note .baisse { color: var(--green); font-weight: 600; }
.mini-echelle { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 10px; color: var(--text-soft); }
.kpi-tuiles.deux { grid-template-columns: repeat(2, 1fr); }
.kpi-tuiles.deux .kpi-tuile-val { font-size: 16px; }

/* Montant et pastille d'échéance empilés à droite de la ligne : la pastille
   était sur la même ligne que le numéro et le tronquait. */
.pf-droit { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }

/* Le bouton qui déplie un tableau détaillé. */
.deplier { margin-top: 10px; }
.repliable { margin-top: 14px; }

/* ---- Rapports : le diagnostic des données --------------------------- */
.diag-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px 30px; }
.diag-ligne { min-width: 0; }
.diag-tete { display: flex; align-items: baseline; gap: 12px; }
.diag-titre { font-size: 12.5px; color: var(--text); font-weight: 500; flex: 1; min-width: 0; }
.diag-chiffre { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 20px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.diag-piste { height: 7px; border-radius: 7px; background: rgba(255,255,255,0.07); overflow: hidden; margin: 8px 0 7px 0; }
.diag-part { height: 100%; border-radius: 7px; }
.diag-detail { font-size: 11.5px; color: var(--text-muted); }

.diag-soustitre { font-family: 'Blinker', sans-serif; font-size: 14px; margin: 26px 0 12px 0; }
.diag-verdicts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.diag-verdict { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm); padding: 13px 15px; background: var(--surface-2); }
.diag-verdict.vert  { border-left-color: var(--green); }
.diag-verdict.ambre { border-left-color: var(--amber); }
.diag-verdict.rouge { border-left-color: var(--red); }
.diag-verdict-titre { font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.diag-verdict-texte { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.diag-fin { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px 0; line-height: 1.55; max-width: 78ch; }
.diag-fin strong { color: var(--text); }

/* ---- Rapports : les « bons à payer » -------------------------------- */
.bon-form { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 18px; background: var(--surface-2); }
.bon-form-liste { max-height: 300px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.bon-form-ligne { display: flex; align-items: center; gap: 11px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.bon-form-ligne:hover { background: var(--surface-2); }
.bon-form-ligne + .bon-form-ligne { border-top: 1px solid var(--border); }
.bon-form-ligne input[type="checkbox"] { width: 17px; height: 17px; flex-shrink: 0; }
.bon-form-nom { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; }
.bon-form-meta { display: block; font-size: 11px; color: var(--text-soft); font-weight: 400; margin-top: 2px; }
.bon-form-ligne .badge { flex-shrink: 0; font-size: 10px; padding: 2px 7px; }
.bon-form-mt { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 13px; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.bon-carte { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px 16px; background: var(--surface-2); }
.bon-carte + .bon-carte { margin-top: 12px; }
/* Le lien reste visible en entier : un lien tronqué se copie mal à la main. */
.bon-lien { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.bon-lien input { flex: 1; min-width: 230px; font-size: 12px; font-family: ui-monospace, monospace; }
.bon-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.bon-detail-col { min-width: 0; }
.bon-detail-ligne { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 5px 0; }
.bon-detail-ligne + .bon-detail-ligne { border-top: 1px solid var(--border); }
.bon-note-patron { font-size: 12.5px; color: var(--text); background: var(--surface); border-left: 3px solid var(--orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 10px 14px; margin: 14px 0 0 0; font-style: italic; }

/* Bandeau posé en haut de Factures quand on arrive depuis une sélection. */
.bandeau-bon { border-color: var(--orange) !important; background: var(--orange-soft) !important; }

/* ==========================================================================
   La messagerie du dirigeant
   --------------------------------------------------------------------------
   Une pastille discrète en bas à droite, qui s'allume quand une réponse
   arrive. Volontairement une conversation et pas un tableau de plus :
   l'information est un message de quelqu'un, à un moment donné.
   ========================================================================== */
#messagerie { position: fixed; right: 22px; bottom: 22px; z-index: 55; }
/* Une fenêtre ouverte passe avant la pastille : posée par-dessus, elle
   venait manger le bouton « Enregistrer » dans le coin. */
body:has(.modal-overlay:not(.hidden)) #messagerie { display: none; }
/* La bulle d'alertes aussi. Sur un téléphone elle se posait EN PLEIN MILIEU
   d'une fenêtre ouverte et en masquait le texte : on lisait « 1 facture
   envoyée » puis plus rien. Elle n'a rien d'urgent au point de recouvrir ce
   qu'on est en train de faire, et elle revient dès la fenêtre fermée. */
body:has(.modal-overlay:not(.hidden)) #alert-toast { display: none; }
/* Pas de cercle autour : le visage est un autocollant, avec son contour blanc
   et sa propre silhouette. L'enfermer dans un disque lui couperait les
   oreilles et le casque. L'ombre portée suit donc la forme, pas une boîte. */
.msg-pastille {
  width: 58px; height: 58px; border: 0; background: none; padding: 0;
  cursor: pointer; position: relative; display: block;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.5));
  transition: transform .14s ease, filter .14s ease;
}
.msg-pastille:hover { transform: translateY(-2px); filter: drop-shadow(0 14px 26px rgba(0,0,0,0.55)); }
.msg-visage { display: block; width: 100%; height: 100%; position: relative; }
.msg-visage img { display: block; width: 100%; height: 100%; }
.msg-visage.petit { width: 34px; height: 34px; flex-shrink: 0; }
.msg-pastille:hover { transform: translateY(-2px); }
/* Deux poses superposées. Au repos, bouche fermée ; quand il prend la parole,
   l'autre pose, redressée et un peu agrandie. C'est ce léger décalage qui
   donne l'impression qu'il parle, plutôt qu'un simple échange d'image.
   Même traitement que sur la page du sous-traitant, pour que ce soit le même
   personnage des deux côtés. */
.msg-pose {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transition: opacity .16s ease, transform .16s ease;
}
.msg-pose-parle { opacity: 0; transform: scale(.94) rotate(-4deg); }
#messagerie.parle .msg-pose-repos { opacity: 0; transform: scale(.94) rotate(4deg); }
#messagerie.parle .msg-pose-parle { opacity: 1; transform: scale(1.06) rotate(0deg); }
@media (prefers-reduced-motion: reduce) {
  .msg-pose { transition: none; transform: none !important; }
}

/* Ce qu'il dit avant qu'on ouvre le panneau : une phrase courte, le temps
   d'être lue, puis elle s'efface. Le badge, lui, reste. */
.msg-dit {
  position: absolute; right: 0; bottom: 68px;
  width: max-content; max-width: min(300px, calc(100vw - 44px));
  background: var(--surface-solid);
  border: 1px solid rgba(255, 138, 82, 0.42);
  border-radius: 14px; padding: 11px 13px;
  color: var(--orange-dark); font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  animation: msg-dit-arrivee .22s ease-out;
}
.msg-dit strong { color: var(--orange); }
@keyframes msg-dit-arrivee {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .msg-dit { animation: none; } }
/* Rouge et non orange : posé sur un casque orange, un badge orange
   disparaîtrait dans le casque. Décalé vers l'extérieur pour ne pas manger
   le dessin. */
.msg-badge {
  position: absolute; top: -4px; right: -6px; min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #241f1e;
  font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg); z-index: 2;
}
/* Un battement lent, trois fois, puis plus rien : signaler sans harceler.
   Il n'y a plus de boîte à faire briller — on anime donc l'ombre portée,
   qui épouse la silhouette de l'autocollant. */
@keyframes msg-battement {
  0%, 100% { filter: drop-shadow(0 10px 22px rgba(0,0,0,0.5)) drop-shadow(0 0 0 rgba(255,80,2,0)); }
  50%      { filter: drop-shadow(0 10px 22px rgba(0,0,0,0.5)) drop-shadow(0 0 10px rgba(255,80,2,0.85)); }
}
.msg-pastille.a-du-neuf { animation: msg-battement 1.8s ease-out 3; }
@media (prefers-reduced-motion: reduce) { .msg-pastille.a-du-neuf { animation: none; } }

.msg-panneau {
  position: absolute; right: 0; bottom: 66px; width: 370px; max-width: calc(100vw - 32px);
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.msg-tete { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.msg-titre { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 15px; }
.msg-fermer { background: none; border: none; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.msg-fermer:hover { color: var(--text); }
.msg-fil { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.msg-pied { padding: 12px 16px; border-top: 1px solid var(--border); }
.msg-vide { color: var(--text-muted); font-size: 13px; line-height: 1.6; margin: 6px 0; text-align: center; }

.msg-bulle { border-radius: 16px; padding: 11px 13px; font-size: 12.5px; line-height: 1.5; max-width: 92%; }
/* Ce que le bureau a envoyé : à droite, discret. Ce que le dirigeant répond :
   à gauche, mis en avant — c'est ça qu'on vient lire. */
.msg-bulle.moi { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-bottom-right-radius: 5px; }
.msg-bulle.lui { align-self: flex-start; background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-left-radius: 5px; }
.msg-bulle.lui.neuf { border-color: var(--orange); background: rgba(255,122,61,0.16); }
.msg-bulle.etat { align-self: center; background: none; border: none; color: var(--text-soft); font-size: 11.5px; padding: 2px 0; }
.msg-texte strong { color: var(--text); }
.msg-liste { list-style: none; margin: 9px 0 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.msg-liste li { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.msg-liste li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-partiel { font-weight: 400; color: var(--amber); }
.msg-ecarte { margin-top: 9px; font-size: 11.5px; color: var(--text-muted); }
.msg-note { margin-top: 9px; padding-left: 9px; border-left: 2px solid var(--orange); font-style: italic; font-size: 12px; }
.msg-actions { margin-top: 11px; }
.msg-heure { margin-top: 7px; font-size: 10.5px; color: var(--text-soft); }

/* La bulle occupe le coin bas droit : l'alerte transitoire monte d'un cran
   pour ne pas se poser dessus. */
.alert-toast { bottom: 90px; }
@media (max-width: 900px) {
  #messagerie { right: 14px; bottom: 88px; }
  .msg-pastille { width: 52px; height: 52px; }
  .msg-panneau { bottom: 60px; right: 0; width: min(370px, calc(100vw - 28px)); }
  .msg-dit { bottom: 62px; }
}
@media (max-width: 640px) { .alert-toast { bottom: 150px; } }

/* Signaler brièvement la carte vers laquelle on vient de sauter : sans ça, la
   page défile et on ne sait plus où on a atterri. */
@keyframes carte-signalee {
  0%   { box-shadow: var(--shadow-sm), var(--glass-edge), 0 0 0 0 rgba(255,80,2,0.55); border-color: var(--orange); }
  100% { box-shadow: var(--shadow-sm), var(--glass-edge), 0 0 0 14px rgba(255,80,2,0); border-color: var(--border); }
}
.carte-signalee { animation: carte-signalee 1.5s ease-out 2; }
@media (prefers-reduced-motion: reduce) { .carte-signalee { animation: none; border-color: var(--orange); } }

/* ---- Bons de commande aux sous-traitants ---------------------------- */
.bc-form { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px; margin-bottom: 20px; background: var(--surface-2); }
/* Une ligne de métré tient sur UNE ligne à l'écran : désignation, détail,
   quantité, unité, prix, total. Sur petit écran elle se replie en colonne
   plutôt que de forcer un défilement horizontal dans un formulaire. */
.bc-ligne { display: grid; grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 1.8fr) 90px 70px 110px 90px 34px;
  gap: 8px; align-items: center; margin-bottom: 8px; }
.bc-ligne input { font-size: 13px; padding: 9px 10px; }
/* Un titre de section se reconnaît sans le lire : pleine largeur, texte en
   capitales et en gras, un filet orange à gauche. C'est le même rôle que le
   bandeau sombre sur le PDF, rendu ici avec les moyens de l'écran. */
.bc-ligne.bc-ligne-titre {
  grid-template-columns: 1fr 34px 34px 34px;
  margin-top: 14px; padding-left: 10px; border-left: 3px solid var(--orange);
}
.bc-ligne.bc-ligne-titre:first-child { margin-top: 0; }
/* Pas de capitales forcées : le titre s'affiche comme il sera imprimé, tel
   que saisi. « 1er » ne doit pas devenir « 1ER ». */
.bc-ligne-titre input { font-weight: 700; }
.bc-ligne-titre input::placeholder { font-weight: 400; }
.bc-total { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .bc-ligne { grid-template-columns: 1fr 1fr; }
  .bc-ligne.bc-ligne-titre { grid-template-columns: 1fr 34px 34px 34px; }
  .bc-ligne input[data-champ="designation"], .bc-ligne input[data-champ="details"] { grid-column: 1 / -1; }
  .bc-total { text-align: left; }
}

/* Un poste de régie : le chantier, les heures qui y ont été prestées, et la
   durée relue en clair. La même personne passe souvent sur deux ou trois
   chantiers dans le mois. */
.bc-poste { display: grid; grid-template-columns: 1fr 150px 110px 34px;
  gap: 8px; align-items: center; margin-bottom: 8px; }
.bc-poste select, .bc-poste input { font-size: 13px; padding: 9px 10px; }
.bc-pheures { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 13px;
  text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
@media (max-width: 900px) {
  .bc-poste { grid-template-columns: 1fr 1fr 34px; }
  .bc-poste select { grid-column: 1 / -1; }
  .bc-pheures { text-align: left; }
}

/* Le détail des journées est replié par défaut : on fait un bon de régie avec
   un total, pas en ressaisissant vingt lignes. */
.bc-detail-journees { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.bc-detail-journees > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.bc-detail-journees > summary:hover { color: var(--text); }
.bc-detail-journees[open] > summary { color: var(--text); margin-bottom: 4px; }

/* Une journée de régie : date, entrée, sortie, pause, et les heures qui en
   découlent. Les heures ne se saisissent pas, elles se calculent — un champ
   qu'on peut remplir à la main finit toujours par contredire les horaires
   juste à côté de lui. */
/* Le nom du jour est une largeur FIXE : lui donner 1fr laissait un trou de
   quatre cents pixels entre « Lundi » et l'heure d'entrée. C'est la colonne
   des heures calculées qui prend la place restante, calée à droite comme sur
   le bon imprimé. */
.bc-journee { display: grid; grid-template-columns: 148px 86px 1fr 122px 122px 78px 88px 34px;
  gap: 8px; align-items: center; margin-bottom: 8px; }
.bc-journee input, .bc-journee select { font-size: 13px; padding: 9px 10px; }
.bc-jjour { font-size: 12.5px; color: var(--text-muted); }
.bc-jheures { font-family: 'Blinker', sans-serif; font-weight: 700; font-size: 13px;
  text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .bc-journee { grid-template-columns: 1fr 1fr 1fr; }
  .bc-journee input[data-champ="date"] { grid-column: 1 / -1; }
  .bc-journee select[data-champ="chantierCode"] { grid-column: 1 / -1; }
  .bc-jjour { grid-column: 1 / -1; }
  .bc-jheures { text-align: left; }
}

/* Intitulés de section dans la fenêtre d'encodage : ils découpent un
   formulaire long en quatre temps (la facture, son rattachement, les
   montants, les dates) au lieu d'une suite de champs sans respiration. */
.form-section {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  font-weight: 700; color: var(--text-muted);
  margin: 22px 0 12px 0; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-section-debut { margin-top: 2px; padding-top: 0; border-top: 0; }

/* ==========================================================================
   Obligation de retenue (30bis / 402 CIR) dans la fenêtre d'encodage
   --------------------------------------------------------------------------
   Le bloc ne s'affiche que pour une facture de sous-traitance. Il doit se
   lire d'un coup d'œil : l'état d'abord (vérifié ou non, retenue ou non),
   le détail ensuite.
   ========================================================================== */
.retenue-zone {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 12px 14px;
}
.retenue-resume { font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.retenue-resume strong { color: var(--text); }
.retenue-resume .retenue-ok { color: var(--green); font-weight: 600; }
.retenue-resume .retenue-alerte { color: var(--red); font-weight: 600; }
.retenue-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.retenue-champs { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.retenue-case {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text); margin-top: 8px; cursor: pointer;
}
.retenue-calcul {
  margin-top: 10px; font-size: 12.5px; line-height: 1.7; color: var(--text-muted);
}
.retenue-calcul .retenue-ligne { display: flex; justify-content: space-between; gap: 12px; }
.retenue-calcul .retenue-net { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

/* Les boutons de l'en-tête de l'aperçu, côte à côte. */
.preview-col-boutons { display: flex; gap: 6px; flex-shrink: 0; }

/* La plaque du véhicule, SOUS la catégorie d'une facture d'amende. Les deux
   pastilles sont empilées et alignées à gauche, de même hauteur et de même
   rayon : posées côte à côte elles se décalaient d'une ligne à l'autre selon
   la longueur de la catégorie. Sur une liste de PV tous à 37 €, la plaque est
   la seule chose qui distingue une ligne d'une autre. */
.cellule-categorie {
  display: flex; flex-direction: column;
  align-items: center; gap: 5px; max-width: 100%;
}
.plaque-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  line-height: 1.25;
  color: var(--text); background: transparent;
  text-decoration: none; white-space: nowrap;
  transition: border-color .12s ease, color .12s ease;
}
.plaque-tag svg { opacity: .8; flex-shrink: 0; }
.plaque-tag:hover { border-color: var(--orange); color: var(--orange); }
.plaque-tag:hover svg { opacity: 1; }
/* En fiche sur téléphone, les deux pastilles se rangent à droite comme le
   reste des valeurs. */
table.en-fiches .cellule-categorie { align-items: flex-end; }
/* La colonne entière est centrée, en-tête compris : sans ça le titre reste
   collé à gauche au-dessus de pastilles centrées, et les pastilles semblent
   poussées vers la droite. */
th.col-categorie, td[data-col="Catégorie"] { text-align: center; }
th.col-categorie .tri-fleche { margin-left: 2px; }

/* Le détail de la catégorie, sous sa grande famille. Plus discret que la
   pastille du dessus : c'est une précision, pas un classement. */
.souscat-tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  color: var(--text-muted); background: transparent;
  border: 1px dashed var(--border);
  white-space: nowrap; max-width: 100%;
}

/* Un bouton montré du doigt par un lien d'accueil : il pulse quelques
   secondes, le temps qu'on le trouve, puis il redevient normal. */
.appel-du-lien { animation: appelDuLien 1.1s ease-in-out 3; outline: 2px solid var(--orange);
  outline-offset: 2px; }
@keyframes appelDuLien {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,80,2,0.5); }
  50% { box-shadow: 0 0 0 7px rgba(255,80,2,0); }
}
@media (prefers-reduced-motion: reduce) { .appel-du-lien { animation: none; } }
