:root {
  --fond: #F4F1EA;
  --surface: #FFFFFF;
  --texte: #1C1D1A;
  --doux: #6B6D66;
  --trait: #E4E0D6;
  --positif: #1F7A4D;
  --negatif: #B3261E;
  --alerte-fond: #FFF4D6;
  --alerte-texte: #6B4E00;
  --ombre: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #141513;
    --surface: #1E1F1C;
    --texte: #EDEBE4;
    --doux: #9B9D95;
    --trait: #2E302B;
    --positif: #5CC98E;
    --negatif: #FF8A80;
    --alerte-fond: #3A3113;
    --alerte-texte: #F2D98A;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
}

.barre { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.titre { flex: 1; text-align: center; }
.titre h1 { font-size: 20px; font-weight: 650; }
.titre p { color: var(--doux); font-size: 14px; }
.nav {
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 26px; line-height: 1; color: var(--doux);
}
.nav:hover { background: var(--trait); }
.nav:disabled { opacity: .25; cursor: default; background: none; }

.total {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--ombre);
  margin-bottom: 14px;
}
.etiquette { color: var(--doux); font-size: 13px; }
.montant-principal { font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 16px; }
.paire { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--trait); padding-top: 14px; }
.montant { font-size: 18px; font-weight: 600; }

.positif { color: var(--positif); }
.negatif { color: var(--negatif); }

.alerte {
  background: var(--alerte-fond); color: var(--alerte-texte);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px;
}

.liste { display: grid; gap: 10px; }
.carte {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--ombre);
  overflow: hidden;
}
.entete {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 6px; text-align: left;
}
.pastille { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nom { flex: 1; font-weight: 600; }
.resultat { font-weight: 700; font-size: 18px; }
.chiffres { display: flex; gap: 16px; padding: 0 16px 14px 36px; font-size: 14px; flex-wrap: wrap; }
.chiffres em { font-style: normal; color: var(--doux); }
.chiffres b { font-weight: 600; }
.avertissement { padding: 0 16px 12px 36px; font-size: 13px; color: var(--alerte-texte); }
.detail {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
  padding: 12px 16px 14px 36px; border-top: 1px solid var(--trait); font-size: 14px;
}
.detail dt { color: var(--doux); }
.detail dd { text-align: right; }

.carte.inactive .entete { cursor: default; padding-bottom: 14px; }
.carte.inactive .nom { color: var(--doux); }
.puce {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--trait); color: var(--doux);
}
.puce.erreur { background: var(--negatif); color: var(--surface); }

.pied {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; font-size: 13px; color: var(--doux);
}
.lien { color: var(--texte); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.lien:disabled { opacity: .4; }

/* ---------- Coûts réels / estimés ---------- */
.couts { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.couts.reels { background: color-mix(in srgb, var(--positif) 15%, transparent); color: var(--positif); }
.couts.estimes { background: var(--trait); color: var(--doux); }

/* ---------- Onglets bas ---------- */
.app { padding-bottom: calc(env(safe-area-inset-bottom) + 84px); }
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--trait);
}
.onglets button {
  flex: 1; max-width: 200px; padding: 10px; border-radius: 12px;
  font-weight: 600; color: var(--doux);
}
.onglets button.actif { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }

/* ---------- Vue factures ---------- */
.bloc {
  background: var(--surface); border-radius: 16px; box-shadow: var(--ombre);
  padding: 16px; margin-bottom: 12px;
}
.bloc h2 { font-size: 16px; margin-bottom: 4px; }
.compte { color: var(--doux); font-weight: 500; }
.aide { color: var(--doux); font-size: 13px; margin-bottom: 12px; }
.bouton {
  display: inline-block; background: var(--texte); color: var(--fond);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; cursor: pointer;
}
.bouton.secondaire { background: var(--trait); color: var(--texte); }
.bouton:disabled { opacity: .4; cursor: default; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.champs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
input:not([type=checkbox]):not([type=file]) {
  width: 100%; font: inherit; font-size: 16px; color: var(--texte);
  background: var(--fond); border: 1px solid var(--trait); border-radius: 10px; padding: 9px 10px;
}
input:focus { outline: 2px solid var(--texte); outline-offset: -1px; }

.lignes-import { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-height: 50vh; overflow-y: auto; }
.ligne-import {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--trait); border-radius: 10px; font-size: 14px;
}
.ligne-import small { grid-column: 2 / 4; color: var(--doux); }
.ligne-import.ko { opacity: .55; }
.etat { font-size: 12px; font-weight: 600; }
.etat.ok { color: var(--positif); }
.etat.ko { color: var(--negatif); }
.etat.attention { color: var(--alerte-texte); }

