:root {
  --bg: #f7f7f5;
  --text: #1f2328;
  --muted: #5f6b76;
  --accent: #2463eb;
  --card: #ffffff;
  --border: #e3e3e0;
  --input-bg: #ffffff;
  --error: #c62828;
  --error-bg: #fdecea;
  --success-bg: #e8f5e9;
  --success-text: #1b5e20;
  --ok: #1f9d55;
  --ko: #d93025;
  --none: #1f2328;
  --none-ring: #1f2328;
  --hover: #f1f2f4;
  --group-bg: #ecece8;
  --accent-hover: #1d54cc;
  --on-color: #ffffff;   /* texte sur un fond de couleur (boutons, pastilles, badges) */
  color-scheme: light;
}
/* Thème sombre, activé par le bouton de la barre du haut (cookie "theme").
   Gris ardoise plutôt que presque noir : meilleur contraste des cartes, bordures et textes secondaires. */
:root[data-theme="dark"] {
  --bg: #22272e;
  --text: #f0f3f6;
  --muted: #b3bdc7;
  --accent: #79a6ff;
  --card: #2d333b;
  --border: #464e59;
  --input-bg: #22272e;
  --error: #ff8a80;
  --error-bg: #432627;
  --success-bg: #1f3a28;
  --success-text: #a5d6a7;
  --ok: #3fd07f;
  --ko: #ff6459;
  --none: #000000;
  --none-ring: #7d8894;
  --hover: #373e47;
  --group-bg: #1c2128;
  --accent-hover: #86adff;
  --on-color: #10151c;   /* les couleurs du thème sombre sont claires : texte foncé dessus */
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* Place de la barre de défilement toujours réservée : la page (et la barre du haut) ne se décale pas
   entre une page courte et une page longue. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--accent-hover); }
/* Liens dans le texte (fil d'Ariane, URLs…) : trait qui se dessine au survol. Classe no-underline : lien qui a son propre style (bouton rond…). */
main a:not(.btn):not(.row-link):not(.tab):not(.no-underline) {
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
  transition: color 0.15s, background-size 0.25s ease;
}
main a:not(.btn):not(.row-link):not(.tab):not(.no-underline):hover { background-size: 100% 1px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}
main.narrow { max-width: 560px; }
main.wide { max-width: 1400px; } /* calendrier : 7 colonnes */
main.full { max-width: none; } /* dashboard : toute la largeur (écrans / télés) */

