:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #e1e6ec;
  --brand: #3e5394;
  --brand-dark: #2f4278;
  --info: #2563eb;
  --danger: #c62828;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.late { color: var(--danger); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* En-tête */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 20px;
  background: var(--brand);
  color: #fff;
}
.brand {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  padding: 8px 0;
}
.brand-logo { height: 40px; width: auto; border-radius: 4px; }
/* Menu défilant horizontalement, avec animation au survol. */
nav { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: thin; scroll-behavior: smooth; }
nav button {
  flex: none;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: #d6deec;
  padding: 14px 12px;
  font: inherit;
  cursor: pointer;
  transition: color .25s ease, border-color .3s ease, transform .25s ease;
}
nav button:hover { transform: translateY(-2px); }
nav button:hover,
nav button.active { color: #fff; border-bottom-color: #fff; }
.land-tile { transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease; }
.land-tile:hover { box-shadow: 0 8px 18px rgba(47, 66, 120, 0.18); }
.land-col .land-tile { animation: rise .5s ease both; }
.land-col .land-tile:nth-child(2) { animation-delay: .06s; }
.land-col .land-tile:nth-child(3) { animation-delay: .12s; }
.land-col .land-tile:nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
/* Ordinateur : menus et commandes sur une seule ligne (la ligne passe à la suite seulement si l'écran est trop étroit). */
@media (min-width: 1100px) {
  .topbar { flex-wrap: nowrap; gap: 12px; }
  nav { flex: 1 1 auto; min-width: 0; gap: 0; }
  nav button { padding: 14px 5px; font-size: 13px; white-space: nowrap; }
  .brand span { white-space: nowrap; }
  .top-right { margin-left: 0; flex-shrink: 0; flex-wrap: nowrap; gap: 6px; }
}
/* Écrans moyens : le nom de l'utilisateur est masqué pour garder tout sur une ligne. */
@media (min-width: 1100px) and (max-width: 1699px) {
  .user-box > span { display: none; }
}
.user-box { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.user-box span { opacity: 0.9; }
.lang-btn,
.top-btn {
  font: inherit;
  font-size: 13px;
  color: #fff;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
.lang-btn:hover,
.top-btn:hover { background: rgba(255, 255, 255, 0.12); }
body.logged-out nav,
body.logged-out .user-box { display: none; }

.site-filter { width: auto; padding: 4px 8px; font-size: 13px; }
/* Filtre de site de la barre de navigation : fond blanc. */
.top-right .site-filter { background: #fff; border-color: #fff; color: #1f2a44; font-weight: 600; }

/* Alertes */
.bell-wrap { position: relative; }
.bell {
  position: relative;
  width: 36px;
  height: 32px;
  font-size: 18px;
  color: #fff;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  cursor: pointer;
}
.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: var(--danger);
  border-radius: 9px;
}
.notif-panel {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 30;
  width: min(340px, 90vw);
  max-height: 420px;
  overflow-y: auto;
  padding: 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.notif-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.notif-head .btn { font-size: 12px; padding: 4px 8px; }
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.notif-item.unread { background: #eef3fb; }
.notif-item small { font-size: 12px; }

/* Connexion */
.auth-card { max-width: 420px; margin: 40px auto; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.error-text { color: var(--danger); margin: 0; min-height: 1em; }
.error-text.full { grid-column: 1 / -1; }

main { max-width: min(1800px, 96vw); margin: 0 auto; padding: 20px 16px 40px; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 12px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

/* Cartes et tableaux */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.grid-2 > .card { margin-bottom: 0; }
/* Registres : en-tête et première colonne figés pendant le défilement. */
.table-wrap { overflow: auto; max-height: calc(100vh - 170px); }
.table-wrap table { border-collapse: separate; border-spacing: 0; }
.table-wrap thead th { position: sticky; top: 0; z-index: 2; background: var(--brand); color: #fff; box-shadow: inset 0 -1px 0 var(--brand-dark); }
.table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.table-wrap thead th:first-child { z-index: 3; background: var(--brand); }
table { width: 100%; border-collapse: collapse; }
/* Colonnes à texte long (détail, actions correctives) : plus larges que les autres. */
th.wide-cell, td.wide-cell { min-width: 300px; }
/* Registres avec colonnes larges : titres sur plusieurs lignes et colonnes courantes plus étroites. */
.reg-wide th { white-space: normal; padding: 8px 6px; }
.reg-wide td { padding: 6px; }
.reg-wide th:not(.wide-cell), .reg-wide td:not(.wide-cell) { min-width: 125px; max-width: 200px; word-break: break-word; }
.file-row { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.att-link { margin: 2px 4px 2px 0; text-align: left; white-space: normal; max-width: 220px; }
.access-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.access-box legend { font-weight: 700; padding: 0 6px; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 12px; }
th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}
tr.chapter td { background: #f0f4f7; font-weight: 700; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin: 2px 0 2px 4px; }

/* Boutons et champs */
.btn {
  font: inherit;
  background: #fff;
  color: var(--text);
  border: 1px solid #c9d1da;
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { border-color: #9aa6b2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; }
.btn.small { padding: 4px 9px; font-size: 12px; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c9d1da;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.toolbar input[type="search"] { width: 280px; }
.toolbar select { width: auto; }

.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.danger-zone { border-color: #f2c4c4; }

.rate { font-size: 26px; }

/* Accueil */
.targets-note { font-size: 12px; color: var(--muted); margin: -8px 0 16px; }
.site-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 12px; margin-bottom: 12px; border-radius: 8px; background: #eef3fb; font-size: 14px; }
.home-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.home-bar .home-actions, .home-bar .home-site { margin-bottom: 0; }
.home-site { margin-bottom: 12px; }

/* Section Effectif et heures : en-tête, indicateurs et tableau. */
.eff-section { margin-bottom: 16px; }
.eff-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.eff-head h3 { margin: 0; }
.eff-pick { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.eff-pick label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
/* Recherche par nom de la liste de présence : même ligne que les boutons. */
#pt-search { width: 170px; }
/* Accueil : bienvenue et modules (style tableau de bord). */
.land-hero { background: linear-gradient(120deg, #f5891f 0%, #3e5394 75%, #2f4278 100%); color: #fff; border-radius: 16px; padding: 22px 26px; margin-bottom: 16px; }
.land-hero h1 { margin: 2px 0 4px; font-size: 28px; color: #fff; }
.land-hero p { margin: 0; color: #f3f6fc; font-size: 14px; }
.land-stage { background: #f4f6fb; border-radius: 16px; padding: 22px; text-align: center; }
.land-stage h2 { margin: 0; font-size: 20px; }
.land-stage > p { margin: 4px 0 18px; }
.land-grid { display: grid; grid-template-columns: 1fr 340px 1fr; gap: 16px; align-items: center; }
.land-col { display: flex; flex-direction: column; gap: 10px; }
.land-tile { display: flex; align-items: center; gap: 10px; text-align: left; background: #fff; border: 1px solid #d5dcee; border-radius: 10px; padding: 8px 12px; font: inherit; color: #2f4278; cursor: pointer; box-shadow: 0 2px 6px rgba(47, 66, 120, 0.08); }
.land-tile:hover { border-color: #f5891f; transform: translateY(-1px); }
.land-tile strong { display: block; font-size: 14px; color: #2f4278; }
.land-tile small { color: #6b7694; font-size: 12px; }
.land-ico { width: 32px; height: 32px; flex: none; border-radius: 8px; background: #fdeedd; display: grid; place-items: center; font-size: 16px; }
.land-hub { display: flex; justify-content: center; }
.land-hub-circle { width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, #4a62a6 0%, #2f4278 75%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; box-shadow: 0 0 0 14px #fde3c8, 0 0 0 26px #fdf1e4; }
.land-hub-circle strong { font-size: 46px; color: #ffb36b; line-height: 1; }
.land-hub-circle > span { font-size: 15px; font-weight: 600; margin-top: 2px; }
.land-hub-hours { display: flex; gap: 16px; margin: 10px 0 6px; }
.land-hub-hours b { display: block; font-size: 20px; color: #fff; }
.land-hub-hours small { font-size: 11px; opacity: .9; }
.land-hub-circle small { font-size: 12.5px; opacity: .92; margin-top: 3px; }
@media (max-width: 1100px) {
  .land-grid { grid-template-columns: 1fr; }
  .land-hub { order: -1; }
  .land-hub-circle { width: 300px; height: 300px; }
}
/* Ordinateur : barre de navigation verticale à droite, par groupes (Pilotage, Exploitation, Gestion, Système). */
body:not(.app-mode) .topbar { position: fixed; top: 0; left: 0; bottom: 0; right: auto; width: 268px; height: 100vh; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; padding: 12px 10px; background: #f7f8fb; color: #2f4278; border-right: 1px solid var(--line); overflow-y: auto; z-index: 30; }
body:not(.app-mode) .brand { color: var(--brand); background: none; padding: 4px 6px; justify-content: flex-start; }
body:not(.app-mode) .brand span { color: var(--brand); font-size: 15px; line-height: 1.25; text-transform: uppercase; text-align: center; }
body:not(.app-mode) .brand-logo { background: var(--brand); border-radius: 8px; padding: 6px; height: 44px; }
body:not(.app-mode) #app { margin-left: 268px; }
body:not(.app-mode) nav { flex-direction: column; flex-wrap: nowrap; overflow: visible; gap: 5px; order: 3; }
body:not(.app-mode) .nav-group { display: flex; flex-direction: column; gap: 1px; padding: 4px 4px 4px 8px; border-left: 3px solid; border-radius: 0 10px 10px 0; }
body:not(.app-mode) .g-pilot { background: #fdeedd; border-color: #f26b1d; }
body:not(.app-mode) .g-exp { background: #e6ecf8; border-color: #3e5394; }
body:not(.app-mode) .g-gest { background: #efe9f7; border-color: #7a5bb0; }
body:not(.app-mode) .g-sys { background: #eceef2; border-color: #7a8291; }
body:not(.app-mode) .nav-title { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: #2f4278; padding: 1px 6px 2px; }
body:not(.app-mode) nav button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 0; border-radius: 6px; padding: 4px 8px; font-size: 12.5px; line-height: 1.3; color: #2f4278; background: transparent; }
body:not(.app-mode) nav button:hover { background: #fff; color: #2f4278; transform: translateX(2px); }
body:not(.app-mode) nav button.active { background: #fff; color: #f26b1d; font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
/* Le choix du site passe juste sous le logo ; alerte, utilisateur et langue restent en bas. */
body:not(.app-mode) .top-right { display: contents; }
body:not(.app-mode) .brand { order: 0; }
body:not(.app-mode) .site-filter { order: 1; width: 100%; }
/* Alertes : tout en bas à gauche de la barre, visibles sur toutes les pages. */
/* Alertes : en bas à droite, à côté du bouton Chat. */
body:not(.app-mode) .bell-wrap { position: fixed; right: 150px; bottom: 16px; z-index: 40; }
body:not(.app-mode) .bell { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); background: #fff; }
body:not(.app-mode) .notif-panel { position: fixed; left: auto; right: 150px; bottom: 66px; top: auto; width: 340px; max-height: 60vh; overflow-y: auto; z-index: 60; }
body:not(.app-mode) #user-box { order: 4; }
body:not(.app-mode) #lang-btn { order: 5; align-self: flex-start; }
body:not(.app-mode) .top-right button,
body:not(.app-mode) .user-box button,
body:not(.app-mode) .user-box .btn,
body:not(.app-mode) .lang-btn { color: #3e5394; background: #fff; border: 1px solid #3e5394; }
body:not(.app-mode) .user-box { color: #2f4278; }
body:not(.app-mode) .bell { color: #3e5394; }
body:not(.app-mode) .menu-toggle { display: none; }
/* Masquer / afficher la barre latérale (ordinateur). */
body:not(.app-mode) .topbar { transition: left .25s ease; }
body:not(.app-mode) #app { transition: margin-left .25s ease; }
.side-toggle { display: none; }
body:not(.app-mode) .side-toggle { display: block; position: fixed; bottom: 16px; left: 226px; z-index: 31; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--brand); background: #fff; color: var(--brand); font-size: 18px; line-height: 1; cursor: pointer; transition: left .25s ease; }
body:not(.app-mode).side-hidden .topbar { left: -268px; }
body:not(.app-mode).side-hidden #app { margin-left: 0; }
body:not(.app-mode).side-hidden .side-toggle { left: 8px; }
/* Téléphone : même présentation que le menu latéral de l'ordinateur (groupes colorés, logo, site, recherche). */
body.app-mode nav { background: #f7f8fb; color: #2f4278; gap: 5px; padding: 12px 10px; }
body.app-mode .brand { color: var(--brand); background: none; padding: 4px 6px; justify-content: center; }
body.app-mode .brand span { display: block; color: var(--brand); font-size: 15px; line-height: 1.25; text-transform: uppercase; text-align: center; }
body.app-mode .brand-logo { background: var(--brand); border-radius: 8px; padding: 8px; height: 84px; }
body.app-mode nav .site-filter, body.app-mode nav .global-search { width: 100%; margin-bottom: 6px; }
body.app-mode .nav-group { display: flex; flex-direction: column; gap: 1px; padding: 4px 4px 4px 8px; border-left: 3px solid; border-radius: 0 10px 10px 0; }
body.app-mode .g-pilot { background: #fdeedd; border-color: #f26b1d; }
body.app-mode .g-exp { background: #e6ecf8; border-color: #3e5394; }
body.app-mode .g-gest { background: #efe9f7; border-color: #7a5bb0; }
body.app-mode .g-sys { background: #eceef2; border-color: #7a8291; }
body.app-mode .nav-title { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: #2f4278; padding: 1px 6px 2px; }
body.app-mode nav button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 0; border-radius: 6px; padding: 6px 8px; font-size: 13.5px; line-height: 1.3; color: #2f4278; background: transparent; }
body.app-mode nav button:hover { background: #fff; color: #2f4278; transform: none; }
body.app-mode nav button.active { background: #fff; color: #f26b1d; font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
body.app-mode nav .drawer-user { color: #2f4278; }
/* Téléphone : logo ATC au début de la barre, sticker ISO transparent au milieu. */
.head-logo, .head-iso { display: none; }
.head-logo { cursor: pointer; }
/* Sticker ISO dans le coin bas à gauche de la page (ordinateur). */
.corner-iso { display: none; }
body.app-mode .corner-iso { display: block; position: fixed; left: 12px; bottom: 18px; width: 80px; height: auto; z-index: 40; }
body.app-mode .head-logo { display: block; height: 40px; width: auto; flex: none; }
body.app-mode .head-iso { display: block; height: 32px; width: auto; margin: 0 auto; flex: none; }
.land-ring-core { cursor: pointer; }
.hub-pop { display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 250px; padding: 12px 14px; background: #fff; color: #1d2b4f; border: 2px solid #f26b1d; border-radius: 10px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25); font-size: 13px; line-height: 1.6; text-align: left; z-index: 5; pointer-events: none; }
.hub-pop-title { display: block; color: #f26b1d; font-size: 15px; margin-bottom: 4px; }
.hub-pop strong { color: #1d2b4f; }
.land-ring-core:hover .hub-pop { display: block; }
.mv-badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #d64545; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); }
.nav-badge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #d64545; color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.ring-tools { position: absolute; left: 50%; transform: translateX(-50%); bottom: -92px; z-index: 5; display: flex; gap: 8px; white-space: nowrap; }
.ring-edit .land-mod-ring { cursor: grab; outline: 2px dashed #f26b1d; outline-offset: 3px; touch-action: none; }
/* Recherche générale : sous le choix du site, résultats en panneau. */
.global-search { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; background: #fff; color: #2f4278; }
body:not(.app-mode) .global-search { order: 2; }
.global-results { position: fixed; left: 280px; top: 60px; width: 440px; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 6px; z-index: 50; }
.gs-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font: inherit; color: #2f4278; cursor: pointer; }
.gs-item:hover { background: #eef3fb; }
.gs-item small { display: block; color: #6b7593; font-size: 12px; margin-top: 2px; }
.gs-empty { padding: 10px; margin: 0; }
@media (max-width: 767px) { .global-results { left: 8px; right: 8px; width: auto; top: 110px; } }
/* Accueil sur une seule page : marges réduites pour éviter le défilement. */
#app:has(> .land) { padding-top: 8px; padding-bottom: 4px; }
/* Accueil inspiré du chantier : bandeau photo, consigne, chiffres clés, modules. */
.land-banner { position: relative; height: 260px; border-radius: 14px; overflow: hidden; background: url('../img/accueil-chantier.jpg') center 50% / cover; }
.land-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(29, 43, 79, 0.85) 0%, rgba(29, 43, 79, 0.6) 45%, rgba(29, 43, 79, 0.35) 100%); }
.land-banner-txt { position: absolute; z-index: 1; left: 0; top: 0; bottom: 0; width: min(560px, 80%); padding: 14px 24px; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.land-banner-txt small { align-self: flex-start; background: #f26b1d; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 3px; text-transform: uppercase; letter-spacing: .6px; }
.land-banner-txt h1 { margin: 6px 0 4px; font-size: 24px; color: #fff; }
.land-banner-txt p { margin: 0; font-size: 14px; opacity: .95; }
.land-safety { display: flex; gap: 14px; align-items: center; background: #fff; border-left: 6px solid #f26b1d; border-radius: 6px; padding: 6px 14px; margin: 4px 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); }
.land-safety-ico { width: 42px; height: 42px; border-radius: 50%; background: #f26b1d; color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none; }
.land-safety b { color: #1d2b4f; }
.land-safety p { margin: 4px 0 0; font-size: 13px; color: #4b5874; }
.land-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.land-kpi { background: #fff; border-radius: 8px; padding: 14px 16px; border-top: 4px solid #1d2b4f; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); }
.land-kpi.warn { border-top-color: #f26b1d; }
.land-kpi span { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #6b7593; }
.land-kpi strong { display: block; font-size: 28px; color: #1d2b4f; margin-top: 4px; }
.land-mods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.land-mods .land-tile { border-bottom: 4px solid #f26b1d; border-radius: 8px; animation: rise .5s ease both; }
.land-foot { margin: 14px 0 0; text-align: center; font-size: 13px; color: #6b7593; }
.land-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 14px; font-size: 13px; color: #6b7593; }
.land-bottom > span { text-align: center; }
.land-link { color: #2f4278; text-decoration: none; }
.land-link:hover { text-decoration: underline; }
.land-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.land-task-card { position: relative; width: 230px; background: #fff; border-top: 3px solid #f26b1d; border-radius: 8px; padding: 6px 10px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06); }
.land-task-head { display: block; width: 100%; background: none; border: 0; padding: 0 0 4px; margin: 0; text-align: left; font: inherit; font-size: 12.5px; font-weight: 700; color: #1d2b4f; cursor: pointer; }
.land-task-head:hover { text-decoration: underline; }
.land-task { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; padding: 3px 0; border-top: 1px solid #eef1f6; color: #2f4278; }
.land-task span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.land-task b { flex: none; color: #4b5874; }
.land-task.late b { color: #c0392b; }
.land-task-empty { margin: 0; font-size: 13px; color: #6b7593; }
.task-pop { display: none; position: absolute; left: 0; top: 100%; margin-top: 6px; width: 280px; max-width: 80vw; background: #fff; color: #1d2b4f; border: 2px solid #f26b1d; border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); font-size: 12px; line-height: 1.9; text-align: left; z-index: 6; pointer-events: none; }
.land-task-card:hover .task-pop { display: block; }
.task-pop > div { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; margin-bottom: 4px; }
.task-pop .pop-late { color: #c0392b; font-weight: 500; }
.task-pop .pop-more { color: #6b7593; }
.mv-pill { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 6px; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 500; line-height: 16px; color: #fff; background: #f26b1d; position: relative; white-space: nowrap; }
.mv-pill.late { background: #c0392b; }
.mv-pill.pulse::after { content: ''; position: absolute; inset: -3px; border-radius: 999px; border: 2px solid currentColor; color: #f26b1d; opacity: 0; animation: mv-ping 1.6s ease-out infinite; pointer-events: none; }
.mv-pill.pulse.late::after { color: #c0392b; }
@keyframes mv-ping { 0% { transform: scale(0.9); opacity: 0.7; } 100% { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mv-pill.pulse::after { animation: none; } }
.btn.icon-only { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; line-height: 0; }
/* Mini calendrier de la barre latérale (ordinateur seulement) */
body:not(.app-mode) .mini-cal { margin: 6px 4px 4px; background: #fff; border-radius: 8px; padding: 4px 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); color: #2f4278; font-size: 10px; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; gap: 4px; }
.mini-cal-head button { flex: none; width: auto; min-width: 0; margin: 0; background: none; border: 0; font-size: 13px; line-height: 1; color: #2f4278; cursor: pointer; padding: 0 4px; text-align: center; }
.mini-cal-head strong { display: block; flex: 1; min-width: 0; font-size: 11px; color: #1d2b4f; text-transform: capitalize; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not(.app-mode) .mini-cal { box-sizing: border-box; width: auto; max-width: 100%; overflow: hidden; }
body:not(.app-mode) .mini-cal-head button { display: inline-block; width: auto; padding: 0 4px; border: 0; border-radius: 0; text-align: center; background: none; }
body:not(.app-mode) .mini-cal-head strong { display: block; width: auto; padding: 0; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); width: 100%; min-width: 0; text-align: center; row-gap: 0; }
.mini-cal-grid > b { font-weight: 600; color: #6b7593; font-size: 9px; line-height: 12px; }
.mini-cal-grid > span { position: relative; height: 14px; line-height: 14px; font-size: 10px; border-radius: 50%; }
.mini-cal-grid > span.today { background: #f26b1d; color: #fff; font-weight: 700; }
.mini-cal-grid .dot { position: absolute; bottom: 0; width: 3px; height: 3px; border-radius: 50%; }
.mini-cal-grid .dot.o { background: #f26b1d; left: 35%; }
.mini-cal-grid .dot.b { background: #2f4278; left: 60%; }
.mini-cal-grid > span.today .dot { background: #fff; }
body.app-mode .mini-cal { display: none; }
.land-ring { position: relative; width: 420px; height: 420px; margin: 0 auto; }
.land-ring-core { position: absolute; left: 105px; top: 105px; width: 210px; height: 210px; border-radius: 50%; background: radial-gradient(circle, #4a62a6 0%, #2f4278 75%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; box-shadow: 0 0 0 12px #fde3c8, 0 0 0 22px #fdf1e4; }
.land-ring-core > strong { font-size: 36px; color: #ffb36b; line-height: 1; }
.land-ring-core > span { font-size: 14px; font-weight: 600; margin-top: 2px; }
.land-ring-core small { font-size: 12px; opacity: .92; margin-top: 3px; }
.land-mod-ring { position: absolute; transform: translate(-50%, -50%); width: 100px; height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 10px; background: #fff; border: 2px solid #f26b1d; border-radius: 50%; color: #1d2b4f; font: inherit; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); transition: transform .25s ease, box-shadow .25s ease; }
.land-mod-ring:hover { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 8px 18px rgba(29, 43, 79, 0.18); }
.land-mod-ring strong { font-size: 11.5px; line-height: 1.15; text-align: center; }
.land-mod-ring .land-ico { width: 26px; height: 26px; font-size: 14px; }
.land-sites { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 2px; }
.land-ring-wrap { display: grid; grid-template-columns: 1fr 420px 1fr; align-items: center; gap: 20px; }
.land-side { color: #2f4278; font-size: 15px; line-height: 1.6; }
.land-side p { margin: 0; }
.land-side b { display: block; font-size: 16px; margin-bottom: 4px; }
.land-badge-wrap { display: flex; justify-content: center; position: relative; }
.land-iso { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 14px); width: 150px; height: auto; }
.land-badge { width: 250px; height: 250px; border-radius: 50%; background: #fff8f2; border: 6px solid #1d2b4f; box-shadow: 0 0 0 6px #f5a623; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px 18px; text-align: center; }
.land-mascot { width: 118px; height: auto; margin-bottom: 2px; border-radius: 8px; }
.land-badge p { margin: 0 auto; max-width: 172px; font-size: 11px; line-height: 1.35; color: #2f4278; }
.land-badge b { display: inline; font-size: 12.5px; color: #1d2b4f; }
@media (max-width: 900px) { .land-ring-wrap { grid-template-columns: 1fr; } }
/* Téléphone : cercle des statistiques et modules en haut, puis les deux badges, puis les cartes des sites. */
@media (max-width: 767px) {
  .land { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
  .land > * { width: 100%; }
  .land > .land-ring { width: 420px; }
  .land-ring-wrap { display: contents; }
  .land-banner { order: 0; height: 96px; background-position: center 28%; }
  .land-banner-txt { width: 100%; padding: 10px 14px; }
  .land-banner-txt small { font-size: 10px; }
  .land-banner-txt h1 { font-size: 18px; margin: 4px 0 2px; }
  .land-banner-txt p { font-size: 12px; }
  .land-safety { order: 1; }
  .land-ring { order: 3; margin: 0 auto; }
  .land-col-left, .land-col-right { order: 2; width: calc(50% - 6px); }
  .land-col .land-task-card { width: 100%; padding: 4px 6px; }
  .land-col .land-task-head { font-size: 11px; }
  .land-col .land-task { font-size: 10px; padding: 2px 0; }
  .land-sites { display: none; }
  .land-col .land-side { display: none; }
  .land-ring-wrap > .land-side .land-badge { width: 230px; height: 230px; margin: 0 auto; }
  .land-mod-ring { width: 82px; height: 82px; padding: 6px; }
  .land-mod-ring strong { font-size: 10px; }
  .land-mod-ring .land-ico { width: 20px; height: 20px; font-size: 11px; }
  .land-bottom { position: fixed; left: 0; right: 0; bottom: 2px; z-index: 40; display: block; text-align: center; font-size: 11px; margin: 0; pointer-events: none; }
  .land-bottom a { pointer-events: auto; }
  .land-bottom > span:last-child { display: none; }
  .land-bottom > span:nth-child(2)::before { content: "· "; }
  .land-bottom > span:nth-child(2) { display: inline; }
}
@media (max-width: 1100px) { .land-sites { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.land-site { display: flex; flex-direction: column; gap: 2px; text-align: left; background: #fff; border: 1px solid #d5dcee; border-top: 3px solid #1d2b4f; border-radius: 8px; padding: 7px 8px; font: inherit; color: #1d2b4f; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.land-site:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(29, 43, 79, 0.15); border-top-color: #f26b1d; }
.land-site > strong { font-size: 13px; }
.land-site > b { font-size: 16px; }
.land-site > small { color: #6b7593; font-size: 11px; }
.land-row { display: flex; justify-content: space-between; font-size: 11px; margin-top: 2px; }
.land-row b.warn { color: #c62828; }
.land-bar { display: block; height: 5px; background: #e6e9ed; border-radius: 3px; margin-top: 6px; overflow: hidden; }
/* Téléphone : cercle circulaire réduit à la largeur de l'écran (même disposition que sur ordinateur). */
@media (max-width: 767px) {
  .land-ring { transform: scale(0.6); transform-origin: top center; align-self: center; margin: 0 0 -168px calc(50% - 210px); }
}
.land-bar span { display: block; height: 100%; background: #f26b1d; }
@media (max-width: 900px) { .land-kpis, .land-mods { grid-template-columns: 1fr 1fr; } .land-banner-txt h1 { font-size: 24px; } }
/* Messagerie (bouton et panneau en bas à droite). */
#chat-root .chat-fab { position: fixed; right: 18px; bottom: 18px; z-index: 900; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }
#chat-root .chat-panel { position: fixed; right: 18px; bottom: 70px; z-index: 901; width: min(720px, calc(100vw - 36px)); height: min(520px, 70vh); display: none; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25); overflow: hidden; }
#chat-root .chat-panel.open { display: flex; }
#chat-root .chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--brand); color: #fff; }
#chat-root .chat-head .icon-btn { color: #fff; }
#chat-root .chat-body { display: flex; flex: 1; min-height: 0; }
#chat-root .chat-side { width: 200px; border-right: 1px solid var(--line); padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
#chat-root .chat-section { font-size: 11px; text-transform: uppercase; color: var(--muted, #667); margin: 8px 4px 2px; }
#chat-root .chat-person { display: flex; align-items: center; gap: 6px; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; font: inherit; cursor: pointer; }
#chat-root .chat-person:hover, #chat-root .chat-person.active { background: #eef3fb; }
#chat-root .chat-dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; flex: none; }
#chat-root .chat-dot.on { background: #2e9d4a; }
#chat-root .chat-unread { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #d64545; color: #fff; font-size: 11px; text-align: center; }
#chat-root .chat-pick { width: 100%; margin: 2px 0; font-size: 12px; }
#chat-root .chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-root .chat-title { padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
#chat-root .chat-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
#chat-root .chat-msg { max-width: 80%; background: #f3f5f9; border-radius: 10px; padding: 6px 10px; align-self: flex-start; }
#chat-root .chat-msg.mine { align-self: flex-end; background: #dbe8ff; }
#chat-root .chat-msg p { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
#chat-root .chat-meta small { color: #777; }
#chat-root .chat-del { border: 0; background: none; color: #999; cursor: pointer; margin-left: 4px; }
#chat-root .chat-del:hover { color: #d64545; }
#chat-root .chat-form { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
#chat-root .chat-form input { flex: 1; }
@media (max-width: 767px) {
  #chat-root .chat-panel { right: 8px; left: 8px; width: auto; bottom: 64px; height: 75vh; }
  #chat-root .chat-side { width: 130px; }
}
.eff-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.eff-kpis > div { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 12px; color: #fff; background: var(--brand); box-shadow: 0 4px 14px rgba(31, 42, 68, 0.18); }
.eff-kpis > div:nth-child(2) { background: linear-gradient(135deg, #f5891f, #e0701a); }
.eff-kpis > div:nth-child(3) { background: linear-gradient(135deg, #2e9e5b, #1f7d46); }
/* Heures du mois et de l'année : couleurs propres (la carte LTI reste en couleur de marque). */
.eff-kpis > div:nth-child(4) { background: linear-gradient(135deg, #8e5bd6, #6a3fb3); }
.eff-kpis > div:nth-child(5) { background: linear-gradient(135deg, #1ba3b8, #117d8f); }
/* Jours sans accident (LTI) : vert citron. */
.eff-kpis > div:nth-child(6) { background: linear-gradient(135deg, #8fc21f, #6fa10f); }
.eff-kpis span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.9; }
.eff-kpis strong { font-size: 32px; font-weight: 700; line-height: 1; }
/* Grille de pointage : défilement horizontal et cellules compactes. */
.pt-section { margin-bottom: 16px; }
.pt-wrap { overflow-x: auto; }
.pt-table { font-size: 12px; min-width: 1100px; }
.pt-table th { background: var(--brand); color: #fff; font-size: 11px; white-space: nowrap; padding: 4px 5px; }
.pt-table td { padding: 3px 4px; white-space: nowrap; }
.pt-table input { width: 110px; padding: 3px 4px; font-size: 12px; }
.pt-table input.pt-day { width: 48px; text-align: center; }
.pt-table select.pt-day { width: 62px; padding: 2px; font-size: 12px; }
.pt-table tfoot td { font-weight: 700; background: #eef3fb; color: var(--danger); }
.eff-table { font-size: 13px; }
.eff-table th { background: var(--brand); color: #fff; font-size: 12px; white-space: nowrap; }
.eff-table td { padding: 5px 8px; }
.eff-table input { width: 80px; padding: 4px 6px; }
.eff-table input[type="text"] { width: 150px; }
.eff-table tfoot td { font-weight: 700; background: #eef3fb; color: var(--danger); }
.home-site label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.home-site select { width: auto; padding: 6px 10px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
@media (min-width: 1100px) {
  .home-cards .card { padding: 20px; }
  .home-cards h3 { font-size: 17px; }
  .home-days strong { font-size: 40px; }
  .home-hours strong { font-size: 19px; }
  .mini span { font-size: 12px; }
  .mini strong { font-size: 21px; }
}
.home-days { display: flex; flex-direction: column; align-items: center; padding: 10px 0; margin-bottom: 10px; border-radius: 8px; background: #eef3fb; }
.home-days strong { font-size: 34px; color: var(--brand); }
.home-days span { font-size: 12px; color: var(--muted); }
/* Documents HSE : fil d'Ariane et dossiers. */
.doc-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.doc-crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-folders { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.doc-folder { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.doc-folder-open { background: none; border: 0; font: inherit; color: var(--brand); font-weight: 600; cursor: pointer; }
.site-milestones { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.site-milestones h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.site-ms { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 12px; padding: 4px 0; }
.site-ms strong { font-size: 14px; }
.home-hours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.home-hours div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; }
.home-hours strong { font-size: 16px; }
.home-hours span { font-size: 11px; color: var(--muted); text-align: center; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.mini span { font-size: 11px; color: var(--muted); }
.mini strong { font-size: 18px; }
.mini.ok { border-left: 4px solid #1e8e4e; }
.mini.danger { border-left: 4px solid var(--danger); }

/* Sites */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.site-card { margin-bottom: 0; }
.site-card p { margin: 6px 0; }
.site-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* Téléphone (navigateur ou APK) : menu à droite, activé par la classe app-mode posée dans js/app.js */
.menu-toggle, .nav-overlay, .drawer-user { display: none; }

body.app-mode .menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: 8px;
  font-size: 24px;
  color: #fff;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  cursor: pointer;
}
body.app-mode .brand span { display: none; }
body.app-mode .brand-logo { height: 32px; }
body.app-mode .top-right { margin-left: auto; flex-wrap: nowrap; gap: 4px; }
/* Téléphone : logo, icônes, sélecteur de site et bouton menu restent sur une seule ligne. */
body.app-mode .topbar { flex-wrap: nowrap; gap: 8px; }
/* Téléphone : cloche, sélecteur de site et bouton de langue plus compacts. */
body.app-mode .bell { width: 30px; height: 28px; font-size: 15px; }
body.app-mode .top-right .site-filter { width: 84px; padding: 3px 4px; font-size: 12px; }
body.app-mode .lang-btn { padding: 3px 6px; font-size: 12px; }
/* Téléphone : pas de tableau qui défile dans sa propre case ; c'est toute la page qui défile, la barre du haut reste fixe. */
body.app-mode .table-wrap { max-height: none; overflow-y: visible; }
/* En-tête de tableau défilant avec la page : sur téléphone, il ne se pose plus sous la barre du haut et ne cache plus les lignes. */
body.app-mode .table-wrap thead th { position: static; }
/* Téléphone : registres de levage et de protection. Colonnes visibles : Numéro d'entreprise, dates de contrôle, statut, actions. */
body.app-mode table.eq-slim { width: 100%; }
body.app-mode table.eq-slim th, body.app-mode table.eq-slim td { min-width: 0; max-width: none; white-space: normal; word-break: break-word; padding: 6px 4px; font-size: 12px; }
body.app-mode table.eq-slim th:nth-child(1), body.app-mode table.eq-slim td:nth-child(1),
body.app-mode table.eq-slim th:nth-child(2), body.app-mode table.eq-slim td:nth-child(2),
body.app-mode table.eq-slim th:nth-child(4), body.app-mode table.eq-slim td:nth-child(4),
body.app-mode table.eq-slim th:nth-child(5), body.app-mode table.eq-slim td:nth-child(5),
body.app-mode table.eq-slim th:nth-child(6), body.app-mode table.eq-slim td:nth-child(6) { display: none; }
body.app-mode table.eq-slim thead th { position: static; }
body.app-mode table.eq-slim td.row-actions { display: table-cell; min-width: 72px; white-space: nowrap; }
body.app-mode table.eq-slim td.row-actions .btn { display: block; width: 100%; margin: 2px 0; padding: 3px 2px; font-size: 10px; white-space: nowrap; }
/* Le menu latéral doit passer au-dessus de l'écran assombri : la barre ne doit pas créer son propre contexte d'empilement. */
/* En application, la barre reste visible en haut de l'écran. Quand le menu latéral est ouvert, elle n'a plus de contexte d'empilement pour que le menu passe au-dessus. */
body.app-mode .topbar { position: sticky; top: 0; z-index: 5; }
body.app-mode.menu-open .topbar { position: static; z-index: auto; }
body.app-mode .user-box { display: none; }
body.app-mode nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: 270px;
  max-width: 80vw;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
  padding: 12px 12px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #f7f8fb;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.25);
  transform: translateX(105%);
  transition: transform 0.25s ease;
}
body.app-mode nav.open { transform: none; }
/* Menu téléphone : chaque entrée garde sa hauteur, la liste défile en entier au lieu de se répartir en colonnes hors écran. */
body.app-mode nav > * { flex-shrink: 0; }
body.app-mode nav button {
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
  line-height: 1.3;
  color: #2f4278;
  border: 0;
  border-bottom: 0;
  border-radius: 6px;
  background: transparent;
}
body.app-mode nav button.active { color: #f26b1d; font-weight: 700; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
body.app-mode nav button:hover { border-bottom-color: rgba(255, 255, 255, 0.12); }
body.app-mode .nav-overlay { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(15, 23, 32, 0.4); }
body.app-mode .nav-overlay.hidden { display: none; }
body.app-mode .drawer-user {
  display: flex;
  flex-direction: column;
  gap: 10px;
  order: 0;
  padding: 14px 22px 0;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #e6ecf7;
  font-size: 14px;
}
body.app-mode .drawer-user .top-btn { width: 100%; padding: 10px; text-align: center; }
/* Écran de connexion : pas de menu, donc pas de bouton. */
body.logged-out .menu-toggle { display: none; }

/* Fiche de détail */
.detail-table th { width: 35%; text-transform: none; font-size: 13px; color: var(--text); vertical-align: top; }
.detail-table td { white-space: pre-wrap; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: #e3f5ea; color: #17703d; }
.badge.info { background: #e4edfd; color: #1d4fb8; }
.badge.warn { background: #fdf0d9; color: #9a5a00; }
.badge.danger { background: #fbe3e3; color: #a31f1f; }
.badge.muted { background: #eceff3; color: #4f5b68; }
/* Tags des équipements : couleur du trimestre de la prochaine inspection. */
.badge.tag-red { background: #d13b33; color: #fff; }
.badge.tag-green { background: #5daf5a; color: #fff; }
.badge.tag-blue { background: #3b64b0; color: #fff; }
.badge.tag-yellow { background: #f2e64f; color: #3a3300; }
.badge.tag-orange { background: #f39c12; color: #fff; }

/* Cartes et lignes cliquables : le détail ou le registre s'ouvre au clic. */
.card-link { cursor: pointer; }
.card-link:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #fff4e8; }
td.matrix-cell { cursor: pointer; }

/* Menu clic droit de la grille de pointage (Copier, Coller, Tout sélectionner). */
.pt-ctx { position: fixed; z-index: 1000; display: flex; flex-direction: column; min-width: 170px; padding: 4px 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.pt-ctx button { background: none; border: 0; text-align: left; padding: 8px 14px; font: inherit; cursor: pointer; }
.pt-ctx button:hover { background: #f5f7fb; }
td.pt-col-selected { background: #fde7cf !important; }
/* Sélection de lignes et de cellules de la grille de pointage (tableur). */
#pt-body td:first-child { cursor: pointer; }
td.pt-sel { background: #d6e7ff !important; }
body.pt-dragging { user-select: none; }
.matrix-filter { font: inherit; font-size: 11px; font-weight: 400; margin-top: 2px; max-width: 100%; }

/* Matrice des formations : colonnes de formation étroites, noms lisibles. */
.table-wrap table.matrix th,
.table-wrap table.matrix td { min-width: 0; padding: 4px 6px; font-size: 12px; }
.table-wrap table.matrix th { width: 84px; white-space: normal; vertical-align: bottom; }
.table-wrap table.matrix th:nth-child(-n+4),
.table-wrap table.matrix td:nth-child(-n+4) { white-space: nowrap; }
.table-wrap table.matrix th:nth-child(-n+4) { width: auto; }

/* Tableau de bord */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 10px;
  padding: 14px;
}
.kpi.danger { border-top-color: var(--danger); }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi strong { font-size: 26px; }
.kpi small { color: var(--muted); }

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 36px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.bar {
  height: 10px;
  background: #eef1f5;
  border-radius: 6px;
  overflow: hidden;
}
.bar.big { height: 14px; }
.bar-fill {
  height: 100%;
  background: var(--info);
  border-radius: 6px;
  transition: width 0.3s;
}
.bar-row strong { text-align: right; }

/* ISO */
.segmented {
  display: inline-flex;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.segmented button {
  font: inherit;
  border: 0;
  background: none;
  padding: 9px 16px;
  cursor: pointer;
}
.segmented button.active { background: var(--brand); color: #fff; }
.score-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.score-head span { font-size: 22px; font-weight: 700; }
.iso-status { min-width: 190px; }
.evidence-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.evidence-item { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.evidence-item a {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--info);
}
.evidence-item .icon-btn { font-size: 16px; padding: 0 4px; }
label.btn { display: inline-block; }
.iso-note { min-width: 240px; }

/* Formulaires */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Modale et notifications */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  overflow: auto;
  background: rgba(15, 23, 32, 0.45);
}
.modal-box {
  width: 100%;
  max-width: 780px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.icon-btn {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 18px;
  border-radius: 8px;
  background: #1d2733;
  color: #fff;
}
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .toolbar input[type="search"] { width: 100%; }
  .bar-row { grid-template-columns: 110px 1fr 30px; }
  nav button { padding: 10px 8px; }
}
