/* Chantier Studio — identité propre (distincte du Convertisseur), esprit "chantier/sécurité" */
:root {
  --dark:     #2A2118;
  --darker:   #1C160F;
  --accent:   #E8971C;
  --accent-h: #C97D0F;
  --bg:       #FAF7F2;
  --card:     #F0ECE4;
  --card2:    #F7F4EE;
  --sep:      #DDD5C7;
  --text:     #23201B;
  --text-dim: #6B6558;
  --white:    #FFFFFF;
  --ok:       #1A7A4C;
  --err:      #A32E1F;
  --accent-tint: #F4E6CE;
  --radius:   12px;
  /* Echelle d'espacement documentee (audit UX) : consolide les valeurs deja
     dominantes dans ce fichier (verifie par comptage, pas devinees) plutot
     que d'en introduire de nouvelles. --text-dim n'a PAS ete change malgre
     une premiere estimation d'audit : verification par calcul du ratio de
     contraste WCAG (formule croisee avec la reference connue #767676/blanc
     = 4.54) donne #6B6558 a 5.42:1 sur --bg et 4.91:1 sur --card, donc deja
     conforme AA (>=4.5:1) sur les deux — rien a corriger ici.
  */
  --space-1: 4px; --space-2: 6px; --space-3: 8px; --space-4: 10px; --space-5: 12px;
  --space-6: 14px; --space-7: 16px; --space-8: 18px; --space-9: 20px; --space-10: 22px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 3px rgba(28,22,15,0.06);
  /* --surface est la couleur de "carte/bloc" (chart-card, stat-box, dash-table,
     formulaires...) — separee de --white (qui reste litteralement blanc,
     utilise pour du TEXTE sur fond deja sombre : sidebar, bandeaux hero,
     hover de bouton colore — ces fonds ne changent pas entre les themes,
     donc --white ne doit jamais etre remplace par le mode sombre, seul
     --surface l'est). */
  --surface: #FFFFFF;
}

/* Mode sombre (audit UX) : bascule via l'attribut data-theme sur <html>,
   applique au chargement AVANT le premier paint (cf. le script inline dans
   index.html) pour eviter un flash de theme clair. Seuls les tokens de
   couleur sont redefinis ; --accent reste le meme ambre dans les deux themes
   (identite de marque), --white n'est jamais touche (cf. commentaire ci-dessus). */
:root[data-theme="dark"] {
  --dark:     #17130E;
  --darker:   #0F0C08;
  --bg:       #1A1611;
  --card:     #241F18;
  --card2:    #211C16;
  --sep:      #3A322A;
  --text:     #EFE9DD;
  --text-dim: #B3A895;
  --surface:  #241F18;
  --accent-tint: #3A2E14;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--dark);
  color: #E3DCCF;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; padding: 6px 10px 18px; color: var(--white); letter-spacing: 0.3px; }
.brand-icon { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }

/* Recherche globale (audit UX : aucune recherche n'existait nulle part). */
.global-search { position: relative; margin-bottom: 14px; }
.global-search input {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--radius-sm); color: var(--white); padding: 8px 10px; font-size: 0.84rem;
}
.global-search input::placeholder { color: #9C9384; }
.global-search input:focus { outline: none; border-color: var(--accent); }
#global-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 400;
  background: var(--card2); border: 1px solid var(--sep); border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0,0,0,0.28); max-height: 60vh; overflow-y: auto; padding: 6px;
}
.global-search-group-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); padding: 6px 8px 2px; }
.global-search-result { display: block; width: 100%; text-align: left; padding: 7px 8px; border-radius: 6px; border: none; background: none; cursor: pointer; font-size: 0.84rem; color: var(--text); }
.global-search-result:hover { background: var(--card); }
.global-search-result .gsr-sub { display: block; color: var(--text-dim); font-size: 0.76rem; }
.global-search-empty { padding: 10px 8px; color: var(--text-dim); font-size: 0.82rem; }

.alert-section + .alert-section { margin-top: 14px; }
.alert-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 0.92rem; }
.alert-list { display: flex; flex-direction: column; gap: 2px; }
.alert-row {
  display: block; width: 100%; text-align: left; padding: 7px 8px; border-radius: 6px;
  border: none; background: none; cursor: pointer; font-size: 0.84rem; color: var(--text);
}
.alert-row:hover { background: var(--card); }

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.sidebar .btn-secondary { background: rgba(255,255,255,0.05); color: #E3DCCF; border: 1px solid rgba(255,255,255,0.16); }
.sidebar .btn-secondary:hover { background: rgba(255,255,255,0.09); border-color: var(--accent); color: var(--accent); }
/* "Charger un chantier de demo" demote a une action d'onboarding discrete
   (audit UX) : le texte clair de base (--text-dim) serait illisible sur le
   fond sombre de la sidebar, d'ou cette variante. */
.sidebar .btn-tertiary { color: #9C9384; }
.sidebar .btn-tertiary:hover { color: var(--accent); text-decoration: underline; }

.nav-group-title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #9C9384; padding: 10px 10px 4px; font-weight: 600;
}

.site-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; overflow-y: auto; max-height: 26vh; }
.site-list:empty::after { content: "—"; color: #6B6558; font-size: 0.8rem; padding: 4px 10px; display: block; }

.site-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  cursor: pointer; font-size: 0.88rem;
}
.site-item:hover { border-color: var(--accent); }
.site-item.active { background: var(--accent); border-color: var(--accent); color: var(--darker); font-weight: 700; }
.site-item .site-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-item .del-btn { background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; font-size: 0.95rem; padding: 2px 4px; }
.site-item .del-btn:hover { opacity: 1; color: var(--err); }

