/* Maquette fonctionnelle : volontairement sobre. Toutes les couleurs et
   tailles sont des variables pour la future passe graphique. */
:root {
  --fond: #f4f4f5;
  --surface: #ffffff;
  --texte: #18181b;
  --texte-doux: #71717a;
  --bord: #e4e4e7;
  --accent: #18181b;
  --accent-texte: #ffffff;
  --ok: #16a34a;
  --alerte: #d97706;
  --erreur: #dc2626;
  --rayon: 12px;
  --espace: 12px;
  --s-commande: #a1a1aa;
  --s-arrive: #60a5fa;
  --s-en_vente: #22c55e;
  --s-vendu: #f59e0b;
  --s-livre: #16a34a;
  --hauteur-onglets: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #09090b; --surface: #18181b; --texte: #fafafa; --texte-doux: #a1a1aa;
    --bord: #27272a; --accent: #fafafa; --accent-texte: #09090b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--hauteur-onglets) + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
h3 { font-size: .9rem; margin: 14px 0 6px; color: var(--texte-doux); }
small { color: var(--texte-doux); }
img { max-width: 100%; }

/* --- Structure --- */
.entete {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--bord);
}
.entete h1 { flex: 1; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete-action, .entete-retour { text-decoration: none; font-size: 1.4rem; padding: 0 6px; }
.page { max-width: 720px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: var(--espace); }
.onglets {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--surface);
  border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom);
}
.onglets a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--hauteur-onglets); text-decoration: none; font-size: .72rem; color: var(--texte-doux);
}
.onglets a span { font-size: 1.3rem; position: relative; }
.onglets a.actif { color: var(--texte); font-weight: 600; }
.pastille {
  position: absolute; top: -4px; right: -12px; background: var(--erreur); color: #fff; border-radius: 99px;
  font-size: .65rem; padding: 1px 5px; font-style: normal;
}