/* ---- Barre de navigation ---- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
/* Barre fixe : toujours toute la largeur, quelle que soit la largeur de la page (rien ne bouge d'un écran à l'autre). */
.topbar-inner {
  padding: 10px clamp(16px, 2vw, 24px); /* marge de 16 px sur téléphone */
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  color: var(--muted);
  padding: 2px 0;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 50% 100% / 0 2px;
  transition: color 0.15s, background-size 0.25s ease;
}
.topbar nav a:hover { color: var(--text); background-size: 100% 2px; }
.topbar nav a.active { color: var(--text); background-size: 100% 2px; } /* pas de gras : le lien garderait sa largeur et pousserait les suivants */
/* Menus déroulants de la barre (superviseurs, admins de Time Off et d'Academy) : "Moi" et "Mon équipe". Même style que les liens de la barre. */
.nav-menu { position: relative; }
.nav-menu summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  padding: 2px 0;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 50% 100% / 0 2px;
  transition: color 0.15s, background-size 0.25s ease;
  user-select: none;
}
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: " ▾"; font-size: 0.8em; }
.nav-menu summary:hover, .nav-menu[open] summary { color: var(--text); }
.nav-menu.active summary { color: var(--text); background-size: 100% 2px; } /* page en cours dans ce menu */
/* Pont invisible entre le titre et le menu : la souris peut descendre sans que le menu se ferme. */
.nav-menu-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.nav-menu-panel {
  position: absolute;
  left: -12px;
  top: calc(100% + 10px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.topbar nav .nav-menu-panel a { padding: 7px 10px; border-radius: 6px; background: none; color: var(--text); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.topbar nav .nav-menu-panel a:hover { background: var(--hover); }
.topbar nav .nav-menu-panel a.active { background: var(--hover); font-weight: 600; }
.nav-menu-panel .badge { margin-left: auto; }
/* Cadre de focus seulement au clavier (pas après un clic). */
.nav-menu summary:focus:not(:focus-visible) { outline: none; }

h1 { margin: 0 0 8px; font-size: 1.8rem; line-height: 1.25; }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
.lead { margin: 0 0 24px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-head h1, .page-head .lead { margin-bottom: 0; }
.breadcrumb { font-size: 0.9rem; margin-bottom: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ---- Menu de la personne connectée (barre du haut de tous les outils, core/views/partials/user-menu.ejs) ---- */
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; font-size: 0.9rem; color: var(--muted); user-select: none; }
.user-menu summary:focus:not(:focus-visible) { outline: none; } /* cadre de focus seulement au clavier */
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: " ▾"; }
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.user-menu-panel a, .user-menu-panel .btn-link { color: var(--text); font-size: 0.9rem; text-align: left; white-space: nowrap; }

/* ---- Formulaires ---- */
.field { margin-bottom: 16px; }
label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 0.95rem;
}
input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
/* Boutons radio et cases à cocher : pas de carré au clic de souris, seulement au clavier (Tab). */
input[type=radio]:focus, input[type=checkbox]:focus { outline: none; }
input[type=radio]:focus-visible, input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 180px; margin-bottom: 0; }

button, .btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-color);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
button:hover, .btn:hover { background-color: var(--accent-hover); color: var(--on-color); }
button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--border); }
.btn-danger:hover { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.btn-link { background: none; border: none; padding: 0; color: var(--muted); }
.btn-link:hover { background: none; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

.alert {
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  background: var(--error-bg);
  color: var(--error);
}
.success {
  padding: 16px;
  border-radius: 6px;
  background: var(--success-bg);
  color: var(--success-text);
}

/* Éditeur de choix */
.choice-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.choice-row input[type=text] { flex: 1; }
.choice-row .correct {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-weight: 400;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---- Listes / tableaux ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
code.url { font-size: 0.8rem; word-break: break-all; color: var(--muted); }

/* ---- Pastilles d'état ---- */
.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  vertical-align: middle;
}
.dot.ok { background: var(--ok); }
.dot.ko { background: var(--ko); }
.dot.none { background: var(--none); box-shadow: inset 0 0 0 1px var(--none-ring); } /* contour à l'intérieur : même taille que les points verts et rouges */

/* ---- Dashboard ---- */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.875rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.live { font-size: 0.875rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.live.on::before { background: var(--ok); }
.objects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start; /* chaque carte garde sa propre hauteur */
}
.objects-grid .card { margin: 0; }
.object-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.object-head h2 { margin: 0; }
.cp-list { list-style: none; margin: 0; padding: 0; }
.cp-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.dot.big { width: 18px; height: 18px; }
/* Mauvaise réponse : le point clignote sur le dashboard pour attirer l'attention. */
.cp-list .dot.ko { animation: blink 1s ease-in-out infinite; }
@keyframes blink {
  50% { opacity: 0.15; }
}
@media (prefers-reduced-motion: reduce) {
  .cp-list .dot.ko { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ko) 35%, transparent); }
}

/* ---- Formulaire public ---- */
.check-object { color: var(--muted); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85rem; }
.options { display: grid; gap: 8px; margin: 12px 0 20px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 400;
  cursor: pointer;
  margin: 0;
}
.option:has(input:checked) { border-color: var(--accent); outline: 1px solid var(--accent); }
.option input { width: 18px; height: 18px; margin: 0; }
.btn-block { width: 100%; padding: 12px; font-size: 1rem; }