.sidebar-account { margin-top: auto; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,0.1); border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-account-name { font-size: 0.82rem; color: #E3DCCF; font-weight: 600; margin-bottom: 8px; }

.sidebar-footer { font-size: 0.72rem; color: #9C9384; padding: 10px; line-height: 1.5; }

/* ---- Connexion ---- */
/* Photo de chantier en fond (choix delibere du proprietaire du produit — sa
   touche personnelle, plus chaleureuse qu'un simple degrade uni) + voile
   sombre pour la lisibilite du texte blanc par-dessus. */
.login-view {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(rgba(28,22,15,0.6), rgba(28,22,15,0.72)),
    url('assets/backgrounds/login-bg.jpg') center/cover no-repeat;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card2); border: 1px solid var(--sep); border-radius: var(--radius);
  padding: 32px 34px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-brand { padding: 0; color: var(--dark); }
.login-error { color: var(--err); font-size: 0.85rem; margin: 0; }

.main { flex: 1; padding: 36px 42px; max-width: 980px; }

/* Bandeau "hero" en tete de page (photo de chantier + voile de lisibilite,
   cf. remarque ci-dessus sur le login) — chaque vue garde sa hauteur propre
   plutot qu'une taille uniforme forcee. */
.view-hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  margin-bottom: 20px; background-size: cover; background-position: center;
  display: flex; align-items: flex-end;
}
.view-hero-overlay {
  width: 100%; padding: var(--space-8) var(--space-10);
  background: linear-gradient(to top, rgba(28,22,15,0.78), rgba(28,22,15,0.1));
}
.view-hero-overlay h2 { color: var(--white); margin: 0 0 4px; }
.view-hero-overlay p.hint { color: rgba(255,255,255,0.88); margin: 0; }

.view-hero-dashboard { height: 200px; background-image: url('assets/backgrounds/dashboard-bg.jpg'); }
.view-hero-settings { height: 170px; background-image: url('assets/backgrounds/settings-bg.jpg'); }
.view-hero-chantier { height: 150px; background-image: url('assets/backgrounds/chantier-bg.jpg'); }
.view-hero-sm { height: 110px; margin-bottom: 16px; }
.view-hero-stocks { background-image: url('assets/backgrounds/stocks-bg.jpg'); }

#no-site-selected { color: var(--text-dim); text-align: center; padding: 80px 20px; }
#no-site-selected h2 { color: var(--text); }

.hidden { display: none !important; }

h2 { margin: 0 0 6px; font-size: 1.5rem; color: var(--dark); }
h3 { margin: 0 0 10px; font-size: 1.1rem; color: var(--dark); }
h4 { margin: 14px 0 8px; font-size: 0.92rem; color: var(--accent-h); text-transform: uppercase; letter-spacing: 0.04em; }

.hint { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 18px; line-height: 1.5; }
.hint.hidden { display: none; }

.subtool {
  margin-bottom: 20px;
  background: var(--card2);
  border: 1px solid var(--sep);
  border-radius: var(--radius);
  padding: 22px;
}

/* ---- Onglets d'un chantier (ruban horizontal) ---- */
/* overflow-x:auto + boutons non-retrecissables : defile horizontalement sur
   petit ecran au lieu de casser la mise en page (jamais de retour a la ligne
   qui ferait sauter la hauteur du ruban). */
.site-tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 18px; border-bottom: 2px solid var(--sep); }
.site-tab {
  flex: 0 0 auto; white-space: nowrap; background: transparent; border: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  padding: 10px 18px; font-family: inherit; font-size: 0.9rem; font-weight: 700;
  color: var(--text-dim); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.site-tab svg { flex-shrink: 0; }
.site-tab:hover { color: var(--accent-h); }
.site-tab.active { color: var(--accent-h); border-bottom-color: var(--accent); }

/* Bouton d'enrichissement IA place juste sous un champ de saisie (formulaire
   d'entree) : petit et discret, pas au meme niveau visuel que les actions
   principales (Enregistrer, etc.) — mais toujours accessible d'un coup d'oeil
   juste apres le champ concerne. */
.ai-enrich-btn {
  display: inline-block; margin: -10px 0 14px; font-size: 0.76rem; padding: 4px 10px;
  border-radius: 6px; border: 1px solid var(--sep); background: var(--surface); color: var(--accent-h);
  cursor: pointer; font-family: inherit;
}
.ai-enrich-btn:hover { border-color: var(--accent); background: var(--accent-tint); }
.ai-enrich-btn:disabled { opacity: 0.6; cursor: default; }

/* Tables larges (Gantt, catalogue/solde stocks, membres, tableau de bord,
   utilisateurs, etc.) : rien n'empechait un debordement horizontal sur petit
   ecran ou fenetre etroite. Regle GENERIQUE plutot qu'une liste d'ID
   maintenue a la main (constate a plusieurs reprises : un nouveau tableau
   oublie dans la liste deborde silencieusement) — n'importe quel conteneur
   direct d'un .dash-table devient scrollable automatiquement, y compris pour
   les tableaux ajoutes plus tard sans y repenser.  */
div:has(> table.dash-table) {
  overflow-x: auto;
}

/* Le Gantt (8-9 colonnes editables : nom, 4 dates, %, budget, statut, action)
   et le catalogue de stocks sont trop denses pour la taille standard des
   champs de formulaire (pensee pour un champ isole, pas une cellule de
   tableau) — deborde meme sur un ecran de bureau normal. Champs retrecis et
   largeur plafonnee par colonne (au lieu de laisser chaque input a sa largeur
   navigateur par defaut) pour que tout tienne sans defiler, le overflow-x
   ci-dessus ne servant plus que de filet de securite sur fenetre etroite. */
#gantt-table .dash-table th, #gantt-table .dash-table td,
#stocks-catalog-table .dash-table th, #stocks-catalog-table .dash-table td {
  padding: 5px 4px;
  font-size: 0.78rem;
}
#gantt-table .dash-table input, #stocks-catalog-table .dash-table input {
  font-size: 0.76rem;
  padding: 4px 3px;
}
#gantt-table .dash-table input[type="text"] { width: 92px; }
#gantt-table .dash-table input[type="date"] { width: 104px; }
#gantt-table .dash-table input[type="number"] { width: 44px; }
/* Budget (F CFA) cible par classe, pas par position de colonne : le nombre de
   colonnes varie selon que le chantier est VRD (Composant/Segment en plus),
   une regle basee sur nth-child se serait retrouvee a cibler la mauvaise
   colonne selon le type de chantier — deja constate (le champ Budget
   affichait un nombre tronque, illisible, pour un montant a 9 chiffres). */
