/* ═══════════════════════════════════════════════════════════════════════════
   KANALO — statistiques (tablette et HUB), rendues par stats.js
   Une teinte pour mesurer : le bleu de Prusse. La couleur d'un canal n'apparaît
   que dans sa pastille, à côté de son nom. Les textes restent à l'encre.
   Barres fines (12 px), bout arrondi côté valeur, pied carré sur la ligne de base.
   ═══════════════════════════════════════════════════════════════════════════ */

.kn-stats { display: flex; flex-direction: column; gap: 16px; -webkit-user-select: none; user-select: none; }
.kn-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Filtres : une seule ligne, au-dessus de tout ce qu'ils règlent ─────── */
.kn-stats-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.kn-stats-filtres .kn-segments { background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 1px rgba(255, 255, 255, .9) inset, 0 6px 16px -12px rgba(var(--kn-prusse-rgb), .35); }
.kn-stats-filtres .kn-segments button[aria-pressed='true'] { background: var(--kn-prusse); color: #fff; box-shadow: 0 8px 16px -10px rgba(var(--kn-prusse-rgb), .7); }
.kn-stats-perso { display: flex; gap: 8px; align-items: flex-end; }
.kn-stats-perso .kn-champ { flex-direction: row; align-items: center; gap: 8px; }
.kn-stats-perso input { min-height: 44px; padding: 0 12px; }
.kn-stats-liste select { min-height: 44px; }
.kn-stats-export { margin-left: auto; }

.kn-stats-corps { display: flex; flex-direction: column; gap: 16px; transition: opacity .2s; }
.kn-stats-corps[aria-busy='true'] { opacity: .55; }
.kn-stats-attente { margin: 40px 0; text-align: center; color: var(--kn-encre-2); font-weight: 500; }
.kn-stats-vide { align-self: center; max-width: 520px; padding: 36px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin-top: 24px; }
.kn-stats-vide .kn-bulle { width: 64px; height: 64px; border-radius: 22px; font-size: 32px; }

/* ── Quatre chiffres ────────────────────────────────────────────────────── */
.kn-stats-chiffres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kn-chiffre { padding: 18px 20px 20px; border-radius: 26px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kn-chiffre-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.kn-chiffre-nom { font-family: var(--kn-etroit); font-weight: 600; font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--kn-encre-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-chiffre-valeur { font-weight: 600; font-size: clamp(26px, 2.6vw, 34px); line-height: 1.1; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; min-width: 0; }
.kn-chiffre-valeur span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kn-chiffre-hero { font-size: clamp(40px, 4.4vw, 56px); font-weight: 500; letter-spacing: -.035em; }
.kn-chiffre-texte { font-size: clamp(18px, 1.7vw, 22px); letter-spacing: -.01em; line-height: 1.15; }
/* Un nom de canal peut être long : deux lignes plutôt que des points de suspension. */
.kn-chiffre-texte span { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.kn-chiffre-sous { font-size: 13.5px; color: var(--kn-encre-2); margin-top: auto; }
/* L'écart avec la période précédente : une flèche ET un signe, jamais la couleur seule. */
.kn-ecart { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px 3px 7px; border-radius: 999px; font-weight: 600; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; background: rgba(var(--kn-prusse-rgb), .06); color: var(--kn-encre-2); }
.kn-ecart [class^='kn-i-'] { font-size: 15px; }
.kn-ecart-haut { background: #e2f6e6; color: #0b6b1f; }
.kn-ecart-bas { background: var(--kn-alerte-fond); color: var(--kn-alerte); }

/* ── Cartes ─────────────────────────────────────────────────────────────── */
.kn-stats-grandes { display: flex; flex-direction: column; gap: 16px; }
.kn-stats-grandes:empty, .kn-stats-paires:empty { display: none; }
/* Petites cartes : deux colonnes qui se remplissent l'une après l'autre, sans trou sous une carte courte. */
.kn-stats-paires { columns: 2; column-gap: 16px; }
.kn-stats-paires > .kn-carte { break-inside: avoid; margin: 0 0 16px; display: inline-block; width: 100%; vertical-align: top; }
.kn-stats-paires > .kn-carte:last-child { margin-bottom: 0; }
.kn-carte { border-radius: 28px; padding: 22px 24px 24px; min-width: 0; }
.kn-carte-large { grid-column: 1 / -1; }
.kn-carte-tete { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; margin-bottom: 18px; }
.kn-carte-sous { margin: 3px 0 0; font-size: 13.5px; color: var(--kn-encre-2); }
.kn-carte-tete .kn-segments button { min-height: 36px; padding: 0 14px; font-size: 13.5px; }
.kn-stats-note { margin: 14px 0 0; font-size: 13.5px; color: var(--kn-encre-2); }

/* ── Barres classées ────────────────────────────────────────────────────── */
.kn-barres { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.kn-barres li { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 46px; padding: 4px 8px; margin: 0 -8px; border-radius: 14px; outline-offset: 0; transition: background-color .12s; }
.kn-barres li:hover, .kn-barres li:focus-visible { background: rgba(var(--kn-prusse-rgb), .05); }
.kn-barre-nom { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; font-size: 15px; }
.kn-barre-nom > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kn-barre-piste { display: block; height: 12px; }
.kn-barre-piste i { display: block; height: 100%; min-width: 0; background: var(--kn-prusse); border-radius: 0 4px 4px 0; transition: width .5s var(--kn-doux); }
.kn-barres li:hover .kn-barre-piste i, .kn-barres li:focus-visible .kn-barre-piste i { background: var(--kn-prusse-3); }
.kn-barre-valeur { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; min-width: 96px; font-variant-numeric: tabular-nums; }
.kn-barre-valeur b { font-weight: 600; font-size: 15.5px; }
.kn-barre-valeur small { font-size: 13px; color: var(--kn-encre-2); min-width: 42px; text-align: right; }

/* ── Colonnes dans le temps ─────────────────────────────────────────────── */
.kn-cols-zone { position: relative; }
.kn-cols-plan { position: relative; height: clamp(170px, 26vh, 240px); margin-left: 54px; }
.kn-cols-axe { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.kn-cols-axe span { position: relative; height: 0; border-top: 1px solid var(--kn-ardoise-ligne); }
.kn-cols-axe span:last-child { border-top-color: #c9cad6; }
.kn-cols-axe em { position: absolute; right: 100%; top: 0; transform: translateY(-50%); margin-right: 10px; font-style: normal; font-size: 12px; color: var(--kn-encre-2); white-space: nowrap; }
.kn-cols { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; }
.kn-col { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; justify-content: center; outline-offset: -1px; border-radius: 6px; }
.kn-col i { display: block; width: 100%; max-width: 24px; background: var(--kn-prusse); border-radius: 4px 4px 0 0; transition: height .5s var(--kn-doux), background-color .12s; }
.kn-col:hover, .kn-col:focus-visible { background: rgba(var(--kn-prusse-rgb), .06); }
.kn-col:hover i, .kn-col:focus-visible i { background: var(--kn-prusse-3); }
.kn-cols-dates { position: relative; height: 26px; margin-left: 54px; }
.kn-cols-dates span { position: absolute; top: 8px; transform: translateX(-50%); font-size: 12px; color: var(--kn-encre-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kn-cols-dates span:first-child { transform: translateX(-20%); }
.kn-cols-dates span:last-child { transform: translateX(-80%); }

/* ── Jours × heures ─────────────────────────────────────────────────────── */
.kn-heures { display: flex; flex-direction: column; gap: 4px; }
.kn-heures-ligne { display: grid; grid-template-columns: 44px repeat(var(--heures, 10), minmax(0, 1fr)) 56px; gap: 4px; align-items: center; }
.kn-heures-ligne > span:first-child { font-weight: 600; font-size: 13.5px; color: var(--kn-encre-2); }
.kn-heures-ligne > i { display: block; height: clamp(22px, 3.4vh, 30px); border-radius: 7px; outline-offset: 1px; transition: transform .12s; }
.kn-heures-ligne > i:hover, .kn-heures-ligne > i:focus-visible { transform: scale(1.08); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--kn-prusse); }
/* Aucune vente : une case vide, seulement cernée — pour ne pas la confondre avec la teinte la plus claire. */
.kn-heures-zero { background: transparent; box-shadow: 0 0 0 1px var(--kn-ardoise-ligne) inset; }
.kn-heures-ligne > b { text-align: right; font-weight: 600; font-size: 14px; }
.kn-heures-tete span { font-size: 11.5px; color: var(--kn-encre-2); text-align: left; white-space: nowrap; }
.kn-heures-tete span:last-child { text-align: right; font-family: var(--kn-etroit); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.kn-heures-pointe > span:first-child, .kn-heures-pointe > b { color: var(--kn-encre); }
.kn-heures-pointe > b::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--kn-menthe); box-shadow: 0 0 0 1px rgba(var(--kn-prusse-rgb), .25); margin-left: 6px; vertical-align: 1px; }
.kn-heures-legende { display: flex; align-items: center; gap: 5px; margin-top: 14px; font-size: 12.5px; color: var(--kn-encre-2); }
.kn-heures-legende i { width: 20px; height: 10px; border-radius: 3px; }
.kn-heures-legende span:first-child { margin-right: 4px; }
.kn-heures-legende span:last-child { margin-left: 4px; }

/* ── Listes : à retenir, dernières saisies ──────────────────────────────── */
.kn-stats-retenir, .kn-stats-dernieres { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.kn-stats-retenir li, .kn-stats-dernieres li { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.kn-stats-dernieres { gap: 10px; }
.kn-stats-dernieres li { align-items: center; }
.kn-stats-retenir div, .kn-stats-dernieres div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kn-stats-retenir b, .kn-stats-dernieres b { font-weight: 600; font-size: 15px; line-height: 1.3; }
.kn-stats-dernieres b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-stats-retenir span, .kn-stats-dernieres span { font-size: 13.5px; color: var(--kn-encre-2); }
.kn-stats-dernieres strong { font-weight: 600; font-size: 15px; white-space: nowrap; }

/* ── Bulle d'information ────────────────────────────────────────────────── */
.kn-info { position: fixed; z-index: 90; left: 0; top: 0; min-width: 150px; max-width: 280px; padding: 10px 14px 12px; border-radius: 16px; pointer-events: none;
  background: var(--kn-prusse); color: #fff; box-shadow: 0 16px 34px -14px rgba(var(--kn-prusse-rgb), .7); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; font-size: 13.5px; line-height: 1.35; }
.kn-info.kn-visible { opacity: 1; transform: none; }
.kn-info > b { display: block; font-family: var(--kn-etroit); font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255, 255, 255, .72); margin-bottom: 6px; }
.kn-info > div { display: flex; align-items: baseline; gap: 8px; }
.kn-info strong { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kn-info span { color: rgba(255, 255, 255, .78); }

/* ── Écrans étroits ─────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .kn-stats-chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kn-stats-paires { columns: 1; }
}
@media (max-width: 620px) {
  .kn-stats { gap: 12px; }
  .kn-stats-chiffres { gap: 10px; }
  .kn-chiffre { padding: 14px 16px 16px; border-radius: 22px; }
  /* Deux tuiles par rangée : le nom passe au-dessus de l'écart plutôt que d'être coupé (« Chiffr… »). */
  .kn-chiffre-tete { flex-wrap: wrap; gap: 6px; }
  .kn-chiffre-nom { white-space: normal; }
  .kn-carte { padding: 18px 16px 20px; border-radius: 24px; }
  .kn-barres li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; min-height: 0; padding: 8px; }
  .kn-barre-piste { grid-column: 1 / -1; grid-row: 2; height: 10px; }
  .kn-barre-valeur { min-width: 0; }
  .kn-cols-plan, .kn-cols-dates { margin-left: 44px; }
  .kn-heures-ligne { grid-template-columns: 34px repeat(var(--heures, 10), minmax(0, 1fr)) 40px; gap: 3px; }
  .kn-stats-export { margin-left: 0; }
}