/* ---- QR codes ---- */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
/* Étiquette Preflight (image SVG complète, apps/preflight/lib/label.js) + liens de téléchargement dessous. */
.qr-card { text-align: center; break-inside: avoid; }
.qr-card > svg { width: 100%; max-width: 260px; height: auto; display: block; margin: 0 auto; }
.qr-meta { max-width: 260px; margin: 6px auto 0; }
.qr-card .qr-url { font-size: 0.65rem; color: var(--muted); word-break: break-all; }
/* Formats Medium et Small : étiquettes plus petites, plus nombreuses par ligne. */
.qr-grid.size-medium { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.qr-grid.size-medium .qr-card > svg, .qr-grid.size-medium .qr-meta { max-width: 200px; }
.qr-grid.size-small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.qr-grid.size-small .qr-card > svg { max-width: 130px; }
.qr-grid.size-small .qr-meta { max-width: 150px; }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); gap: 10mm; }
  .qr-grid.size-medium { grid-template-columns: repeat(4, 1fr); gap: 8mm; }
  .qr-grid.size-small { grid-template-columns: repeat(6, 1fr); gap: 6mm; }
  .qr-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; } /* garde les bandeaux bleus */
  .qr-card > svg { max-width: none; }
}


/* ---- Lignes cliquables (liste des objets) ---- */
.rows { list-style: none; margin: -8px -12px; padding: 0; }
.rows li + li { border-top: 1px solid var(--border); }
.row-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text);
  transition: background-color 0.15s;
}
.row-link:hover { background: var(--hover); color: var(--text); }
.row-link .grow { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.row-dots .dot { width: 10px; height: 10px; }
.chevron {
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 0.2s ease, color 0.15s;
}
.row-link:hover .chevron { transform: translateX(4px); color: var(--accent); }

/* ---- Animations ---- */

/* Apparition des cartes au chargement, l'une après l'autre. */
@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
}
/* Courte et sans cascade : le contenu doit apparaître tout de suite, l'animation n'est qu'un adoucissement. */
main .card { animation: enter 0.15s ease-out both; }
.no-enter .card { animation: none; }

/* Dashboard : point qui vient de changer d'état en direct. */
.dot.ok { color: var(--ok); }
.dot.ko { color: var(--ko); }
.dot.none { color: var(--none-ring); }
@keyframes pop {
  0% { transform: scale(0.6); }
  40% { transform: scale(1.35); box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 35%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px transparent; }
}
.cp-list .dot.changed { animation: pop 0.6s ease-out; }
.cp-list .dot.ko.changed { animation: pop 0.6s ease-out, blink 1s ease-in-out 0.6s infinite; }

/* Formulaire admin : choix ajoutés / retirés. */
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
}
@keyframes fade-out {
  to { opacity: 0; transform: translateX(12px); }
}
.choice-row.entering { animation: slide-in 0.2s ease-out; }
.choice-row.leaving { animation: fade-out 0.2s ease-in forwards; pointer-events: none; }

/* Formulaire public : coche de confirmation. */
.done { text-align: center; padding: 28px 20px; }
.done p { margin: 12px 0 0; font-weight: 600; }
.check-anim { width: 64px; height: 64px; fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check-anim circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.5s ease-out 0.1s forwards; }
.check-anim path { stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw 0.3s ease-out 0.55s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Message "Saved" après une action dans l'admin. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.95rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
  animation: toast-in 0.25s ease-out, toast-out 0.3s ease-in 2.7s forwards;
  pointer-events: none;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 10px); } }

/* Bascule de thème en douceur (classe posée seulement pendant le changement). */
.theme-anim, .theme-anim * {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s !important;
}

/* Respect du réglage "réduire les animations" de l'appareil. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .check-anim circle, .check-anim path { animation-delay: 0s !important; }
}

/* ---- Types : onglets et boîtes du dashboard ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.tabs[hidden] { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tab-alert { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ko); }
.tab.has-ko .tab-alert { display: inline-block; animation: blink 1s ease-in-out infinite; }

.group {
  background: var(--group-bg);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  animation: enter 0.15s ease-out both;
}
.no-enter .group { animation: none; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
}
.group-head h2 { margin: 0; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Admin : titres de groupes. */
.group-heading { display: flex; align-items: baseline; gap: 8px; }