#gantt-table .dash-table .gantt-budget-input { width: 128px; }
/* Les fleches de spinner d'un input number (~18-20px, fixes, non retrecissables)
   mangeaient une part disproportionnee d'une colonne deja etroite — retirees
   sur les champs Budget/Segment (VRD), ou seule la valeur importe, jamais
   incrementee au clic ici. */
#gantt-table .dash-table .gantt-budget-input::-webkit-inner-spin-button,
#gantt-table .dash-table .gantt-budget-input::-webkit-outer-spin-button,
#gantt-table .dash-table .segment-range-picker input::-webkit-inner-spin-button,
#gantt-table .dash-table .segment-range-picker input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#gantt-table .dash-table .gantt-budget-input,
#gantt-table .dash-table .segment-range-picker input {
  -moz-appearance: textfield;
}
#gantt-table .dash-table .remove-btn { width: 24px; height: 24px; font-size: 0.72rem; }
#stocks-catalog-table .dash-table input[type="text"] { width: 100px; }
#stocks-catalog-table .dash-table input[type="number"] { width: 78px; }

/* Table des situations (module Sous-traitance) : meme compacite que
   Gantt/Stocks ci-dessus, mais avec une colonne Notes en texte libre qui doit
   pouvoir s'etendre (width:100%) plutot que d'etre coupee a une largeur fixe. */
#subcontractors-list .dash-table th, #subcontractors-list .dash-table td {
  padding: 5px 4px;
  font-size: 0.78rem;
}
#subcontractors-list .dash-table input, #subcontractors-list .dash-table select {
  font-size: 0.76rem;
  padding: 4px 3px;
  box-sizing: border-box;
}
#subcontractors-list .dash-table input[type="date"] { width: 108px; }
#subcontractors-list .dash-table input[type="number"] { width: 100px; }
#subcontractors-list .dash-table select { width: 100px; }
#subcontractors-list .dash-table input[type="text"] { width: 100%; min-width: 120px; }

/* Formulaires de creation compacts (nouvelle tache / nouveau materiau suivi) :
   4 champs sur une meme ligne avec une largeur non contrainte (min-width:auto
   par defaut sur un item flex) peuvent forcer un defilement horizontal plutot
   que de passer a la ligne proprement. Base plus etroite + min-width:0
   (autorise un item flex a retrecir sous la largeur naturelle de son contenu)
   pour que tout tienne sans avoir a scroller. */
#gantt-add-form .form-row label,
#stocks-catalog-add-form .form-row label {
  flex: 1 1 140px;
  min-width: 0;
}
#gantt-add-form .form-row input,
#stocks-catalog-add-form .form-row input {
  width: 100%;
}

/* Formulaires de creation repliables (natif <details>, comme .pmbok-help) :
   replies par defaut pour ne pas encombrer la place quand on n'a rien a
   ajouter, un clic sur le "+" les deplie. */
.add-form-details { margin-bottom: 14px; }
.add-form-details summary {
  cursor: pointer; font-weight: 700; color: var(--accent-h); font-size: 0.88rem;
  list-style: none; display: inline-block; padding: 6px 0;
}
.add-form-details summary::-webkit-details-marker { display: none; }
.add-form-details summary:hover { text-decoration: underline; }
.add-form-details[open] summary { margin-bottom: 10px; }

/* ---- Aide PMBOK (formules/interpretation, panneau repliable) ---- */
.pmbok-help { margin-top: 16px; border: 1px solid var(--sep); border-radius: var(--radius-sm); padding: var(--space-4) var(--space-7); background: var(--surface); }
.pmbok-help summary { cursor: pointer; font-weight: 700; color: var(--accent-h); font-size: 0.86rem; }
.pmbok-help dl { margin: 12px 0 0; }
.pmbok-help dt { font-weight: 700; color: var(--text); font-size: 0.86rem; margin-top: 10px; }
.pmbok-help dt:first-child { margin-top: 0; }
.pmbok-help dd { margin: 3px 0 0; color: var(--text-dim); font-size: 0.84rem; line-height: 1.5; }