.liste-simple { display: grid; grid-template-columns: minmax(0, 1fr); }
.element {
  border-top: 1px solid var(--trait); padding: 10px 0;
}
.element:first-child { border-top: 0; }
.element-tete {
  width: 100%; display: flex; gap: 10px; align-items: center; text-align: left;
}
.element-tete .pastille { margin-top: 0; }
.element-tete .principal { flex: 1; min-width: 0; }
.element-tete .principal b { font-weight: 600; }
.element-tete .principal small {
  display: block; color: var(--doux); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.element-tete .droite { text-align: right; font-size: 14px; }
.element-tete .droite small { display: block; color: var(--doux); font-size: 12px; }
.formulaire { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.formulaire label { font-size: 12px; color: var(--doux); display: grid; gap: 4px; }
.formulaire .large { grid-column: 1 / -1; }
.formulaire .actions { grid-column: 1 / -1; margin-top: 0; }
.supprimer { color: var(--negatif); font-size: 13px; font-weight: 600; }
.vide { color: var(--doux); font-size: 14px; padding: 6px 0; }

/* ---------- Onglet factures ---------- */
.bouton.plein { display: block; width: 100%; margin-bottom: 12px; padding: 13px; font-size: 16px;
  text-align: center; text-decoration: none; }

/* ---------- Tableau jour par jour / mois par mois ---------- */
.tableau { background: var(--surface); border-radius: 16px; box-shadow: var(--ombre); overflow: hidden; }
.tableau-entete, .ligne-tete {
  display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr 1fr 1.1fr; gap: 6px; align-items: center;
}
.tableau-entete { padding: 10px 14px; font-size: 12px; color: var(--doux); border-bottom: 1px solid var(--trait); }
.tableau-entete span:not(:first-child), .ligne-tete span:not(:first-child) { text-align: right; }
.ligne { border-bottom: 1px solid var(--trait); }
.ligne:last-child { border-bottom: 0; }
.ligne-tete { width: 100%; padding: 12px 14px; text-align: left; font-size: 15px; }
.ligne-tete .quand b { display: block; font-weight: 600; }
.ligne-tete .quand small { color: var(--doux); font-size: 12px; }
.ligne-tete .res { font-weight: 700; }
.ligne.vide .ligne-tete { color: var(--doux); }
.ligne.futur .ligne-tete { opacity: .45; cursor: default; }
.ligne.courante { background: color-mix(in srgb, var(--texte) 4%, transparent); }
.ligne.courante > .ligne-tete .quand b::after { content: " •"; color: var(--positif); }
.ligne-detail { padding: 2px 14px 14px; display: grid; gap: 10px; }
.ligne-detail dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.ligne-detail dt { color: var(--doux); }
.ligne-detail dd { text-align: right; }
.par-boutique { display: grid; gap: 4px; font-size: 13px; border-top: 1px dashed var(--trait); padding-top: 8px; }
.par-boutique div { display: flex; align-items: center; gap: 8px; }
.par-boutique .pastille { width: 8px; height: 8px; }
.par-boutique span.n { flex: 1; }
.par-boutique small { color: var(--doux); }
.boutiques-off { color: var(--doux); font-size: 13px; margin-top: 10px; }

/* ---------- Sous-lignes par boutique, total, favicons ---------- */
.ligne-detail { padding: 0 0 8px; gap: 0; }
.ligne-detail > .aide { padding: 0 14px; margin: 0; }
.sous-ligne { border-top: 1px dashed var(--trait); }
.sous-ligne .ligne-tete { padding: 9px 14px 9px 24px; font-size: 14px; }
.sous-ligne .quand b { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.sous-ligne .ligne-detail { padding: 0 14px 10px 24px; gap: 6px; }
.favicon { width: 16px; height: 16px; border-radius: 4px; flex: none; object-fit: contain; }
.total-ligne { border-top: 2px solid var(--texte); }
.total-ligne > .ligne-tete { font-size: 16px; }
.total-ligne > .ligne-tete .quand b { font-weight: 800; }
.ligne-tete[aria-expanded="true"] .quand b::before { content: "▾ "; color: var(--doux); }
.ligne-tete .quand b, .ligne-tete .quand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sous-ligne .ligne-tete { grid-template-columns: minmax(0, 1.6fr) .9fr .9fr 1.1fr; }
.sous-ligne .quand b { font-size: 13px; }
.sous-ligne .quand b > :not(.favicon):not(.pastille) { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bande horizontale de cartes ---------- */
.bande {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 4px 16px 12px; scrollbar-width: none;
}
.bande::-webkit-scrollbar { display: none; }
.carte-periode {
  flex: 0 0 78%; max-width: 300px; scroll-snap-align: start;
  background: var(--surface); border-radius: 18px; box-shadow: var(--ombre);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.carte-periode header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.carte-periode header b { font-size: 16px; font-weight: 650; }
.carte-periode .res { font-size: 24px; font-weight: 750; letter-spacing: -.01em; }
.carte-periode .sous { font-size: 13px; color: var(--doux); }
.carte-periode.courante { outline: 2px solid var(--positif); outline-offset: -2px; }
.carte-periode.futur { opacity: .45; box-shadow: none; border: 1px dashed var(--doux); background: transparent; }
.jauge { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--negatif) 22%, transparent); overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--positif); border-radius: 4px; }
.jauge.perte { background: var(--negatif); }
.rangee-boutiques { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.boutique { display: grid; justify-items: center; gap: 3px; padding: 6px; border-radius: 12px; }
.boutique.active { background: color-mix(in srgb, currentColor 10%, transparent); }
.boutique small { font-size: 12px; font-weight: 600; }
.favicon { width: 36px; height: 36px; border-radius: 9px; object-fit: contain; background: white; display: block; }
.zone-detail:empty { display: none; }
.zone-detail { border-top: 1px solid var(--trait); padding-top: 8px; display: grid; gap: 6px; }
.titre-detail { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.titre-detail .favicon { width: 20px; height: 20px; border-radius: 5px; }
dl.frais { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 13px; }
dl.frais dt { color: var(--doux); }
dl.frais dd { text-align: right; }

/* ---------- Grand écran : cartes en grille, barre d'onglets centrée ---------- */
@media (min-width: 900px) {
  .app { max-width: 1080px; padding-left: 32px; padding-right: 32px; }
  .total, .alerte { max-width: 560px; margin-left: auto; margin-right: auto; }
  .bande {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    overflow: visible; margin: 0; padding: 4px 0 12px;
  }
  .carte-periode { max-width: none; }
  #vue-factures { max-width: 640px; margin: 0 auto; }
  .onglets {
    left: 50%; right: auto; transform: translateX(-50%); width: 420px; bottom: 16px;
    border: 1px solid var(--trait); border-radius: 16px; padding: 6px;
  }
}

/* ---------- Onglet Retours ---------- */
.grille-chiffres { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.chiffre { background: var(--surface); border-radius: 16px; box-shadow: var(--ombre); padding: 12px 14px; }
.chiffre .montant { font-size: 20px; font-weight: 700; margin-top: 2px; }
.chiffre.positif .montant { color: var(--positif); }
.chiffre.negatif .montant { color: var(--negatif); }
.chiffre .aide { margin: 4px 0 0; font-size: 12px; }
#vue-retours { max-width: 720px; margin: 0 auto; }
.onglets button { padding: 10px 6px; font-size: 14px; }
@media (min-width: 900px) { .onglets { width: 520px; } }

.chiffre.large { grid-column: 1 / -1; }
.chiffre.large .montant { font-size: 30px; }
dl.frais .fort { font-weight: 700; color: var(--texte); border-top: 1px solid var(--trait); padding-top: 4px; }
#retours-decomposition { display: grid; gap: 10px; }

.paire { grid-template-columns: repeat(4, 1fr); }
.ligne-retours { font-size: 12px; color: var(--alerte-texte); background: var(--alerte-fond);
  border-radius: 8px; padding: 3px 8px; justify-self: start; align-self: flex-start; }
dl.frais dt.sous-titre { font-weight: 700; color: var(--texte); margin-top: 6px; }
dl.frais .info { font-size: 12px; font-style: italic; }

/* ---------- Carte récap (total) ---------- */
.carte-periode.total { background: var(--surface); color: var(--texte); border: 2px solid var(--texte); }
.carte-periode.total header small { color: var(--doux); font-size: 13px; }
dl.recap { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 15px; margin: 2px 0; }
dl.recap dt { color: var(--doux); }
dl.recap dd { text-align: right; font-variant-numeric: tabular-nums; }
dl.recap .fort { font-weight: 700; font-size: 18px; color: var(--texte); border-top: 1px solid var(--trait); padding-top: 6px; }
dl.recap dd.fort.positif { color: var(--positif); }
dl.recap dd.fort.negatif { color: var(--negatif); }

/* ---------- Tableau comparatif par boutique ---------- */
.carte-periode { flex: 0 0 auto; width: max(78%, 280px); max-width: none; }
.compare-cadre { overflow-x: auto; margin: 2px -4px 0; }
table.compare { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.compare th, table.compare td { padding: 4px 6px; text-align: right; white-space: nowrap; }
table.compare thead th { padding-bottom: 6px; }
table.compare thead .favicon { width: 26px; height: 26px; border-radius: 7px; display: inline-block; }
table.compare tbody th { text-align: left; font-weight: 500; color: var(--doux); }
table.compare tbody tr + tr { border-top: 1px solid var(--trait); }
table.compare td.zero { color: color-mix(in srgb, var(--doux) 55%, transparent); }
table.compare td.plus { color: var(--positif); }
table.compare .col-total { font-weight: 700; background: color-mix(in srgb, var(--texte) 5%, transparent); }
table.compare thead .col-total { font-size: 12px; color: var(--doux); }
table.compare tr.resultat-ligne { border-top: 2px solid var(--texte) !important; }
table.compare tr.resultat-ligne th { color: var(--texte); font-weight: 700; }
table.compare tr.resultat-ligne td { font-weight: 700; font-size: 14px; }
.aide.unite { font-size: 11px; text-align: right; margin: 2px 4px 0; }
@media (min-width: 900px) { .carte-periode { width: auto; } .bande { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }

/* Téléphone : carte quasi pleine largeur pour que toutes les colonnes tiennent */
@media (max-width: 899px) {
  .carte-periode { width: calc(100vw - 40px); padding: 14px 12px; }
  table.compare { font-size: 12px; }
  table.compare th, table.compare td { padding: 4px 3px; }
  table.compare thead .favicon { width: 22px; height: 22px; }
}

/* ---------- Bilan (tableau périodes × postes) ---------- */
.titre-section, .bilan h2 { font-size: 17px; font-weight: 700; margin: 18px 2px 10px; }
.bilan { background: var(--surface); border-radius: 18px; box-shadow: var(--ombre); padding: 6px 0 10px; margin-bottom: 8px; }
.bilan h2 { margin: 10px 16px 8px; }
.bilan-cadre { overflow-x: auto; }
table.bilan-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.bilan-table th, .bilan-table td { padding: 7px 12px; text-align: right; white-space: nowrap; }
.bilan-table thead th { font-size: 13px; color: var(--doux); font-weight: 600; border-bottom: 1px solid var(--trait); }
.bilan-table thead th.en-cours { color: var(--texte); }
.bilan-table th.poste { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1;
  font-weight: 500; color: var(--doux); min-width: 150px; }
.bilan-table tbody tr + tr td, .bilan-table tbody tr + tr th { border-top: 1px solid var(--trait); }
.bilan-table td.zero { color: color-mix(in srgb, var(--doux) 50%, transparent); }
.bilan-table td.en-cours { background: color-mix(in srgb, var(--positif) 6%, transparent); }
.bilan-table .col-total { font-weight: 700; background: color-mix(in srgb, var(--texte) 6%, transparent); }
.bilan-table tr.sous-total th, .bilan-table tr.sous-total td { font-weight: 700; color: var(--texte); }
.bilan-table tr.resultat th, .bilan-table tr.resultat td { font-weight: 800; font-size: 16px; color: var(--texte);
  border-top: 2px solid var(--texte) !important; }
.bilan-table tr.resultat td.positif { color: var(--positif); }
.bilan-table tr.resultat td.negatif { color: var(--negatif); }
.bilan-table tr.marge td, .bilan-table tr.marge th { font-weight: 600; }
.bilan-table tr.info th, .bilan-table tr.info td { font-size: 13px; color: var(--doux); }
.bilan-table tr.info:first-of-type th { border-top: 2px solid var(--trait); }

/* Grand écran : toute la largeur */
@media (min-width: 900px) {
  .app { max-width: none; padding-left: 40px; padding-right: 40px; }
  .total, .alerte { max-width: none; }
  .bilan-table { font-size: 15px; }
  .bilan-table th, .bilan-table td { padding: 9px 16px; }
  #vue-factures, #vue-retours { max-width: 1100px; }
}

/* ---------- Toutes les périodes sur une ligne (carrousels) ---------- */
.entete-carrousel { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bilan .entete-carrousel { padding-right: 12px; }
.fleches { display: none; gap: 6px; }
.fleche { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--trait);
  background: var(--surface); color: var(--texte); font-size: 20px; line-height: 1; }
.fleche:hover { background: var(--trait); }
.bande { display: flex !important; overflow-x: auto; scroll-snap-type: x proximity; scroll-behavior: smooth; }
.carte-periode { scroll-snap-align: end; }
.bilan-cadre { scroll-behavior: smooth; }
.bilan-table thead th:not(.poste) { min-width: 118px; }
@media (min-width: 900px) {
  .fleches { display: inline-flex; }
  .bande { margin: 0; padding: 4px 0 14px; gap: 14px; }
  .carte-periode { flex: 0 0 360px; width: 360px; }
}
@media (max-width: 899px) {
  .bilan-table th.poste { min-width: 0; max-width: 118px; white-space: normal; line-height: 1.2; font-size: 13px; }
  .bilan-table th, .bilan-table td { padding: 7px 9px; }
  .bilan-table thead th:not(.poste) { min-width: 100px; }
}

/* ---------- Stats & Graphiques ---------- */
#vue-stats, #vue-graphiques { max-width: 1200px; margin: 0 auto; }
.choix-periode { display: flex; gap: 6px; justify-content: center; margin: -4px 0 14px; }
.choix-periode button { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--trait);
  font-size: 14px; font-weight: 600; color: var(--doux); background: transparent; }
.choix-periode button.actif { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.chiffre .delta { font-weight: 700; }
.bloc h2 + .aide { margin-top: 2px; }

.rep { display: grid; grid-template-columns: 140px 1fr 70px; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.rep-lib { color: var(--doux); }
.rep-jauge { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--trait) 60%, transparent); overflow: hidden; }
.rep-jauge i { display: block; height: 100%; border-radius: 99px; background: color-mix(in srgb, var(--negatif) 70%, transparent); }
.rep.reste { border-top: 1px solid var(--trait); margin-top: 4px; padding-top: 9px; font-weight: 700; }
.rep.reste .rep-lib { color: var(--texte); }
.rep.reste .rep-jauge i { background: var(--positif); }
.rep.reste .rep-jauge i.neg { background: var(--negatif); }
.rep-val { text-align: right; font-variant-numeric: tabular-nums; }

.tableau-cadre { overflow-x: auto; margin: 8px -16px 0; padding: 0 16px; }
table.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 8px 10px; text-align: right; white-space: nowrap; vertical-align: top; }
.stats-table th { font-size: 12px; color: var(--doux); font-weight: 600; border-bottom: 1px solid var(--trait); }
.stats-table tbody tr + tr td { border-top: 1px solid var(--trait); }
.stats-table .gauche { text-align: left; }
.stats-table td small { display: block; font-size: 12px; color: var(--doux); font-weight: 400; }
.stats-table.produits td.gauche { white-space: normal; min-width: 130px; font-weight: 600; }

.graphes { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .graphes { grid-template-columns: 1fr 1fr; }
  .graphes .graphe-bloc:first-child { grid-column: 1 / -1; }
}
.graphe-bloc { margin: 0; min-width: 0; }
svg.graphe { width: 100%; height: auto; display: block; margin-top: 6px; overflow: visible; }
.graphe .axe { stroke: var(--trait); stroke-width: 1; }
.graphe .axe.zero { stroke: var(--doux); }
.graphe .grad { fill: var(--doux); font-size: 12px; }
.graphe .courbe { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.graphe .aire { opacity: .15; stroke: none; }
.graphe .seuil { stroke: var(--doux); stroke-width: 1.5; stroke-dasharray: 5 4; }
.c-ca { fill: #3E7CB1; stroke: #3E7CB1; background: #3E7CB1; }
.c-pub { fill: #E0A23B; stroke: #E0A23B; background: #E0A23B; }
.c-res { fill: var(--positif); stroke: var(--positif); background: var(--positif); }
.c-roas { fill: #7B5EA7; stroke: #7B5EA7; background: #7B5EA7; }
.c-cmd { fill: #5B8C85; stroke: #5B8C85; background: #5B8C85; }
.graphe .point { stroke: var(--surface); stroke-width: 1.5; }
.legende { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--doux); margin-top: 4px; }
.legende .pastille { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legende .pastille.trait { height: 3px; border-radius: 2px; vertical-align: 3px; width: 16px; }
.barres-h { display: grid; gap: 8px; margin-top: 8px; }
.bh { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 80px; gap: 10px; align-items: center; font-size: 14px; }
.bh-lib small { display: block; color: var(--doux); font-size: 12px; }
.bh-piste { height: 14px; background: color-mix(in srgb, var(--trait) 50%, transparent); border-radius: 4px; overflow: hidden; }
.bh-piste i { display: block; height: 100%; border-radius: 4px; }
.bh-piste i.neg { background: var(--negatif); }
.bh-val { text-align: right; font-variant-numeric: tabular-nums; }
.onglets { gap: 4px; }
.onglets button { font-size: 13px; padding: 10px 4px; }
@media (min-width: 900px) { .onglets { width: 680px; } .onglets button { font-size: 14px; } }
@media (max-width: 420px) { .onglets { padding-left: 6px; padding-right: 6px; } .onglets button { font-size: 12px; } }
@media (min-width: 900px) { #stats-kpi { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 900px) { .onglets { width: 760px; } }

/* ---------- Onglet Boutiques ---------- */
#vue-boutiques { max-width: 1200px; margin: 0 auto; }
.choix-boutiques { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: -4px 0 14px; }
.choix-boutique { width: 64px; height: 64px; border-radius: 18px; background: var(--surface); box-shadow: var(--ombre);
  display: grid; place-items: center; border: 2px solid transparent; opacity: .55; }
.choix-boutique.actif { border-color: var(--texte); opacity: 1; }
.choix-boutique .favicon { width: 40px; height: 40px; border-radius: 10px; }
.aide.centre { text-align: center; }
#vue-boutiques .bilan { margin-bottom: 12px; }
@media (min-width: 900px) { #boutique-kpi { grid-template-columns: repeat(5, 1fr); } .onglets { width: 840px; } }
/* 8 onglets : sur téléphone, la barre défile si besoin */
@media (max-width: 520px) {
  .onglets { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .onglets::-webkit-scrollbar { display: none; }
  .onglets button { flex: 0 0 auto; padding: 10px 9px; }
}

/* La barre d onglets passe devant la colonne figée des tableaux */
.onglets { z-index: 50; }
@media (max-width: 520px) { .choix-boutiques { gap: 10px; flex-wrap: nowrap; } .choix-boutique { width: 54px; height: 54px; border-radius: 15px; } .choix-boutique .favicon { width: 34px; height: 34px; } }

/* Filtre boutique des onglets Stats et Graphiques */
.choix-boutiques.petit .choix-boutique { width: 48px; height: 48px; border-radius: 14px; }
.choix-boutiques.petit .choix-boutique .favicon { width: 30px; height: 30px; }
.choix-boutique .toutes { font-size: 12px; font-weight: 700; color: var(--texte); }
