/* ============================================================================
   Analyse de flotte — usage réel, anomalies, coût au kilomètre.

   Le centre de contrôle répond à « où est ce véhicule maintenant ». Cet écran
   répond aux questions qui viennent après, et qui se lisent en comparant :
   aucun chiffre n'y est présenté seul.
   ============================================================================ */

.ana-periode {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: wrap;
}

.ana-periode input { min-height: var(--touch-min, 44px); font-size: 16px; }

.ana-section { margin-top: var(--space-5, 1.25rem); }

.ana-titre {
  font-size: var(--font-size-md, 1rem);
  font-weight: 600;
  margin: 0 0 var(--space-3, .75rem);
}

.ana-intro {
  max-width: 70ch;
  line-height: 1.6;
  margin: 0 0 var(--space-3, .75rem);
}

/* --- Anomalies --------------------------------------------------------- */

.ana-anomalies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-3, .75rem);
}

.ana-anomalie {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: .8rem .9rem;
}

.ana-anomalie--critique { border-left-color: var(--color-danger, #e02424); }
.ana-anomalie--alerte   { border-left-color: var(--color-warning, #d97706); }

.ana-anomalie header {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  margin-bottom: .4rem;
}

.ana-anomalie header a { text-decoration: none; }

.ana-anomalie__titre { font-weight: 600; }
.ana-anomalie--critique .ana-anomalie__titre { color: var(--color-danger, #e02424); }
.ana-anomalie--alerte   .ana-anomalie__titre { color: #b45309; }

.ana-anomalie p {
  margin: 0;
  font-size: var(--font-sm, .84rem);
  line-height: 1.5;
  color: var(--color-text-muted);
}

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

.ana-table small { display: block; }
.ana-table td.num { font-variant-numeric: tabular-nums; }

/* La barre rend le classement lisible sans lire les chiffres : c'est la
   comparaison qui informe, pas la valeur absolue. */
.ana-barre {
  height: 6px;
  border-radius: 3px;
  background: var(--color-surface-alt);
  overflow: hidden;
  margin-bottom: .2rem;
  min-width: 90px;
}

.ana-barre span {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
}

.ana-valeur { font-variant-numeric: tabular-nums; font-size: var(--font-sm, .85rem); }

@media (max-width: 820px) {
  .ana-anomalies { grid-template-columns: 1fr; }

  /* Sept colonnes ne tiennent pas sur un téléphone : chaque ligne devient une
     fiche dont les cellules portent leur intitulé (data-label dans la vue). */
  .ana-table thead { display: none; }
  .ana-table, .ana-table tbody, .ana-table tr, .ana-table td { display: block; width: 100%; }

  .ana-table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .7rem .85rem;
    margin-bottom: .7rem;
  }

  .ana-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .3rem 0;
    border: 0;
    text-align: right;
  }

  .ana-table td::before {
    content: attr(data-label);
    font-size: var(--font-xs, .72rem);
    color: var(--color-text-muted);
    text-align: left;
    flex: 0 0 auto;
  }

  .ana-barre { display: none; }   /* sans voisins à comparer, elle n'apprend rien */
}