hr { border: none; border-top: 1px solid var(--sep); margin: 24px 0; }

.dropzone {
  border: 2px dashed #D8BE8E;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-dim);
  background: var(--surface);
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: #FDF0DA; }
.dropzone p { margin: 0; font-size: 0.9rem; }
.dropzone-sm { padding: 16px; margin-bottom: 8px; }

.form-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-bottom: 14px; }
.form-row label, label {
  font-size: 0.88rem; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 5px;
}
.checkbox-inline { flex-direction: row !important; align-items: center; gap: 6px !important; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  font-family: inherit; font-size: 0.92rem; padding: 8px 10px;
  border-radius: 7px; border: 1px solid var(--sep);
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
/* Navigation clavier (audit UX) : aucun focus visible n'existait au-dela des
   champs de formulaire — boutons, onglets, lignes cliquables et boutons de
   suppression en etaient totalement depourvus. */
button:focus-visible, .site-tab:focus-visible, .dash-table tr.clickable:focus-visible,
.remove-btn:focus-visible, a:focus-visible, .site-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { width: 100%; resize: vertical; margin-bottom: 4px; }

/* .btn-danger fusionne dans la base commune (audit UX) : avant, il n'avait
   ni padding/radius/font-size/poids propres et lisait comme un bouton
   secondaire discret plutot qu'une action destructive clairement identifiee. */
.btn-primary, .btn-secondary, .btn-danger, .btn-tertiary {
  font-family: inherit; font-size: 0.92rem; font-weight: 700;
  padding: 10px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  margin-right: 8px; margin-top: 4px; transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: var(--darker); }
.btn-primary:hover { background: var(--accent-h); color: var(--white); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--sep); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-h); }
.btn-danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn-danger:hover { background: var(--err); color: var(--white); }
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }
/* Action ponctuelle/onboarding (ex: "Charger un chantier de demo") : discrete
   par defaut, jamais au meme poids visuel qu'une action de navigation
   courante (.btn-secondary) ou primaire (.btn-primary). */
.btn-tertiary { background: transparent; color: var(--text-dim); border: 1px solid transparent; padding-left: 8px; padding-right: 8px; }
.btn-tertiary:hover { color: var(--accent-h); text-decoration: underline; }

.dyn-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.dyn-row input[type="text"], .dyn-row input[type="number"], .dyn-row select { flex: 1; min-width: 90px; }
.remove-btn {
  background: none; border: 1px solid var(--sep); border-radius: 6px; color: var(--text-dim);
  width: 30px; height: 30px; cursor: pointer; flex-shrink: 0; font-size: 0.9rem;
}
.remove-btn:hover { border-color: var(--err); color: var(--err); }

/* Dependances du Gantt (colonne "Dependances" du tableau des taches) : puces
   + select d'ajout, reste dans le flux normal (hauteur = nombre de puces),
   pas un <select multiple> qui gonflait la hauteur de chaque ligne. */
.dependency-picker { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 220px; }
.dependency-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--sep); border-radius: 12px;
  padding: 2px 4px 2px 8px; font-size: 0.74rem; color: var(--text);
}
.dependency-chip button {
  border: none; background: none; cursor: pointer; color: var(--text-dim);
  font-size: 0.85rem; line-height: 1; padding: 0 3px;
}
.dependency-chip button:hover { color: var(--err); }
.dependency-picker-add { font-size: 0.74rem; padding: 3px 5px; flex: 0 0 auto; max-width: 110px; }

.segment-range-picker { display: flex; align-items: center; gap: 4px; }
.segment-range-picker input { width: 80px; }

/* Cycle jour/nuit de la carte VRD (Phase 2) : #site-map doit etre en position
   relative pour que ce calque se positionne bien par-dessus les tuiles/panes
   Leaflet (z-index eleve, au-dela de ceux utilises par Leaflet en interne). */
