/**
 * Back-office Sonnette (console) : coquille à menu latéral, pages et composants.
 * Couleurs de l'ardoise (variables --sn-* émises par la coquille, mode sombre
 * compris) ; couleurs d'état fixes, choisies pour un œil daltonien et toujours
 * doublées d'un libellé écrit.
 */

@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-hyperlegible-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-hyperlegible-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bo-bleu: #0057D9; --bo-sur-bleu: #FFFFFF; --bo-bleu-texte: #0057D9;
  --bo-jaune: #F2A900; --bo-sur-jaune: #2B2B2B; --bo-jaune-texte: #9A6A00;
  --bo-rouge: #E3000F; --bo-sur-rouge: #FFFFFF; --bo-rouge-texte: #B5000C;
  --bo-noir: #2B2B2B; --bo-sur-noir: #FFFFFF;
  --bo-gris: #C4CCD4; --bo-sur-gris: #2B2B2B;
  --bo-surface: var(--sn-surface, #FFFFFF);
  --bo-titre: "Bricolage Grotesque", system-ui, sans-serif;
  --bo-texte: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.op-body { font-family: var(--bo-texte); }

/* ---------------------------------------------------------- Coquille */

.bo { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.bo-menu { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--sn-primary); color: var(--sn-on-primary); overflow-y: auto; }
.bo-marque { display: flex; align-items: center; gap: 10px; padding: 4px 10px 10px; color: inherit; text-decoration: none; font: 700 1.25rem/1 var(--bo-titre); }
.bo-marque small { font: 400 0.8rem var(--bo-texte); opacity: 0.75; margin-left: 4px; }
.bo-marque__cloche { width: 26px; height: 26px; }
.bo-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.bo-nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 0.95rem; opacity: 0.86; }
.bo-nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.bo-nav a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, 0.16); box-shadow: inset 3px 0 0 var(--sn-on-primary); }
.bo-nav__picto { width: 20px; height: 20px; flex: none; }
.bo-menu__pied { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; font-size: 0.82rem; }
.bo-menu__qui { opacity: 0.8; overflow-wrap: anywhere; }
.bo-quitter { align-self: flex-start; font: inherit; font-weight: 700; background: rgba(255, 255, 255, 0.16); color: inherit; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 38px; cursor: pointer; }

.bo-page { min-width: 0; display: flex; flex-direction: column; }
.bo-barre { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 28px; background: var(--sn-bg); border-bottom: 1px solid var(--sn-border); }
.bo-titre { font: 700 1.6rem/1.15 var(--bo-titre); margin-right: auto; overflow-wrap: anywhere; }
.bo-recherche input { width: min(340px, 70vw); min-height: 42px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--sn-border); background: var(--bo-surface); color: var(--sn-text); font: inherit; }
.bo-contenu { display: flex; flex-direction: column; gap: 20px; padding: 22px 28px 60px; max-width: 1360px; width: 100%; }

@media (max-width: 900px) {
  .bo { grid-template-columns: 1fr; }
  .bo-menu { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 8px; }
  .bo-nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .bo-nav a { white-space: nowrap; min-height: 40px; }
  .bo-menu__pied { margin: 0 0 0 auto; flex-direction: row; align-items: center; padding: 0; }
  .bo-menu__qui { display: none; }
  .bo-barre { position: static; padding: 12px 16px; }
  .bo-contenu { padding: 16px 16px 48px; }
}

/* ---------------------------------------------------------- Cartes et grilles */

.bo-carte { background: var(--bo-surface); border: 1px solid var(--sn-border); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bo-carte--jaune { border-left: 5px solid var(--bo-jaune); }
.bo-carte__titre { font: 700 1.1rem/1.25 var(--bo-titre); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bo-carte__sous-titre { font-size: 0.95rem; font-weight: 700; margin-top: 6px; }
.bo-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; align-items: start; }
.bo-pli summary { cursor: pointer; }
.bo-compteur { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--sn-text); color: var(--bo-surface); font: 700 0.85rem var(--bo-texte); }

