/* Application QSE Biollay — feuille de style mobile-first.
   Palette : rouge Biollay #E41F18 (logo), blanc, gris clair. */

:root {
  --marque: #E41F18;
  --marque-clair: #ff5248;
  --gris: #f0f2f5;
  --gris-bord: #d8dde3;
  --texte: #1c2530;
  --vert: #228B22;
  --rouge: #c0392b;
  --rayon: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--texte);
  background: var(--gris);
  -webkit-text-size-adjust: 100%;
}

/* --- Barre supérieure --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: #fff; color: var(--marque);
  padding: 10px 14px;
  border-bottom: 3px solid var(--marque);
}
.topbar__logo {
  height: 32px; width: auto;
}
.topbar__title { flex: 1; font-size: 16px; font-weight: 700; letter-spacing: .5px; color: var(--marque); }
.topbar__version { font-size: 11px; font-weight: 600; color: #999; flex: none; }
.topbar__net { width: 12px; height: 12px; border-radius: 50%; background: #888; flex: none; }
.topbar__net.online { background: #43d17a; }
.topbar__net.offline { background: #e0a800; }
.topbar__utilisateur { font-size: 12px; font-weight: 600; color: #667; flex: none; }
.topbar__deconnexion {
  font-size: 16px; line-height: 1; flex: none; border: none; background: none;
  color: #999; cursor: pointer; padding: 2px;
}
.topbar__deconnexion:active { color: var(--marque); }

/* --- Contenu --- */
#ecran { padding: 16px 14px 90px; max-width: 900px; margin: 0 auto; }
.page-title { font-size: 20px; margin: 6px 0 14px; color: var(--marque); }
.page-title small { font-weight: 400; color: #667; font-size: 14px; }
.page-subtitle { font-size: 16px; margin: 22px 0 10px; color: var(--marque); }
.vide { color: #889; font-style: italic; }

/* --- Barre de navigation inférieure --- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: #fff; border-top: 1px solid var(--gris-bord);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar__item {
  flex: 1; text-align: center; padding: 10px 4px 8px;
  text-decoration: none; color: #667; font-size: 12px;
}
.tabbar__item.actif { color: var(--marque); font-weight: 600; }
.tabbar__icone { display: block; font-size: 20px; line-height: 1; margin-bottom: 2px; }

/* --- Écran d'accueil --- */
.grille-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.carte-fiche {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 96px; padding: 14px;
  background: var(--marque); color: #fff; text-decoration: none;
  border-radius: var(--rayon); box-shadow: 0 2px 5px rgba(0,0,0,.12);
}
.carte-fiche:active { background: var(--marque-clair); }
.carte-fiche__label { font-weight: 600; font-size: 15px; }
.carte-fiche__sous { font-size: 12px; opacity: .8; margin-top: 4px; }

.rappel {
  background: #fff3cd; border: 1px solid #ffe69c; color: #664d03;
  padding: 10px 12px; border-radius: var(--rayon); margin-bottom: 14px;
}
.rappel a { color: #664d03; }
.rappel--install {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.rappel--install .btn { padding: 8px 14px; font-size: 14px; }

/* --- Listes de fiches --- */
.liste-fiches { list-style: none; padding: 0; margin: 0; }
.liste-fiches li { margin-bottom: 8px; }
.liste-fiches a {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  background: #fff; border: 1px solid var(--gris-bord);
  border-radius: var(--rayon); padding: 12px; text-decoration: none; color: var(--texte);
}
.liste-fiches__titre { font-weight: 600; grid-column: 1; }
.liste-fiches__meta { grid-column: 1; font-size: 13px; color: #667; margin-top: 2px; }
.badge {
  grid-row: 1 / span 2; grid-column: 2;
  font-size: 11px; padding: 4px 8px; border-radius: 20px; text-transform: capitalize;
  background: var(--gris); color: #445;
}
.badge--brouillon { background: #e7ecf3; color: #445; }
.badge--en_attente { background: #ffe9cc; color: #9a4d00; }
.badge--publie { background: #d8f3df; color: #1c6b34; }
.badge--conforme { background: #d8f3df; color: #1c6b34; }
.badge--non-conforme { background: #fbe1de; color: var(--rouge); }

/* Variante non-lien de .liste-fiches (boutons d'action inline au lieu d'un
   simple lien de consultation, ou mélange des deux — écran Fiches, S9/§17.6 :
   titre cliquable (fusion locale) à côté de boutons d'action). */
.liste-fiches__ligne {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  background: #fff; border: 1px solid var(--gris-bord);
  border-radius: var(--rayon); padding: 12px;
}
.liste-fiches__ligne a.liste-fiches__titre { color: inherit; text-decoration: none; }
.liste-fiches__actions {
  grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.liste-fiches__actions .btn { padding: 8px 14px; font-size: 13px; flex: none; }

/* --- Formulaires --- */
.champ { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.champ[hidden] { display: none; }
.champ-pleine-largeur { grid-column: 1 / -1; }
.champ label { font-size: 13px; font-weight: 600; color: var(--marque); }
.champ input, .champ select {
  font-size: 15px; padding: 9px 10px;
  border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: #fff; color: var(--texte); width: 100%;
}
.champ input.champ-lecture-seule {
  background: var(--gris); color: var(--texte-att, #666); cursor: not-allowed;
}

.champ select:disabled { background: var(--gris); color: #888; cursor: not-allowed; }
.lien-parametres { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--marque); }

.grille-champs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px;
}
@media (max-width: 480px) {
  .grille-champs { grid-template-columns: 1fr; }
}

.radio-group { display: flex; gap: 16px; padding: 6px 0; }
.radio-group label { font-weight: 400; display: flex; align-items: center; gap: 6px; }

/* Tableaux de mesures */
.tableau-conteneur { overflow-x: auto; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.tableau-mesures { border-collapse: collapse; width: 100%; min-width: 560px; background: #fff; }
.tableau-mesures th, .tableau-mesures td {
  border: 1px solid var(--gris-bord); padding: 6px 8px; font-size: 13px; text-align: center;
}
.tableau-mesures th { background: var(--gris); color: var(--marque); white-space: nowrap; }
.tableau-mesures td.critere-libelle { text-align: left; min-width: 160px; }
.tableau-mesures input, .tableau-mesures select {
  width: 100%; min-width: 56px; padding: 4px; border: 1px solid var(--gris-bord);
  border-radius: 6px; font-size: 13px; text-align: center; box-sizing: border-box;
}
.tableau-mesures input.champ-solution {
  min-width: 0; width: 100%; text-align: left;
  white-space: normal; word-break: break-word;
}
.tableau-mesures td.critere-solution { width: 38%; min-width: 150px; vertical-align: middle; }
.tableau-mesures td.critere-conforme { width: 14%; min-width: 72px; text-align: center; vertical-align: middle; white-space: nowrap; }
.tableau-reception { min-width: 460px; }
.tableau-reception .th-conforme { width: 14%; white-space: nowrap; }
.tableau-reception .th-solution { width: 38%; }
.tableau-mesures th { white-space: pre-line; }
.btn-solution-toggle {
  font-size: 12px; color: var(--marque); background: none;
  border: 1px dashed var(--marque); border-radius: 6px;
  padding: 3px 8px; cursor: pointer; white-space: nowrap;
}
.btn-conforme-toggle {
  font-size: 12px; font-weight: 600; border-radius: 6px;
  padding: 4px 8px; cursor: pointer; white-space: nowrap; width: 100%;
  background: var(--gris); color: #667; border: 1px solid var(--gris-bord);
}
.btn-conforme-toggle.oui {
  background: #d8f3df; color: #1c6b34; border-color: #a3d9b1;
}
.btn-conforme-toggle.non {
  background: #fbe1de; color: var(--rouge); border-color: #f3b8b3;
}
.tableau-mesures td[data-cell] { font-weight: 600; white-space: nowrap; }
.tableau-mesures td[data-cell].conforme { color: #1c6b34; }
.tableau-mesures td[data-cell].non-conforme { color: var(--rouge); }

.legende { font-size: 13px; color: #667; font-style: italic; margin: 0 0 8px; }

.bouton-icone {
  border: none; background: transparent; color: var(--rouge);
  font-size: 16px; cursor: pointer; padding: 2px 6px;
}

/* Bloc de résultats (essais d'arrachement) */
.bloc-resultats {
  background: #fff; border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  padding: 12px 14px; margin: 10px 0; font-size: 14px;
}
.bloc-resultats p { margin: 4px 0; }
.bloc-resultats .seuils { font-size: 12px; color: #667; }

.badge-conformite {
  display: inline-block; padding: 6px 14px; border-radius: 20px;
  font-weight: 600; font-size: 13px; background: var(--gris); color: #445;
  margin-top: 8px;
}
.badge-conformite.conforme { background: #d8f3df; color: #1c6b34; }
.badge-conformite.non-conforme { background: #fbe1de; color: var(--rouge); }

/* T5e — schéma en coupe + tableau d'acceptation de la pastille d'arrachement */
.pastille-reference {
  margin-top: 10px; border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: var(--gris); padding: 10px 12px;
}
.pastille-reference__titre {
  font-size: 13px; font-weight: 600; color: var(--marque); margin: 0 0 8px;
}
.pastille-reference__schema {
  display: block; max-width: 280px; height: auto; margin: 0 0 10px;
  background: #fff; border: 1px solid var(--gris-bord); border-radius: var(--rayon);
}
.tableau-acceptation {
  width: 100%; border-collapse: collapse; font-size: 12px; background: #fff;
}
.tableau-acceptation th, .tableau-acceptation td {
  border: 1px solid var(--gris-bord); padding: 4px 8px; text-align: left;
}
.tableau-acceptation th { background: var(--gris); font-weight: 700; }
.tableau-acceptation td:first-child { font-weight: 700; text-align: center; white-space: nowrap; }
.tableau-acceptation tr.garder td:last-child { color: #1e7e34; font-weight: 600; }
.tableau-acceptation tr.eliminer td:last-child { color: var(--marque); font-weight: 600; }

/* T7 — bloc de référence réglementaire SIA 252 (fiche réception) */
.reception-reference {
  margin-top: 14px; border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: var(--gris); padding: 10px 12px;
}
.reception-reference__titre {
  font-size: 14px; font-weight: 700; color: var(--marque); margin: 0 0 10px;
}
.tableau-reference { margin-bottom: 12px; }
.tableau-reference h4 {
  font-size: 13px; font-weight: 600; margin: 0 0 4px;
}
.tableau-reference__table {
  width: 100%; border-collapse: collapse; font-size: 12px; background: #fff;
}
.tableau-reference__table th, .tableau-reference__table td {
  border: 1px solid var(--gris-bord); padding: 4px 8px; text-align: left;
}
.tableau-reference__table th { background: var(--gris); font-weight: 700; }
.tableau-reference__notes { margin: 4px 0 0; padding-left: 18px; font-size: 12px; color: #555; }
.reception-reference__notes { margin-top: 4px; }
.note-complementaire { margin-bottom: 10px; font-size: 13px; }
.note-complementaire ul { margin: 2px 0 0; padding-left: 18px; color: #555; }
.reception-reference__nota {
  margin: 10px 0 0; font-size: 12px; font-style: italic; color: #555;
  border-top: 1px solid var(--gris-bord); padding-top: 8px;
}

/* T4 — Historique groupé par chantier */
.groupe-chantier { margin-bottom: 18px; }
.groupe-chantier__titre {
  font-size: 14px; font-weight: 700; color: var(--marque);
  padding: 6px 10px; margin: 0 0 4px;
  background: var(--gris); border-left: 3px solid var(--marque);
  border-radius: 0 var(--rayon) var(--rayon) 0;
}

/* T3c — Seuils configurables au-dessus du tableau d'arrachement */
.seuils-config { margin-bottom: 10px; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 620px) {
  .seuils-config { grid-template-columns: 1fr; }
}

/* Signatures */
.signature-zone {
  background: #fff; border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  padding: 12px 14px; margin-bottom: 14px;
}
.signature-zone h3 { margin: 0 0 8px; font-size: 15px; color: var(--marque); }
.pad-signature-conteneur { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pad-signature {
  width: 100%; max-width: 320px; height: 140px;
  border: 1px dashed var(--gris-bord); border-radius: var(--rayon);
  background: #fff; touch-action: none;
}

/* Boutons */
.btn {
  font-size: 15px; font-weight: 600; padding: 12px 18px;
  border: none; border-radius: var(--rayon); cursor: pointer;
}
.btn-principal { background: var(--marque); color: #fff; }
.btn-principal:active { background: var(--marque-clair); }
.btn-secondaire { background: var(--gris); color: var(--marque); border: 1px solid var(--gris-bord); }
.btn-texte { background: none; color: var(--marque); padding: 6px 0; text-decoration: underline; }
.btn--desactive { opacity: .5; pointer-events: none; }

.boutons-action {
  display: flex; gap: 10px; margin: 18px 0 10px; flex-wrap: wrap;
}
.boutons-action .btn { flex: 1; min-width: 140px; }

/* --- Historique : filtres --- */
.filtres { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.champ-filtre {
  flex: 1; min-width: 140px; font-size: 14px; padding: 9px 10px;
  border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: #fff; color: var(--texte);
}

/* --- Paramètres : onglets, ajout, listes --- */
.ligne-sync {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.ligne-sync .btn-texte { padding: 4px 0; }

.onglets-param { display: flex; gap: 8px; margin-bottom: 6px; }
.onglet-param {
  flex: 1; font-size: 14px; font-weight: 600; padding: 10px;
  border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: #fff; color: #667; cursor: pointer;
}
.onglet-param.actif { background: var(--marque); color: #fff; border-color: var(--marque); }

.ligne-ajout { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.ligne-ajout input, .ligne-ajout select {
  flex: 1; min-width: 120px; font-size: 15px; padding: 9px 10px;
  border: 1px solid var(--gris-bord); border-radius: var(--rayon);
  background: #fff; color: var(--texte);
}
.ligne-ajout .btn { flex: none; }

.liste-param { list-style: none; padding: 0; margin: 0; }
.liste-param li {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border: 1px solid var(--gris-bord);
  border-radius: var(--rayon); padding: 10px 12px; margin-bottom: 8px;
}
.liste-param li em { font-style: normal; color: #667; }
.liste-param__actions { display: flex; gap: 6px; align-items: center; flex: none; }

/* Écran Paramètres > Comptes (S5) : révélation unique du mot de passe temporaire. */
.encart-mot-de-passe {
  border: 2px solid var(--marque); border-radius: var(--rayon);
  background: #fff5f4; padding: 12px 14px; margin: 12px 0;
}
.encart-mot-de-passe__valeur {
  font-family: monospace; font-size: 20px; font-weight: 700;
  letter-spacing: 1px; margin: 6px 0;
}