/* --- Blocs --- */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.carte-lien { text-decoration: none; }
.carte-solde { text-align: center; align-items: center; }
.carte-alerte { border-color: var(--alerte); }
.carte-action { border: 2px solid var(--accent); }
.gros-chiffre { font-size: 2.2rem; font-weight: 700; margin: 0; }
.gros { font-size: 1.2rem; }
.grille-chiffres { display: grid; grid-template-columns: 1fr 1fr; gap: var(--espace); }
.chiffre { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chiffre b { font-size: 1.25rem; }
.ligne-entre { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.boutons, .actions-rapides { display: flex; flex-wrap: wrap; gap: 8px; }
.actions-rapides .bouton { flex: 1; }
.vide { color: var(--texte-doux); font-style: italic; }
.aide { color: var(--texte-doux); font-size: .88rem; margin: 0; }
.infos { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.infos dt { color: var(--texte-doux); }
.infos dd { margin: 0; text-align: right; }
.liste-simple { margin: 0; padding-left: 18px; }
.liste-simple li { margin: 3px 0; }
.activite { margin: 0; font-size: .9rem; }
.flash { padding: 10px 12px; border-radius: var(--rayon); background: #dcfce7; color: #14532d; }
.flash-erreur { background: #fee2e2; color: #7f1d1d; }
.flash-alerte { background: #fef3c7; color: #78350f; }
.zone-danger { margin-top: 12px; color: var(--texte-doux); }
.menu { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); }
.menu a { padding: 14px; border-bottom: 1px solid var(--bord); text-decoration: none; }
.menu a:last-child { border-bottom: 0; }

/* --- Badges de statut --- */
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--bord); white-space: nowrap; }
.badge-commande { border-color: var(--s-commande); }
.badge-arrive { border-color: var(--s-arrive); }
.badge-en_vente { border-color: var(--s-en_vente); }
.badge-vendu { border-color: var(--s-vendu); }
.badge-livre { border-color: var(--s-livre); }
.frise { display: flex; list-style: none; padding: 0; margin: 4px 0; }
.frise li { flex: 1; text-align: center; opacity: .3; display: flex; flex-direction: column; font-size: 1.1rem; }
.frise li small { font-size: .65rem; }
.frise li.fait { opacity: 1; }

/* --- Listes d'articles --- */
.ligne-article {
  display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 8px; text-decoration: none;
}
.carte .ligne-article { border: 0; border-top: 1px solid var(--bord); border-radius: 0; padding: 8px 0; }
.ligne-article img, .sans-image { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.sans-image { display: grid; place-items: center; background: var(--fond); font-size: 1.5rem; }
.ligne-article-texte { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.ligne-article-texte b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ligne-article-prix { text-align: right; font-weight: 600; white-space: nowrap; }
.filtres-statut { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.filtres-statut a {
  white-space: nowrap; text-decoration: none; padding: 6px 10px; border-radius: 99px; background: var(--surface);
  border: 1px solid var(--bord); font-size: .85rem;
}
.filtres-statut a.actif { background: var(--accent); color: var(--accent-texte); }
.recherche { display: flex; flex-wrap: wrap; gap: 6px; }
.recherche input[type=search] { flex: 1 1 100%; }
.recherche select { flex: 1; min-width: 0; }

/* --- Images --- */
.galerie, .carrousel { display: flex; gap: 8px; overflow-x: auto; }
.vignette { display: block; flex-shrink: 0; border-radius: 8px; overflow: hidden; background: var(--fond); position: relative; text-decoration: none; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette-m { width: 96px; height: 96px; }
.vignette-g { width: 220px; height: 220px; }
.carrousel .vignette-g { width: 80vw; max-width: 360px; height: 80vw; max-height: 360px; }
.vignette-texte { display: grid; place-items: center; text-align: center; font-size: .8rem; padding: 4px; }
.vignette-video b { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 2rem; text-shadow: 0 0 6px #000; }
.grille-preuves { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preuve { margin: 0; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.preuve .vignette { width: 100%; height: 130px; }
.preuve figcaption { display: flex; flex-direction: column; font-size: .82rem; }

/* --- Jauges et graphiques --- */
.jauge, .barre { height: 6px; background: var(--fond); border-radius: 99px; overflow: hidden; }
.jauge i, .barre i { display: block; height: 100%; background: var(--ok); }
.ligne-barre { display: grid; grid-template-columns: 60px 1fr 32px; gap: 8px; align-items: center; font-size: .85rem; }
.ligne-barre b { text-align: right; }
.histo { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.histo-barre { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.histo-barre i { display: block; width: 100%; background: var(--bord); border-radius: 4px 4px 0 0; min-height: 1px; }
.histo-barre i.histo-benef { position: absolute; bottom: 18px; width: 50%; background: var(--ok); }
.histo-barre small { font-size: .65rem; height: 18px; }
.histo-fin { height: 80px; gap: 1px; }
.legende { font-size: .8rem; color: var(--texte-doux); margin: 0; }
.pastille-ca, .pastille-benef { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--bord); }
.pastille-benef { background: var(--ok); }
.tableau { width: 100%; border-collapse: collapse; font-size: .85rem; }
.tableau th, .tableau td { padding: 6px 4px; border-bottom: 1px solid var(--bord); text-align: right; white-space: nowrap; }
.tableau td:first-child { white-space: normal; }
.carte:has(> .tableau) { overflow-x: auto; }
.tableau th:first-child, .tableau td:first-child { text-align: left; }
.tableau .barre { height: 4px; margin-top: 3px; }

/* --- Formulaires --- */
.formulaire { display: flex; flex-direction: column; gap: 10px; }
.formulaire-ligne { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
fieldset { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
legend { font-weight: 600; padding: 0 4px; }
.champ { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; min-width: 0; }
.champ > span { color: var(--texte-doux); }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 10px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); min-height: 44px;
}
input[type=file] { font-size: .85rem; max-width: 100%; }
.avec-bouton { display: flex; gap: 6px; }
.choix { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.choix input[name=prix] { width: 120px; }
.ligne-saisie { border-top: 1px dashed var(--bord); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ligne-saisie:first-child { border-top: 0; padding-top: 0; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--bord); background: var(--surface); text-decoration: none; cursor: pointer;
}
.bouton-principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); font-weight: 600; }
.bouton-danger { background: var(--erreur); color: #fff; border-color: var(--erreur); }
.bouton-large { width: 100%; }
.lien-discret { background: none; border: 0; color: var(--texte-doux); cursor: pointer; padding: 4px; text-decoration: underline; }
.progression { height: 22px; background: var(--fond); border-radius: 8px; overflow: hidden; position: relative; font-size: .8rem; }
.progression i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ok); opacity: .4; }
.progression span { position: relative; padding-left: 8px; line-height: 22px; }
details summary { cursor: pointer; padding: 6px 0; }
.ligne-reglement { border-top: 1px solid var(--bord); padding-top: 8px; }

/* --- Chat --- */
.page-chat .page { padding-bottom: 0; }
.fil { display: flex; flex-direction: column; gap: 8px; padding-bottom: 150px; }
.message { align-self: flex-start; max-width: 85%; background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.message-moi { align-self: flex-end; background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.message-moi small, .message-moi a { color: inherit; opacity: .8; }
.message p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.message header { font-size: .78rem; }
.message-article { font-size: .82rem; text-decoration: none; padding: 4px 8px; border-radius: 8px; background: rgba(127,127,127,.15); }
.message-fichier { display: flex; flex-direction: column; gap: 4px; }
.associer { font-size: .85rem; }
.associer .formulaire { color: var(--texte); background: var(--surface); padding: 8px; border-radius: 8px; }
.saisie-chat {
  position: fixed; left: 0; right: 0; bottom: calc(var(--hauteur-onglets) + env(safe-area-inset-bottom)); z-index: 9;
  background: var(--surface); border-top: 1px solid var(--bord); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px;
}
.saisie-chat-options, .saisie-chat-ligne { display: flex; gap: 6px; max-width: 720px; width: 100%; margin: 0 auto; }
.saisie-chat-options select { flex: 1; min-height: 36px; padding: 4px 8px; }
.saisie-chat-ligne textarea { flex: 1; resize: none; min-height: 44px; max-height: 140px; }

/* --- Connexion --- */
.page-connexion { padding-bottom: 0; }
.connexion { max-width: 360px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 14px; text-align: center; align-items: center; }
.connexion .formulaire { width: 100%; text-align: left; }
.carte-inactive { opacity: .6; }
