
:root{--sand:#F5F3EE;--rn-navy:#0A1E36;--rn-navy-l:#E6E9EE;--rn-navy-m:#1B3350;--rn-cream:#F5F3EE;--rn-teal:#5CBDB9;--rn-teal-d:#3E9C98;--rn-teal-l:#E3F3F2;--rn-teal-m:#B4E0DE;}
@keyframes om-dash{to{stroke-dashoffset:-40;}}
body{margin:0;background:#F5F3EE;}
a{color:var(--rn-teal-d);text-decoration:none;}
a:hover{color:var(--rn-navy);}
*{box-sizing:border-box;}
@keyframes om-spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}
@keyframes om-spin-rev{from{transform:rotate(360deg);}to{transform:rotate(0deg);}}
@keyframes om-pulse{0%,100%{transform:translate(-50%,-50%) scale(1);}50%{transform:translate(-50%,-50%) scale(1.1);}}
@keyframes om-ring{0%{transform:translate(-50%,-50%) scale(0.35);opacity:0.55;}100%{transform:translate(-50%,-50%) scale(1.6);opacity:0;}}
@keyframes om-float{0%,100%{transform:translateY(0);}50%{transform:translateY(-10px);}}
@keyframes om-marquee{from{transform:translateX(0);}to{transform:translateX(-50%);}}
@keyframes om-in{from{opacity:0;transform:translateY(22px);}to{opacity:1;transform:translateY(0);}}
.leaflet-container{font-family:var(--font-sans);}
.om-leaflet-pane .leaflet-popup-content-wrapper{border-radius:10px;box-shadow:var(--shadow-modal);font-family:var(--font-sans);}
.om-leaflet-pane .leaflet-popup-tip{box-shadow:none;}
::-webkit-scrollbar{height:8px;width:8px;}
::-webkit-scrollbar-thumb{background:var(--n-300);border-radius:4px;}

/* --- Tableau de la base : colonnes masquées par priorité quand la largeur diminue,
       jamais de défilement horizontal ; le détail complet reste dans la fiche --- */
.tableau-base th, .tableau-base td { white-space: normal; overflow-wrap: anywhere; }
.tableau-base th { overflow-wrap: normal; }                              /* un en-tête ne se coupe pas au milieu d'un mot */
.tableau-base .col-identification { min-width: 170px; }                 /* la colonne prioritaire garde sa place */
/* Ordre de priorité des colonnes (la première disparaît en dernier) :
   1 Identification · 2 bouton Fiche (icône seule sous 768) · 3 Répondant ·
   4 Poids déclarés retenus · 5 Membres · Infrastructures · 6 Activités ·
   7 Forme juridique. Tout le détail reste sur la fiche, ouverte par la ligne. */
.tableau-base .col-activites { width: 220px; max-width: 220px; }   /* étiquettes à la ligne, jamais tronquées */
@media (max-width: 1024px) { .tableau-base .col-forme { display: none; } .tableau-base .col-activites { width: 180px; max-width: 180px; } }
@media (max-width: 768px) { .tableau-base .col-activites, .col-btn-libelle { display: none; } }
@media (max-width: 480px) { .tableau-base .col-membres, .tableau-base .col-poids { display: none; } .tableau-base .col-identification { min-width: 0; } .tableau-base th, .tableau-base td { padding-left: 8px; padding-right: 8px; } }

/* --- Impression de la fiche : navigation, boutons, contrôles de carte et pied de
       page interactif masqués ; la fiche entière, dépliée, avec ses bases et ses
       notes ; en-tête et pied répétés sur chaque page (position fixe) --- */
.impression-seulement { display: none; }
@media print {
  @page { size: A4 portrait; margin: 16mm 12mm 18mm 12mm; }
  html, body { background: #fff !important; }
  header, footer, button, nav, .leaflet-control-container, [data-screen-label="Hero"] { display: none !important; }
  [data-screen-label="Fiche site"] { min-height: auto !important; background: #fff !important; padding-top: 10mm; padding-bottom: 10mm; }
  [data-screen-label="Fiche site"] * { overflow: visible !important; box-shadow: none !important; }
  /* la carte garde son cadre : ses tuiles sont positionnées hors du conteneur */
  [data-screen-label="Fiche site"] .leaflet-container { overflow: hidden !important; }
  [data-screen-label="Fiche site"] a[href="#"] { display: none !important; }
  .impression-seulement { display: block; }
  .impression-entete { position: fixed; top: 0; left: 0; right: 0; font: 600 10pt Inter, sans-serif; color: #0A1E36; border-bottom: 1px solid #C9CED8; padding-bottom: 2mm; }
  .impression-pied { position: fixed; bottom: 0; left: 0; right: 0; font: 9pt Inter, sans-serif; color: #6B7589; border-top: 1px solid #C9CED8; padding-top: 2mm; text-align: right; }
  canvas { max-width: 100% !important; }
}

/* --- Petites largeurs : l'en-tête passe à la ligne et la grille du pied de page
       se replie sur une colonne, pour qu'aucune largeur ne fasse défiler la page --- */
@media (max-width: 768px) {
  header > div:not(.nav-mobile) { height: auto !important; flex-wrap: wrap; padding: 10px 16px !important; }
  header nav { flex-wrap: wrap; justify-content: flex-start !important; }
  footer div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* --- Filtre global : bandeau permanent tant qu'un filtre est actif, bouton
       flottant et panneau. Le bandeau colle sous l'en-tête sur toutes les sections --- */
.bandeau-filtre { position: sticky; top: 76px; z-index: 1050; background: #FFF4DF; border-bottom: 2px solid #8A5A00; color: #0A1E36; }
.bandeau-filtre-int { max-width: 1140px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
.bandeau-filtre-btn { height: 34px; padding: 0 14px; border-radius: 8px; border: 1.5px solid #8A5A00; background: #fff; color: #8A5A00; font-weight: 700; font-size: 0.82rem; cursor: pointer; }
/* Bouton filtre : gros rond turquoise vif (icône seule), bien détaché du
   fond bleu de la carte et du hero. */
.filtre-bouton { position: fixed; left: 24px; bottom: 24px; z-index: 1200; width: 64px; height: 64px; padding: 0; border-radius: 50%; border: 3px solid #FFFFFF; background: var(--rn-teal); color: var(--rn-navy); cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; box-shadow: 0 6px 20px rgba(10,30,54,0.45); transition: background var(--t-base) var(--easing), transform var(--t-base) var(--easing); }
.filtre-bouton i { font-size: 1.35rem; line-height: 1; }
.filtre-bouton .col-btn-libelle { display: block; font-size: 0.62rem; font-weight: 700; line-height: 1; letter-spacing: 0.3px; }   /* le mot « Filtre » sous l'icône */
.filtre-bouton:hover { background: #7FD3CF; transform: scale(1.06); }
.filtre-panneau { position: fixed; left: 20px; bottom: 80px; z-index: 1200; width: 320px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--n-200); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; font-size: 0.88rem; }
.filtre-panneau-titre { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--rn-navy); }
.filtre-panneau-fermer { border: none; background: transparent; cursor: pointer; color: var(--fg-3); font-size: 1rem; }
.filtre-champ { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 600; color: var(--fg-2); }
.filtre-champ select { height: 40px; padding: 0 10px; border-radius: 8px; border: 1.5px solid var(--n-200); background: var(--surface); font-size: 0.88rem; color: var(--fg-1); font-weight: 500; }
.filtre-aide { font-weight: 400; color: var(--fg-3); }
.filtre-bascules { display: flex; gap: 18px; font-weight: 600; color: var(--fg-1); }
.filtre-bascules input { margin-right: 6px; }
.filtre-panneau-pied { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--fg-3); font-size: 0.8rem; border-top: 1px solid var(--n-100); padding-top: 10px; }
@media print { .bandeau-filtre, .filtre-bouton, .filtre-panneau { display: none !important; } }

/* --- Gestion (Paramètres, profil) : tables sans défilement horizontal, colonnes
       masquées par priorité (g3 dès 1024 px, g2 dès 768 px, g1 dès 480 px) ; la
       ligne s'ouvre pour montrer le reste --- */
.tableau-gestion { width: 100%; border-collapse: collapse; table-layout: auto; }
.tableau-gestion th { text-align: left; padding: 12px 14px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: rgba(245,243,238,0.85); background: var(--rn-navy); }
.tableau-gestion td { padding: 10px 14px; font-size: 0.86rem; color: var(--fg-2); border-bottom: 1px solid var(--n-100); vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.tableau-gestion tr.ligne-cliquable { cursor: pointer; }
.tableau-gestion tr.ligne-cliquable:hover { background: #F5F3EE; }
.tableau-gestion td.col-actions { white-space: nowrap; text-align: right; }
.ligne-detail td { background: #FAF9F6; padding: 12px 18px 16px; }
.ligne-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 0.85rem; }
.ligne-detail dt { color: var(--fg-3); font-weight: 600; }
.ligne-detail dd { margin: 0; color: var(--fg-1); overflow-wrap: anywhere; }
.ligne-detail .actions-detail { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 1024px) { .tableau-gestion .col-g3 { display: none; } }
@media (max-width: 768px) { .tableau-gestion .col-g2 { display: none; } .ligne-detail dl { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .tableau-gestion .col-g1 { display: none; } .tableau-gestion th, .tableau-gestion td { padding-left: 8px; padding-right: 8px; } }
.badge-etat { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.badge-actif { background: var(--rn-teal-l); color: var(--rn-teal-d); }
.badge-inactif { background: #FFF4DF; color: #8A5A00; }
.bouton-icone { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--n-200); background: var(--surface); color: var(--rn-navy); cursor: pointer; font-size: 0.9rem; margin-left: 4px; }
.bouton-icone:hover { background: var(--rn-teal-l); border-color: var(--rn-teal-m); }
.bouton-icone.danger:hover { background: #FDECEC; border-color: #E8A0A0; color: #A23B3B; }
.bouton-principal { height: 44px; padding: 0 18px; border-radius: 8px; border: none; background: var(--rn-teal); color: #fff; font-weight: 600; font-size: 0.88rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.bouton-principal:disabled { opacity: 0.55; cursor: default; }
.bouton-secondaire { height: 44px; padding: 0 16px; border-radius: 8px; border: 1.5px solid var(--n-200); background: var(--surface); color: var(--rn-navy); font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.bouton-danger { height: 44px; padding: 0 18px; border-radius: 8px; border: none; background: #A23B3B; color: #fff; font-weight: 700; font-size: 0.88rem; cursor: pointer; }
.bouton-danger:disabled { opacity: 0.45; cursor: default; }
.onglets { display: flex; gap: 4px; border-bottom: 2px solid var(--n-200); margin-bottom: 20px; }
.onglet { padding: 10px 18px; border: none; background: transparent; font-weight: 600; font-size: 0.92rem; color: var(--fg-3); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.onglet.actif { color: var(--rn-teal-d); border-bottom-color: var(--rn-teal); }
.barre-outils { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.barre-outils input, .barre-outils select { height: 42px; padding: 0 12px; border-radius: 8px; border: 1.5px solid var(--n-200); background: var(--surface); font-size: 0.88rem; color: var(--fg-1); min-width: 0; }
.barre-outils input[type="search"] { flex: 1; min-width: 180px; }
.carte-gestion { background: var(--surface); border: 1px solid var(--n-200); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.pied-table { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--n-200); flex-wrap: wrap; gap: 10px; font-size: 0.82rem; color: var(--fg-3); }
.message-gestion { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; }
.message-ok { background: var(--rn-teal-l); color: var(--rn-teal-d); }
.message-refus { background: #FDECEC; color: #A23B3B; }
.champ-form { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 0.8rem; font-weight: 600; color: var(--fg-2); }
.champ-form input, .champ-form select { height: 44px; padding: 0 12px; border-radius: 8px; border: 1.5px solid var(--n-200); background: var(--input-bg, var(--surface)); font-size: 0.95rem; color: var(--fg-1); font-weight: 400; }
.champ-form input:disabled { background: #F0EFEA; color: var(--fg-3); }
.champ-aide { font-weight: 400; color: var(--fg-3); font-size: 0.76rem; }
.modale-fond { position: fixed; inset: 0; background: rgba(13,20,36,0.55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px; }
.modale { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 520px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; padding: 28px; position: relative; }
.modale h3 { margin: 0 0 6px; }
.modale-pied { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* --- Menu utilisateur : avatar à initiales, menu déroulant --- */
.avatar-bouton { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px 0 4px; border-radius: 999px; border: 1.5px solid var(--n-200); background: #fff; cursor: pointer; color: var(--rn-navy); font-weight: 600; font-size: 0.85rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--rn-navy); color: #F5F3EE; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.5px; }
.avatar-grand { width: 72px; height: 72px; font-size: 1.5rem; }
.menu-utilisateur { position: absolute; right: 0; top: 52px; width: 240px; background: var(--surface); border: 1px solid var(--n-200); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; z-index: 1300; }
.menu-utilisateur-tete { padding: 10px 12px 12px; border-bottom: 1px solid var(--n-100); margin-bottom: 6px; }
.menu-utilisateur a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--rn-navy); font-size: 0.88rem; font-weight: 600; }
.menu-utilisateur a:hover { background: var(--rn-teal-l); color: var(--rn-teal-d); }
@media (max-width: 480px) { .avatar-nom { display: none; } }

/* --- Fenêtre de session propre à l'application : le voile gris du moteur et
       ses notifications de reconnexion ne s'affichent jamais --- */
#shiny-disconnected-overlay, #shiny-notification-panel { display: none !important; }
.fenetre-session { position: fixed; inset: 0; z-index: 3000; background: linear-gradient(160deg, #0A1E36 0%, #12294A 55%, #0F3A44 100%); display: flex; align-items: center; justify-content: center; padding: 24px; font-family: var(--font-sans, Inter, system-ui, sans-serif); }
.fenetre-session-carte { background: #FFFFFF; border-radius: 16px; box-shadow: 0 24px 64px rgba(0,0,0,0.35); width: 460px; max-width: 100%; padding: 32px; color: #0A1E36; text-align: center; }
.fenetre-session-carte img { height: 56px; width: auto; margin-bottom: 18px; }
.fenetre-session-icone { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: #E3F3F2; color: #3E9C98; }
.fenetre-session-icone.alerte { background: #FFF4DF; color: #8A5A00; }
.fenetre-session h2 { margin: 0 0 8px; font-size: 1.35rem; letter-spacing: -0.3px; }
.fenetre-session p { margin: 0 0 18px; color: #4A5568; font-size: 0.95rem; line-height: 1.5; }
.fenetre-session-attente { display: inline-block; width: 22px; height: 22px; border: 3px solid #B4E0DE; border-top-color: #3E9C98; border-radius: 50%; animation: om-spin 0.9s linear infinite; vertical-align: middle; margin-right: 8px; }
.fenetre-session button { height: 48px; padding: 0 22px; border-radius: 8px; border: none; background: #5CBDB9; color: #fff; font-weight: 700; font-size: 0.95rem; cursor: pointer; }
.fenetre-session .fenetre-session-note { font-size: 0.8rem; color: #6B7589; margin: 14px 0 0; }
.journal-note { font-size: 0.8rem; color: var(--fg-3); padding: 10px 16px 14px; border-top: 1px solid var(--n-100); line-height: 1.5; }
.badge-supprime { background: #FDECEC; color: #A23B3B; }
.barre-outils label.case { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--fg-2); font-weight: 600; cursor: pointer; }

/* --- Petits écrans : rien ne déborde, à aucune largeur. Deux points de rupture :
       768 px, en dessous duquel une grille à deux colonnes de 1140 px ne laisse
       plus 340 px par colonne (tablette en portrait) ; 480 px, en dessous duquel
       deux cartes de chiffres côte à côte passent sous 200 px (téléphone). Les
       tables ont déjà 1024/768/480. Tout dépend de la largeur, jamais de l'agent. --- */
@media (max-width: 768px) {
  .hero-grille { grid-template-columns: 1fr !important; gap: 24px !important; padding: 36px 16px 40px !important; }
  .hero-chaine { display: none !important; }
  .hero-grille h1 { font-size: 2.3rem !important; }
  .stats-grille { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
  .stats-grille > div, .stats-grille > template + div { padding: 18px 16px !important; }
  /* Carte : une colonne, l'encadré au-dessus, la carte dessous ; chiffres masqués */
  .carte-section { height: auto !important; min-height: 0 !important; display: flex; flex-direction: column; }
  .carte-haut { position: static !important; pointer-events: auto !important; }
  .carte-haut > div { flex-direction: column; padding: 16px !important; }
  .carte-encadre { max-width: none !important; }
  .carte-chiffres { display: none !important; }
  .carte-conteneur { position: relative !important; inset: auto !important; height: 62vh !important; min-height: 380px; order: 2; }
  .carte-bas { position: static !important; order: 3; padding: 12px 0; }
  .carte-bas > div { padding: 0 16px !important; }
  /* Production, équipements : cartes de chiffres en défilement, graphiques empilés */
  /* Cartes de chiffres : empilées, toutes visibles, sans défilement ; le libellé passe à la ligne */
  .kpis-defilants { grid-template-columns: 1fr !important; gap: 10px !important; }
  .kpis-defilants div[style*="text-overflow"] { white-space: normal !important; overflow: visible !important; }
  .graphiques-duo { flex-direction: column !important; }
  .graphiques-duo > div { flex: none !important; width: 100% !important; }
  .graphique-anneau { order: 1; }
  .graphique-evolution { order: 2; }
  /* Filtre : panneau en pleine largeur depuis le bas, fermeture toujours visible */
  .filtre-panneau { left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100% !important; max-width: none !important; max-height: 80vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 0 16px 16px !important; box-shadow: 0 -8px 32px rgba(10,30,54,0.25); }
  .filtre-panneau-titre { position: sticky; top: 0; background: var(--surface); padding: 14px 0 10px; z-index: 1; }
  .filtre-panneau-fermer { width: 40px; height: 40px; font-size: 1.2rem; }
  .pied-grille { grid-template-columns: 1fr !important; gap: 28px !important; }
  .bandeau-filtre-int { padding: 10px 16px; }
}
@media (max-width: 480px) {
  .stats-grille { gap: 10px !important; }
  .stats-grille > div > div:nth-child(3) { font-size: 1.7rem !important; }
  .filtre-bouton { bottom: 16px; left: 16px; width: 58px; height: 58px; }
  .filtre-bouton i { font-size: 1.2rem; }
  header > div:not(.nav-mobile) { padding: 8px 12px !important; }
}
/* Carte au doigt : le défilement vertical de la page reste au navigateur ; le
   pincement zoome (touchZoom). Leaflet pose lui-même touch-action selon dragging. */
.carte-conteneur { touch-action: pan-y pinch-zoom; }
/* Petits écrans : la navigation reste sur une ligne, défilante au doigt, au lieu
   de s'empiler sous le logo. */
@media (max-width: 768px) {
  header > div:not(.nav-mobile) { flex-wrap: nowrap !important; height: 64px !important; gap: 8px; }
  header nav { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start !important; gap: 14px !important; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  header nav::-webkit-scrollbar { display: none; }
  header img { height: 40px !important; }
}

/* --- Menu hamburger : navigation repliée sous 768 px --- */
.hamburger { display: none; width: 44px; height: 44px; border-radius: 8px; border: 1.5px solid var(--n-200); background: #fff; color: var(--rn-navy); font-size: 1.4rem; cursor: pointer; align-items: center; justify-content: center; flex: none; }
.nav-mobile { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--n-200); box-shadow: var(--shadow-md); display: flex; flex-direction: column; padding: 8px 12px 12px; z-index: 1150; }
.nav-mobile a { padding: 12px 10px; border-radius: 8px; font-weight: 600; color: var(--rn-navy); font-size: 1rem; border-bottom: 1px solid var(--n-100); }
.nav-mobile a:last-child { border-bottom: none; }
.nav-mobile a:hover { background: var(--rn-teal-l); color: var(--rn-teal-d); }
@media (max-width: 768px) {
  .hamburger { display: inline-flex; }
  .nav-principale { display: none !important; }
  header > div:not(.nav-mobile) { justify-content: space-between !important; }
}

/* Roue de la mise à jour des données en cours */
@keyframes rn-tourne { to { transform: rotate(360deg); } }