.bo-tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.bo-tuile { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--sn-border); background: var(--bo-surface); color: inherit; text-decoration: none; }
a.bo-tuile:hover { border-color: var(--sn-text); }
.bo-tuile__valeur { font: 700 1.75rem/1.1 var(--bo-titre); font-variant-numeric: tabular-nums; }
.bo-tuile__valeur small { font-size: 1rem; color: var(--sn-muted); }
.bo-tuile__libelle { font-size: 0.86rem; color: var(--sn-muted); }
.bo-tuile--bleu { box-shadow: inset 0 4px 0 var(--bo-bleu); }
.bo-tuile--jaune { box-shadow: inset 0 4px 0 var(--bo-jaune); }
.bo-tuile--alerte { box-shadow: inset 0 4px 0 var(--bo-rouge); }
.bo-tuile--alerte .bo-tuile__libelle::after { content: " : à regarder"; color: var(--bo-rouge-texte); font-weight: 700; }

/* ---------------------------------------------------------- Badges d'état */

.bo-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; border: 2px solid transparent; }
.bo-badge--bleu { background: var(--bo-bleu); color: var(--bo-sur-bleu); }
.bo-badge--jaune { background: var(--bo-jaune); color: var(--bo-sur-jaune); }
.bo-badge--gris { background: var(--bo-gris); color: var(--bo-sur-gris); }
.bo-badge--noir { background: var(--bo-noir); color: var(--bo-sur-noir); }
.bo-badge--rouge { background: var(--bo-rouge); color: var(--bo-sur-rouge); }
.bo-badge--bleu-trait { border-color: var(--bo-bleu); color: var(--bo-bleu-texte); }
.bo-badge--rouge-trait { border-color: var(--bo-rouge); color: var(--bo-rouge-texte); }
.bo-badge--noir-trait { border-color: var(--bo-noir); color: var(--sn-text); }
.bo-badge--gris-trait { border-color: var(--bo-gris); color: var(--sn-muted); }

/* ---------------------------------------------------------- À traiter */

