/* ─── ESPACE RAPPORTS — styles (15/10/2026) ───
   Feuille autonome : le « chrome » commun (lock screen, pastilles, bouton
   Actualiser, bannière hors-ligne) est redéclaré ici au lieu d'importer
   demandes.css, qui redéfinit .card et toute la table du dashboard — l'inclure
   mélangerait deux systèmes de cartes et ferait courir un risque de régression
   à /demandes/, qui tourne en prod. Duplication assumée, ~50 lignes.
   Les couleurs viennent exclusivement des tokens de /style.css (thème clair). */

/* PIÈGE CONNU DU PROJET : l'attribut hidden est écrasé par tout display: défini
   par une classe → chaque élément piloté par el.hidden doit avoir sa règle. */
#lock-screen[hidden],
#report-screen[hidden],
#offline-banner[hidden],
.lock-error[hidden],
.refresh-btn[hidden],
.rap-reset[hidden] { display: none; }

.rap-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

/* ─── CHROME COMMUN (repris de /demandes/) ─── */

.back-link {
  font-size: 1.375rem;
  line-height: 1;
  color: var(--text2);
  text-decoration: none;
  padding: 0.25rem 0.5rem 0.25rem 0;
}

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.refresh-btn {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  border-radius: 100px;
  padding: 6px 14px;
  cursor: pointer;
}

#lock-screen { display: flex; justify-content: center; padding-top: 3rem; }

.lock-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.lock-card form { text-align: left; margin-top: 1.5rem; }
.lock-card .submit-btn { margin-bottom: 0; }

.lock-error {
  color: var(--red);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

#offline-banner {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-top: 1rem;
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--gold-border); }
.chip.active { color: var(--gold); background: var(--gold-bg); border-color: var(--gold-border); }

/* ─── BARRE DE FILTRES ─── */

.rap-filters {
  position: sticky;
  top: 57px; /* hauteur du header collant */
  z-index: 20;
  background: var(--bg);
  padding: 0.875rem 0 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.rap-filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.rap-filters-row + .rap-filters-row { margin-top: 0.625rem; }

.rap-vue {
  margin-left: auto;
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 2px;
}
.vue-btn {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text2);
  background: none;
  border: 0;
  border-radius: 100px;
  padding: 0.4rem 0.875rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.vue-btn.active { color: var(--white); background: var(--cyan); }

.rap-selects { gap: 0.5rem; }

.rap-select { display: inline-flex; flex-direction: column; gap: 0.2rem; }
.rap-select > span {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  padding-left: 0.25rem;
}
.rap-select select {
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  max-width: 14rem;
}
.rap-select select:focus { outline: none; border-color: var(--border-focus); }

.rap-reset {
  align-self: flex-end;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid transparent;
  border-radius: 100px;
  padding: 0.45rem 0.875rem;
  cursor: pointer;
}

.rap-selection {
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  color: var(--text2);
}
.rap-selection strong { color: var(--text); }

/* ─── CARTES ─── */

/* minmax(0,1fr) + min-width:0 : sans ça une grille CSS laisse ses items grandir
   au contenu (min-width:auto par défaut) et un tableau large pousse la page
   entière au lieu de scroller dans son conteneur. */
#rap-blocs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }

.card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.125rem 1.25rem 1.25rem;
}
.card h2 {
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
.card h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin: 1.125rem 0 0.5rem;
}
.card h3:first-of-type { margin-top: 0.75rem; }
.card-aide {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text3);
  margin-bottom: 0.875rem;
}
.card > .card-aide:last-child { margin: 0.875rem 0 0; }
.vide { font-size: 0.8125rem; color: var(--text3); padding: 0.5rem 0; }
.muted { color: var(--text3); font-weight: 400; }
.bad { color: var(--red); }

/* ─── À RETENIR ─── */

.retenir { list-style: none; display: grid; gap: 0.625rem; margin-top: 0.75rem; }
.retenir li {
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text2);
}
.retenir strong { color: var(--text); }
.r-ico {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 0.875rem;
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  border-radius: 8px;
}