/* Page d'un objet : choix du type à côté des boutons. */
.type-picker { display: flex; align-items: center; gap: 8px; }
.type-picker label { margin: 0; font-weight: 400; }
.type-picker select { width: auto; padding: 8px 10px; }

/* ---- Types de réponse ---- */
[hidden] { display: none !important; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.kind-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kind-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.kind-option:hover { background: var(--hover); }
.kind-option:has(input:checked) { border-color: var(--accent); outline: 1px solid var(--accent); }
.kind-option input { margin-top: 4px; }
.kind-option > span { display: flex; flex-direction: column; line-height: 1.35; }
.range-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-row input { flex: 1; min-width: 80px; }
.range-row input.unit { flex: 1.3; }

/* Formulaire public */
.question legend { font-size: 1.05rem; margin-bottom: 0; }
.answer-field { margin: 12px 0 20px; }
.number-input { display: flex; align-items: center; gap: 10px; }
.number-input input { font-size: 1.3rem; padding: 12px 14px; font-variant-numeric: tabular-nums; }
.unit-suffix { font-size: 1.1rem; color: var(--muted); white-space: nowrap; }
.option input[type=checkbox] { width: 18px; height: 18px; margin: 0; }
textarea.short { min-height: 60px; }

/* ---- Échéances : formulaire et info-bulles "Next inspection" ---- */
.deadline-row { display: flex; gap: 8px; }
.deadline-row input { width: 90px; flex: none; }
.deadline-row select { width: auto; }

.has-tip, .cp-list li { position: relative; }
.has-tip { display: inline-flex; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 5;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  animation: tip-in 0.12s ease-out;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }
/* L'animation d'apparition isole chaque carte : la carte survolée passe devant pour que l'info-bulle ne soit pas masquée. */
main .card, .row-link { position: relative; }
main .card:hover, .row-link:hover { z-index: 3; }

/* Page d'un objet : prochaine inspection de chaque point. */
.next-inspection { display: flex; flex-direction: column; min-width: 140px; line-height: 1.3; }
.next-inspection strong { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.next-inspection.due strong { color: var(--ko); }

/* ---- Dashboard : barre de progression vert / rouge / noir ---- */
.progress { position: relative; padding: 4px 0; } /* zone de survol un peu plus haute que la barre */
.progress .bar {
  display: flex;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.progress .seg { display: block; height: 100%; transition: width 0.4s ease; }
.progress .seg.ok { background: var(--ok); }
.progress .seg.ko { background: var(--ko); }
.progress .seg.none { background: var(--none); }
/* Sur une carte d'objet, la barre forme le bord supérieur (collée au bord, coins arrondis de la carte). */
.card > .progress { margin: -20px -20px 14px; padding: 0 0 4px; }
.card > .progress .bar { height: 6px; border-radius: 9px 9px 0 0; }
.group-head .progress { flex: 1 1 60px; max-width: 200px; margin-left: auto; }
.group-head { align-items: center; }

/* ---- Calendrier ---- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.cal-toolbar select { width: auto; } /* filtres à leur largeur naturelle (la règle générale des select prend toute la ligne) */
.cal-nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.cal-nav h2 { margin: 0 0 0 8px; font-size: 1.15rem; }
.cal-nav button { padding: 6px 12px; }
#cal-type { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; border-radius: 0; background: var(--card); color: var(--text); padding: 6px 14px;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--hover); color: var(--text); }
.segmented button.active { background: var(--text); color: var(--bg); }
.segmented button:active { transform: none; }

/* Couleur de charge : de plus en plus foncée avec le nombre d'inspections. */
/* Valeur par défaut (calendriers sans niveau de charge, ex. Time Off) : sinon le fond des cases est ignoré (transparent). */
:root { --load: transparent; }
.load-0 { --load: transparent; }
.load-1 { --load: color-mix(in srgb, var(--accent) 12%, transparent); }
.load-2 { --load: color-mix(in srgb, var(--accent) 26%, transparent); }
.load-3 { --load: color-mix(in srgb, var(--accent) 42%, transparent); }
.load-4 { --load: color-mix(in srgb, var(--accent) 60%, transparent); }

.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.cal-dow { font-size: 0.8rem; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(var(--load), var(--load)), var(--card);
  color: var(--text);
  text-align: left;
  font-size: 0.9rem;
}
.cal-cell:hover { background: linear-gradient(var(--load), var(--load)), var(--hover); color: var(--text); }
.cal-cell:active { transform: scale(0.98); }
.cal-cell.outside { opacity: 0.45; }
.cal-cell.past .cal-date { color: var(--muted); }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-cell.selected { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-date { font-weight: 600; }
.cal-cell .cal-count { font-size: 1.35rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cal-overdue {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--on-color);
  background: var(--ko);
  padding: 1px 7px;
  border-radius: 999px;
}

.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.cal-item:last-child { border-bottom: 0; }
.cal-item-main { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.cal-item-time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-item.overdue .cal-item-time { color: var(--ko); font-weight: 600; }
#cal-day h2 { display: flex; align-items: baseline; gap: 10px; }

.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.cal-col { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 140px; }
.cal-col.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-col.past { opacity: 0.6; }
.cal-col header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 0.9rem; }
.cal-col .cal-count { font-weight: 700; }
/* Colonnes étroites : l'heure passe sous le nom pour ne pas chevaucher le texte. */
.cal-col .cal-item { gap: 2px 6px; flex-wrap: wrap; align-items: flex-start; }
.cal-col .cal-item .dot { margin-top: 3px; }
.cal-col .cal-item-main { flex: 1 1 0; overflow-wrap: anywhere; }
.cal-col .cal-item-time { flex-basis: 100%; padding-left: 20px; font-size: 0.75rem; white-space: normal; }
.cal-col .cal-item-main strong { font-size: 0.85rem; }
@media (max-width: 900px) {
  .cal-week { grid-template-columns: 1fr; }
  .cal-cell { min-height: 56px; padding: 6px; }
  .cal-cell .cal-count { font-size: 1.05rem; }
  .cal-overdue { font-size: 0.65rem; }
}

/* ---- Horaire d'un point : heure de début + jours travaillés ---- */
.schedule-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.inline-label { margin: 0; font-weight: 400; }
.schedule-row input[type=time] { width: auto; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.weekday { margin: 0; font-weight: 400; cursor: pointer; }
.weekday input { position: absolute; opacity: 0; pointer-events: none; }
.weekday span {
  display: inline-block;
  min-width: 48px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-align: center;
  font-size: 0.9rem;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.weekday:hover span { background: var(--hover); }
.weekday input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); }
.weekday input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Dashboard plein écran (télés) ---- */
.head-actions { display: flex; align-items: center; gap: 12px; }
html.tv .topbar { display: none; }
html.tv { scrollbar-gutter: auto; } /* télé : pas de barre du haut à stabiliser, toute la largeur pour le dashboard */
html.tv main.full { padding-top: 20px; }
html.idle, html.idle * { cursor: none !important; }
html.idle #fullscreen { opacity: 0; }
#fullscreen { transition: opacity 0.3s; }

/* Grands écrans : tout grossit pour rester lisible de loin. */
@media (min-width: 1600px) {
  main.full { font-size: 1.15rem; }
  main.full #objects { --card-w: 320px; }
  main.full .dot.big { width: 22px; height: 22px; }
  main.full .card > .progress .bar { height: 8px; }
}
@media (min-width: 2400px) {
  main.full { font-size: 1.4rem; }
  main.full #objects { --card-w: 400px; }
  main.full .dot.big { width: 28px; height: 28px; }
}

/* ---- Dashboard : boîtes de type ajustées à leur contenu, côte à côte, objets centrés ---- */
#objects { --card-w: 280px; }
#objects .objects-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}
#objects .objects-grid > .card { width: var(--card-w); max-width: 100%; }
/* Boîtes de type en maçonnerie : placées par dashboard.js (position, largeur, --span = nombre de colonnes). */
#objects.grouped { position: relative; }
#objects.grouped > .group { position: absolute; margin: 0; max-width: none; box-sizing: border-box; }
#objects.grouped .objects-grid { display: grid; grid-template-columns: repeat(var(--span, 1), minmax(0, 1fr)); gap: 12px; }
#objects.grouped .objects-grid > .card { width: auto; }
/* Ordre réglable à la souris : objets (carte entière) et boîtes de type (par leur en-tête). */
#objects .card[data-obj], #objects .group-head { cursor: grab; }
/* Élément déplacé : soulevé (ombre, au premier plan), il suit la souris. */
#objects .dragging { position: relative; z-index: 20; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22); transition: none; animation: none !important; will-change: transform; } /* animation : sinon "enter" (fill both) écrase le déplacement */
#objects .group.dragging { background: linear-gradient(var(--group-bg), var(--group-bg)), var(--bg); } /* opaque : on ne voit pas à travers en passant sur les autres */
body.is-dragging { user-select: none; }
body.is-dragging, body.is-dragging #objects * { cursor: grabbing !important; }
body.is-dragging [data-tip]::after, body.is-dragging [data-tip]::before { display: none; } /* pas d'infobulle pendant le glisser */

/* ---- Fenêtre de confirmation de suppression (taper le nom) ---- */
.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.confirm-dialog[open] { animation: enter 0.2s ease-out; }
.confirm-dialog h2 { margin: 0 0 8px; overflow-wrap: anywhere; }
.confirm-dialog p { margin: 0 0 16px; }
.confirm-dialog label { font-weight: 400; }
.confirm-dialog input { margin-bottom: 16px; }
.btn-danger-solid { background: var(--ko); color: var(--on-color); }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--ko) 85%, #000); }
.btn-danger-solid:disabled { background: var(--border); color: var(--muted); }

/* Logo Preflight dans la barre du haut. */
.brand { display: inline-flex; align-items: center; gap: 7px; }
.brand img { display: block; border-radius: 4px; }

/* ---- Accueil de la plateforme : liste des outils ---- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s;
}
.tool-card:hover { background: var(--hover); border-color: var(--accent); color: var(--text); }
.tool-card img { border-radius: 8px; flex: none; }
.tool-card > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.tool-card:hover .chevron { transform: translateX(4px); color: var(--accent); }

/* ---- Sélecteur d'outils (barre du haut) ---- */
.tool-switcher { position: relative; }
.tool-switcher summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.tool-switcher summary::-webkit-details-marker { display: none; }
.tool-switcher summary:hover, .tool-switcher[open] summary { background: var(--hover); color: var(--text); }
/* Icônes flottantes : pas de panneau, chaque application descend en cascade (--i : rang) sous le bouton. */
.tool-float-list {
  position: absolute;
  /* Bulles (46 px) centrées sur l'axe du bouton (32 px), et sous la bande d'en-tête avec un peu d'air. */
  left: -7px;
  top: calc(100% + 22px);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
/* Flou seulement derrière les bulles, aux bords fondus (masque radial) : le texte de la page ne gêne plus. */
.tool-float-list::before {
  content: "";
  position: absolute;
  inset: -60px -140px -70px -60px; /* zone large : le bord a de la place pour s'estomper */
  z-index: -1;
  background: rgba(238, 243, 248, 0.45);
  backdrop-filter: blur(5px);
  /* Bord très progressif (plusieurs paliers) : pas de limite visible entre le flou et la page nette. */
  --tool-veil-mask: radial-gradient(ellipse 50% 50% at 38% 50%, #000 0%, rgba(0, 0, 0, 0.92) 30%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0.4) 68%, rgba(0, 0, 0, 0.15) 84%, transparent 100%);
  -webkit-mask-image: var(--tool-veil-mask);
  mask-image: var(--tool-veil-mask);
  animation: tool-veil-in 0.25s ease-out both;
}
:root[data-theme="dark"] .tool-float-list::before { background: rgba(10, 27, 46, 0.5); }
@keyframes tool-veil-in { from { opacity: 0; } }
/* Fermeture (classe "closing", posée par le script le temps de l'animation) : bulles qui remontent et s'effacent, flou en fondu. */
.tool-switcher.closing .tool-float { animation: tool-lift 0.2s ease-in both; animation-delay: calc(var(--i, 0) * 25ms); }
.tool-switcher.closing .tool-float-list::before { animation: tool-veil-out 0.25s ease-in both; }
@keyframes tool-lift { to { opacity: 0; transform: translateY(-10px) scale(0.92); } }
@keyframes tool-veil-out { to { opacity: 0; } }
/* Zones cliquables jointives (marge intérieure, pas d'espace entre elles) : le survol passe d'une bulle à l'autre sans trou. */
.tool-float {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 5px 14px 5px 0;
  color: var(--text);
  animation: tool-drop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes tool-drop {
  from { opacity: 0; transform: translateY(-18px) scale(0.85); }
}
.tool-float-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(10, 27, 46, 0.16);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.tool-float-icon img { display: block; border-radius: 7px; }
.tool-float-name {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(10, 27, 46, 0.12);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.tool-float:hover { color: var(--text); }
.tool-float:hover .tool-float-icon, .tool-float:focus-visible .tool-float-icon { transform: scale(1.08); border-color: var(--accent); box-shadow: 0 8px 22px rgba(10, 27, 46, 0.22); }
/* Application en cours : anneau de couleur d'accent. */
.tool-float.current .tool-float-icon { border: 2px solid var(--accent); }
.tool-float.current .tool-float-name { color: var(--accent); }
:root[data-theme="dark"] .tool-float-icon, :root[data-theme="dark"] .tool-float-name { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
@media (prefers-reduced-motion: reduce) { .tool-float, .tool-float-list::before { animation: none !important; } }
html.tv .tool-switcher { display: none; }

/* Boîtes de type du dashboard : la boîte survolée passe devant ses voisines (l'animation d'apparition
   isole chaque boîte), et la bulle de la barre de progression s'ouvre vers la gauche, à l'intérieur de la boîte. */
.group { position: relative; }
.group:hover { z-index: 4; }
.group-head .progress[data-tip]:hover::after { left: auto; right: 0; }
.group-head .muted.small { white-space: nowrap; }

/* ---- Dashboard Preflight : fil des scans (en haut à droite) ---- */
.killfeed {
  position: fixed;
  top: 128px; /* valeur de départ ; recalculée par dashboard.js pour se placer sous l'en-tête */
  right: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}
.kill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  animation: kill-in 0.3s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.kill.ok { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), inset 0 0 0 1px color-mix(in srgb, var(--ok) 45%, transparent); }
.kill.ko { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), inset 0 0 0 1px color-mix(in srgb, var(--ko) 45%, transparent); }
.kill .dot { width: 16px; height: 16px; flex: none; }
.kill-body { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.kill-body strong, .kill-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kill-body span { color: var(--muted); font-size: 0.85rem; }
/* Commentaire du scan : en italique, entre guillemets (<q>), sur 2 lignes au plus. */
.kill-body .kill-comment {
  margin-top: 3px;
  color: var(--text);
  font-size: 0.85rem;
  font-style: italic;
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  quotes: "“" "”";
}
.kill-time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; flex: none; }
.kill.leaving { opacity: 0; transform: translateX(24px); }
@keyframes kill-in { from { opacity: 0; transform: translateX(40px); } }
@media (min-width: 1600px) {
  .killfeed { width: 400px; }
  .kill { padding: 12px 14px; font-size: 1.05rem; }
}