.bo-taches { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.bo-tache { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; background: var(--sn-bg); }
.bo-tache a { color: inherit; font-weight: 700; text-decoration: none; }
.bo-tache a:hover { text-decoration: underline; }
.bo-tache__niveau { flex: none; min-width: 92px; text-align: center; padding: 3px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.bo-tache--critique .bo-tache__niveau { background: var(--bo-rouge); color: var(--bo-sur-rouge); }
.bo-tache--chaud .bo-tache__niveau { background: var(--bo-jaune); color: var(--bo-sur-jaune); }
.bo-tache--info .bo-tache__niveau { background: var(--bo-gris); color: var(--bo-sur-gris); }

/* ---------------------------------------------------------- Entonnoir et jauges */

.bo-entonnoir { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.bo-entonnoir li { display: grid; grid-template-columns: 110px minmax(0, 1fr) 44px 48px; align-items: center; gap: 10px; }
.bo-entonnoir__libelle { font-size: 0.9rem; }
.bo-entonnoir b { text-align: right; font-variant-numeric: tabular-nums; }
.bo-entonnoir__passage { font-size: 0.8rem; color: var(--sn-muted); font-variant-numeric: tabular-nums; }
.bo-jauge { display: block; height: 12px; border-radius: 999px; background: var(--sn-bg); border: 1px solid var(--sn-border); overflow: hidden; }
.bo-jauge--courte { display: inline-block; width: 56px; height: 9px; vertical-align: middle; margin-right: 8px; }
.bo-jauge__barre { display: block; height: 100%; width: 0; background: var(--bo-bleu); border-radius: 999px; }
.bo-chaleur { display: inline-flex; align-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- Tableaux */

.bo-tableau-defile { overflow-x: auto; }
.bo-tableau { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bo-tableau th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sn-muted); padding: 8px 10px; border-bottom: 1.5px solid var(--sn-border); white-space: nowrap; }
.bo-tableau td { padding: 10px; border-bottom: 1px solid var(--sn-border); vertical-align: top; }
.bo-tableau tbody tr:hover { background: var(--sn-bg); }
.bo-tableau--compact td, .bo-tableau--compact th { padding: 6px 8px; }
.bo-tableau th[data-tri] { cursor: pointer; user-select: none; }
.bo-tableau th[data-tri]::after { content: " ↕"; opacity: 0.45; }
.bo-tableau th[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; }
.bo-tableau th[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }
.bo-tableau__nom { font-weight: 700; color: var(--sn-text); text-decoration: none; }
.bo-tableau__nom:hover { text-decoration: underline; }
.bo-nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bo-eteint { opacity: 0.6; }
.bo-tableau time { white-space: nowrap; }
.bo-tableau .bo-ecart { display: block; }
.bo-tableau td:first-child { min-width: 190px; }

/* ---------------------------------------------------------- Boutons (liens comme boutons) */

.bo-contenu .op-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; text-decoration: none; border: 1.5px solid var(--sn-border); background: var(--bo-surface); color: var(--sn-text); }
.bo-contenu .op-button:hover { border-color: var(--sn-text); }
.bo-contenu .op-button--primary { background: var(--sn-primary); color: var(--sn-on-primary); border-color: var(--sn-primary); }

/* ---------------------------------------------------------- Fiche compte */

.bo-entete { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.bo-entete__titre { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bo-actions form { margin: 0; }
.bo-champs { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 8px 14px; font-size: 0.92rem; }
.bo-champs dt { color: var(--sn-muted); }
.bo-champs dd { margin: 0; overflow-wrap: anywhere; }
.bo-copie { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; font-weight: 700; }
.bo-copie input, .bo-copie-ligne input { width: 100%; min-height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--sn-border); background: var(--sn-bg); color: var(--sn-text); font: 400 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace; cursor: copy; }
.bo-copie-ligne { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.bo-note { display: flex; flex-direction: column; gap: 8px; }
.bo-note textarea { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--sn-border); background: var(--sn-bg); color: var(--sn-text); font: inherit; resize: vertical; }
.bo-note button { align-self: flex-start; }
.bo-notes { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.bo-notes li { padding: 10px 12px; border-radius: 10px; background: var(--sn-bg); }

/* ---------------------------------------------------------- Listes, journal, filtres */

.bo-liste { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.bo-liste a { color: var(--sn-text); font-weight: 700; }
.bo-journal { list-style: none; display: flex; flex-direction: column; font-size: 0.9rem; }
.bo-journal li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--sn-border); }
.bo-journal__quand { flex: 0 0 170px; }
.bo-journal li > a { font-weight: 700; color: var(--sn-text); }
.bo-journal__quand { color: var(--sn-muted); font-size: 0.85rem; }
@media (max-width: 600px) { .bo-journal__quand { flex-basis: 100%; } }
.bo-filtres { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; font-size: 0.86rem; }
.bo-filtres label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.bo-filtres select, .bo-filtres input { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--sn-border); background: var(--bo-surface); color: var(--sn-text); font: inherit; }
.bo-filtres__compte { margin-left: auto; color: var(--sn-muted); }
.bo-pastilles { display: flex; gap: 6px; flex-wrap: wrap; }
.bo-pastilles a { padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--sn-border); color: var(--sn-text); text-decoration: none; font-size: 0.86rem; font-weight: 700; }
.bo-pastilles a[aria-current="page"] { background: var(--sn-text); color: var(--bo-surface); border-color: var(--sn-text); }

/* ---------------------------------------------------------- Histogrammes */

.bo-barres { width: 100%; height: auto; display: block; }
.bo-barres__barre { fill: var(--bo-bleu); }
.bo-barres__axe { stroke: var(--sn-border); stroke-width: 1; }
.bo-barres__valeur { fill: var(--sn-text); font: 700 11px var(--bo-texte); text-anchor: middle; }
.bo-barres__etiquette { fill: var(--sn-muted); font: 400 10px var(--bo-texte); text-anchor: middle; }

/* ---------------------------------------------------------- Petits textes */

.bo-sous { display: block; font-size: 0.8rem; color: var(--sn-muted); font-weight: 400; }
.bo-ecart { font-size: 0.8rem; color: var(--sn-muted); }
.bo-vide { color: var(--sn-muted); font-style: italic; }
.bo-lien { color: var(--bo-bleu); font-weight: 700; }

.bo-alerte { padding: 10px 12px; border-radius: 10px; border: 2px solid var(--bo-rouge); color: var(--bo-rouge-texte); font-weight: 700; }
.bo-code { font: 0.78rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--sn-muted); overflow-wrap: anywhere; }
.bo-visuel-masque { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Mailing ----------------------------------------------------------------- */
.bo-flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; border: 2px solid var(--bo-bleu); }
.bo-flash--erreur { border-color: var(--bo-rouge); color: var(--bo-rouge-texte); }
.bo-grille--mailing { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.bo-redaction { display: flex; flex-direction: column; gap: 14px; }
.bo-deux { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.op-field textarea {
  font: inherit; font-size: 0.95rem; line-height: 1.5; width: 100%; padding: 10px 12px; resize: vertical;
  border: 1.5px solid var(--sn-border); border-radius: 10px; background: var(--sn-bg); color: var(--sn-text);
}
.op-field textarea:focus { outline: none; border-color: var(--sn-primary); box-shadow: 0 0 0 3px var(--sn-primary-soft); }
.op-field select[disabled] { opacity: 0.7; }
.bo-variables summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.bo-variables code, .bo-redaction code { font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.bo-message {
  margin: 12px 0; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--bo-gris);
  font: 0.92rem/1.55 var(--bo-texte); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 560px; overflow: auto;
}
.bo-entetes-mail { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 0.9rem; }
.bo-entetes-mail dt { color: var(--sn-muted); }
.bo-entetes-mail dd { margin: 0; overflow-wrap: anywhere; }
.bo-case { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; font-weight: 600; }
.bo-case input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--bo-bleu); }
.bo-tableau td.bo-actions { align-items: center; }
.bo-filtres input { min-width: min(100%, 300px); }