#site-map { position: relative; }
.vrd-daynight-overlay {
  position: absolute; inset: 0; pointer-events: none;
  z-index: 1000; transition: background 1s linear; border-radius: inherit;
}
.vrd-emoji-icon-wrap { background: none; border: none; }
.vrd-emoji-icon { font-size: 18px; line-height: 1; display: inline-block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.vrd-emoji-icon.lit { filter: drop-shadow(0 0 6px #FFD666) drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.vrd-vehicle-icon-wrap { background: none; border: none; }
.vrd-vehicle-icon-wrap img { filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6)); }

.thumb-list { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.thumb-item { width: 130px; border: 1px solid var(--sep); border-radius: var(--radius-sm); padding: var(--space-2); background: var(--surface); text-align: center; }
.thumb-item img { width: 100%; height: 90px; object-fit: cover; border-radius: 5px; margin-bottom: 5px; background: var(--card); }
.thumb-item input[type="text"] { width: 100%; font-size: 0.75rem; padding: 4px 6px; margin-bottom: 4px; }
.thumb-item button { font-size: 0.72rem; padding: 3px 8px; border-radius: 5px; border: 1px solid var(--sep); background: var(--surface); cursor: pointer; }
.thumb-item button:hover { border-color: var(--err); color: var(--err); }

/* Galerie photos par chantier (audit UX) — grille responsive simple, meme
   esprit visuel que .thumb-item mais en lecture seule (lien vers la photo
   plein format, pas d'edition de legende ici). */
.photo-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery-thumb { display: block; border: 1px solid var(--sep); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); text-decoration: none; color: var(--text-dim); }
.gallery-thumb img { width: 100%; height: 100px; object-fit: cover; display: block; background: var(--card); }
.gallery-thumb-date { display: block; font-size: 0.74rem; padding: 4px 6px; text-align: center; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; margin-right: 6px;
}
.badge-ok { background: #DCF0E4; color: var(--ok); }
.badge-warn { background: #FBEAD2; color: var(--accent-h); }
.badge-err { background: #F6DCD8; color: var(--err); }
.badge-neutral { background: var(--card); color: var(--text-dim); }

/* ---- Timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.entry-card { background: var(--surface); border: 1px solid var(--sep); border-radius: var(--radius); padding: 18px 20px; }
.entry-card-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.entry-date { font-size: 1.05rem; font-weight: 700; color: var(--dark); }
.entry-meta { font-size: 0.82rem; color: var(--text-dim); }
.entry-section-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-h); margin: 10px 0 4px; font-weight: 700; }
.entry-list { margin: 0; padding-left: 18px; font-size: 0.88rem; color: var(--text); }
.entry-list li { margin-bottom: 2px; }
.entry-photos { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.entry-photo-card { width: 220px; border: 1px solid var(--sep); border-radius: 8px; padding: 8px; background: var(--surface); }
.entry-photo-card img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; cursor: pointer; display: block; }
.entry-photo-analysis { margin-top: 6px; font-size: 0.8rem; color: var(--text); }
.entry-photo-analysis .finding { margin: 4px 0; }
.entry-card-actions { margin-top: 12px; }
.entry-card-actions button { font-size: 0.78rem; padding: 5px 12px; }
.timeline-empty { color: var(--text-dim); font-style: italic; padding: 20px 0; }

.stats-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-box { background: var(--surface); border: 1px solid var(--sep); border-radius: var(--radius-sm); padding: var(--space-6) var(--space-8); min-width: 120px; }
.stat-box .num { font-size: 1.5rem; font-weight: 700; color: var(--accent-h); }
.stat-box .label { font-size: 0.78rem; color: var(--text-dim); }

/* ---- Analyse (listes classées) ---- */
/* Chaque liste dans sa propre carte (comme les graphiques du tableau de bord,
   .chart-card) au lieu de flotter directement sur le fond du panneau — c'est
   ce qui donne l'impression de "produit" (separation/profondeur) plutot que
   des titres et des barres empiles a plat. */
.analytics-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 4px 0; }
.analytics-card h4 { display: flex; align-items: center; gap: 7px; }
.analytics-card .rank-list { margin-bottom: 0; }

/* ---- Vue client (role viewer) : galerie photo epuree ---- */
.client-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.client-photo-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--card); }
.client-photo-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.client-photo-date {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px;
  background: rgba(28,22,15,0.65); color: var(--white); font-size: 0.7rem; text-align: center;
}

/* ---- Informations (fiche chantier) : meme traitement carte+icone ---- */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin: 4px 0 16px; }
.info-card-head { margin-bottom: 12px; }
.info-card-head h4 { display: flex; align-items: center; gap: 7px; margin: 0; }
.info-cards .form-row:last-child { margin-bottom: 0; }
/* Zone de danger (audit UX) : "Supprimer" ne doit jamais avoir le meme poids
   visuel ni etre au meme endroit que l'action de sauvegarde courante — separee
   par une marge nette et une bordure, avec un avertissement explicite. */
.danger-zone { margin-top: var(--space-10); padding-top: var(--space-9); border-top: 1px solid var(--sep); }
.danger-zone-warning { margin: 0 0 var(--space-4); color: var(--err); }
.rank-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 16px; }
.rank-row { display: flex; align-items: center; gap: 12px; font-size: 0.86rem; padding: 5px 8px; border-radius: 7px; margin: 0 -8px; }
.rank-row:hover { background: var(--card2); }
.rank-label { flex: 0 0 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
/* Piste = un pas plus clair de la MEME teinte que le remplissage (pas un gris
   neutre) : c'est ce qui fait lire tout le meter comme un seul dégradé plutôt
   que "bloc orange posé sur un fond gris". Le remplissage est carré côté
   départ (la barre grandit depuis 0) et arrondi côté valeur (l'extrémité) —
   jamais arrondi des deux côtés, qui casse la lecture "grandit depuis zéro". */
.rank-bar { flex: 1; height: 10px; background: var(--accent-tint); border-radius: 5px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--accent-h); border-radius: 0 5px 5px 0; }
/* La valeur porte le poids (gras) mais jamais la couleur de la donnée — le
   texte reste dans les tokens de texte (ici le plus foncé, --text, puisque
   c'est la valeur qu'on veut le plus lisible), l'identité/l'intensité vit
   uniquement dans la barre colorée à côté. Largeur FIXE (pas min-width) pour
   que "7h" et "2 occurrences" alignent leur bord droit au même endroit d'une
   ligne à l'autre plutôt que de faire onduler la fin des barres. */
.rank-value { flex: 0 0 92px; text-align: right; font-weight: 700; color: var(--text); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  padding: 12px 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--sep);
  color: var(--text); font-size: 0.88rem; box-shadow: 0 8px 32px rgba(20,27,33,0.18);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--ok); }
.toast-error { border-left: 3px solid var(--err); }

