/* Charte HAFA dérivée des maquettes design/project/*.dc.html. */
:root {
  --accent: #CF1740; --bg: #F4F4F1; --ink: #1C1C1C; --muted: #5C5B57; --line: #E3E2DE; --line2: #EEEDE9; --field: #F8F8F6;
  --late: #B32E2E; --late-bar: #d03b3b; --near: #8A5A00; --near-bar: #c98500; --ok: #006300;
  --title: Montserrat, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "Open Sans", system-ui, sans-serif; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--title); margin: 0; }
h1 { font-size: 32px; font-weight: 700; }
code { background: var(--line2); padding: 0 .25rem; border-radius: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.caps { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; } /* sinon le display d'une classe (.filters…) l'emporte sur l'attribut */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }

/* En-tête */
.top { background: #fff; border-bottom: 1px solid var(--line); padding: 0 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; font: 800 22px/1 var(--title); letter-spacing: .5px; color: var(--accent); }
.logo { width: 32px; height: 32px; border-radius: 6px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.brand-sub { font-weight: 600; font-size: 14px; color: var(--muted); letter-spacing: 0; border-left: 1px solid var(--line); padding-left: 12px; }
.brand-by { font-weight: 700; font-size: 15px; letter-spacing: 0; color: var(--ink); } /* nom de l'appli « KPI by HAFA » (Nicolas, 27/11/2026) */
.spacer { flex: 1 1 40px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav form { margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.who { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px 0 14px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2F3B52; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }

/* Barre de sélection et onglets */
.bar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 32px 0; display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0; }
.field { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); max-width: 100%; }
.field > span { color: var(--muted); }
.field select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); min-width: 0; max-width: 100%; }
.field:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; } /* le select sans bordure n'a pas de contour lisible */
.field :focus-visible { outline: 0; }
.scope { color: var(--muted); font-size: 13px; margin-left: auto; }
/* Onglets : passent à la ligne (Portefeuille en a 10) ; sur écran étroit, une ligne défilante au doigt (app.js centre l'actif). */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.tab { display: inline-flex; align-items: center; height: 44px; padding: 0 14px; border-bottom: 2px solid transparent; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); }
.admin-tabs { flex-direction: row; padding-top: 0; }
/* Sélecteur avec recherche (app.js) : bouton à la place du select, panneau sous le champ, arbre BU › équipe › commercial
   ou liste de clients. Le panneau se place sous le libellé du champ : pleine largeur (moins les marges) à 375 px. */
