/* FermeConnect : Édition Python · feuille de style v2.3
   Recalibrée sur le DESIGN SYSTEM EXACT de l'application d'origine
   (src/app/globals.css + src/app/(app)/app-shell.tsx de FermeConnect) :
   --background #f8fafc · --foreground #0f172a · --card #ffffff ·
   --muted #f1f5f9 · --muted-foreground #64748b · --border rgba(0,0,0,0.1) ·
   --primary #166534 · success #22c55e · warning #f59e0b · info #2563eb ·
   error #dc2626 · rayon de base 12px (cartes 16px).
   Polices LOCALES : Inter (interface) et JetBrains Mono (montants et
   méta-informations chiffrées, signature visuelle de l'originale).
   Les icônes colorées (émojis) du menu et des cartes sont conservées
   (consigne du client), à la place des icônes monochromes de l'originale.
   Mode sombre de l'originale : reproduit en v2.3 (jetons .dark en fin de fichier). */

/* ---------- Polices locales (aucune police distante) ---------- */
@font-face { font-family: 'Inter'; src: url('../fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-800.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  /* Jetons exacts de l'application d'origine */
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --popover: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: rgba(0, 0, 0, 0.1);
  --input: rgba(0, 0, 0, 0.15);
  --primary: #166534;
  --primary-fonce: #14532d;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #2563eb;
  --error: #dc2626;
  --primary-solid: #166534;
  --turquoise: #0E9488;
  --fond-doux: rgba(15, 23, 42, .04);
  --texte-25: rgba(15, 23, 42, .25);
  --turquoise-fonce: #0B7C72;
  --rayon: 12px;
  --rayon-carte: 16px;
  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ombre: 0 1px 2px rgba(15, 23, 42, .05);
  --ombre-forte: 0 16px 40px rgba(15, 23, 42, .16);
  /* Alias de compatibilité (anciens noms encore référencés çà et là) */
  --fond: var(--background);
  --carte: var(--card);
  --bord: var(--border);
  --bord-fort: rgba(0, 0, 0, 0.15);
  --texte: var(--foreground);
  --texte-doux: var(--muted-foreground);
  --etiquette: var(--muted-foreground);
  --vert: var(--primary);
  --vert-fonce: var(--primary-fonce);
  --danger: var(--error);
  --danger-fond: #fef2f2;
  --ok: #15803d;
  --ok-fond: #dcfce7;
  --alerte: #92400e;
  --alerte-fond: #fef3c7;
  --info-fond: #dbeafe;
  --gris-fond: var(--muted);
  --vert-clair: rgba(22, 101, 52, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(34, 197, 94, .25); }
.cache { display: none !important; }
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.mono { font-family: var(--font-mono); }

/* Barres de défilement masquées en PWA installée et sur mobile (comme l'originale) */
@media (display-mode: standalone), (max-width: 767px) {
  * { scrollbar-width: none; -ms-overflow-style: none; }
  *::-webkit-scrollbar { display: none; }
}

/* ---------- Logo (reproduction du composant Logo de l'originale) ---------- */
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.logo-marque {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; background: var(--primary-solid);
  display: inline-flex; align-items: center; justify-content: center;
}
.logo-marque svg { width: 16px; height: 16px; }
.logo-texte { font-size: 16px; font-weight: 800; letter-spacing: -.02em; color: var(--foreground); white-space: nowrap; }
.logo-texte em { font-style: normal; color: var(--primary); }
.logo.petit .logo-marque { width: 24px; height: 24px; border-radius: 7px; }
.logo.petit .logo-marque svg { width: 14px; height: 14px; }
.logo.petit .logo-texte { font-size: 14px; }

/* ---------- Démarrage ---------- */
.splash {
  position: fixed; inset: 0; z-index: 200; background: var(--background); color: var(--foreground);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.splash-logo {
  width: 76px; height: 76px; border-radius: 20px; background: var(--primary-solid);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--ombre-forte);
}
.splash-logo svg { width: 42px; height: 42px; }
.splash-titre { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 0; }
.splash-sous { margin: 0; color: var(--muted-foreground); font-size: 14px; }

/* ---------- Coquille : structure ---------- */
.layout { display: flex; min-height: 100dvh; }
.zone-contenu { flex: 1; min-width: 0; margin-left: 256px; display: flex; flex-direction: column; }
.contenu {
  flex: 1; min-width: 0; width: 100%; max-width: 1280px; margin: 0 auto;
  padding: 24px 32px 32px;
}

/* ---------- Barre latérale bureau (app-shell : fixe 256px, fond = page) ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 60;
  background: var(--background); border-right: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column;
}
.sidebar .logo-lien { display: inline-flex; padding: 0 8px; margin-bottom: 24px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-lien {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: 8px; color: rgba(15, 23, 42, .65); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: background .12s ease, color .12s ease;
}
.nav-lien:hover { background: var(--fond-doux); }
.nav-lien.actif { background: rgba(22, 101, 52, .10); color: var(--primary); }
.nav-icone { font-size: 18px; width: 22px; text-align: center; flex: 0 0 22px; }
.nav-badge {
  margin-left: auto; background: var(--error); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; font-family: var(--font-mono);
}
.sidebar-pied { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.org-carte { background: var(--fond-doux); border-radius: 8px; padding: 10px; }
.org-nom { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-exploitations { font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
.user-ligne { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 0 4px; }
.user-nom { font-size: 12px; font-weight: 500; color: rgba(15, 23, 42, .8); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: rgba(15, 23, 42, .4); }
.btn-deco-icone {
  background: none; border: none; padding: 6px; border-radius: 6px; color: rgba(15, 23, 42, .4);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.btn-deco-icone:hover { background: rgba(0, 0, 0, .05); color: var(--error); }
.btn-deco-icone svg { width: 16px; height: 16px; }
.sidebar-mode { color: var(--muted-foreground); font-size: 11.5px; margin: 10px 4px 0; }
.avatar {
  border-radius: 50%; color: #fff; font-weight: 700; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; font-size: 13px; font-family: var(--font-sans);
}
.avatar.petit { width: 28px; height: 28px; font-size: 11px; }

/* ---------- Barre supérieure bureau ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: var(--background);
  border-bottom: 1px solid var(--border);
}
.topbar-titre { font-weight: 600; font-size: 15px; }
.topbar-droite { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-user { line-height: 1.25; }
.topbar-user .nom { font-size: 13px; font-weight: 600; }
.topbar-user .role { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: rgba(15, 23, 42, .4); }
.btn-cloche {
  position: relative; width: 38px; height: 38px; border-radius: 8px;
  border: none; background: none; font-size: 19px; color: rgba(15, 23, 42, .7);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn-cloche:hover { background: rgba(0, 0, 0, .05); }
.btn-cloche .pastille {
  position: absolute; top: 1px; right: 1px; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--error); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 0 5px; border: 2px solid var(--background);
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono);
}

/* Panneau des alertes (cloche) */
.panneau-notifs {
  position: fixed; top: 62px; right: 24px; width: min(370px, calc(100vw - 24px)); z-index: 100;
  background: var(--popover); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--ombre-forte); padding: 8px;
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .15s ease, transform .15s ease;
}
.panneau-notifs.ouvert { opacity: 1; transform: none; pointer-events: auto; }
.panneau-notifs .pn-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 6px; font-size: 13px; font-weight: 600;
}
.panneau-notifs .pn-entete .compte { font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); }
.notif-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 9px 10px; border: none; background: none; border-radius: 8px; font-size: 13.5px; color: var(--foreground);
}
.notif-item:hover { background: var(--muted); }
.notif-item .n-icone { font-size: 16px; flex: 0 0 auto; }
.pn-vide { padding: 12px 10px; font-size: 13.5px; color: var(--muted-foreground); }