/* ─── TUILES KPI ─── */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}
.kpis-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpis-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.kpi-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}
.kpi-val {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.kpi-sous { font-size: 0.75rem; color: var(--text2); }

.evo { font-weight: 700; white-space: nowrap; }
.evo.up { color: var(--green); }
.evo.down { color: var(--red); }
.evo.flat { color: var(--text3); }

/* Les tuiles KPI rendues hors d'une carte portent leur propre fond */
#rap-blocs > .kpis { margin: 0; }

/* ─── BARRES ─── */

.bars { display: grid; gap: 0.5rem; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr 2.5rem minmax(7rem, 9rem);
  align-items: center;
  gap: 0.625rem;
  font-size: 0.8125rem;
}
.bar-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  position: relative;
  height: 20px;
  background: #EFECE6; /* plus soutenu que --bg : sur une carte blanche, le
                          volume de la barre doit rester lisible */
  border-radius: 100px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #9FDCE8; /* cyan tenu : --cyan-light disparaît sur fond clair */
  border-radius: 100px;
}
.bar-fill.win { background: var(--green); }
.bar-n { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.bar-taux { font-size: 0.75rem; color: var(--text3); text-align: right; }
.bar-taux.ok { color: var(--green); font-weight: 700; }

/* ─── ENTONNOIR ─── */

.funnel { display: grid; gap: 0.5rem; }
.fn-row {
  display: grid;
  grid-template-columns: minmax(6rem, 8rem) 1fr 2.5rem minmax(9rem, 13rem);
  align-items: center;
  gap: 0.625rem;
  font-size: 0.8125rem;
}
.fn-label { font-weight: 700; }
.fn-track { height: 24px; background: #EFECE6; border-radius: var(--radius-sm); overflow: hidden; }
.fn-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-light), var(--gold));
  border-radius: var(--radius-sm);
}
.fn-fill.win { background: var(--green); }
.fn-n { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.fn-step { font-size: 0.75rem; color: var(--text3); }

/* ─── TABLEAUX ─── */

.table-wrap {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  /* Ombres de bord en CSS pur (background-attachment: local) : sur mobile, elles
     apparaissent du côté où il reste des colonnes à faire défiler. */
  background:
    linear-gradient(to right, var(--card) 30%, rgba(255,255,255,0)) left center,
    linear-gradient(to left, var(--card) 30%, rgba(255,255,255,0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.10), transparent) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.10), transparent) right center;
  background-repeat: no-repeat;
  background-size: 28px 100%, 28px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
.table-wrap + h3 { margin-top: 1.25rem; }
.card .bars + .table-wrap { margin-top: 1rem; }

.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.table-wrap th {
  text-align: left;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrap td {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrap tbody tr:first-child td { border-top: none; }
.table-wrap th:not(:first-child), .table-wrap td:not(:first-child) { text-align: right; }
.table-wrap a { color: var(--cyan); font-weight: 600; text-decoration: none; }
.table-wrap a:hover { text-decoration: underline; }

/* ─── TABLEAU TRIABLE ─── */

.tab-tri th.th-tri {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.tab-tri th.th-tri:hover { color: var(--text2); background: var(--bg); }
.tab-tri th.th-tri.actif { color: var(--cyan); }
.tri-fleche { margin-left: 0.25rem; font-size: 0.6875rem; opacity: 0.45; }
.tab-tri th.actif .tri-fleche { opacity: 1; }
.tab-tri td.num, .tab-tri th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tab-tri td:first-child { font-weight: 600; }
.tab-tri .ok { color: var(--green); }

/* Une ligne qui filtre la page : on doit voir que c'est cliquable */
.tab-tri tr.tr-filtre { cursor: pointer; }
.tab-tri tr.tr-filtre:hover td { background: var(--gold-bg); }
.tab-tri tr.tr-filtre.actif td {
  background: var(--cyan-light);
  box-shadow: inset 3px 0 0 var(--cyan);
}

/* Pastilles de choix d'axe, au-dessus du tableau */
.filter-chips.axes { margin: 0.5rem 0 0.875rem; }
.filter-chips.axes .chip { font-size: 0.75rem; padding: 0.35rem 0.75rem; }

.kpi-note {
  margin-top: 0.625rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text3);
}

/* ─── COURBE ─── */

.chart { margin-top: 0.5rem; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.c-area { fill: var(--gold-bg); }
.c-line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; }
.c-dot { fill: var(--gold); }
.c-val { font-size: 9px; font-weight: 700; fill: var(--text2); text-anchor: middle; }
.c-lab { font-size: 9px; fill: var(--text3); text-anchor: middle; }

/* ─── FIABILITÉ ─── */

.fiab { list-style: none; display: grid; gap: 0.5rem; }
.fiab li {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text2);
  padding-left: 1rem;
  position: relative;
}
.fiab li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text3);
}

/* ─── TABLETTE / MOBILE (équipe en déplacement : les 3 formats doivent tenir) ─── */

@media (max-width: 860px) {
  .rap-filters { top: 55px; }
  .bar-row { grid-template-columns: minmax(5.5rem, 8rem) 1fr 2rem; }
  .bar-taux { grid-column: 2 / -1; text-align: left; margin-top: -0.25rem; }
  .fn-row { grid-template-columns: minmax(5rem, 7rem) 1fr 2rem; }
  .fn-step { grid-column: 2 / -1; margin-top: -0.25rem; }
}

@media (max-width: 560px) {
  .rap-container { padding: 0.75rem 0.75rem 2.5rem; }
  .card { padding: 1rem; }
  .rap-vue { margin-left: 0; }
  .rap-select { flex: 1 1 8rem; }
  .rap-select select { max-width: none; width: 100%; }
  .kpi-val { font-size: 1.5rem; }
  .bar-label, .fn-label { font-size: 0.75rem; }
}