/* Suppression définitive : trait rouge, libellé écrit (jamais la couleur seule). */
.bo-carte--danger { border: 2px solid var(--bo-rouge); }

/* Petit formulaire en ligne dans une carte de la fiche (responsable). */
.bo-formulaire-ligne { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 12px; }
.bo-formulaire-ligne label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; font-size: 0.85rem; color: var(--sn-muted); }
.bo-formulaire-ligne input { min-height: 40px; padding: 0 10px; border: 1px solid var(--sn-border); border-radius: 10px; background: var(--bo-surface); color: var(--sn-text); font: inherit; }
.bo-notes .bo-actions { margin-top: 6px; }
.bo-filtres__case { flex-direction: row !important; align-items: center; gap: 6px; }

/* Préparer une app : formulaire en grille, propositions de fiches Google. */
.bo-preparer { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.bo-preparer label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--sn-muted); position: relative; }
.bo-preparer input, .bo-preparer select { min-height: 40px; padding: 0 10px; border: 1px solid var(--sn-border); border-radius: 10px; background: var(--bo-surface); color: var(--sn-text); font: inherit; }
.bo-preparer__fiche { grid-column: 1 / -1; }
.bo-preparer__propositions { display: flex; flex-direction: column; border: 1px solid var(--sn-border); border-radius: 10px; background: var(--bo-surface); overflow: hidden; }
.bo-preparer__choix { padding: 10px 12px; border: 0; border-bottom: 1px solid var(--sn-border); background: transparent; color: var(--sn-text); text-align: left; font: inherit; cursor: pointer; }
.bo-preparer__choix:hover, .bo-preparer__choix:focus-visible { background: var(--sn-surface); }
