/* === DERNIÈRES MESURES (titre + tags + recap unique) === */
.summary-card { display: flex; flex-direction: column; gap: 0.7rem; }
.summary-title { font-size: 1.25rem; }
.meas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 0.6rem; }
.meas-card {
  position: relative; cursor: default;
  background: var(--bg-secondary); border: 1px solid var(--header-border);
  border-radius: var(--radius-md); padding: 0.6rem 0.7rem;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.meas-label { font-size: 0.9rem; font-weight: 600; }
.meas-value { font-family: var(--font-title); font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.meas-unit { font-size: 0.7rem; font-weight: 400; color: var(--text-secondary); }
.meas-date { font-size: 0.68rem; color: var(--text-secondary); }

/* Carte de survol : plage optimale + danger (bordure = couleur de la métrique, posée en JS). */
.meas-tip {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  min-width: 9rem;
  background: var(--bg-card); border: 1px solid var(--text-secondary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-card);
  padding: 0.5rem 0.6rem; font-size: 0.72rem; color: var(--text-secondary);
  opacity: 0; visibility: hidden; transform: translateY(-3px);
  transition: opacity 0.15s ease, transform 0.15s ease; pointer-events: none;
}
.meas-card:focus-within .meas-tip,
.meas-card.show-tip .meas-tip { opacity: 1; visibility: visible; transform: none; }
@media (hover: hover) { .meas-card:hover .meas-tip { opacity: 1; visibility: visible; transform: none; } }
.tip-row { display: flex; justify-content: space-between; gap: 0.8rem; }
.tip-row + .tip-row { margin-top: 0.25rem; }
.tip-k { text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.62rem; }
.tip-danger { color: var(--bad); }

/* Recommandations (apparaissent seulement s'il y a un souci) */
.reco { font-size: 0.86rem; line-height: 1.5; padding: 0.6rem 0.85rem; border-radius: var(--radius-sm); background: var(--bg-secondary); }
.reco-u { color: var(--text-secondary); font-size: 0.92em; margin-inline-start: 0.15rem; }

/* === GRAPHIQUE === */
.chart-head { display: flex; flex-direction: column; align-items: stretch; gap: 0.6rem; margin-bottom: 1rem; }
.range-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; width: 100%; }
.range-btn {
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-pill);
  color: var(--text-secondary); cursor: pointer; font-size: 0.82rem; padding: 0.3rem 0.85rem;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.range-btn:hover { color: var(--text-primary); }
.range-btn.is-active { background: var(--accent-muted); color: var(--accent); border-color: var(--accent); }
.chart-wrap { position: relative; height: clamp(260px, 48vh, 440px); }
.param-buttons {
  margin-top: 0.25rem; margin-bottom: 0.9rem;
  flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px;
}
.param-buttons .range-btn { flex: 0 0 auto; }
/* Dégradé seulement du côté encore scrollable (classes posées en JS). Aucun si tout tient. */
.param-buttons.fade-left, .add-chips.fade-left  { -webkit-mask-image: linear-gradient(to right, transparent, #000 16px); mask-image: linear-gradient(to right, transparent, #000 16px); }
.param-buttons.fade-right, .add-chips.fade-right { -webkit-mask-image: linear-gradient(to left, transparent, #000 16px); mask-image: linear-gradient(to left, transparent, #000 16px); }
.param-buttons.fade-left.fade-right, .add-chips.fade-left.fade-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}
/* Plusieurs métriques : grille de petits graphes (colonnes fixes par palier ->
   largeurs régulières, pas d'étirement de la dernière rangée). min-width:0 = les
   cellules peuvent rétrécir sous la largeur intrinsèque du canvas (sinon débordement). */
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.chart-grid .mini-chart { min-width: 0; }
.chart-grid .mini-wrap { min-width: 0; }
@media (min-width: 560px) { .chart-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 920px) { .chart-grid { grid-template-columns: repeat(3, 1fr); } }
.mini-chart {
  border: 1px solid var(--header-border); border-radius: var(--radius-md);
  background: var(--bg-secondary); padding: 0.5rem 0.6rem 0.6rem;
}
.mini-title { font-family: var(--font-title); font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; padding-inline-end: 1.2rem; }
.mini-wrap { position: relative; height: 170px; }
.chart-empty { text-align: center; padding: 1.5rem 0; }

/* Petit graphe cliquable -> ouvre la vue agrandie (indice ⤢ en coin). */
.chart-grid .mini-chart { position: relative; cursor: pointer; transition: border-color 0.15s ease; }
.chart-grid .mini-chart:hover { border-color: var(--accent); }
/* Bouton « agrandir » (coin haut-droite) : discret, révélé au survol desktop ; toujours visible
   et cible tactile sur mobile. Remplace l'ancien indice ::after (non cliquable). Ouvrir la vue
   focus passe par CE bouton en tactile -> le tap sur le corps du graphe reste dédié au tooltip. */
.mini-expand {
  position: absolute; top: 0.3rem; inset-inline-end: 0.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.9rem; height: 1.9rem; padding: 0; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  /* Toujours visible (desktop compris), renforcée au survol/focus. */
  opacity: 0.55; transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.mini-expand svg { width: 15px; height: 15px; }
.chart-grid .mini-chart:hover .mini-expand { opacity: 1; }
.mini-expand:hover, .mini-expand:focus-visible { opacity: 1; background: var(--accent-muted); color: var(--accent); }
@media (max-width: 639px) {
  .chart-grid .mini-chart { cursor: default; }
  .mini-expand { opacity: 0.55; width: 2.25rem; height: 2.25rem; }
}

/* === VUE AGRANDIE D'UN GRAPHE (modale) === */
body.modal-open { overflow: hidden; }
.chart-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem; background: rgba(0, 0, 0, 0.6); }
.chart-modal[hidden] { display: none; }
.chart-modal-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card);
  width: min(820px, calc(100% - 7rem)); max-height: 90vh; display: flex; flex-direction: column; padding: 1rem 1.25rem 1.25rem;
}
.chart-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.chart-modal-title { font-family: var(--font-title); font-size: 1.15rem; font-weight: 700; }
.chart-modal-sub { color: var(--text-secondary); font-size: 0.85rem; font-weight: 400; }
.chart-modal-close {
  flex: 0 0 auto; width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 0.95rem; line-height: 1;
}
.chart-modal-close:hover { color: var(--accent); border-color: var(--accent); }
.chart-modal-ranges { justify-content: center; margin-bottom: 0.75rem; }
.chart-modal-body { position: relative; height: clamp(300px, 60vh, 520px); }
/* Flèches préc/suiv : flex items qui flanquent le panneau (chevron SVG centré). */
.chart-modal-nav {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--bg-card); color: var(--text-primary);
  cursor: pointer;
}
.chart-modal-nav svg { display: block; }
/* Recentrage optique : la pointe du chevron attire l'œil, on nudge de 1px vers l'extérieur. */
.chart-modal-prev svg { transform: translateX(-1px); }
.chart-modal-next svg { transform: translateX(1px); }
.chart-modal-nav:hover { color: var(--accent); border-color: var(--accent); }
.chart-modal-nav[hidden] { display: none; }

/* Légende du graphe agrandi (option B) : sous la courbe, avant le résumé.
   Explique la bande cible (plage optimale) + le repère événement (si présent). */
.chart-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem;
  margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--header-border);
  font-size: 0.85rem; color: var(--text-secondary);
}
.chart-legend[hidden] { display: none; }
.chart-legend-i { display: inline-flex; align-items: center; gap: 0.45rem; }
.chart-legend-band { width: 26px; height: 13px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend-ev { width: 0; height: 15px; border-inline-start: 2px dashed var(--text-secondary); display: inline-block; }

/* Résumé statistique sous le graphe agrandi : dernière / plage / moyenne. */
.chart-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
  margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--header-border);
}
.chart-summary-item { display: flex; flex-direction: column; gap: 0.15rem; text-align: center; min-width: 0; }
.chart-summary-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); }
.chart-summary-val { font-family: var(--font-title); font-weight: 600; font-size: 1rem; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.chart-summary[hidden] { display: none; }

/* Mobile : graphe agrandi en plein écran, sans les flèches latérales (place) -> panel pleine largeur. */
@media (max-width: 640px) {
  .chart-modal { padding: 0.75rem; }
  .chart-modal-nav { display: none; }
  .chart-modal-panel { width: 100%; max-height: 92vh; }
  .chart-modal-body { height: clamp(260px, 52vh, 460px); }
}

/* Overview (haut de Suivi) : grille de CARTES-RÉSUMÉ cliquables (points d'entrée M3). Chaque carte
   renvoie vers son onglet ; pas les valeurs de params (elles vivent dans « Dernières mesures »). */
.suivi-ovw { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1.5rem; }
@media (min-width: 560px) { .suivi-ovw { grid-template-columns: repeat(4, 1fr); } }
.ovc { text-align: start; background: var(--bg-card); border: 1px solid var(--header-border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 0.7rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; cursor: pointer; font-family: inherit; transition: border-color 0.15s ease, transform 0.05s ease; }
.ovc:hover { border-color: var(--accent); }
.ovc:active { transform: scale(0.99); }
.ovc-top { display: flex; align-items: center; gap: 0.35rem; color: var(--text-secondary); font-size: 0.72rem; }
.ovc-lab { text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ovc-chev { margin-inline-start: auto; opacity: 0.5; font-size: 1.05rem; line-height: 1; }
.ovc-val { font-size: 1.05rem; font-weight: 800; line-height: 1.15; }
.ovc-val.is-ok { color: var(--ok); }
.ovc-val.is-warn { color: var(--warn); }
.ovc-val.is-bad { color: var(--bad); }
.ovc-sub { font-size: 0.68rem; color: var(--text-secondary); min-height: 0.8em; }

/* Empty state « premier bac » (Suivi à 0 bac) : on masque tout le contenu normal du Suivi et on ne
   garde que la carte d'invite (funnel de création). Scopé par la classe du panneau. */
#tab-bac.is-first-tank > :not(#suivi-first-tank) { display: none; }
/* Centrage vertical de l'invite dans la zone de contenu (sous le header). À 0 bac la sous-nav est
   masquée, donc #tab-bac est le seul enfant en flux de .app-view : l'offset soustrait couvre les
   paddings verticaux de .app-view (pt + pb réservé à la nav fixe) pour rester centré sans jamais
   déborder à 320px. */
#tab-bac.is-first-tank { display: grid; place-items: center; min-height: calc(100dvh - var(--header-height) - 8rem); }
.first-tank { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.7rem; padding: 2.4rem 1.2rem; }
.first-tank-ic { color: var(--accent); display: inline-flex; }
.first-tank-ic svg { width: 44px; height: 44px; }
.first-tank-title { margin: 0; font-size: 1.15rem; }
.first-tank-body { margin: 0; color: var(--text-secondary); font-size: 0.9rem; max-width: 42ch; line-height: 1.5; }
.first-tank-cta { margin-top: 0.4rem; cursor: pointer; }

/* Gabarit d'état vide RÉUTILISABLE (Photos, Habitants, Reproduction) : contenu centré
   verticalement dans la zone dispo, icône trait + message + CTA. Même esprit que .first-tank. */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.6rem; min-height: 42vh; padding: 2rem 1rem; }
.empty-state-ic { color: var(--accent); display: inline-flex; }
.empty-state-ic svg { width: 42px; height: 42px; }
.empty-state-msg { margin: 0; color: var(--text-secondary); font-size: 0.9rem; max-width: 34ch; line-height: 1.5; }