/* ---- Modale de confirmation (remplace confirm()/prompt() natifs, cf. audit UX) ---- */
.confirm-modal-overlay {
  /* Au-dessus des controles Leaflet (.leaflet-top/.leaflet-bottom sont a
     z-index:1000) — constate : une modale ouverte depuis la carte VRD
     (detail de troncon, visionneuse photo) se faisait recouvrir par les
     boutons zoom/couches/plein ecran de Leaflet avant ce correctif. */
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28,22,15,0.55);
}
.confirm-modal-card {
  max-width: 400px; width: calc(100% - 40px);
  background: var(--card2); border: 1px solid var(--sep); border-radius: var(--radius);
  padding: var(--space-9) var(--space-10);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.confirm-modal-card p { margin: 0; color: var(--text); font-size: 0.92rem; line-height: 1.5; }
.confirm-modal-input { width: 100%; margin-top: 14px; }
.confirm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.confirm-modal-actions button { margin: 0; }

/* ---- Modale de detail de tronçon VRD (clic sur la carte) — meme voile que
   la modale de confirmation, carte plus large pour loger infos + galerie. ---- */
.vrd-segment-modal-card { max-width: 560px; position: relative; max-height: calc(100vh - 80px); overflow-y: auto; }
.vrd-segment-modal-close {
  position: absolute; top: 10px; right: 12px; border: none; background: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; color: var(--text-dim); padding: 4px;
}
.vrd-segment-modal-close:hover { color: var(--text); }
.vrd-segment-detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0;
  font-size: 0.88rem;
}
.vrd-segment-detail-grid dt { color: var(--text-dim); }
.vrd-segment-detail-grid dd { margin: 0; color: var(--text); font-weight: 600; }

/* ---- Etiquettes rondes sur la carte VRD (zone + photo) ---- */
.vrd-zone-pin {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45); cursor: pointer;
}
.vrd-photo-pin {
  display: block; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45); cursor: pointer;
  background-size: cover; background-position: center; background-color: var(--card);
}
.vrd-photo-lightbox {
  position: relative; max-width: min(90vw, 720px); max-height: 85vh;
  background: var(--card2); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.vrd-photo-lightbox img { display: block; max-width: 100%; max-height: 75vh; border-radius: 6px; margin: 0 auto; }

.vrd-geotech-pin {
  display: block; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45); cursor: pointer;
  background-size: cover; background-position: center; background-color: var(--card);
}
/* Icone fournie (deja un badge rond autonome) : pas de fond/bordure ajoutes
   par-dessus, juste une taille reduite pour rester discrete sur la carte. */
.vrd-hydraulic-pin-img { display: block; width: 20px; height: 20px; cursor: pointer; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4)); }

/* ---- Tableau de bord ---- */
.dash-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--sep); border-radius: var(--radius); overflow: hidden; }
.dash-table th, .dash-table td { text-align: left; padding: 10px 14px; font-size: 0.88rem; border-bottom: 1px solid var(--sep); }
.dash-table th { background: var(--card); color: var(--text-dim); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr.clickable { cursor: pointer; }
.dash-table tr.clickable:hover { background: var(--card2); }
.dash-table tr.clickable.active { background: var(--card2); }
.dash-table .site-link { color: var(--accent-h); font-weight: 700; cursor: pointer; }
.dash-table .site-link:hover { text-decoration: underline; }

/* ---- Graphiques du tableau de bord ---- */
/* Une seule colonne (pleine largeur) plutot que 2 par ligne : des graphes
   plus larges/plus lisibles, plus "vrais graphes" que des vignettes cote a
   cote — chacun a la taille qu'il lui faut au lieu d'etre comprime par le
   voisin. */
.chart-panel { display: flex; flex-direction: column; gap: 18px; margin: 4px 0 24px; }
.chart-card { background: var(--surface); border: 1px solid var(--sep); border-radius: var(--radius); padding: var(--space-9) var(--space-10); box-shadow: var(--shadow-card); }
.chart-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.chart-card-head h4 { margin: 0; }
/* .chart-card est desormais un <details> (replie par defaut, cf. dashboard.js
   chartCard()) — le <summary> remplace le marqueur triangle natif par le
   curseur pointeur seul, le contenu (titre + bouton export) reste identique
   qu'il soit dans un <div> (analytics.js) ou un <summary> (dashboard.js). */
summary.chart-card-head { cursor: pointer; list-style: none; }
summary.chart-card-head::-webkit-details-marker { display: none; }
.chart-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.chart-type-select {
  font-size: 0.72rem; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--sep);
  background: var(--surface); color: var(--text-dim); cursor: pointer;
}
.chart-type-select:hover { border-color: var(--accent); color: var(--accent-h); }
.chart-card canvas { height: 380px !important; width: 100% !important; }
/* Legende complementaire du Gantt (statuts + chemin critique) — la legende
   native Chart.js ne couvre que les 2 datasets (Prévu/Réel), pas les
   couleurs par statut a l'interieur de "Réel". */