.field:has(.picker), .lab:has(.picker), .multi { position: relative; }
.picker { display: flex; min-width: 0; }
.picker-btn { display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; min-height: 38px; padding: 0; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.picker-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-btn::after, .multi > summary::after { content: ""; flex: none; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.lab .picker-btn { flex: 1; justify-content: space-between; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 400; }
.picker-panel { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: min(460px, calc(100vw - 32px)); padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(28, 28, 28, .12); font-weight: 400; }
.picker-q { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); font: inherit; color: var(--ink); }
.field .picker-q:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; } /* .field :focus-visible l'enlève */
.field:has(.picker-q:focus-visible) { outline: 0; } /* un seul contour : celui de la recherche */
.picker-list { position: relative; list-style: none; margin: 6px 0 0; padding: 0; max-height: min(60vh, 420px); overflow: auto; overscroll-behavior: contain; }
.picker-list li { display: flex; align-items: center; min-height: 36px; padding: 4px 8px 4px calc(8px + var(--d, 0) * 18px); border-radius: 6px; cursor: pointer; }
.picker-list li:hover { background: var(--field); }
.picker-list li.act { outline: 2px solid var(--accent); outline-offset: -2px; } /* élément actif au clavier (aria-activedescendant) */
.picker-list [aria-selected="true"] { background: #FBE9EE; color: var(--accent); font-weight: 600; }
.picker-list [aria-level="1"] { font-weight: 600; }
.picker-list [aria-disabled="true"] { color: var(--muted); cursor: default; }
.picker-tw { flex: none; align-self: stretch; width: 26px; margin: -4px 0 -4px -6px; display: inline-flex; align-items: center; justify-content: center; } /* toute la hauteur de la ligne */
[aria-expanded] > .picker-tw { cursor: pointer; }
[aria-expanded] > .picker-tw::before { content: ""; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(-45deg); }
[aria-expanded="true"] > .picker-tw::before { transform: rotate(45deg); }
.picker-list mark { background: #FFE3A3; color: inherit; border-radius: 2px; }
.picker-none { margin: 8px 4px 4px; }
/* Filtre à choix multiple (details.multi) : résumé façon champ (valeurs cochées), cases à cocher dans un .picker-panel. */
.multi > summary { cursor: pointer; list-style: none; }
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary > b { font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi .picker-panel { display: grid; max-height: min(60vh, 420px); overflow: auto; overscroll-behavior: contain; }
.bar .multi .picker-panel, .lab .multi .picker-panel { grid-template-columns: 1fr 1fr; width: min(320px, calc(100vw - 32px)); } /* 12 mois */
.lab .multi > summary { display: flex; justify-content: space-between; background: #fff; }
.lab .multi > summary > b { font-weight: 400; max-width: none; } /* composeur d'embeds : champ pleine largeur, comme .lab .picker-btn */
.multi .check { padding: 0 8px; border-radius: 6px; cursor: pointer; }
.multi .check:hover { background: var(--field); }
.multi .picker-panel .btn { grid-column: 1 / -1; justify-content: center; margin-top: 6px; }
.multi .check-all { grid-column: 1 / -1; border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; margin-bottom: 4px; } /* KPI Prod : « Toutes les machines » */
/* Écran en cours de rechargement après un choix (app.js) */
.busy { cursor: progress; }
.busy main { opacity: .5; transition: opacity .2s .2s; }

/* Pages */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 40px 32px 64px; display: flex; flex-direction: column; gap: 24px; }
.page.wide { max-width: 1376px; padding: 24px 32px 48px; gap: 20px; }
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.hello p { margin: 6px 0 0; font-size: 14px; }
.hello strong { color: var(--ink); }
.section { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Cartes d'applications (home) */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 20px; }
.cards.small { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.card { display: flex; flex-direction: column; gap: 16px; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 200px; }
.card.row { min-height: 0; gap: 2px; padding: 18px 20px; }
a.card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(28, 28, 28, .08); color: var(--ink); }
.card.soon { background: var(--field); border-style: dashed; } /* pas d'opacité : le texte gris resterait sous 4,5:1 */
.card.soon .app-ico { opacity: .65; }
.card.soon .open { color: var(--muted); }
.card-top, .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { display: flex; flex-direction: column; gap: 6px; }
.card-body h3 { font-size: 18px; font-weight: 700; }
.card-body p { margin: 0; font-size: 14px; }
.card-foot { margin-top: auto; color: var(--muted); font-size: 13px; }
.open { color: var(--accent); font-weight: 600; }
.app-ico { width: 44px; height: 44px; border-radius: 10px; background: #FBE9EE; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.app-ico.grey { background: #EEF1F6; color: #2F3B52; }
.badge { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.badge.soon { color: #7A4B00; background: #FFF3DD; border-color: transparent; }

/* Grille de tuiles : colonnes auto-fit, une tuile peut couvrir 2, 3 colonnes ou toute la largeur. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 16px; grid-auto-flow: dense; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }
.rows-2 { grid-row: span 2; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 10px; }
.tile-title { font-size: 15px; font-weight: 700; }
.tile-err { margin: 0; color: var(--late); }
.lbl { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.kpi { font: 700 28px/1 var(--title); font-variant-numeric: tabular-nums; }
.kpi sup { font-size: 14px; }
/* Tuile chiffre (kind stat) : le chiffre domine, proportionné à la largeur de la tuile ; descriptions en retrait. */
/* Taille commune à toutes les tuiles chiffre de la page (--kpi-size, posée par app.js : la plus grande qui fasse tenir
   tous les chiffres, entre 28 et 72 px) ; la tuile garde sa taille, un chiffre trop long malgré tout est coupé (…). */
.tile > .kpi { font-size: var(--kpi-size, 40px); margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile > .kpi.txt { font-size: min(var(--kpi-size, 40px), 24px); white-space: normal; text-overflow: clip; } /* texte (« Aucune vente ») : plus petit, sur plusieurs lignes */
/* En-tête des tuiles chiffre en deux rangées de hauteur fixe (titre sur 2 lignes au plus, puis statut) : le chiffre tombe
   à la même hauteur dans toutes les tuiles d'une rangée. */
.tile:has(> .kpi) > .tile-head { display: grid; grid-template-rows: calc(2 * 1.35 * 12px) 16px; gap: 4px; align-content: start; justify-items: start; }
.tile:has(> .kpi) > .tile-head .lbl { line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.tile:has(> .kpi) > .tile-head > :not(.lbl) { line-height: 16px; }
.tile > .kpi ~ .muted, .tile > .kpi ~ .delta { font-size: 12px; line-height: 1.35; }
.tile > .kpi ~ .sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; } /* texte complet au survol */
.ico { flex: none; }

/* Statuts d'objectif et variations : icône + libellé, jamais la couleur seule */
.status, .delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.status { font-size: 12px; }
.delta { font-size: 13px; }
.late, .down { color: var(--late); }
.near { color: var(--near); }
.ok, .up { color: var(--ok); }
.flat { color: var(--muted); }
.progress { height: 6px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.progress > span { display: block; height: 100%; }
.progress .late { background: var(--late-bar); }
.progress .near { background: var(--near-bar); }
.progress .ok { background: var(--ok); }

/* Graphiques */
.chart { display: block; height: auto; font-family: "Open Sans", sans-serif; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hbars li.me { font-weight: 600; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; border-radius: 5px; background: var(--line2); overflow: hidden; }
.hb-bar { display: block; height: 100%; background: #2a78d6; }
.hb-val { font-variant-numeric: tabular-nums; }
.rank { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.rank-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rank-list li span { margin-right: 8px; }
.rank-list li.me { font-weight: 700; }
/* Classement E9 : nom et valeur sur une ligne, barre fine dessous, nom jamais tronqué ; 3 colonnes au plus à l'écran
   (un embed garde ses colonnes : .embed .grid.cols-N, plus loin, l'emporte). */
.grid:has(.hbars.e9) { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.hbars.e9 { gap: 6px; }
.hbars.e9 li { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; }
.hbars.e9 .hb-label { white-space: normal; overflow-wrap: anywhere; }
.hbars.e9 .hb-track { grid-column: 1 / -1; height: 6px; }
.hbars.e9 li:not(.top3) .hb-bar { background: #B7B6AE; } /* hors top 3 : gris, comme Toucan */
.hbars.e9 li.top3 .hb-bar { background: var(--ok); }
.hbars.e9 li.top3 .hb-val { color: var(--ok); font-weight: 700; }

/* Tableaux (tuiles et administration) */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
tr:hover td { background: #FAFAF8; }
.tile th, .tile td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile th:first-child, .tile td:first-child { text-align: left; }
.tile td a { font-weight: 600; }
td.st { font-weight: 600; }
td.st .ico { margin-right: 4px; vertical-align: -1px; }
tr.muted-row td { color: var(--muted); }
.tile tr[data-level="1"] td:first-child { padding-left: 28px; }
.tile tr[data-level="2"] td:first-child { padding-left: 44px; }
.tile tr[data-level="3"] td:first-child { padding-left: 60px; }
svg.spark { vertical-align: middle; }
tr.total td { font-weight: 600; background: var(--field); }
td form { display: inline; }

@media (max-width: 800px) {
  .span-3 { grid-column: 1 / -1; }
  .rows-2 { grid-row: auto; }
  .top, .bar { padding-left: 16px; padding-right: 16px; }
  .page, .page.wide { padding: 20px 16px 40px; }
  .scope { margin-left: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } /* une ligne défilante au doigt */
  h1 { font-size: 26px; }
}
@media (max-width: 540px) {
  .span-2 { grid-column: 1 / -1; }
  .brand-sub { display: none; }
}

/* Fraîcheur SPACE_DATA (internal/kpi/fresh.go) : pseudo-tuile en tête de grille, sans carte. */
.tile:has(> .fresh) { background: none; border: 0; padding: 0; }
.fresh { margin: 0; font-size: 13px; color: var(--muted); text-align: right; }
.fresh.reload { text-align: left; padding: 10px 14px; border-radius: 8px; background: #FFF3DD; color: #7A4B00; font-weight: 600; }

/* Admin › Données */
.dn-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 0; }
.dn-form .lab:has([type="file"]) { flex: 1 1 240px; }
/* Embeds : page publique plein écran (colonnes et thème choisis à l'enregistrement), composeur d'Admin › Embeds. */
.embed-page { min-height: 100vh; padding: 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.embed-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.embed-head h1 { font-size: 22px; flex: 1 1 300px; }
@media (min-width: 801px) {
  .embed .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .embed .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .embed .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .embed .grid.cols-2 .span-3 { grid-column: 1 / -1; } /* sinon la grille ajoute une colonne implicite */
}
/* Embed : chaque tuile dans une cellule dont la largeur et la hauteur (grid-column/row: span) sont fixées à la composition. */
.embed .grid { grid-auto-rows: minmax(120px, auto); }
/* Écran (≥ 801 px) : l'embed tient exactement dans la fenêtre, jamais de défilement ; les lignes de la grille se partagent
   la hauteur restante à parts égales et chaque tuile coupe ce qui dépasse (l'éditeur d'Admin › Embeds montre ces proportions). */
@media (min-width: 801px) {
  .embed-page { height: 100vh; min-height: 0; overflow: hidden; }
  .embed .grid { flex: 1; min-height: 0; grid-auto-rows: minmax(0, 1fr); }
  .embed .cell, .embed .cell > .tile { min-height: 0; }
  .embed .cell > .tile { overflow: hidden; }
  .embed .cell .chart { max-height: 100%; min-height: 0; }
}
.embed .cell { display: flex; min-width: 0; }
.embed .cell > .tile { flex: 1; }
/* Chiffre à logo (Taux 3C) : logo et chiffre proportionnés à la largeur de la tuile (unités cqi), sans déborder d'une tuile étroite. */
.kpi-logo { container-type: inline-size; display: flex; align-items: center; justify-content: center; margin-block: auto; cursor: default; } /* hauteur = celle du logo, centrée dans la tuile : le chiffre se cale sur le bas du C quelle que soit la hauteur de la tuile */
.kpi-logo img { flex: 0 1 55cqi; min-width: 0; max-width: 320px; height: auto; aspect-ratio: 1; object-fit: contain; }
.kpi-logo .kpi.txt { align-self: center; margin: 0 0 0 2cqi; font-size: clamp(16px, 6cqi, 32px); white-space: normal; color: var(--muted); } /* « Aucune livraison » : à côté du logo, sans déborder */
.kpi-logo .kpi { align-self: flex-end; margin: 0 0 12cqi -12cqi; line-height: 1; font-size: clamp(26px, 19cqi, 110px); white-space: nowrap; } /* chevauche le C du logo */
.sent { font-size: 12px; font-weight: 700; }
/* Admin › Seuils : couleur du chiffre selon des bornes (règles « si valeur > X, alors couleur »). */
.seuil { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.seuil > span { flex: 0 1 320px; font-weight: 600; }
.rules { flex: 1 1 320px; }
.rules summary { cursor: pointer; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.rules summary::before { content: "▸ Couleurs"; font-weight: 600; color: var(--ink); margin-right: 4px; }
.rules[open] summary::before { content: "▾ Couleurs"; }
.sent-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); white-space: nowrap; }
.sent-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.rules-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 6px; }
.sentiment { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.sentiment select, .sentiment input[type=number] { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font: inherit; background: #fff; color: var(--ink); }
.sentiment input[type=number] { width: 90px; }
.sentiment input[type=text] { width: 150px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; background: #fff; color: var(--ink); }
.sentiment input[type=color] { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.sentiment .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.sentiment .sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
@media (min-width: 801px) { .embed .grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .embed .grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } .embed .grid.cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
@media (max-width: 800px) { .embed-page { padding: 16px; } .embed .cell { grid-column: auto !important; grid-row: auto !important; } }
body.dark { --bg: #141413; --ink: #F4F4F1; --muted: #B7B6AE; --line: #33332F; --line2: #2C2C2A; --field: #262624;
  --late: #FF8A80; --near: #F0B44C; --ok: #6CCB5F; } /* statuts éclaircis : contraste lisible sur fond sombre */
.dark .tile { background: #1F1F1E; }
/* Couleurs des seuils (Admin › Seuils, posées en style par kind-stat) : les trois teintes de la charte sont éclaircies comme
   les statuts, sinon un chiffre vert ou rouge se lit mal sur un écran d'atelier sombre ; une autre teinte reste telle quelle. */
.dark [style*="color:#006300" i] { color: var(--ok) !important; }
.dark [style*="color:#B32E2E" i] { color: var(--late) !important; }
.dark [style*="color:#8A5A00" i] { color: var(--near) !important; }
.dark tr:hover td { background: transparent; }
.dark svg [fill="#5C5B57"] { fill: #B7B6AE; }
.dark svg [stroke="#E1E0D9"] { stroke: #2C2C2A; }
.dark svg [stroke="#C3C2B7"] { stroke: #4A4A46; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 14px; }
.tiles-pick { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tiles-pick > legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.tiles-pick fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.tiles-pick fieldset > legend { padding: 0 0 4px; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); column-gap: 24px; }
.pick { display: flex; align-items: center; gap: 10px; min-height: 40px; border-bottom: 1px solid var(--line2); }
.pick label { flex: 1; align-self: stretch; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.pick:has(:checked) label { font-weight: 600; }
.ordre { width: 56px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 4px; font: inherit; text-align: center; background: #fff; color: var(--ink); }
.lab .embed-code { width: 100%; font: 12.5px ui-monospace, Consolas, monospace; padding: 10px 12px; border-radius: 8px; background: var(--ink); color: var(--bg); border: 0; }
/* Libellés .sr-only (position absolue) d'un tableau défilant : sans bloc conteneur, ils élargissaient la page sur mobile. */
.table-wrap, .card-table { position: relative; }
/* Administration (maquettes Admin-*.dc.html) : navigation latérale, fiches, formulaires ; connexion et Mon compte. */
body.admin { display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
body.admin > .top { grid-column: 1 / -1; }
body.admin .page { max-width: none; margin: 0; padding: 32px; gap: 20px; }
body.admin h1 { font-size: 26px; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.side a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 8px; white-space: nowrap; }
.side a[aria-current="page"] { background: #FBE9EE; color: var(--accent); font-weight: 600; }
.side-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 0 12px 8px; }
.side-h ~ .side-h { padding-top: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head p { margin: 4px 0 0; max-width: 80ch; }
.h2 { font-size: 15px; font-weight: 700; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-head .btn.primary { height: 44px; padding: 0 18px; }
.btn.primary:hover { color: #fff; filter: brightness(.92); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { margin: 0; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > :first-child { flex: 999 1 520px; min-width: 0; }
.split > :last-child { flex: 1 1 320px; max-width: 400px; }
.card-table { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.card-table td { vertical-align: middle; }
.table-foot { padding: 12px 16px; color: var(--muted); font-size: 13px; }
tr.sel td { background: #FBE9EE; }
td.clip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel p { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; margin: 0; min-width: 0; }
.lab { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.lab > span:not(.picker), .lab > legend { font-weight: 600; font-size: 13px; padding: 0; }
fieldset.lab label, .check { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.lab input:not([type=radio], [type=checkbox]), .lab select, .lab textarea, .search, .inline select, select.perm {
  height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; background: #fff; color: var(--ink); max-width: 100%; }
.lab textarea { height: auto; padding: 8px 10px; resize: vertical; }
.lab input[type="file"] { padding: 5px; }
::file-selector-button { font: inherit; font-weight: 600; height: 28px; padding: 0 12px; margin-right: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); cursor: pointer; }
.search { flex: 1 1 260px; max-width: 380px; }
select.perm { height: 36px; font-weight: 600; min-width: 100px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.inline select { flex: 1 1 160px; height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 13px; font-weight: 600; margin: 0; }
.chip button { border: 0; background: transparent; font: inherit; cursor: pointer; color: var(--muted); padding: 0 2px; }
.chip button:hover { color: var(--accent); }
.pill { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 10px; }
.pill.ok { color: #0A5A0A; background: #E4F3E4; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #C3C2B7; margin-right: 6px; }
.dot.on { background: #0A7A0A; }
.person { display: flex; align-items: center; gap: 10px; }
.person small { display: block; }
.person h2 { font-size: 17px; }
.avatar.lg { width: 44px; height: 44px; font-size: 14px; flex: none; }
.note { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 8px; background: var(--field); border: 1px solid var(--line2); font-size: 13px; }
.link { color: var(--accent); font-weight: 600; }
.alert, .success { margin: 0; padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.alert { background: #FBE9EE; color: var(--late); }
.success { background: #E4F3E4; color: #0A5A0A; }
.rule { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.rule.cur { border: 2px solid var(--accent); }
.rule.off { background: var(--field); } /* pas d'opacité (contraste) ; la pastille « Inactive » porte l'état */
.rule-head, .panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.grid-check td:not(:first-child), .grid-check th:not(:first-child) { text-align: center; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.levels .panel { gap: 6px; }
.tabs.line { border-bottom: 1px solid var(--line); }
code.block { display: block; padding: 8px; white-space: pre-wrap; word-break: break-word; }
.narrow { max-width: 480px; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.login h1 { font-size: 24px; }
.login .btn { justify-content: center; }
.login p { margin: 0; }
@media (max-width: 800px) {
  body.admin { display: block; }
  .side { flex-direction: row; overflow-x: auto; scrollbar-width: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 16px; }
  .side-h { display: none; }
  body.admin .page { padding: 20px 16px 40px; }
  .split > :last-child { max-width: none; }
}
/* Écran tactile ou étroit : cibles d'au moins 44 px. */
@media (max-width: 800px), (pointer: coarse) {
  .btn, .btn.sm, .who, .side a, .ordre, .lab input:not([type=radio], [type=checkbox]), .lab select, .search, .inline select, select.perm { height: 44px; }
  .field, .brand, .pick, fieldset.lab label, .check { min-height: 44px; }
  form.chip { min-height: 44px; padding: 0 0 0 12px; }
  .chip button { min-width: 44px; min-height: 44px; }
  .picker-q, .lab .picker-btn { height: 44px; }
  .picker-q, .field select { font-size: 16px; } /* sous 16 px, iOS zoome la page au focus */
  .picker-btn, .picker-list li { min-height: 44px; }
  .picker-tw { width: 44px; margin-left: -12px; }
  /* Liens de tableau : zone tactile agrandie sans changer la hauteur de ligne ; ce qui dépasse sous la dernière ligne
     ne doit pas rendre le tableau défilable verticalement. */
  td a { display: inline-block; padding: 12px 0; margin: -12px 0; }
  .table-wrap, .card-table { overflow-y: hidden; }
}
/* Pagination des tableaux longs (app.js : table[data-page]) */
.tile:has(table[data-page]) { align-self: start; } /* seule une tuile de liste paginée prend la hauteur de sa page, les autres restent alignées */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.pager .btn:disabled { opacity: .45; cursor: default; }
.pager .btn:disabled:hover { border-color: var(--line); color: var(--ink); }
/* Survol vertical des graphiques (app.js : charts) */
.tile { position: relative; }
.chart [data-cx], .chart rect.month { pointer-events: none; } /* plus d'infobulle native, le panneau .tip la remplace */
.chart .guide { stroke: #C3C2B7; stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; z-index: 5; pointer-events: none; display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(28, 28, 28, .12); font-size: 12px; white-space: nowrap; }
.tip b { font-size: 13px; }

/* Admin › Embeds : éditeur de mise en page (aperçu de la grille de l'embed, tuiles à glisser et à tirer par le coin). */
.layout-edit { display: flex; flex-direction: column; gap: 8px; }
.layout-edit p { margin: 0; }
.layout-info { font-weight: 600; }
.layout-grid { display: grid; gap: 8px; grid-auto-rows: minmax(0, 1fr); aspect-ratio: 16 / 9; grid-auto-flow: dense; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--field); min-height: 76px; }
.layout-box { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 22px 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: grab; overflow: hidden; user-select: none; }
.layout-box small { font-weight: 400; color: var(--muted); }
.layout-box.moving { opacity: .4; }
.layout-box:hover { border-color: var(--accent); }
.layout-grip { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 55%, var(--accent) 55%, var(--accent) 65%, transparent 65%, transparent 78%, var(--accent) 78%, var(--accent) 88%, transparent 88%); }

/* Admin › Permissions : case « Embeds » sous le niveau ; écrans : embeds de l'app en fin d'onglets. */
.perm-embeds { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.tab-embed { color: var(--muted); }

/* KPI Prod : période libre (semaine, mois, calendrier), alertes rouges (cailloux, arrêts), graphiques interactifs (app.js ichart). */
.field.dates input[type="date"] { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); min-height: 38px; }
.field.dates label { color: var(--muted); }
td.hot { color: var(--late); font-weight: 700; background: #FBE9EE; } /* un caillou, un arrêt : voyant d'un coup d'œil */
.ichart { display: flex; flex-direction: column; gap: 8px; }
.ich-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; }
.seg .btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; position: relative; }
.ich-plot { position: relative; }
.ich-legend .lg { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.ich-legend .lg:hover { background: var(--field); }
.ich-legend .lg[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.chart.ich .band { fill: #FBE9EE; }
.chart.ich.drill .hit { cursor: pointer; }
.tip .sw { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.tip .tot { font-weight: 600; border-top: 1px solid var(--line2); padding-top: 2px; }
.dark .seg .btn[aria-pressed="true"] { background: var(--ink); color: #141413; }
.dark .chart.ich .band { fill: #3A2228; }
.dark .tip { background: #1F1F1E; }
.rank-list strong.hot { color: var(--late); }
.dark td.hot { background: #3A2228; }
.chart.ich { display: block; }
/* Embed : le graphique interactif prend la hauteur que la grille donne à sa tuile (app.js le trace à cette hauteur). */
.embed .cell .ichart, .embed .cell .ich-plot { flex: 1; min-height: 0; }

/* Admin › Permissions : barre de recherche et filtres, tableau défilant à en-têtes et colonne « Utilisateur » figés,
   couleur par niveau, cases modifiées surlignées (app.js, form#perms). */
.perm-tools { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.perm-count { margin-left: auto; }
.card-table.perm-table { max-height: calc(100vh - 250px); min-height: 320px; overflow: auto; }
.perm-table thead th { position: sticky; top: 0; z-index: 2; background: #fff; vertical-align: bottom; white-space: normal; min-width: 132px; box-shadow: inset 0 -1px 0 var(--line); }
.perm-table .perm-user { position: sticky; left: 0; z-index: 1; background: #fff; min-width: 220px; max-width: 280px; box-shadow: inset -1px 0 0 var(--line); }
.perm-table thead .perm-user { z-index: 3; vertical-align: bottom; box-shadow: inset -1px 0 0 var(--line), inset 0 -1px 0 var(--line); }
.perm-table tbody th.perm-user { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; color: var(--ink); white-space: normal; padding: 9px 12px; border-bottom: 1px solid var(--line2); }
.perm-table tbody th.perm-user a:hover strong { color: var(--accent); }
.perm-app { display: block; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.perm-all, .perm-row { display: block; height: 30px; margin-top: 6px; max-width: 100%; padding: 0 6px; border: 1px dashed #C3C2B7; border-radius: 6px; background: var(--field); font: inherit; font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; cursor: pointer; }
select.perm[data-level="none"] { color: var(--muted); }
select.perm[data-level="view"] { background: #EAF2FC; border-color: #BFD6F3; }
select.perm[data-level="edit"] { background: #E8F4EA; border-color: #B9DDBF; }
select.perm[data-level="admin"] { background: #FBE9EE; border-color: #F0BFCD; color: var(--accent); }
.perm-table td.chg { background: #FFF6DA; box-shadow: inset 3px 0 0 #E0A800; }
.perm-pending { color: #8A5A00; font-weight: 600; }