/* ---------- Pastille de connexion (ConnectivityBadge de l'originale) ---------- */
.badge-connexion {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 600; border: 1px solid; white-space: nowrap;
}
.badge-connexion .point-connexion { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 8px; }
.badge-connexion.en-ligne { color: #15803d; background: rgba(34, 197, 94, .10); border-color: rgba(34, 197, 94, .30); }
.badge-connexion.hors-ligne { color: #b45309; background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .35); }
.badge-connexion.hors-ligne .point-connexion { animation: pulse-point 1.6s ease-in-out infinite; }
@keyframes pulse-point { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* ---------- Barre supérieure mobile ---------- */
.barre-mobile {
  display: none; position: fixed; inset: 0 0 auto 0; z-index: 70;
  align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--background); border-bottom: 1px solid var(--border);
}
.barre-mobile .bm-gauche { display: flex; align-items: center; gap: 8px; min-width: 0; }
.barre-mobile .bm-droite { display: flex; align-items: center; gap: 2px; }
.barre-mobile .btn-cloche { width: 36px; height: 36px; }
.profil-lien { display: inline-flex; border-radius: 50%; text-decoration: none; }

/* ---------- Barre de navigation inférieure mobile ---------- */
.nav-bas {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 70;
  align-items: stretch; background: var(--background); border-top: 1px solid var(--border);
  padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
}
.nav-bas-lien {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px 2px; text-align: center; font-size: 11px; line-height: 1.15; font-weight: 500;
  color: rgba(15, 23, 42, .5); text-decoration: none; background: none; border: none;
}
.nav-bas-lien .nb-icone { font-size: 24px; line-height: 1; position: relative; }
.nav-bas-lien.actif { color: var(--primary); }
.nav-bas-lien .nav-badge { position: absolute; top: -6px; right: -12px; margin: 0; }

/* ---------- Feuille mobile (bottom sheet « Plus ») ---------- */
.feuille-fond {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.feuille-fond.ouvert { opacity: 1; pointer-events: auto; }
.feuille-mobile {
  position: fixed; inset: auto 0 0 0; z-index: 95; max-height: 85vh; overflow-y: auto;
  background: var(--background); border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0; box-shadow: 0 -16px 40px rgba(15, 23, 42, .22);
  padding: 16px; padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  transform: translateY(105%); transition: transform .22s ease;
}
.feuille-mobile.ouverte { transform: translateY(0); }
.feuille-poignee { width: 40px; height: 4px; border-radius: 999px; background: rgba(0, 0, 0, .15); margin: 0 auto 12px; }
.feuille-entete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.feuille-mobile .sidebar-nav { overflow: visible; }
.feuille-mobile .sidebar-pied { margin-top: 16px; }

/* ---------- Titres et cartes ---------- */
.page-entete { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-entete h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.page-sous { color: var(--muted-foreground); margin: 3px 0 0; font-size: 14px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.retour-haut, .retour { color: var(--muted-foreground); font-weight: 500; font-size: 14px; text-decoration: none; display: inline-block; margin-bottom: 6px; }
.retour:hover, .retour-haut:hover { color: var(--foreground); }

.salut { color: var(--muted-foreground); font-size: 14.5px; margin: 2px 0 0; }
.salut-titre { font-size: 28px; font-weight: 800; margin: 2px 0 0; letter-spacing: -.03em; }

.carte {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--rayon-carte);
  box-shadow: var(--ombre); padding: 18px; margin-bottom: 16px;
}
.carte h2 { font-size: 16.5px; font-weight: 600; margin: 0 0 10px; letter-spacing: -.01em; }
.carte h3 { font-size: 15px; font-weight: 600; margin: 14px 0 8px; }
.carte-entete { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.carte-entete h2 { margin: 0; }
.carte-entete .lien-tout { margin-left: auto; font-weight: 500; font-size: 14px; text-decoration: none; color: var(--primary); }
.grille { display: grid; gap: 14px; }
.grille-2 { grid-template-columns: repeat(2, 1fr); }
.grille-3 { grid-template-columns: repeat(3, 1fr); }
.grille-4 { grid-template-columns: repeat(4, 1fr); }

/* Cartes statistiques : étiquette 11px majuscules #64748b, valeur chiffrée
   en JetBrains Mono (signature de l'originale), détail doux */
.stat-carte { background: var(--card); border: 1px solid var(--border); border-radius: var(--rayon-carte); box-shadow: var(--ombre); padding: 15px 16px; position: relative; }
.stat-haut { display: flex; align-items: center; gap: 8px; }
.stat-icone {
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px; flex: 0 0 30px;
  background: var(--muted); display: inline-flex; align-items: center; justify-content: center;
}
.stat-libelle { font-size: 11px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-chev { margin-left: auto; color: var(--texte-25); font-size: 18px; }
.stat-valeur { font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-top: 7px; color: var(--foreground); letter-spacing: -.01em; }
.stat-valeur small { font-size: 14px; font-weight: 500; }
.stat-valeur.danger { color: #d97706; }
.stat-valeur.rouge { color: var(--error); }
.stat-detail { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.stat-alerte { border-color: rgba(245, 158, 11, .45); background: #fffbeb; color: #78350f; }

/* Vue d'ensemble (tableau de bord) */
.vue-ensemble { padding: 20px; }
.vue-ensemble .carte-entete { margin-bottom: 14px; }
.vue-ensemble h2 { font-size: 18px; }
.onglets-periode {
  margin-left: auto; display: inline-flex; gap: 2px;
  background: var(--muted); border-radius: 999px; padding: 3px;
}
.onglets-periode .filtre {
  border: none; background: transparent; border-radius: 999px; padding: 5px 14px;
  font-size: 13px; font-weight: 500; color: var(--muted-foreground);
}
.onglets-periode .filtre.actif { background: var(--card); color: var(--foreground); box-shadow: var(--ombre); }

/* Recherche du tableau de bord */
.recherche-ligne { display: flex; gap: 10px; margin: 16px 0 18px; flex-wrap: wrap; align-items: stretch; }
.recherche-boite { flex: 1; min-width: 220px; position: relative; }
.recherche-boite .recherche { margin-bottom: 0; padding-left: 40px; height: 100%; }
.recherche-boite .loupe { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .55; }

/* Graphique en barres CSS */
.graph { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.graph-mois { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.graph-barres { display: flex; align-items: flex-end; gap: 4px; height: 128px; }
.graph-barre { width: 15px; border-radius: 4px 4px 0 0; min-height: 3px; }
.graph-barre.ventes { background: var(--primary); }
.graph-barre.depenses { background: var(--error); opacity: .75; }
.graph-mois-lib { font-size: 11.5px; color: var(--muted-foreground); font-family: var(--font-mono); }
.graph-legende { display: flex; gap: 18px; font-size: 13px; color: var(--muted-foreground); margin-top: 8px; }
.graph-legende .point { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* Alertes et listes douces */
.alerte-panneau { background: #fffbeb; color: #78350f; border: 1px solid rgba(245, 158, 11, .4); border-radius: var(--rayon-carte); padding: 16px 18px; margin-bottom: 16px; }
.alerte-panneau h3 { margin: 0 0 8px; font-size: 15px; color: #92400e; }
.surveiller-item { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; font-size: 14px; }
.surveiller-item:last-child { border-bottom: none; }
.surveiller-icone {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; font-size: 17px;
  background: var(--danger-fond); display: inline-flex; align-items: center; justify-content: center;
}
.surveiller-icone.douce { background: rgba(22, 101, 52, .08); }
.prio-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.prio-item:last-child { border-bottom: none; }

/* ---------- Boutons (app-shell / originale : principal #166534, text-sm medium ;
   CTA d'ajout des modules en turquoise #0E9488) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; text-decoration: none; min-height: 40px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primaire { background: var(--primary-solid); color: #fff; }
.btn-primaire:hover { background: var(--primary-fonce); }
.btn-secondaire { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn-secondaire:hover { background: var(--background); border-color: rgba(0, 0, 0, .22); }
.btn-turquoise { background: var(--turquoise); color: #fff; }
.btn-turquoise:hover { background: var(--turquoise-fonce); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-petit { padding: 7px 12px; min-height: 34px; font-size: 13px; }
.btn-icone { background: none; border: none; font-size: 16px; padding: 6px; color: var(--muted-foreground); border-radius: 8px; }
.btn-icone:hover { background: var(--muted); color: var(--foreground); }
.btn-lien { background: none; border: none; color: var(--primary); font-weight: 500; padding: 6px 4px; text-decoration: none; font-size: 14px; }
.btn-lien.danger { color: var(--error); }

/* ---------- Tableaux et listes ---------- */
.table-wrap { overflow-x: auto; }
table.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tableau th, table.tableau td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tableau th { color: var(--muted-foreground); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
table.tableau tbody tr:hover td { background: var(--background); }
.num { text-align: right !important; font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
td.num, th.num { text-align: right !important; }

.liste-cartes { display: grid; gap: 12px; }
.item-carte {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--rayon-carte);
  box-shadow: var(--ombre); padding: 15px 17px; display: flex; gap: 12px; align-items: flex-start;
}
.item-carte.principale { cursor: pointer; }
.item-carte.principale:hover { border-color: rgba(22, 101, 52, .45); }
.item-corps { flex: 1; min-width: 0; }
.item-titre { font-weight: 600; font-size: 15.5px; letter-spacing: -.01em; }
.item-meta { color: var(--muted-foreground); font-size: 13.5px; margin-top: 2px; }
.item-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.icone-tuile {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}
.vide { text-align: center; color: var(--muted-foreground); padding: 26px 12px; font-size: 14px; }
.vide .gros { font-size: 34px; display: block; margin-bottom: 6px; }
.section-titre { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; }
.section-titre h2 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.section-titre .lien-tout { margin-left: auto; font-weight: 500; font-size: 14px; text-decoration: none; color: var(--primary); }
.chev { color: var(--texte-25); font-size: 19px; align-self: center; }

/* Cartes parcelles / équipements */
.carte-tuile-haut { display: flex; align-items: flex-start; gap: 8px; }
.superficie { margin-left: auto; font-weight: 700; font-size: 16px; white-space: nowrap; font-family: var(--font-mono); }
.pied-carte { border-top: 1px solid var(--border); margin-top: 11px; padding-top: 10px; font-size: 13px; color: var(--muted-foreground); display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Badges / puces (teintes exactes demandées) ---------- */
.badge {
  display: inline-block; padding: 2.5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #f1f5f9; color: #64748b; white-space: nowrap; vertical-align: 1px; font-family: var(--font-sans);
}
.badge.ok { background: #dcfce7; color: #166534; }          /* EN COURS / Actif / En stock */
.badge.gris { background: #f1f5f9; color: #64748b; }         /* TERMINÉE / Clôturée */
.badge.danger { background: #fef2f2; color: #dc2626; }      /* SOUS LE SEUIL */
.badge.alerte { background: #fef3c7; color: #92400e; }       /* EN ENTRETIEN / Récoltée / Partiel */
.badge.info { background: #dbeafe; color: #2563eb; }        /* Planifiée / À faire */
.badge.cult-0 { background: #FEF3C7; color: #B45309; }
.badge.cult-1 { background: #dcfce7; color: #15803d; }
.badge.cult-2 { background: #FDECEA; color: #C2410C; }
.badge.cult-3 { background: #EDE9FE; color: #6D28D9; }
.badge.cult-4 { background: #E0F2FE; color: #0369A1; }
.badge.cult-5 { background: #FCE7F3; color: #BE185D; }

/* Filtres puces + contrôle segmenté */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filtre {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 7px 15px; font-size: 14px; font-weight: 500; color: var(--foreground);
}
.filtre:hover { border-color: rgba(0, 0, 0, .22); }
.filtre.actif { background: var(--turquoise); border-color: var(--turquoise); color: #fff; }
.segmente { display: inline-flex; background: var(--muted); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.segmente button { border: none; background: transparent; padding: 6px 15px; border-radius: 8px; font-weight: 500; font-size: 13.5px; color: var(--muted-foreground); }
.segmente button.actif { background: var(--card); color: var(--foreground); box-shadow: var(--ombre); }
.recherche {
  width: 100%; padding: 10px 13px; border: 1px solid var(--input); border-radius: 10px;
  margin-bottom: 14px; min-height: 42px; background: var(--card); color: var(--foreground);
}
.recherche:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 101, 52, .18); }

/* Onglets (rapports) */
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.onglet {
  border: none; background: none; padding: 10px 14px; font-size: 14.5px; font-weight: 500;
  color: var(--muted-foreground); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.onglet.actif { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Sélecteur de statut (tâches) */
.statut-select {
  border: none; border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #dbeafe; color: #2563eb; font-family: var(--font-sans);
}
.statut-select.ok { background: #dcfce7; color: #166534; }
.statut-select.gris { background: #f1f5f9; color: #64748b; }
.statut-select.alerte { background: #fef3c7; color: #92400e; }

/* ---------- Formulaires ---------- */
.form-groupe { margin-bottom: 14px; }
.form-groupe label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 5px; }
.form-groupe .aide { font-weight: 400; color: var(--muted-foreground); font-size: 12.5px; }
.form-controle {
  width: 100%; padding: 10px 12px; border: 1px solid var(--input); border-radius: 8px;
  background: var(--card); min-height: 42px; color: var(--foreground);
}
.form-controle:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 101, 52, .18); }
textarea.form-controle { min-height: 74px; resize: vertical; }
.form-erreur { color: var(--error); background: var(--danger-fond); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.form-rangee { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.case-ligne { display: flex; align-items: center; gap: 9px; padding: 8px 0; font-size: 14px; }
.case-ligne input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---------- Modales ---------- */
.modal-fond {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 120;
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 22px 12px;
}
.modal-carte { background: var(--card); border-radius: 16px; width: 100%; max-width: 560px; padding: 20px 22px; box-shadow: var(--ombre-forte); }
.modal-petite { max-width: 420px; }
.modal-entete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-entete h2, .modal-carte > h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.modal-pied { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Notifications (toasts) ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 170; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--ombre-forte); font-size: 14px; max-width: 340px;
}
.toast.erreur { background: var(--error); }

/* ---------- Connexion / inscription ---------- */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px 14px; background: var(--background); }
.auth-carte { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--ombre-forte); width: 100%; max-width: 460px; padding: 28px 28px 22px; }
.auth-carte.large { max-width: 560px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-logo .sidebar-logo { width: 48px; height: 48px; font-size: 19px; }
.auth-titre { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.auth-sous { color: var(--muted-foreground); font-size: 14px; }
.auth-carte h1 { font-size: 20px; font-weight: 600; margin: 14px 0 4px; }
.auth-bas { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted-foreground); }
.modules-choix { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.module-choix {
  border: 1px solid var(--input); border-radius: var(--rayon); padding: 14px; cursor: pointer; text-align: center; background: var(--card);
}
.module-choix .emoji { font-size: 30px; display: block; margin-bottom: 5px; }
.module-choix.sel { border-color: var(--primary); background: rgba(22, 101, 52, .06); }
.module-choix input { display: none; }
.marque-logo, .sidebar-logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--primary-solid); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; font-family: var(--font-sans);
}

/* ---------- Assistant (panneau latéral bureau / plein écran bas mobile) ---------- */
.assistant-fond {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 130;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.assistant-fond.ouvert { opacity: 1; pointer-events: auto; }
.assistant-panneau {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(430px, 100vw); z-index: 140;
  background: var(--card); box-shadow: -16px 0 40px rgba(15, 23, 42, .20);
  transform: translateX(105%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.assistant-panneau.ouvert { transform: translateX(0); }
.assistant-entete {
  display: flex; align-items: center; gap: 10px; padding: 15px 16px;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.assistant-entete .titre { font-weight: 600; font-size: 16px; }
.assistant-entete .sous { font-size: 12.5px; color: var(--muted-foreground); }
.assistant-corps { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.btn-assistant-flottant {
  position: fixed; right: 18px; bottom: 18px; z-index: 110;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--primary-solid); color: #fff; font-size: 25px;
  box-shadow: var(--ombre-forte); display: flex; align-items: center; justify-content: center;
}
.btn-assistant-flottant:hover { background: var(--primary-fonce); }
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 380px; }
.assistant-corps .chat-wrap { height: 100%; min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.bulle { max-width: 85%; padding: 11px 14px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; line-height: 1.5; }
.bulle.assistant { background: var(--muted); border-bottom-left-radius: 4px; align-self: flex-start; }
.bulle.user { background: var(--primary-solid); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 8px; }
.suggestion {
  border: 1px solid rgba(22, 101, 52, .4); color: var(--primary); background: var(--card);
  border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 500;
}
.suggestion:hover { background: rgba(22, 101, 52, .06); }
.chat-saisie { display: flex; gap: 9px; padding: 10px 12px 14px; border-top: 1px solid var(--border); }
.chat-saisie input { flex: 1; }
.exemples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---------- Divers ---------- */
.retour { margin-bottom: 10px; }
.marge-positive { color: var(--ok); font-weight: 700; font-family: var(--font-mono); }
.marge-negative { color: var(--error); font-weight: 700; font-family: var(--font-mono); }
.texte-doux { color: var(--muted-foreground); }
.mt { margin-top: 14px; }
.rapport-section h2 { border-bottom: 2px solid var(--primary); padding-bottom: 5px; }
.rapport-redige { font-size: 15px; line-height: 1.65; }
.fiche-ligne { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.fiche-ligne:last-child { border-bottom: none; }

/* ---------- Responsive : mobile < 768px (barre haute + barre basse + feuille) ---------- */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .topbar { display: none; }
  .barre-mobile { display: flex; }
  .nav-bas { display: flex; }
  .zone-contenu {
    margin-left: 0;
    padding-top: calc(env(safe-area-inset-top) + 57px);
    padding-bottom: 96px;
  }
  .contenu { padding: 20px 20px 8px; }
  .grille-4 { grid-template-columns: repeat(2, 1fr); }
  .grille-3 { grid-template-columns: 1fr; }
  .grille-2 { grid-template-columns: 1fr; }
  .form-rangee { grid-template-columns: 1fr; }
  .panneau-notifs { top: calc(env(safe-area-inset-top) + 62px); right: 12px; }
  .btn-assistant-flottant { bottom: calc(96px + env(safe-area-inset-bottom)); right: 14px; }
  /* Assistant : plein écran qui remonte du bas */
  .assistant-panneau {
    top: auto; bottom: 0; left: 0; right: 0; width: 100vw; height: 100dvh;
    transform: translateY(103%); box-shadow: 0 -16px 40px rgba(15, 23, 42, .22);
  }
  .assistant-panneau.ouvert { transform: translateY(0); }
  .chat-wrap { height: calc(100dvh - 210px); }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); right: 12px; left: 12px; align-items: stretch; }
  .toast { max-width: none; }
}
@media (max-width: 520px) {
  .stat-valeur { font-size: 19px; }
  .salut-titre { font-size: 24px; }
  .graph-barre { width: 11px; }
  .page-entete h1 { font-size: 21px; }
}
@media (min-width: 768px) and (max-width: 1100px) {
  .grille-4 { grid-template-columns: repeat(2, 1fr); }
  .grille-3 { grid-template-columns: repeat(2, 1fr); }
  .contenu { padding: 20px 22px 28px; }
  .topbar { padding: 12px 22px; }
}

/* ---------- Impression (rapports PDF via fenêtre d'impression) ---------- */
@media print {
  :root { --background: #ffffff; --foreground: #111827; }
  .dark { --background: #ffffff; --foreground: #111827; --card: #ffffff; --muted: #f1f5f9; --muted-foreground: #475569; --border: #bbbbbb; }
  .sidebar, .barre-mobile, .nav-bas, .feuille-mobile, .feuille-fond, .topbar, .panneau-notifs,
  .page-actions, .btn, .toasts, .modal-fond, .filtres, .recherche,
  .assistant-panneau, .assistant-fond, .btn-assistant-flottant, .onglets, .segmente { display: none !important; }
  body { background: var(--card); }
  .zone-contenu { margin-left: 0; padding: 0; }
  .contenu { padding: 0; max-width: none; }
  .carte, .stat-carte, .item-carte { box-shadow: none; border-color: #bbb; break-inside: avoid; }
}


/* ================= v2.3 : thème sombre (jetons exacts de l'originale) ===== */
.dark {
  color-scheme: dark;
  --background: #0b1320;
  --foreground: #f8fafc;
  --card: #152032;
  --card-foreground: #f8fafc;
  --popover: #152032;
  --muted: #1e2d42;
  --muted-foreground: #94a3b8;
  --border: rgba(255, 255, 255, 0.16);
  --input: rgba(255, 255, 255, 0.2);
  --primary: #22c55e;
  --primary-fonce: #22c55e;
  --primary-solid: #15803d;
  --success: #22c55e;
  --warning: #fbbf24;
  --info: #3b82f6;
  --error: #ef4444;
  --bord-fort: rgba(255, 255, 255, 0.25);
  --danger-fond: rgba(239, 68, 68, .16);
  --ok: #4ade80;
  --ok-fond: rgba(34, 197, 94, .16);
  --alerte: #fcd34d;
  --alerte-fond: rgba(251, 191, 36, .15);
  --info-fond: rgba(59, 130, 246, .20);
  --vert-clair: rgba(34, 197, 94, .14);
  --fond-doux: rgba(255, 255, 255, .06);
  --texte-25: rgba(255, 255, 255, .35);
  --ombre: 0 1px 2px rgba(0, 0, 0, .45);
  --ombre-forte: 0 16px 40px rgba(0, 0, 0, .55);
}
.dark .nav-lien.actif { background: rgba(34, 197, 94, .14); }
.dark .badge-connexion.hors-ligne { background: rgba(251, 191, 36, .15); color: #fcd34d; }
.dark .badge-connexion.en-ligne { background: rgba(34, 197, 94, .15); color: #4ade80; }
.dark .stat-alerte, .dark .alerte-panneau { background: rgba(251, 191, 36, .12); color: var(--alerte); }
.dark select.form-controle option { background: #152032; color: #f8fafc; }

/* ---------- v2.3 : navigation (cartes et lignes cliquables, retour) ------ */
a.stat-carte { display: block; text-decoration: none; color: inherit; cursor: pointer; }
button.stat-carte { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
a.stat-carte:hover, button.stat-carte:hover, a.item-carte:hover { border-color: var(--primary); }
a.item-carte { display: flex; text-decoration: none; color: inherit; cursor: pointer; }
button.item-carte { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.retour-ligne { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.btn-retour {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card);
  color: var(--foreground); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-retour:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- v2.3 : alertes du tableau de bord (sévérités) ---------------- */
.alerte-ligne {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 10px 6px; border: 0; border-bottom: 1px solid var(--border);
  background: none; font: inherit; color: inherit; cursor: pointer; text-decoration: none;
}
.alerte-ligne:last-child { border-bottom: 0; }
.alerte-ligne:hover .alerte-titre { color: var(--primary); }
.alerte-icone { font-size: 18px; flex: 0 0 24px; text-align: center; }
.alerte-titre { font-weight: 600; font-size: 14px; }
.alerte-detail { font-size: 12.5px; color: var(--muted-foreground); }
.sev {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; margin-top: 2px;
}
.sev-CRITICAL { background: var(--danger-fond); color: var(--error); }
.sev-WARNING { background: var(--alerte-fond); color: var(--alerte); }
.sev-INFO { background: var(--info-fond); color: var(--info); }

/* ---------- v2.3 : graphiques à barres horizontales ---------------------- */
.bh-ligne { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.bh-libelle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bh-piste { height: 10px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.bh-remplissage { height: 100%; border-radius: 999px; min-width: 2px; }
.bh-valeur { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }

/* ---------- v2.3 : photos (profil, fiches, formulaires) ------------------ */
.avatar { overflow: hidden; }
.avatar-photo { background: var(--muted); padding: 0; }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-principale { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--rayon-carte); border: 1px solid var(--border); display: block; }
.galerie-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.galerie-item { position: relative; width: 92px; height: 92px; }
.galerie-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; }
.galerie-retirer {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--error);
  font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
}
.champ-photos .photos-ligne { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.photo-mini { position: relative; width: 64px; height: 64px; display: inline-block; }
.photo-mini img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.photo-retirer {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--error);
  font-size: 11px; line-height: 1; cursor: pointer; padding: 0;
}
.profil-photo-ligne { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profil-photo-ligne .avatar { width: 64px; height: 64px; font-size: 22px; }

/* ---------- v2.3 : saisie facilitée (puces de choix rapide) -------------- */
.puces-saisie { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.puce-saisie {
  border: 1px solid var(--border); background: var(--muted); color: var(--foreground);
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
}
.puce-saisie:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- v2.3 : actions de l'assistant dans le chat ------------------- */
.bulle .actions-assistant { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.btn-action-assistant {
  border: 1px solid var(--primary); color: var(--primary); background: var(--card);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-action-assistant:hover { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }

/* ---------- v2.3 : carnet de bord, comparaisons, divers ------------------ */
.journal-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); }
.journal-photo { width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; display: block; }
.tableau-comparer td:first-child { font-weight: 600; color: var(--muted-foreground); width: 34%; }
.avancement { height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; margin-top: 6px; }
.avancement > div { height: 100%; background: var(--primary); border-radius: 999px; }
.choix-saisie { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.choix-saisie button {
  border: 1px solid var(--border); background: var(--card); border-radius: var(--rayon);
  padding: 14px 10px; font: inherit; color: inherit; cursor: pointer; text-align: center;
}
.choix-saisie button:hover { border-color: var(--primary); }
.choix-saisie .cs-icone { font-size: 26px; display: block; margin-bottom: 6px; }
.btn-theme { font-size: 17px; }