.gantt-status-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-top: 10px; font-size: 0.8rem; color: var(--text-dim); }
.gantt-status-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.gantt-status-legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.gantt-status-legend-critical { background: var(--surface); border: 3px solid #1C160F; width: 6px; height: 6px; }
/* Squelette de chargement (audit UX) : pendant l'attente d'un graphique qui
   depend d'un appel serveur (courbe en S), affiche un rectangle pulsant
   plutot qu'un vide — retire/remplace des que les donnees arrivent. */
.skeleton-chart { height: 380px; background: var(--card); animation: skeleton-pulse 1.5s ease-in-out infinite; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.chart-png-btn { flex-shrink: 0; font-size: 0.72rem; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--sep); background: var(--surface); color: var(--text-dim); cursor: pointer; }
.chart-png-btn:hover { border-color: var(--accent); color: var(--accent-h); }
.chart-panel-empty { grid-column: 1 / -1; }

/* ---- Barre de jalons (évolution du chantier dans le temps) ---- */
.milestone-card { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--sep); border-radius: var(--radius); padding: 20px 26px 22px; }
.milestone-track-wrap { padding: 20px 8px 0; }
.milestone-track { position: relative; height: 8px; background: var(--card); border-radius: 4px; margin: 0 8px; }
.milestone-fill { position: absolute; top: 0; left: 0; height: 100%; background: var(--accent); border-radius: 4px; }
.milestone-dot { position: absolute; top: 50%; width: 15px; height: 15px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--sep); cursor: default; }
.milestone-dot.ok { background: var(--ok); }
.milestone-dot.warn { background: var(--err); }
.milestone-today { position: absolute; top: -12px; width: 2px; height: 30px; background: var(--dark); transform: translateX(-50%); }
.milestone-endpoints { display: flex; justify-content: space-between; margin-top: 18px; font-size: 0.82rem; color: var(--text-dim); font-weight: 600; }
.milestone-legend { display: flex; gap: 22px; margin-top: 18px; font-size: 0.8rem; color: var(--text-dim); flex-wrap: wrap; }
.milestone-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.milestone-legend .dot.ok { background: var(--ok); }
.milestone-legend .dot.warn { background: var(--err); }
.milestone-legend .dot.today { background: var(--dark); }

/* ---- Mode lecture seule (role "viewer" sur le chantier ouvert) ---- */
/* Cache les actions d'ecriture plutot que de les desactiver visuellement : un
   viewer n'a pas a se demander pourquoi un bouton est grise, il n'existe
   simplement pas pour lui. Les exports PDF/Word restent volontairement visibles
   (lecture, pas ecriture) — seule la sidebar #site-view est concernee. */
#site-view.viewer-mode #site-save-btn,
#site-view.viewer-mode #site-delete-btn,
#site-view.viewer-mode #site-locate-btn,
#site-view.viewer-mode #site-doc-drop,
#site-view.viewer-mode #entry-material-add-btn,
#site-view.viewer-mode #entry-stockout-add-btn,
#site-view.viewer-mode #entry-incident-add-btn,
#site-view.viewer-mode #entry-reserve-add-btn,
#site-view.viewer-mode #entry-losttime-add-btn,
#site-view.viewer-mode #entry-save-btn,
#site-view.viewer-mode #entry-cancel-edit-btn,
#site-view.viewer-mode #entry-photos-drop,
#site-view.viewer-mode #export-enhance-row,
#site-view.viewer-mode .ai-enrich-btn {
  display: none !important;
}
/* input/select/textarea desactives directement en JS (attribut disabled,
   plus robuste que pointer-events pour un clavier) — juste le rendu visuel ici. */
#site-view.viewer-mode input:disabled,
#site-view.viewer-mode select:disabled,
#site-view.viewer-mode textarea:disabled {
  background: var(--card);
  color: var(--text-dim);
}
#site-view.viewer-mode .dyn-row .remove-btn,
#site-view.viewer-mode .thumb-item button {
  display: none;
}

/* ---- Documents du chantier ---- */
.doc-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.doc-item {
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-3) var(--space-5); border: 1px solid var(--sep); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 0.86rem;
}
.doc-item .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .doc-size { color: var(--text-dim); font-size: 0.78rem; }
.doc-item button, .doc-item .doc-dl-link {
  font-size: 0.78rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--sep);
  background: var(--surface); cursor: pointer; color: inherit; text-decoration: none;
}
.doc-item button:hover, .doc-item .doc-dl-link:hover { border-color: var(--accent); color: var(--accent-h); }
.doc-item button.doc-del:hover { border-color: var(--err); color: var(--err); }

/* ---- Assistant IA (chat flottant par chantier) ---- */
#site-chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 500; display: flex; flex-direction: column; align-items: flex-end; }
#site-chat-toggle {
  display: flex; align-items: center; gap: 8px; margin: 0;
  background: var(--accent); color: var(--darker); border: none; border-radius: 999px;
  padding: 13px 22px; font-weight: 700; font-size: 0.9rem; font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
#site-chat-toggle:hover { background: var(--accent-h); }

#site-chat-panel {
  margin-bottom: 14px; width: 400px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--sep); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28);
  display: flex; flex-direction: column; max-height: 560px; overflow: hidden;
}
#site-chat-panel.drag { outline: 2px dashed var(--accent); outline-offset: -6px; }

.site-chat-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--darker); }
.site-chat-header-title { display: flex; flex-direction: column; gap: 1px; }
.site-chat-header-name { font-weight: 700; font-size: 0.95rem; color: var(--white); }
.site-chat-header-sub { font-size: 0.74rem; color: var(--accent); }
.site-chat-header-actions { display: flex; align-items: center; gap: 2px; }
.site-chat-header-actions button {
  background: transparent; border: none; color: var(--white); opacity: 0.65;
  font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; line-height: 1;
  display: flex; align-items: center;
}
.site-chat-header-actions button:hover { opacity: 1; background: rgba(255,255,255,0.14); }

