/*
  CamHydra — composants communs et cadre de la refonte (docs/DESIGN_REFONTE.md
  § 1 et § 2). Chargé après tokens.css et styles.css : à spécificité égale,
  ces règles l'emportent sur les anciennes.

  Ce sont les composants du kit des maquettes
  (analyses/design-camhydra-2026-10-18/maquettes/src/kit.css), sans le préfixe
  .mk. Une seule différence de nom : le bouton-icône du kit (.icon-btn)
  s'appelle ici .btn-icon, parce que .icon-btn sert encore aux boutons des
  lignes du tableau de flotte (app.js).

  Mise en page : moins de 760 px = téléphone.
*/

/* ---------------------------------------------------------------- Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--link);
}

a:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--primary) 25%, transparent);
}

/* Champs sans style propre : ceux des anciennes pages gardent leurs règles
   (spécificité nulle de :where). */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

:where(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

:where(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--primary);
}

::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- Utilitaires */
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.t-12 { font-size: 12px; line-height: 16px; }
.t-13 { font-size: 13px; line-height: 18px; }
.t-16 { font-size: 16px; line-height: 24px; }
.t-18 { font-size: 18px; line-height: 26px; }
.t-20 { font-size: 20px; line-height: 28px; }
.t-24 { font-size: 24px; line-height: 32px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stack-4 { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-24 { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.only-phone { display: none; }
.page-pad { padding: 16px 24px; }

/* ---------------------------------------------------------------- Icônes (icons.js) */
.ic {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; }
.ic-box { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; }
.ic-lg { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 20px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--link); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger-solid); color: var(--on-danger); border-color: var(--danger-solid); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-ghost-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover:not(:disabled) { background: none; }

/* Bouton-icône (.icon-btn du kit) */
.btn-icon {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-icon .count-badge,
.tab-item .count-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  border: 2px solid var(--surface);
  display: grid;
  place-items: center;
  background: var(--danger-solid);
  color: var(--on-danger);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---------------------------------------------------------------- États */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 8px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted-fg);
  background: var(--muted-bg);
}
.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.chip.no-dot { padding: 0 10px; }
/* Dans une colonne (.stack…), une pastille garde sa largeur. */
:is(.stack, .stack-4, .stack-8, .stack-16, .stack-24) > :is(.chip, .tag, .sev, .segmented) { align-self: flex-start; }
.chip.no-dot::before { display: none; }
.chip[data-st="alarme"] { color: var(--st-alarme); background: var(--st-alarme-bg); }
.chip[data-st="mission"] { color: var(--st-mission); background: var(--st-mission-bg); }
.chip[data-st="dispo"] { color: var(--st-dispo); background: var(--st-dispo-bg); }
.chip[data-st="verif"] { color: var(--st-verif); background: var(--st-verif-bg); }
.chip[data-st="eteint"] { color: var(--st-eteint); background: var(--st-eteint-bg); }
/* La forme distingue l'état sans la couleur : losange, carré, cercle vide. */
.chip[data-st="alarme"]::before { border-radius: 2px; transform: rotate(45deg); width: 7px; height: 7px; }
.chip[data-st="verif"]::before { border-radius: 2px; }
.chip[data-st="eteint"]::before { background: transparent; border: 2px solid currentColor; width: 9px; height: 9px; box-sizing: border-box; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--st-eteint-dot); }
.dot[data-st="alarme"] { background: var(--st-alarme-dot); }
.dot[data-st="mission"] { background: var(--st-mission-dot); }
.dot[data-st="dispo"] { background: var(--st-dispo-dot); }
.dot[data-st="verif"] { background: var(--st-verif-dot); }
.dot[data-st="eteint"] { background: var(--st-eteint-dot); }
.sev {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.sev-crit { background: var(--danger-solid); color: var(--on-danger); }
.sev-warn { background: var(--warning-bg); color: var(--warning); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--muted-bg);
  color: var(--muted-fg);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Conteneurs */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
  color: var(--text);
}
.card-pad { padding: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 15px; line-height: 20px; font-weight: 700; }
.section-title { margin: 0; font-size: 13px; line-height: 18px; font-weight: 700; color: var(--text-muted); }
.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  font-weight: 600;
}
.notice-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.notice-info { background: var(--info-bg); color: var(--info); }
.notice-warning { background: var(--warning-bg); color: var(--warning); }
.notice-success { background: var(--success-bg); color: var(--success); }
.notice .notice-text { flex: 1 1 auto; min-width: 0; }
.notice .notice-text span { font-weight: 400; color: var(--text); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.kv dt { color: var(--text-subtle); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; }
.divider { height: 1px; background: var(--border); }

/* ---------------------------------------------------------------- Filtres, onglets */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
/* Revue M12 : ce que la recherche cache, à côté des filtres. */
.filters-hidden {
  align-self: center;
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.filter.is-on,
.filter[aria-pressed="true"] {
  border-color: var(--link);
  background: var(--info-bg);
  color: var(--link);
  box-shadow: inset 0 0 0 1px var(--link);
}
.filter .n { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 700; }
.filter.is-on .n,
.filter[aria-pressed="true"] .n { color: var(--link); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.is-active,
.tab[aria-selected="true"] { color: var(--link); border-bottom-color: var(--link); }
.tab .tn {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.tab .tn.is-alarm { background: var(--danger-solid); color: var(--on-danger); }
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 3px; border-radius: 10px; background: var(--surface-2); }
.segmented > button,
.segmented > span {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.segmented > .is-on,
.segmented > [aria-pressed="true"],
.segmented > [aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------------------------------------------------------------- Listes et tableaux */
.list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.list-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.list-group-head .n { margin-left: auto; font-variant-numeric: tabular-nums; }
.lrow {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: stretch;
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.lrow:last-child { border-bottom: 0; }
.lrow-mark { border-radius: 0 3px 3px 0; background: var(--st-mission-dot); }
.lrow[data-st="alarme"] .lrow-mark { background: var(--st-alarme-dot); }
.lrow[data-st="verif"] .lrow-mark { background: var(--st-verif-dot); }
.lrow[data-st="eteint"] .lrow-mark { background: var(--st-eteint-dot); }
.lrow[data-st="dispo"] .lrow-mark { background: var(--st-dispo-dot); }
.lrow.is-selected { background: var(--info-bg); box-shadow: inset 0 0 0 2px var(--link); }
.plate { font-family: var(--mono); font-weight: 700; letter-spacing: 0.02em; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
table.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table td.num,
table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-weight: 600; font-size: 13px; line-height: 18px; color: var(--text); }
.input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-width: 0;
}
textarea.input { padding: 10px 12px; min-height: 88px; resize: vertical; }
.input:focus,
.input:focus-visible { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.help { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-subtle); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; }
.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
.choice.is-on,
.choice:has(input:checked) { border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); background: var(--info-bg); }
.choice input { margin: 2px 0 0; width: 18px; height: 18px; flex: 0 0 auto; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 12px;
  background: var(--border-strong);
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
  border: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  transition: left 120ms ease;
}
.switch.is-on,
.switch:checked { background: var(--primary); }
.switch.is-on::after,
.switch:checked::after { left: 19px; }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- Fenêtres et panneaux */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 1200; }
.dialog {
  position: fixed;
  z-index: 1210;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
}
.dialog.is-lg { width: min(720px, calc(100% - 32px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.dialog-title { margin: 0; font-size: 18px; line-height: 24px; font-weight: 700; }
.dialog-body { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.sheet {
  position: fixed;
  z-index: 1210;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
}
.sheet .dialog-body { flex: 1 1 auto; }
.actionbar { display: none; }

/* ---------------------------------------------------------------- Photos, frise, progression */
.photo { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--photo-a); max-width: 100%; margin: 0; }
.photo > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo.is-big { aspect-ratio: 16 / 10; }
.photo .ph-time,
.photo .ph-tag {
  position: absolute;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.photo .ph-time { left: 6px; bottom: 6px; background: rgb(0 0 0 / 0.55); }
.photo .ph-tag { right: 6px; top: 6px; background: rgb(180 35 24 / 0.9); }
.timeline { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.tl { display: grid; grid-template-columns: 52px 14px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; position: relative; }
.tl-time { font-size: 12px; font-weight: 700; color: var(--text-subtle); font-variant-numeric: tabular-nums; text-align: right; line-height: 20px; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; background: var(--border-strong); position: relative; z-index: 1; }
.tl:not(:last-child)::after { content: ""; position: absolute; left: 67px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot[data-st="alarme"] { background: var(--st-alarme-dot); }
.tl-dot[data-st="mission"] { background: var(--st-mission-dot); }
.tl-dot[data-st="dispo"] { background: var(--st-dispo-dot); }
.tl-dot[data-st="verif"] { background: var(--st-verif-dot); }
.tl-text { min-width: 0; }
.tl-text .who { color: var(--text-subtle); font-size: 12px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--st-mission-dot); border-radius: 4px; }
.route-line { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.route-line .arrow { color: var(--text-subtle); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-label { font-size: 12px; font-weight: 600; color: var(--text-subtle); display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.tile.is-ok .tile-value { color: var(--st-dispo); }
.tile.is-warn .tile-value { color: var(--st-verif); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--info);
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

/* ==========================================================================
   Cadre commun (nav.js) : barre de gauche, barre du haut, onglets du bas
   ========================================================================== */

body.has-shell .shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 24px 24px;
}

body.has-shell {
  padding-left: var(--side-w);
}

/* Barre de gauche : marine, fixe, 232 px. Le cadre passe au-dessus des
   cartes Leaflet (panneaux à 400, contrôles à 1000) et sous les fenêtres
   (1200 et plus). */
body.has-shell #mainNav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1100;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--nav-bg);
  color: var(--nav-fg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  color: var(--nav-fg);
  text-decoration: none;
  border-radius: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--nav-fg);
  color: var(--nav-bg);
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
  line-height: 20px;
}

.brand-sub {
  display: block;
  font-size: 12px;
  line-height: 16px;
  color: var(--nav-fg-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--nav-fg-muted);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-fg);
}

.nav-item.is-active {
  background: var(--nav-active-bg);
  color: var(--nav-fg);
}

.nav-item:focus-visible,
.side-brand:focus-visible {
  outline: 2px solid var(--nav-fg);
  outline-offset: -2px;
}

.nav-item .count {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--nav-count-bg);
  color: var(--nav-count-fg);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nav-item .count.is-alarm {
  background: var(--danger-solid);
  color: var(--on-danger);
}

.nav-sep {
  height: 1px;
  margin: 10px 8px;
  background: rgb(255 255 255 / 0.14);
}

.nav-label {
  padding: 4px 12px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--nav-fg-muted);
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
}

/* Barre du haut : titre, recherche, cloche, son, compte. */
.app-top {
  position: sticky;
  top: 0;
  z-index: 1100;
  height: var(--top-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 -24px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.app-top-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 0 1 auto;
}

.app-top-title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 26px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
  white-space: nowrap;
}

.crumb a {
  color: var(--link);
  font-weight: 600;
  text-decoration: none;
}

.crumb a:hover {
  text-decoration: underline;
}

.app-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  flex: 0 1 380px;
  min-width: 0;
  margin: 0 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-subtle);
}

.app-search:focus-within {
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

.app-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  box-shadow: none;
}

.app-search input::-webkit-search-cancel-button {
  cursor: pointer;
}

.app-top-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.app-top .btn-icon.is-search {
  display: none;
}

/* La cloche et le son (notifications.js) prennent la forme des boutons-icônes. */
.app-top .notif-bell,
.app-top .notif-sound {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.app-top .notif-bell:hover,
.app-top .notif-sound:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-top .notif-bell svg,
.app-top .notif-sound svg {
  width: 20px;
  height: 20px;
}

.app-top .notif-bell.has-critical {
  color: var(--danger);
  border-color: transparent;
}

.app-top .notif-badge {
  top: 2px;
  right: 0;
  border: 2px solid var(--surface);
}

.app-top .notif-sound.is-muted {
  width: auto;
  padding: 0 10px;
  grid-auto-flow: column;
  gap: 6px;
  color: var(--warning);
  background: var(--warning-bg);
}

.app-top .notif-sound-label {
  font-size: 12px;
  font-weight: 700;
}

/* Menu du compte */
.account {
  position: relative;
  flex: 0 0 auto;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 4px 10px 4px 4px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.account-button:hover,
.account-button[aria-expanded="true"] {
  background: var(--surface-2);
}

.account-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu {
  position: absolute;
  z-index: 70;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}

.menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  min-width: 0;
}

.menu-head .avatar {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.menu-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-who strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.menu-item .ic {
  color: var(--text-muted);
}

.menu-item.is-danger,
.menu-item.is-danger .ic {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

.menu-label {
  padding: 8px 10px 4px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text-subtle);
}

.menu .segmented {
  margin: 0 10px 6px;
}

.menu .segmented > button {
  flex: 1 1 auto;
  justify-content: center;
  padding: 0 8px;
  font-size: 13px;
}

/* Onglets du bas (téléphone) et panneau « Plus » */
.tabbar {
  display: none;
}

.tab-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-subtle);
  font: inherit;
  font-size: 12px;
  line-height: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.tab-item.is-active {
  color: var(--link);
}

.tab-item .count-badge {
  top: 6px;
  right: auto;
  left: calc(50% + 6px);
}

.shell-sheet {
  position: fixed;
  z-index: 1210;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--text);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shell-sheet .segmented {
  margin: 0 10px 6px;
}

.shell-sheet .segmented > button {
  flex: 1 1 auto;
  justify-content: center;
}

/* Petite fenêtre « Aide » */
.help-dialog .dialog-body p {
  margin: 0;
}

.help-contact {
  font-family: var(--mono);
  font-weight: 700;
  user-select: all;
}

/* Lignes d'information sous la barre du haut (nav.js et lot 5) */
body.has-shell .time-zone-notice,
body.has-shell .closed-alarms-notice {
  margin: 0;
}

/* Page en construction (Alarmes et Missions, en attendant leur contenu) */
.page-soon {
  max-width: 640px;
}

.page-soon p {
  margin: 0;
}

/* Mon compte (compte.html) */
.compte-page {
  width: 100%;
  max-width: 760px;
}

.compte-card h2,
.compte-card p {
  margin: 0;
}

.compte-avatar {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

#securite {
  scroll-margin-top: calc(var(--top-h) + 16px);
}

/* ==========================================================================
   Pages pleine hauteur (Supervision, Alarmes) : body.page-flush
   Le cadre ne laisse plus de marge : la page occupe toute la hauteur sous la
   barre du haut, et ses listes défilent à l'intérieur.
   ========================================================================== */

body.has-shell.page-flush .shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  gap: 0;
}

body.has-shell.page-flush .app-top {
  margin: 0;
}

body.has-shell.page-flush .time-zone-notice,
body.has-shell.page-flush .closed-alarms-notice {
  margin: 8px 24px 0;
}

/* Fraîcheur des données (session.js), sous le titre de la barre du haut. */
.app-top-title .app-fresh {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
}

/* ==========================================================================
   Supervision (index.html, app.js) : docs/DESIGN_REFONTE.md § 4.1
   ========================================================================== */

.sup {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sup-head {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 24px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.sup-strip .ic-box svg {
  width: 20px;
  height: 20px;
}

.sup-strip.is-late #alarmStripOldest {
  font-weight: 700;
}

.sup-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.sup-bar .filters {
  min-width: 0;
}

.sup-view {
  display: none;
}

.sup-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
}

.sup-list {
  min-height: 0;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sup-list-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
}

.sup-list-tools .freshness {
  margin-right: auto;
}

.sup-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sup-sort select {
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.sup-list .list-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  font-size: 12px;
  line-height: 16px;
}

.sup-empty {
  padding: 24px 16px;
  color: var(--text-muted);
}

/* Une ligne : trait de couleur, plaque et client, motif ou trajet, dernier
   signal. C'est un bouton (clavier, lecteur d'écran) : il ouvre la fiche. */
button.lrow {
  width: 100%;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.lrow:last-child {
  border-bottom: 0;
}

button.lrow:hover {
  background: var(--surface-2);
}

button.lrow.is-selected {
  background: var(--info-bg);
}

button.lrow:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.lrow-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  align-self: center;
}

.lrow-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.lrow .plate {
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.lrow-small {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lrow-reason,
.lrow-route,
.lrow-sub {
  display: block;
  font-size: 13px;
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lrow-reason {
  font-weight: 700;
  color: var(--text);
}

.lrow[data-st="alarme"] .lrow-reason { color: var(--st-alarme); }
.lrow[data-st="verif"] .lrow-reason,
.lrow-reason.is-warn { color: var(--st-verif); }

.lrow-route {
  font-weight: 600;
  color: var(--text);
}

.lrow-sub {
  color: var(--text-muted);
}

.lrow .side-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
  white-space: nowrap;
}

.vitals {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vitals > span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.vitals .is-bad { color: var(--danger); }
.vitals .is-warn { color: var(--warning); }

.tag.tag-warn {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Formes d'état (filtres, groupes, légende, marqueurs) : la forme dit l'état
   sans la couleur — losange en alarme, carré à vérifier, cercle vide éteint. */
.st-shape[data-st="alarme"] { border-radius: 2px; transform: rotate(45deg) scale(0.86); }
.st-shape[data-st="verif"] { border-radius: 2px; }
.st-shape[data-st="eteint"] { background: transparent; box-shadow: inset 0 0 0 2px var(--st-eteint-dot); }

/* La carte */
.sup-map {
  position: relative;
  min-height: 0;
  min-width: 0;
}

.sup-map #map {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.sup-map .map-legend {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}

.sup-map .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.st-marker-wrap {
  background: none;
  border: 0;
}

.st-marker {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
}

.st-marker .st-shape {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--st-dispo-dot);
}

.st-marker[data-st="alarme"] .st-shape { background: var(--st-alarme-dot); border-radius: 2px; }
.st-marker[data-st="mission"] .st-shape { background: var(--st-mission-dot); }
.st-marker[data-st="verif"] .st-shape { background: var(--st-verif-dot); border-radius: 2px; }
.st-marker[data-st="eteint"] .st-shape { background: var(--surface); }

/* Sur la carte, un liseré blanc détache le marqueur du fond. */
.leaflet-marker-icon .st-marker .st-shape {
  outline: 2px solid #ffffff;
}

.leaflet-marker-icon .st-marker[data-st="alarme"] .st-shape,
.leaflet-marker-icon .st-marker.is-selected .st-shape {
  width: 16px;
  height: 16px;
}

.leaflet-marker-icon .st-marker[data-st="alarme"],
.leaflet-marker-icon .st-marker.is-selected {
  width: 22px;
  height: 22px;
}

.leaflet-marker-icon .st-marker.is-selected::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 3px solid var(--link);
}

.st-marker-label {
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}

/* Fiche courte d'un boîtier, sur la carte. */
.quick {
  position: absolute;
  z-index: 600;
  left: 16px;
  bottom: 60px;
  width: 360px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 76px);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-3);
}

.quick p {
  margin: 0;
}

.quick-close {
  width: 32px;
  height: 32px;
}

.quick-reason {
  font-weight: 700;
  color: var(--text);
}

.quick-reason[data-st="alarme"] { color: var(--st-alarme); }
.quick-reason[data-st="verif"],
.quick-reason[data-st="mission"] { color: var(--st-verif); }

.quick .route-line {
  display: block;
}

.quick .route-line .arrow {
  margin: 0 6px;
}

.quick-eta {
  display: block;
  font-weight: 400;
}

/* Lot 7 : l'heure d'arrivée estimée prend la couleur de son statut
   (docs/LOT7_ARRIVEE_ESTIMEE.md § 12) : neutre ; ambre à l'arrêt ou en
   retard ; rouge hors itinéraire ou zone quittée ; gris sans position ni
   itinéraire ; vert arrivé. */
.eta { font-weight: 400; color: var(--text-muted); }
.eta[data-ton="ambre"] { color: var(--warning); font-weight: 600; }
.eta[data-ton="rouge"] { color: var(--st-alarme); font-weight: 600; }
.eta[data-ton="gris"] { color: var(--text-subtle); }
.eta[data-ton="vert"] { color: var(--success); }

.quick-progress-text,
.quick-late {
  display: block;
}

.quick .progress > span {
  background: var(--link);
}

.quick-pir .quick-pir-text {
  color: var(--text-muted);
}

.quick-actions .btn {
  text-decoration: none;
}

/* ==========================================================================
   Fenêtre d'alarme (notifications.js) : docs/DESIGN_REFONTE.md § 4.2
   Un encart en haut à droite, en-tête rouge « Nouvelle alarme ». Les règles
   du lot 4 ne changent pas : tant qu'elle attend un geste, un voile léger
   garde la page dessous hors de portée. En bandeau (alarme technique pendant
   une alarme de sûreté, page live du camion, clôture en cours…), elle reste
   en bas à gauche, sans voile.
   ========================================================================== */

.notif-ack-backdrop {
  align-items: flex-start;
  justify-content: flex-end;
  padding: calc(var(--top-h) + 12px) 20px 20px;
  background: rgb(17 24 39 / 0.2);
  backdrop-filter: none;
}

.notif-ack {
  width: min(400px, 100%);
  max-height: calc(100vh - var(--top-h) - 32px);
  max-height: calc(100dvh - var(--top-h) - 32px);
  padding: 0;
  border: 2px solid var(--danger-solid);
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 20px;
}

.notif-ack > :not(.notif-ack-head) {
  margin-left: 14px;
  margin-right: 14px;
}

.notif-ack-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--danger-solid);
  color: var(--on-danger);
}

.notif-ack-icon {
  display: inline-flex;
}

.notif-ack-kicker {
  color: inherit;
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
}

.notif-ack-count {
  color: inherit;
  font-size: 12px;
  font-weight: 600;
}

.notif-ack-head .notif-ack-sound {
  margin-left: auto;
}

/* Avis passagers (toasts) : en bas à droite, au-dessus des onglets sur
   téléphone ; la fenêtre d'alarme garde le haut de l'écran. */
.notif-toast-stack {
  top: auto;
  right: 16px;
  bottom: 16px;
  flex-direction: column-reverse;
}

.notif-toast {
  border-radius: var(--r);
  border-color: var(--border);
  box-shadow: var(--shadow-2);
}

.notif-ack-sound {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgb(255 255 255 / 0.6);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
}

.notif-ack-sound:hover,
.notif-ack-sound[aria-pressed="true"] {
  background: rgb(255 255 255 / 0.16);
}

.notif-ack-sound:focus-visible {
  outline: 2px solid var(--on-danger);
  outline-offset: 2px;
}

.notif-ack.severity-warning {
  border-color: var(--st-verif-dot);
}

.notif-ack.severity-warning .notif-ack-head {
  background: var(--warning-bg);
  color: var(--warning);
}

.notif-ack.severity-warning .notif-ack-sound {
  border-color: var(--st-verif-dot);
}

.notif-ack.severity-warning .notif-ack-sound:focus-visible {
  outline-color: var(--focus);
}

.notif-ack.severity-warning .notif-ack-kicker {
  color: inherit;
}

.notif-ack-mode {
  margin-top: 10px;
  font-size: 13px;
}

.notif-ack-title {
  margin-top: 12px;
  margin-bottom: 2px;
  font-family: var(--font);
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
}

.notif-ack-device,
.notif-ack.severity-warning .notif-ack-device,
.notif-ack-backdrop.is-banner .notif-ack-device {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
  margin-top: 0;
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.notif-ack-device-id,
.notif-ack-backdrop.is-banner .notif-ack-device-id {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  color: var(--text);
}

.notif-ack-device-detail {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.notif-ack-device-detail::before {
  content: "· ";
}

.notif-ack-body,
.notif-ack-status,
.notif-ack-other,
.notif-ack-pending,
.notif-ack-link,
.notif-ack-error {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 18px;
}

.notif-ack-status {
  color: var(--text-muted);
}

.notif-ack-facts {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 18px;
}

.notif-ack-fact dt {
  font-weight: 600;
  color: var(--text-subtle);
}

.notif-ack-call {
  align-self: flex-start;
  margin-bottom: 8px;
  border-radius: 8px;
  /* La largeur compte la marge intérieure ; un nom long passe à la ligne. */
  box-sizing: border-box;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.notif-ack-queue {
  margin-top: 4px;
  margin-bottom: 4px;
}

.notif-ack-actions {
  justify-content: flex-start;
  margin-top: 8px;
  margin-bottom: 14px;
}

.notif-ack-actions .btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 600;
}

.notif-ack-actions .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.notif-ack-actions .btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.notif-ack-actions .btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--link);
}

.notif-ack-backdrop.is-banner .notif-ack {
  padding: 0;
}

/* En bandeau, la marge de styles.css (`margin: 10px 0 8px`) collait la
   plaque au bord de la carte : même retrait que le reste. */
.notif-ack-backdrop.is-banner .notif-ack-device {
  margin-left: 14px;
  margin-right: 14px;
}

/* ==========================================================================
   Alarmes (alarmes.html, alarmes.js) : docs/DESIGN_REFONTE.md § 4.2
   ========================================================================== */

.al-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.al-head {
  flex: 0 0 auto;
  padding: 8px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.al-head .tabs {
  border-bottom: 0;
}

.al-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.al-list {
  min-height: 0;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.al-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.al-filters .field:last-child {
  grid-column: 1 / -1;
}

.al-filters .label,
.al-journal-tools .label {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}

.al-filters .input,
.al-journal-tools .input {
  min-height: 36px;
}

.al-items {
  display: flex;
  flex-direction: column;
}

button.al-item {
  display: flex;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 14px 16px 14px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

button.al-item:hover {
  background: var(--surface-2);
}

button.al-item.is-selected {
  background: var(--info-bg);
}

button.al-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.al-stripe {
  flex: 0 0 auto;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: var(--st-alarme-dot);
}

.al-item[data-sev="warning"] .al-stripe { background: var(--st-verif-dot); }
.al-item[data-sev="info"] .al-stripe { background: var(--st-mission-dot); }

.al-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.al-item-title {
  font-weight: 700;
  min-width: 0;
}

.al-item-time {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-subtle);
}

.al-late {
  color: var(--st-alarme);
  font-weight: 700;
}

.al-item-who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.al-item-who .plate {
  font-size: 13px;
}

.al-item-client,
.al-item-sub {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.al-item-taken {
  color: var(--info);
}

/* Revue C1 : une alarme arrivée depuis le chargement (« Nouvelle », une
   minute), et le bandeau d'une arrivée hors de la vue de la liste. */
.al-item-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.al-item-head .al-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.al-new-tag {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger-solid);
  color: var(--on-danger);
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

button.al-item.is-new {
  background: var(--danger-bg);
}

button.al-item.is-moved {
  opacity: 0.8;
}

.al-item-note {
  color: var(--text-muted);
}

.al-incoming {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 16px;
  background: var(--danger-bg);
  color: var(--danger);
  border-bottom: 2px solid var(--danger-solid);
  font-size: 13px;
  line-height: 18px;
}

.al-incoming[hidden] {
  display: none;
}

.al-incoming .grow {
  min-width: 0;
}

/* Vérification N2 : au téléphone, sur le détail d'une alarme, les autres
   alarmes ouvertes. En haut de la page, hors de ce qui défile : toujours à
   l'écran, sans croix. */
.al-others {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--danger-solid);
  color: var(--on-danger);
  font-size: 14px;
  line-height: 20px;
}

.al-others[hidden] {
  display: none;
}

.al-others .grow {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.al-others .al-others-see {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  background: #ffffff;
  color: var(--danger-solid);
  border-color: #ffffff;
  font-weight: 700;
}

.al-others .al-others-see:hover:not(:disabled) {
  background: #fdecec;
}

.al-others .al-others-see:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Revue I1 : la page n'a pas pu se remplir (profil illisible). */
.al-offline {
  padding: 24px;
  max-width: 720px;
}

.al-offline .notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.al-offline .notice-text {
  flex: 1 1 280px;
}

.al-foot {
  margin: 0;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
}

.al-more {
  padding: 0 16px 16px;
}

.al-empty {
  margin: 0;
  padding: 24px 16px;
  color: var(--text-muted);
}

.al-detail {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

.al-detail-inner > * {
  margin: 0;
}

/* « ‹ Alarmes » : sur téléphone seulement, où le détail remplace la liste. */
.al-detail .al-back {
  display: none;
  align-self: flex-start;
  padding-left: 0;
}

.al-title {
  margin: 0;
}

.al-who {
  margin: 0;
}

.al-who .plate {
  color: var(--text);
}

.sev-info {
  background: var(--info-bg);
  color: var(--info);
}

.al-status span.ic-box {
  color: inherit;
}

.al-other {
  margin: 0;
}

.al-summary {
  color: var(--text);
}

.al-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.al-grid.no-photos {
  grid-template-columns: minmax(0, 1fr);
}

.al-grid.no-photos .al-side {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
}

.al-photos .card-title,
.al-todo .card-title,
.al-journal-card .card-title {
  margin: 0;
}

.al-photo-big img {
  object-fit: contain;
  background: #0b1220;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

button.al-thumb {
  padding: 0;
  border: 2px solid transparent;
  cursor: pointer;
}

button.al-thumb.is-current {
  border-color: var(--link);
}

.al-thumb .ph-tag {
  top: 4px;
  right: 4px;
  font-size: 10px;
}

.al-place {
  overflow: hidden;
}

.al-map {
  height: 190px;
  border-bottom: 1px solid var(--border);
}

.al-fact-sub {
  font-weight: 400;
  color: var(--text-subtle);
}

.todo {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.todo li .grow {
  flex: 1 1 140px;
}

.al-step {
  width: 24px;
  height: 24px;
}

a.btn {
  text-decoration: none;
}

.al-note-text {
  min-height: 72px;
  resize: vertical;
}

.al-note-status {
  margin: 0;
}

.al-pdf,
.al-live {
  align-self: flex-start;
}

/* Main courante */
.al-journal {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.al-journal[hidden],
.al-body[hidden] {
  display: none;
}

.al-journal-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.al-journal-tools .field {
  min-width: 180px;
}

.al-journal-tools #mcExport {
  margin-left: auto;
}

.al-journal .al-foot {
  padding: 0;
}

.mc-print-title {
  display: none;
}

.mc-table .plate {
  font-size: 13px;
  white-space: nowrap;
}

.mc-table td:first-child {
  white-space: nowrap;
}

.mc-table .btn-link {
  text-align: left;
}

.mc-row-opening td {
  background: var(--surface-2);
}

/* Fenêtre de clôture (main_courante.js) : les issues en cartes-choix. */
.mc-dialog {
  width: min(680px, 100%);
}

.mc-outcomes {
  padding: 0;
  border: 0;
  gap: 8px;
}

.mc-outcomes legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
}

.mc-outcome {
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--surface);
}

.mc-outcome:has(input:checked) {
  border-color: var(--link);
  box-shadow: inset 0 0 0 1px var(--link);
  background: var(--info-bg);
}

.mc-outcome input {
  margin: 2px 0 0;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.mc-outcome-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mc-outcome-label {
  font-weight: 600;
}

.mc-outcome-help {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
}

/* Main courante imprimée (« Exporter (PDF) ») : le tableau seul. */
@media print {
  body.alarmes-page {
    padding: 0;
    background: #ffffff;
  }

  body.alarmes-page #mainNav,
  body.alarmes-page .app-top,
  body.alarmes-page .tabbar,
  body.alarmes-page .al-head,
  body.alarmes-page .al-others,
  body.alarmes-page .al-journal-tools,
  body.alarmes-page .al-more,
  body.alarmes-page .mc-pdf-cell,
  body.alarmes-page .mc-table th:last-child,
  body.alarmes-page .notif-ack-backdrop,
  body.alarmes-page .notif-toast-stack,
  body.alarmes-page .time-zone-notice,
  body.alarmes-page .closed-alarms-notice,
  body.alarmes-page .actionbar {
    display: none !important;
  }

  body.alarmes-page .shell {
    height: auto;
    overflow: visible;
  }

  body.alarmes-page .al-journal {
    overflow: visible;
    padding: 0;
  }

  body.alarmes-page .mc-print-title {
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
  }
}

/* ==========================================================================
   Page d'un boîtier (live.html, docs/DESIGN_REFONTE.md § 4.3)
   En-tête en carte, six onglets, cartes du kit. Les éléments d'avant gardent
   leurs classes (burst-*, yolo-*, fret-*, cmd-log…) : seules leur place et
   leur présentation changent ici.
   ========================================================================== */

.bx {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* En-tête : identité à gauche, mission au milieu, gestes à droite, puces de
   vitalité sous l'identité. */
.bx-head.live-headbar {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) auto;
  grid-template-areas:
    "id mission actions"
    "vitals mission actions"
    "pir pir pir"
    "status status fresh";
  gap: 8px 24px;
  align-items: center;
  margin: 0;
  padding: 16px 20px;
}

.bx-id {
  grid-area: id;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bx-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 0;
}

.bx-plate {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  overflow-wrap: anywhere;
}

/* Le sélecteur de boîtier reste, en petit, à côté du titre. */
.bx-switch {
  display: inline-flex;
  min-width: 0;
}

.bx-head .live-device-select {
  max-width: 220px;
  min-height: 30px;
  padding: 2px 26px 2px 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.bx-who {
  margin: 0;
  overflow-wrap: anywhere;
}

.bx-head .live-identity {
  max-width: none;
  margin: 0;
  padding: 0;
  white-space: normal;
}

.bx-vitals {
  grid-area: vitals;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.vital,
.bx-vitals .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.vital[hidden] {
  display: none;
}

.vital b {
  color: var(--text);
  font-weight: 600;
}

.vital.is-bad,
.vital.is-bad b {
  color: var(--danger);
  background: var(--danger-bg);
}

.vital.is-warn,
.vital.is-warn b {
  color: var(--warning);
  background: var(--warning-bg);
}

.bx-vitals .badge {
  font-weight: 700;
  border: 0;
}

.bx-mission {
  grid-area: mission;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

.bx-mission-top {
  gap: 8px;
}

.bx-mission .route-line {
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.bx-mission .route-line.muted {
  font-weight: 600;
  color: var(--text-muted);
}

.bx-mission .progress[hidden] {
  display: none;
}

.bx-actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bx-actions .btn[hidden] {
  display: none;
}

.bx-head .pir-manual-status {
  grid-area: pir;
}

.bx-head-status {
  grid-area: status;
  margin: 0;
  font-size: 13px;
}

.bx-head-status:empty,
.bx-head .live-headbar-meta:empty {
  display: none;
}

.bx-fresh {
  grid-area: fresh;
  margin: 0;
  text-align: right;
}

.bx-fresh .freshness.is-stale {
  color: var(--warning);
  font-weight: 600;
}

/* Onglets : ceux du kit, qui défilent sur téléphone. */
.bx .live-tabs {
  position: relative;
  flex-wrap: nowrap;
  margin: 0;
}

.bx .live-tab {
  flex: 0 0 auto;
}

.bx .live-tab-panels {
  min-width: 0;
}

.bx .live-tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Grilles des onglets : une large colonne et une étroite, ou deux égales. */
.bx-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.bx-grid.bx-grid-even {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bx-grid .card-head {
  flex-wrap: wrap;
}

.bx-grid .card-head .row {
  flex-wrap: wrap;
}

.bx .card-title {
  font-size: 15px;
}

.bx h3.card-title .subtle {
  font-weight: 400;
}

/* Carte du trajet (Aperçu) et de la position (Santé). */
.bx-map-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bx-map-card .fret-map-wrap,
.bx-map {
  position: relative;
  height: clamp(260px, 42vh, 460px);
  margin: 0;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
}

.bx-map-card #fretMap {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  z-index: 0;
}

.bx-map-hint {
  margin: 0;
  padding: 10px 16px 12px;
}

.bx-map-hint:empty,
.bx-map-hint.hidden {
  display: none;
}

.bx .filter.hidden {
  display: none;
}

.bx .live-map-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.bx .live-map-panel .live-map-wrap {
  height: clamp(220px, 32vh, 340px);
  min-height: 0;
  border: 0;
  border-radius: 0;
}

.bx .live-map-panel:not(.compact) .live-map-wrap {
  height: clamp(360px, 62vh, 640px);
}

.bx .live-map-panel #liveMap {
  min-height: 0;
}

.bx .live-loc-badge {
  margin: 0;
}

.bx-gps-facts {
  padding: 12px 16px 0;
}

/* Dernières photos : trois vignettes 4/3. */
.bx-thumbs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bx-thumbs .photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
}

.bx-thumbs .photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bx-thumbs-empty {
  grid-column: 1 / -1;
}

/* Frise « Ces dernières heures ». */
#liveTimeline .tl:last-child {
  padding-bottom: 0;
}

/* Dernière position, chauffeur et secours, alarmes du camion. */
.bx .last-position {
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
}

.bx .last-position-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bx .last-position-coords {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bx-driver .emergency-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.bx-driver .emergency-btn {
  display: inline-flex;
  flex: 1 1 200px;
  box-shadow: none;
  padding: 0 16px;
  font-weight: 600;
}

.bx-driver .emergency-btn.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.bx-driver .emergency-btn.outline {
  border-width: 1px;
}

.bx-driver .emergency-btn.is-muted {
  opacity: 0.6;
  cursor: not-allowed;
}

.bx .mc-live-block {
  margin: 0;
}

/* Photos et détections : les filtres, le lecteur et le fil côte à côte. */
.bx-photo-filters {
  gap: 8px 12px;
}

.bx-photo-filters .filters {
  flex: 1 1 auto;
}

.bx-photo-day .input {
  min-height: 36px;
}

.bx-photo-take {
  margin-left: auto;
}

.bx-photo-filters + .live-hint:empty {
  display: none;
}

.bx-detect {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.bx-detect[hidden] {
  display: none;
}

.bx-burst .burst-frame-container {
  aspect-ratio: 4 / 3;
  min-height: 0;
  border: 1px solid var(--border);
  background: var(--photo-a);
  cursor: zoom-in;
}

.bx-burst .burst-frame-container.is-empty {
  cursor: default;
  background: var(--surface-2);
}

.bx-burst .burst-image {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.bx-burst #burstFrameLabel {
  margin: 0;
}

.bx-burst .burst-controls .btn {
  min-width: 96px;
}

.bx-feed .yolo-feed-count {
  margin: 0;
}

.bx-feed .yolo-sms-feed {
  max-height: min(60vh, 560px);
  overflow-y: auto;
}

.bx-feed .yolo-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
  align-items: end;
  padding-top: 8px;
}

.bx-feed .yolo-filters-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--link);
}

.bx .snapshot-strip {
  margin: 0;
}

.bx .snapshot-strip button {
  width: 96px;
  height: 72px;
  background: var(--photo-a);
}

.bx .snapshot-strip .strip-flag {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
}

/* Mission : faits, photos côte à côte dans leur cadre, aide repliable. */
.bx .fret-panel,
.bx .fret-route,
.bx .fret-destination {
  margin: 0;
}

.bx .fret-panel button.fret-toggle,
.bx .fret-panel button.fret-toggle.is-running {
  width: auto;
  min-height: 40px;
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.bx .fret-identity {
  margin: 0;
  max-width: none;
  white-space: normal;
}

/* Lot 7 : l'heure d'arrivée estimée en tête de l'onglet Mission ; la
   pastille prend la couleur du statut (§ 12), l'ambre pour un retard. */
.fret-eta {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.fret-eta p { margin: 0; }
.fret-eta-head { gap: 8px; }
.fret-eta-text { font-weight: 600; overflow-wrap: anywhere; }
.chip[data-ton="neutre"] { color: var(--st-mission); background: var(--st-mission-bg); }
.chip[data-ton="ambre"] { color: var(--st-verif); background: var(--st-verif-bg); }
.chip[data-ton="rouge"] { color: var(--st-alarme); background: var(--st-alarme-bg); }
.chip[data-ton="gris"] { color: var(--st-eteint); background: var(--st-eteint-bg); }
.chip[data-ton="vert"] { color: var(--st-dispo); background: var(--st-dispo-bg); }

.bx .fret-details.hidden,
.bx .fret-route.hidden,
.bx .fret-destination.hidden,
.bx .fret-photos.hidden {
  display: none;
}

.bx-facts {
  margin-bottom: 8px;
}

.bx .fret-route-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.bx .fret-route-actions {
  gap: 8px;
}

.bx .fret-route-actions.hidden,
.bx .fret-map-btn.hidden {
  display: none;
}

.bx .fret-route-events {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-muted);
}

.bx .fret-route-events li.is-alert {
  color: var(--danger);
}

.bx .fret-destination-row .input {
  flex: 1 1 auto;
}

.bx .fret-hours-row .input {
  width: auto;
  min-height: 40px;
}

.bx .fret-photos {
  display: flex;
  margin: 0;
}

.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bx .fret-photo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

/* La photo reste dans son cadre 4/3, quelle que soit sa taille d'origine. */
.bx .fret-photo .photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
}

.bx .fret-photo .photo img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: 0;
}

.bx .fret-photo .photo.is-empty {
  background: var(--surface-2);
  cursor: default;
}

.bx .fret-photo figcaption {
  margin: 0;
}

.bx-help > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--link);
}

.bx-help[open] > summary {
  margin-bottom: 10px;
}

.bx-help p {
  margin: 0;
}

.bx-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bx-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.bx-list-item:last-child {
  border-bottom: 0;
}

.bx-list-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 220px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.bx-list-link:hover .fw-600 {
  color: var(--link);
  text-decoration: underline;
}

.bx-list-photos .btn-link {
  font-weight: 600;
}

/* Commandes : quatre groupes, une ligne d'explication par ordre. */
.bx-cmd-head .cmd-eta {
  margin: 0;
  flex: 1 1 320px;
}

.cmd-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.cmd {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cmd + .cmd {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cmd-ic {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.bx .cmd .command-card {
  flex: 0 0 auto;
  min-width: 112px;
  min-height: 44px;
  padding: 6px 12px;
  align-items: center;
  text-align: center;
  border-radius: 8px;
}

.bx .cmd .command-card .cmd-title {
  font-size: 13px;
  line-height: 18px;
}

.bx .cmd .command-card .cmd-sub {
  font-size: 11px;
  line-height: 14px;
  opacity: 0.85;
}

.bx .cmd .command-card.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
}

.bx .cmd .command-card.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.bx .cmd .command-card.danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.bx .cmd .command-card.cmd-cancel {
  border-color: var(--danger);
}

.bx .cmd-label-row {
  margin: 4px 0 0;
}

.bx .cmd-label-row .input {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

/* Historique : le journal complet, sans cadre qui défile. */
.bx .cmd-log {
  max-height: none;
  overflow: visible;
  margin: 0;
  font-size: 13px;
}

.bx .commands-panel .live-hint:empty {
  display: none;
}

.bx-recent {
  overflow: hidden;
}

.bx-recent .table-wrap {
  overflow-x: auto;
}

/* Santé : les tuiles disent d'abord « Bonne » ou « Faible ». */
.bx-tiles .tile {
  position: relative;
}

.bx-tiles .tile-label [data-icon] {
  display: inline-flex;
}

.tile.is-bad .tile-value {
  color: var(--danger);
}

.bx-tiles .vital-spark {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 4px;
}

.bx-tiles .offline-alert {
  margin-top: 6px;
  font-size: 12px;
}

/* Pièces du boîtier : puces vertes, rouges ou grises pointillées. */
.parts.live-modules-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.parts .part.module-tile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  background: var(--st-dispo-bg);
  color: var(--st-dispo);
}

.parts .part.module-tile.ko {
  background: var(--st-alarme-bg);
  color: var(--st-alarme);
}

.parts .part.module-tile.unknown {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
}

/* L'état est dit par l'icône et l'infobulle ; il reste lu à voix haute. */
.parts .part.module-tile em {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.bx .module-issues {
  margin: 0;
  padding-left: 18px;
  color: var(--danger);
  font-size: 13px;
}

.bx-tech-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px 24px;
}

.bx-tech .env-charts {
  display: grid;
  gap: 12px;
}

.bx-tech .env-chart-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.bx-tech .env-chart-block canvas {
  width: 100%;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.bx-tech .env-charts-3 canvas {
  height: 72px;
}

.bx-tech .section-title {
  margin: 0;
}

/* Barre d'action du téléphone : sans gestes, elle disparaît. */
#liveActionbar .btn[hidden] {
  display: none;
}

/* ---- Démarrer une mission (mission_dialog.js) ---- */
.modal-card.mission-dialog {
  max-width: 560px;
}

.mission-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mission-step[hidden] {
  display: none;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stepper li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  min-width: 0;
}

.stepper li::before {
  content: "";
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
}

.stepper li.is-done::before,
.stepper li.is-current::before {
  background: var(--primary);
}

.stepper li.is-current {
  color: var(--link);
}

.stepper .step-dot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.listbox {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
}

.listbox[hidden] {
  display: none;
}

.listbox .opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
  text-align: left;
}

.listbox li:last-child .opt,
.listbox li.opt:last-child {
  border-bottom: 0;
}

.listbox button.opt:hover,
.listbox button.opt:focus-visible {
  background: var(--info-bg);
}

.mission-hours {
  margin: 0;
  padding: 0;
  border: 0;
}

.mission-hours[hidden] {
  display: none;
}

.mission-hours-row,
.mission-driver-row {
  align-items: flex-end;
  gap: 12px 16px;
}

.mission-hours-row .field,
.mission-driver-row .field {
  flex: 1 1 140px;
}

.mission-hours .help.is-error,
.mission-dialog .admin-error:not(:empty) {
  color: var(--danger);
  font-weight: 600;
}

.mission-chosen {
  margin: 0;
}

.mission-promise .ic {
  flex: 0 0 auto;
}

.mission-promise .notice-text {
  font-weight: 400;
  color: var(--text);
}

.mission-photo-line {
  margin: 0;
  color: var(--st-dispo);
  font-weight: 600;
}

.mission-photo-line span {
  color: var(--text);
}

.mission-dialog .notice {
  margin: 0;
}

@media (max-width: 1100px) {
  .bx-head.live-headbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "id actions"
      "vitals actions"
      "mission mission"
      "pir pir"
      "status fresh";
  }

  .bx-mission {
    padding: 10px 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .bx-grid,
  .bx-detect {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 759px) {
  .bx {
    gap: 12px;
  }

  .bx-head.live-headbar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "id"
      "vitals"
      "mission"
      "pir"
      "status"
      "fresh";
    gap: 10px;
    padding: 14px;
  }

  .bx-plate {
    font-size: 20px;
    line-height: 28px;
  }

  .bx-head .bx-actions {
    display: none;
  }

  .bx-fresh {
    text-align: left;
  }

  .bx .live-tab {
    padding: 0 10px;
  }

  .bx-grid.bx-grid-even,
  .cmd-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .bx-map-card .fret-map-wrap,
  .bx-map {
    height: 240px;
  }

  .bx-photo-take {
    margin-left: 0;
  }

  .cmd {
    flex-wrap: wrap;
  }

  .cmd > .stack-4 {
    flex: 1 1 180px;
  }

  .bx .cmd .command-card {
    margin-left: 52px;
  }

  .bx .snapshot-strip button {
    width: 80px;
    height: 60px;
  }

  .stepper {
    gap: 6px;
  }

  .mission-dialog .modal-actions {
    flex-direction: column-reverse;
  }
}

/* ==========================================================================
   Missions (missions.html, docs/DESIGN_REFONTE.md § 4.4)
   ========================================================================== */

.ms {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.ms-lists {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.ms-lists.hidden,
.ms-panel[hidden],
.ms-detail[hidden] {
  display: none;
}

.ms-no-access a {
  font-weight: 600;
}

.ms-tools {
  gap: 8px 12px;
}

.ms-search {
  flex: 1 1 280px;
  min-width: 0;
}

.ms-search .input,
.ms-select .input {
  min-height: 40px;
}

.ms-select .input {
  width: auto;
  max-width: 100%;
  padding-right: 32px;
}

.ms-table td {
  vertical-align: middle;
}

.ms-row {
  cursor: pointer;
}

.ms-row:hover td,
.ms-row.is-active td {
  background: var(--info-bg);
}

.ms-link {
  display: inline-flex;
  flex-direction: column;
  color: var(--text);
  text-decoration: none;
}

.ms-link:hover .mono,
.ms-link:focus-visible .mono {
  color: var(--link);
  text-decoration: underline;
}

.ms-box {
  display: block;
}

.ms-link .mono,
.ms-box,
.ms-progress .num {
  white-space: nowrap;
}

.ms-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.ms-progress .progress {
  flex: 1 1 80px;
  min-width: 60px;
}

/* Lot 7 : « 43 km sur 211 km » sous la barre ; « retard » à côté de l'heure. */
.ms-progress-text {
  display: block;
  margin-top: 2px;
  white-space: nowrap;
}

.ms-late {
  margin-left: 4px;
  vertical-align: middle;
}

.ms-alarms {
  color: var(--st-alarme);
}

.ms-count {
  margin: 0;
  flex: 1 1 auto;
}

.ms-back {
  align-self: flex-start;
}

.ms-head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  grid-template-areas: "id mission actions";
  gap: 8px 24px;
  align-items: center;
  padding: 16px 20px;
}

.ms-head .bx-id p {
  margin: 0;
}

.ms-title {
  margin: 0;
  overflow-wrap: anywhere;
}

.ms-head .bx-actions {
  align-items: stretch;
}

.ms-head .bx-actions .btn {
  justify-content: center;
}

.ms-head .bx-actions [data-icon] {
  display: inline-flex;
}

.ms-head .btn.is-muted {
  opacity: 0.55;
  pointer-events: none;
}

.ms-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.ms-map-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ms-map {
  position: relative;
  height: clamp(260px, 44vh, 480px);
}

.ms-map #fretArchiveMap {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  z-index: 0;
}

.ms-detail .fret-photo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.ms-detail .fret-photo .photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
}

.ms-detail .fret-photo .photo img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: 0;
}

.ms-detail .fret-photo .photo.is-empty {
  background: var(--surface-2);
  cursor: default;
}

.ms-detail .fret-photo figcaption {
  margin: 0;
}

.ms-detail .fret-identity {
  max-width: none;
  white-space: normal;
}

.ms-detail #fretArchiveEmpty.hidden,
.ms-detail #fretArchiveBody.hidden {
  display: none;
}

.ms-tiles {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.ms-tiles .tile {
  padding: 10px 14px;
  box-shadow: none;
}

.ms-tiles .tile-value {
  font-size: 16px;
  line-height: 22px;
  color: var(--text);
}

.ms-more .table-wrap {
  margin-top: 10px;
}

.ms-points {
  max-height: 60vh;
  overflow: auto;
}

.ms-hours tr[data-hour] {
  cursor: pointer;
}

.ms-hours tr.is-active td {
  background: var(--warning-bg);
}

.ms-hours tr.is-empty td {
  color: var(--text-subtle);
}

@media (max-width: 1100px) {
  .ms-head {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "id actions" "mission mission";
  }

  .ms-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 759px) {
  .ms-head {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "id" "mission" "actions";
    padding: 14px;
  }

  .ms-head .bx-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .ms-map {
    height: 260px;
  }

  .ms-select {
    flex: 1 1 140px;
  }

  .ms-select .input {
    width: 100%;
  }

  .ms-row:hover td {
    background: transparent;
  }
}

/* ==========================================================================
   Administration (admin.html, docs/DESIGN_REFONTE.md § 4.5)
   ========================================================================== */

.adm {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.adm .admin-tabs {
  flex-wrap: nowrap;
}

.adm .admin-panel.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.adm .admin-status:empty {
  display: none;
}

.adm-tools {
  gap: 8px 12px;
}

.adm-search {
  flex: 1 1 260px;
  min-width: 0;
}

.adm-search .input,
.adm-select .input {
  min-height: 40px;
}

.adm-select .input {
  width: auto;
  padding-right: 32px;
}

.adm-primary {
  margin-left: auto;
}

.adm-primary [data-icon],
.adm-tools .btn [data-icon] {
  display: inline-flex;
}

.adm .fleet-hint {
  font-size: 13px;
  line-height: 18px;
}

.adm-table-card {
  overflow-x: auto;
}

.adm .fleet-table thead th {
  position: static;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
}

.adm .fleet-table td {
  padding: 10px 12px;
}

.adm .fleet-table th.col-actions {
  width: 56px;
  font-size: 0;
}

.adm .fleet-table td.col-actions {
  width: 56px;
  text-align: right;
}

.adm .admin-user-ident,
.adm-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.adm .admin-user-ident > .avatar {
  align-self: flex-start;
  margin-top: 2px;
}

.admin-user-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-user-name {
  font-weight: 600;
  color: var(--text);
}

.admin-user-login {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--text-subtle);
}

.admin-user-names .badge,
.admin-user-names .watch-badges {
  align-self: flex-start;
}

.adm-role-cell {
  gap: 6px;
}

.adm .role-tag {
  border: 0;
}

.admin-2fa {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.adm .module-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.adm .module-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--muted-bg);
  color: var(--muted-fg);
  font-size: 12px;
  font-weight: 600;
  border: 0;
}

.adm .module-chip.is-override {
  background: var(--warning-bg);
  color: var(--warning);
}

.adm .device-credential-status {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.adm .device-credential-status small {
  font-size: 12px;
  color: var(--text-subtle);
}

/* Menu « … » des lignes */
.row-menu {
  position: relative;
  display: inline-block;
}

.row-menu-list {
  top: calc(100% + 4px);
  right: 0;
  width: 240px;
  z-index: 60;
  text-align: left;
}

.row-menu-list[hidden] {
  display: none;
}

.row-menu-list .menu-item {
  min-height: 40px;
  font-size: 14px;
}

.row-menu-list .menu-item:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Fiches de profil et d'entreprise : un panneau qui glisse de la droite. */
.modal-backdrop.is-sheet {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}

.modal-card.admin-sheet {
  width: min(560px, 100%);
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

.admin-sheet .modal-body {
  flex: 1 1 auto;
}

.adm-sheet-who {
  gap: 12px;
  align-items: center;
}

.adm-sheet-avatar {
  width: 44px;
  height: 44px;
  font-size: 15px;
}

.admin-sheet .modal-head-main p {
  margin: 2px 0 0;
}

.adm-role-seg {
  align-self: flex-start;
}

.adm-role-seg > button {
  min-height: 34px;
}

.perms {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.perms .perm {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
}

.perms .perm:last-child {
  border-bottom: 0;
}

.perms.is-disabled .perm {
  color: var(--text-muted);
  cursor: default;
}

.perms.is-disabled {
  background: var(--surface-2);
}

.perms .switch:disabled {
  opacity: 0.55;
  cursor: default;
}

.adm-2fa {
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}

.adm-2fa[hidden] {
  display: none;
}

.modal-card.adm-small {
  width: min(520px, 100%);
}

.adm-small .device-onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 759px) {
  .adm-primary {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .adm-select {
    flex: 1 1 140px;
  }

  .adm-select .input {
    width: 100%;
  }

  .adm .fleet-table td.col-actions {
    width: auto;
    text-align: left;
  }

  .adm .fleet-table td.col-actions::before {
    display: none;
  }

  /* Sur téléphone, le nom (profil, entreprise, boîtier) ouvre la carte sur
     toute sa largeur, sans l'étiquette « Nom : ». */
  .adm .admin-panel .admin-table td:first-child {
    display: block;
    padding-bottom: 8px;
  }

  .adm .admin-panel .admin-table td:first-child::before {
    display: none;
  }

  .modal-backdrop.is-sheet {
    align-items: flex-end;
  }

  .modal-card.admin-sheet {
    height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  .row-menu-list {
    right: auto;
    left: 0;
  }
}

/* ==========================================================================
   Pages sans menu : connexion et refus (carte centrée, logo)
   ========================================================================== */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.auth-brand .brand-mark {
  background: var(--nav-bg);
  color: var(--nav-fg);
}

:root[data-theme="dark"] .auth-brand .brand-mark {
  background: var(--nav-fg);
  color: var(--nav-bg);
}

.auth-brand .brand-sub {
  color: var(--text-subtle);
}

.auth-card {
  width: min(440px, 100%);
  padding: 28px;
}

.auth-foot {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-subtle);
  text-align: center;
}

/* ==========================================================================
   Lot 5 et lot 6 : couleurs de la refonte
   Les sections « Lot 5 » et « Lot 6 » de styles.css restent telles quelles
   (d'autres travaux les modifient encore) : seules les déclarations qui
   portaient une couleur, une police ou un effet retirés par la refonte sont
   reprises ici, sur les mêmes sélecteurs.
   ========================================================================== */

/* Lot 6 (cartes) */
.map-unavailable {
  border: 1px dashed var(--border);
  color: var(--text-muted);
}

.map-unavailable-title {
  font-family: var(--font);
}

.map-tiles-unavailable {
  border: 1px solid var(--st-verif-dot);
  background: var(--surface);
  font-family: var(--font);
}

/* Lot 6 (droits) */
.command-card.cmd-sensitive {
  background: var(--warning-bg);
  border-color: var(--st-verif-dot);
  box-shadow: var(--shadow-1);
}

.command-card.cmd-sensitive .cmd-sub {
  color: var(--warning);
}

.cmd-log .cmd-log-reason {
  color: var(--text-muted);
}

.cmd-log .cmd-log-cancel {
  border: 1px solid var(--st-verif-dot);
  color: var(--warning);
}

.sensitive-honesty {
  color: var(--text-muted);
}

/* Lot 6 (journal) */
.watch-box {
  border: 1px solid var(--danger);
}

.watch-title {
  color: var(--danger);
}

.watch-suspension {
  color: var(--text-muted);
}

.badge.watch-badge {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}

.watch-dates {
  color: var(--text-muted);
}

.journal-export {
  border: 1px solid var(--border);
  background: var(--surface);
}

.journal-export:hover,
.journal-export:focus-visible {
  border-color: var(--link);
}

.journal-role {
  color: var(--text-muted);
}

.journal-link {
  color: var(--link);
}

/* Lot 5 (alertes hors écran) */
.alerts-modal-status {
  color: var(--text);
}

.closed-alarms-notice {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.closed-alarms-notice a {
  color: var(--link);
}

.alerts-admin-banner {
  color: var(--danger);
}

.alerts-admin-card {
  border: 1px solid var(--border);
  background: var(--surface);
}

.alerts-admin-card h3 {
  color: var(--text);
}

.alerts-admin-line {
  color: var(--text-muted);
}

.alerts-admin-test {
  color: var(--text);
}

.alerts-admin-subtitle {
  color: var(--text);
}

.alerts-admin-rules {
  color: var(--text-muted);
}

/* ==========================================================================
   Téléphone (moins de 760 px)
   ========================================================================== */

@media (max-width: 759px) {
  .hide-phone { display: none !important; }
  .only-phone { display: revert; }
  .page-pad { padding: 12px; }

  body.has-shell {
    padding-left: 0;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }

  body.has-shell .shell {
    gap: 12px;
    padding: 0 12px 12px;
  }

  body.has-shell #mainNav {
    display: none;
  }

  .app-top {
    height: var(--top-h-phone);
    gap: 4px;
    margin: 0 -12px;
    padding: 0 8px 0 12px;
  }

  .app-top-title h1 {
    font-size: 18px;
    line-height: 24px;
  }

  .app-top-title .crumb {
    display: none;
  }

  .app-search {
    display: none;
  }

  .app-top.is-searching .app-top-title,
  .app-top.is-searching .app-top-tools {
    display: none;
  }

  .app-top.is-searching .app-search {
    display: flex;
    flex: 1 1 auto;
    margin: 0;
  }

  .app-top .btn-icon.is-search {
    display: inline-grid;
    margin-left: auto;
  }

  .app-top.is-searching .btn-icon.is-search {
    display: none;
  }

  .account-name,
  .account-button .ic {
    display: none;
  }

  .account-button {
    padding: 4px;
  }

  .app-top .notif-sound.is-muted .notif-sound-label {
    display: none;
  }

  .app-top .notif-sound.is-muted {
    width: 40px;
    padding: 0;
  }

  .tabbar {
    position: fixed;
    z-index: 1100;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  /* Fenêtres : un panneau qui monte du bas, boutons empilés sous le pouce. */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 16px 16px 0 0;
  }

  .modal-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions > button {
    width: 100%;
    min-height: 44px;
  }

  .dialog {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    width: 100%;
    max-height: 88%;
    border-radius: 16px 16px 0 0;
  }

  .dialog-foot {
    flex-direction: column-reverse;
  }

  .dialog-foot .btn {
    width: 100%;
  }

  .actionbar {
    position: fixed;
    z-index: 1100;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  .actionbar .btn {
    flex: 1 1 0;
    /* Un libellé long (« Je garde la main (encore 2 fois) ») passe sur deux
       lignes plutôt que de pousser « … » hors de l'écran. */
    min-width: 0;
    padding: 0 10px;
    white-space: normal;
    line-height: 18px;
    text-align: center;
  }

  /* Revue M1 : « … » garde les autres gestes (rappel dans 10 min, son,
     garder la main), dans un petit menu au-dessus de la barre. */
  .actionbar .actionbar-more-toggle {
    flex: 0 0 48px;
    padding: 0;
    font-weight: 700;
  }

  .actionbar-more {
    position: absolute;
    right: 12px;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  }

  .actionbar-more[hidden] {
    display: none;
  }

  .actionbar-more .btn {
    flex: 0 0 auto;
    min-height: 44px;
  }

  /* Une alarme, la page d'un boîtier : la barre d'action remplace les
     onglets (la page pose body.has-actionbar). */
  body.has-actionbar .tabbar {
    display: none;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-right: -12px;
    padding-right: 12px;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .lrow {
    padding: 12px 12px 12px 0;
  }

  /* Un tableau devient une carte par ligne, le nom de la colonne devant
     chaque valeur (data-label). */
  table.table thead {
    display: none;
  }

  table.table,
  table.table tbody,
  table.table tr,
  table.table td {
    display: block;
    width: 100%;
  }

  table.table tr {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

  table.table td {
    border: 0;
    padding: 2px 0;
  }

  table.table td[data-label]::before {
    content: attr(data-label) " : ";
    color: var(--text-subtle);
    font-weight: 400;
  }

  table.table td.num {
    text-align: left;
  }

  .auth-card {
    padding: 20px;
  }

  /* Pages pleine hauteur : sous la barre du haut et au-dessus des onglets. */
  body.has-shell.page-flush .shell {
    height: calc(100vh - var(--tabbar-h) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom));
  }

  body.has-shell.page-flush .time-zone-notice,
  body.has-shell.page-flush .closed-alarms-notice {
    margin: 8px 12px 0;
  }

  /* Supervision : la liste d'abord, « Liste | Carte » pour passer à la carte. */
  .sup-head {
    gap: 10px;
    padding: 12px;
  }

  .sup-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sup-view {
    display: flex;
  }

  .sup-view > button {
    flex: 1 1 0;
    justify-content: center;
  }

  .sup-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .sup-body[data-view="liste"] .sup-map,
  .sup-body[data-view="carte"] .sup-list {
    display: none;
  }

  .sup-list {
    border-right: 0;
  }

  .sup-list-tools {
    padding: 6px 12px;
  }

  .quick {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100% - 16px);
  }

  .sup-map:has(.quick:not([hidden])) .map-legend {
    display: none;
  }

  .notif-toast-stack {
    top: calc(var(--top-h-phone) + 8px);
    right: 12px;
    bottom: auto;
    flex-direction: column;
  }

  /* Fenêtre d'alarme : en haut, toute la largeur. */
  .notif-ack-backdrop {
    padding: calc(var(--top-h-phone) + 8px) 12px 12px;
  }

  .notif-ack {
    width: 100%;
    max-height: calc(100vh - var(--top-h-phone) - 24px);
    max-height: calc(100dvh - var(--top-h-phone) - 24px);
  }

  .notif-ack-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  /* « Appeler … » : `width: 100%` (styles.css) plus le retrait de 14 px de
     chaque côté dépassait de la carte de 12 px. En bloc, la largeur suit la
     carte, retraits compris. */
  .notif-ack-call {
    display: flex;
    width: auto;
  }

  /* Une clôture en cours (vérification N1) : le bandeau « Alarme en
     attente » couvrait en bas 60 % de l'écran, et avec lui « Clôturer » de
     la fenêtre de clôture. Il passe en haut, plus court (il défile) : le bas
     de la fenêtre de clôture reste sous le pouce. */
  body.mc-modal-open .notif-ack-backdrop.is-banner {
    inset: 8px 8px auto 8px;
  }

  body.mc-modal-open .notif-ack-backdrop.is-banner .notif-ack {
    width: 100%;
    max-height: 40vh;
    max-height: 40dvh;
  }

  /* Alarmes : la liste ou le détail ; « ‹ Alarmes » pour revenir. */
  .al-head {
    padding: 4px 12px 0;
  }

  .al-head .tab {
    padding: 0 10px;
  }

  .al-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .al-body[data-view="liste"] .al-detail,
  .al-body[data-view="detail"] .al-list {
    display: none;
  }

  .al-list {
    border-right: 0;
  }

  .al-detail {
    padding: 12px;
  }

  .al-detail .al-back {
    display: inline-flex;
  }

  .al-detail .al-title {
    font-size: 20px;
    line-height: 26px;
  }

  .al-grid,
  .al-grid.no-photos .al-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .thumbs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .al-journal {
    padding: 12px;
  }

  .al-journal-tools .field {
    flex: 1 1 100%;
    min-width: 0;
  }

  .al-journal-tools #mcExport {
    margin-left: 0;
  }

  .mc-outcomes {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .switch::after {
    transition: none;
  }
}

/* ==========================================================================
   Lot 8 : dossier de mission et historique du boîtier
   (docs/LOT8_DOSSIER_HISTORIQUE.md § 8.6). Couleurs par jetons seulement :
   les deux thèmes suivent.
   ========================================================================== */

/* Déroulé d'une mission (dossier_mission.js) : Missions › détail et onglet
   Mission de la page d'un boîtier. */
.dossier-puces { gap: 6px; }
/* « 1 détection de mouvement, dont 1 avec personne » dépasse 300 px : la
   puce passe à la ligne plutôt que de sortir de la carte. */
.dossier-puces .chip {
  height: auto;
  min-height: 24px;
  max-width: 100%;
  padding-top: 3px;
  padding-bottom: 3px;
  white-space: normal;
}
.tl-time .tl-day { display: block; }
.dossier-list .tl-text,
.hist-events .tl-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-title { overflow-wrap: anywhere; }
.tl-detail { font-size: 13px; line-height: 18px; color: var(--text-muted); overflow-wrap: anywhere; }
.tl-meta { font-size: 12px; line-height: 16px; color: var(--text-subtle); }
.tl-dot[data-st="eteint"] { background: var(--st-eteint-dot); }
.tl-empty { list-style: none; }
.tl-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 18px;
  min-width: 0;
}
.tl-links a { overflow-wrap: anywhere; }
/* Les textes d'état sont longs (« clôturée par … : … ») : ils passent à la
   ligne au lieu de sortir de la carte. */
.tl-links .tag,
.tl-meta .tag {
  height: auto;
  min-height: 22px;
  padding: 2px 8px;
  line-height: 16px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tl-status[data-statut="ouverte"] { background: var(--st-alarme-bg); color: var(--st-alarme); }
.tl-status[data-statut="prise"] { background: var(--st-mission-bg); color: var(--st-mission); }
.tl-now { background: var(--st-verif-bg); color: var(--st-verif); }
.tl-thumb {
  display: block;
  width: 72px;
  aspect-ratio: 4 / 3;
  margin-top: 4px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
}
.tl-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tl-thumb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Un fait qui a son repère s'ouvre sur la carte ; le fait choisi est mis en
   avant (le trait de gauche ne bouge pas). */
.tl.is-pin { cursor: pointer; border-radius: 8px; }
.tl.is-pin:hover { background: var(--surface-2); }
.tl.is-focus { background: var(--info-bg); box-shadow: inset 3px 0 0 var(--link); border-radius: 8px; }
.tl.is-pin:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#mdDossierFilter > button,
#historyPeriod > button { white-space: nowrap; }
.fret-dossier-link { align-self: flex-start; }

/* Repère d'un fait sur la carte (L.divIcon). */
.dossier-pin { display: grid; place-items: center; background: transparent; border: 0; }
.dossier-pin .dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-2);
}

/* Page Alarmes : déroulé de la mission, historique du boîtier. */
.al-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; }

/* Santé : « relevé à 14:32 » sous chaque courbe, et la bulle du point
   survolé (courbes des tuiles et de l'historique). */
#panelSante .bx-tiles { position: relative; }
.spark-at { color: var(--text-subtle); }
.spark-tip {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  font-size: 12px;
  line-height: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-2);
}
.vital-spark,
.hist-charts canvas { touch-action: pan-y; }

/* Historique (historique_boitier.js) : la frise en ligne / hors ligne. */
.hist-text { margin: 0; overflow-wrap: anywhere; }
.hist-now { color: var(--st-alarme); font-weight: 700; }
/* Chaque segment est placé en pourcentage de la fenêtre (left, ou right
   pour une coupure, et width, posés par le script) : la frise reste pleine à
   toutes les largeurs, et la coupure la plus récente reste au bout. */
.hist-bar {
  position: relative;
  display: block;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  isolation: isolate;
  background: var(--surface-2);
}
.hist-seg { position: absolute; top: 0; bottom: 0; display: block; min-width: 0; }
.hist-seg[data-etat="en_ligne"] { background: var(--st-dispo-dot); }
.hist-seg[data-etat="hors_ligne"] { background: var(--st-eteint-dot); min-width: 2px; z-index: 1; }
.hist-seg[data-etat="inconnu"] {
  background: repeating-linear-gradient(135deg, var(--border) 0 4px, transparent 4px 8px);
}
.hist-axis {
  position: relative;
  height: 14px;
  font-size: 11px;
  line-height: 14px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}
.hist-axis > span { position: absolute; top: 0; white-space: nowrap; }
.hist-charts {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.hist-chart { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hist-charts canvas { display: block; width: 100%; height: 112px; }
.live-history #historyMore { align-self: flex-start; }
.live-history #historyNote { margin: 0; }

@media (max-width: 759px) {
  .hist-charts { grid-template-columns: minmax(0, 1fr); }
  .tl-thumb { width: 64px; }
}
/* --- fin du lot 8 --- */

/* ---------------------------------------------------------------- Démonstration
   Copie de démonstration seulement (docs/DEMONSTRATION.md) : pastille de la
   barre du haut (nav.js) et panneau demo.html. */
.demo-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--warning);
  background: var(--warning-bg);
}
.demo-main { display: flex; flex-direction: column; gap: 20px; padding: 20px 0 32px; }
.demo-head { display: flex; flex-direction: column; gap: 14px; }
.demo-stats { display: flex; flex-wrap: wrap; gap: 28px; }
.demo-stats > div { display: flex; flex-direction: column; }
.demo-num { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text); }
.demo-lbl { font-size: 13px; color: var(--text-muted); }
.demo-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.demo-tools .ic-box { margin-right: 6px; }
.demo-hint { margin: 0; color: var(--text-muted); font-size: 14px; }
.demo-message { margin: 0; min-height: 20px; font-weight: 600; color: var(--success); }
.demo-alerte { margin: 0; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--warning); background: var(--warning-bg); }
.demo-message.is-error { color: var(--danger); }
.demo-h2 { margin: 0 0 12px; font-size: 18px; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.demo-cas { display: flex; flex-direction: column; gap: 8px; }
.demo-cas-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.demo-cas-titre { margin: 0; font-size: 16px; }
.demo-cas-qui { margin: 0; font-size: 13px; color: var(--text-muted); }
.demo-cas-texte { margin: 0; font-size: 14px; }
.demo-cas-note { margin: 0; font-size: 13px; color: var(--warning); }
.demo-cas-gestes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.demo-clients-list { margin: 10px 0 0; padding-left: 20px; }
@media (max-width: 759px) {
  .demo-badge { display: none; }
  .demo-grid { grid-template-columns: 1fr; }
}