#site-chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 260px; background: var(--card2); }
.site-chat-msg { max-width: 84%; display: flex; flex-direction: column; gap: 4px; }
.site-chat-msg-user { align-self: flex-end; align-items: flex-end; }
.site-chat-msg-assistant { align-self: flex-start; align-items: flex-start; }
.site-chat-bubble { padding: 10px 13px; border-radius: 14px; font-size: 0.87rem; line-height: 1.5; white-space: pre-wrap; }
.site-chat-msg-user .site-chat-bubble { background: var(--accent); color: var(--darker); border-bottom-right-radius: 4px; }
.site-chat-msg-assistant .site-chat-bubble { background: var(--surface); color: var(--text); border: 1px solid var(--sep); border-bottom-left-radius: 4px; }
.site-chat-msg img { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; cursor: pointer; display: block; margin-bottom: 6px; }
.site-chat-time { font-size: 0.68rem; color: var(--text-dim); padding: 0 4px; }

/* Carte de confirmation du copilote agentique : le modele PROPOSE (create/
   update tache ou materiau), n'execute jamais tout seul — cette carte est le
   seul chemin vers une ecriture reelle, via un clic explicite. */
.site-chat-action-card {
  margin-top: 8px; padding: 9px 11px; border-radius: 9px;
  background: var(--accent-tint); border: 1px solid var(--accent);
}
.site-chat-action-card p { margin: 0 0 4px; font-size: 0.85rem; font-weight: 600; }
.site-chat-action-card .btn-secondary { font-size: 0.78rem; padding: 5px 12px; margin: 0; }

#site-chat-typing { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; font-size: 0.8rem; color: var(--text-dim); background: var(--card2); }
.site-chat-typing-dots { display: inline-flex; gap: 3px; }
.site-chat-typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-h); display: inline-block; animation: chatTypingBounce 1.2s infinite ease-in-out; }
.site-chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.site-chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

#site-chat-image-preview { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--sep); background: var(--surface); }
#site-chat-image-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }

#site-chat-form { border-top: 1px solid var(--sep); padding: 10px 12px; background: var(--surface); }
.site-chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
/* Textarea (pas input) : permet une vraie nouvelle ligne (Maj+Entree), Entree
   seule envoie toujours — cf. site-chat.js. Croit avec le contenu jusqu'a
   une hauteur plafonnee (au-dela, defile) plutot que de pousser tout le
   panneau flottant en hauteur. */
.site-chat-input-row textarea {
  flex: 1; min-width: 0; margin: 0; resize: none; max-height: 100px;
  font-family: inherit; line-height: 1.4;
}
.site-chat-icon-btn {
  flex: 0 0 auto; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--sep); background: var(--surface); color: var(--text-dim); cursor: pointer; padding: 0;
}
.site-chat-icon-btn:hover { border-color: var(--accent); color: var(--accent-h); }
.site-chat-icon-btn.site-chat-send { background: var(--accent); color: var(--darker); border-color: var(--accent); }
.site-chat-icon-btn.site-chat-send:hover { background: var(--accent-h); }
.site-chat-icon-btn:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .main { padding: 24px 18px; max-width: 100%; }
}

/* Passe mobile reelle (audit UX : une seule media query existait avant celle-
   ci, rien ne s'adaptait vraiment en dessous de 900px). Champs empiles en une
   colonne, bandeaux hero plus courts, cibles tactiles agrandies — un vrai
   redecoupage des tableaux denses (Gantt/Stocks) en cartes reste hors scope
   de cette passe, un indicateur de defilement suffit pour l'instant. */
@media (max-width: 640px) {
  .form-row { gap: 12px; }
  .form-row label { flex: 1 1 100%; }
  .stats-row { gap: 8px; }
  .stat-box { flex: 1 1 100%; min-width: 0; }
  .info-cards { grid-template-columns: 1fr; }
  .view-hero-dashboard { height: 120px; }
  .view-hero-settings { height: 100px; }
  .view-hero-chantier { height: 90px; }
  .view-hero-sm { height: 80px; }
  .view-hero-overlay { padding: var(--space-6) var(--space-8); }
  .view-hero-overlay h2 { font-size: 1.15rem; }
  /* Cibles tactiles (WCAG 2.5.5) : 30px/44px etaient trop petits au doigt. */
  .remove-btn { width: 40px; height: 40px; }
  #gantt-table .dash-table input[type="number"] { min-width: 60px; width: auto; }
  /* Indicateur visuel de defilement horizontal sur les tableaux denses (ombre
     statique sur les deux bords, pas dynamique selon la position de scroll —
     plus simple et plus sur qu'un effet base sur background-attachment sans
     pouvoir le verifier visuellement), plutot qu'une refonte complete en
     cartes (hors scope de cette passe). */
  #gantt-table, #stocks-catalog-table, #stocks-balance-table,
  #site-members-list, #dashboard-table, #users-table {
    box-shadow: inset -8px 0 6px -6px rgba(28,22,15,0.15), inset 8px 0 6px -6px rgba(28,22,15,0.15);
  }
}

/* ---- Carte : bouton plein ecran (Fullscreen API native, zero dependance) ---- */
.map-fullscreen-btn {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid rgba(0,0,0,0.2); border-radius: 4px;
  color: var(--text); cursor: pointer; padding: 0;
}
.map-fullscreen-btn:hover { color: var(--accent-h); }
/* L'API Fullscreen agrandit deja l'element au viewport, mais #site-map porte
   une hauteur fixe en inline style (280px) — la surcharger explicitement
   pour que la carte remplisse vraiment tout l'ecran, pas juste sa largeur. */
#site-map:fullscreen { height: 100vh !important; width: 100vw !important; }
