/* Diapason : interface de veille prix
   Palette : encre, laiton (accastillage d'instrument), vert "moins cher", rouge "plus cher" */
:root {
  --fond: #eceee9;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --encre: #1c2433;
  --encre-2: #566072;
  --trait: #d5d9d1;
  --laiton: #9a7a22;
  --laiton-doux: #f3ead1;
  --vert: #2f7d4f;
  --vert-doux: #e3f1e8;
  --rouge: #b83b32;
  --rouge-doux: #f8e3e0;
  --ombre: 0 1px 0 rgba(28, 36, 51, .06), 0 8px 24px -12px rgba(28, 36, 51, .25);
  --r-petit: 6px;
  --r-grand: 14px;
  --police: "Archivo", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #13171e; --surface: #1b212b; --surface-2: #212833; --encre: #e8ebef; --encre-2: #9aa3b2;
    --trait: #2d3542; --laiton: #d6b45c; --laiton-doux: #3a3222; --vert: #5cb884; --vert-doux: #1e3328;
    --rouge: #e56b61; --rouge-doux: #3c2221; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #13171e; --surface: #1b212b; --surface-2: #212833; --encre: #e8ebef; --encre-2: #9aa3b2;
  --trait: #2d3542; --laiton: #d6b45c; --laiton-doux: #3a3222; --vert: #5cb884; --vert-doux: #1e3328;
  --rouge: #e56b61; --rouge-doux: #3c2221; color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--encre); font-family: var(--police);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--laiton); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Connexion ---------- */
.connexion {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.connexion form {
  width: min(380px, 100%); background: var(--surface); border-radius: var(--r-grand);
  box-shadow: var(--ombre); padding: 32px;
}
.marque {
  font-stretch: 75%; font-weight: 800; font-size: 30px; letter-spacing: -.01em; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.marque svg { color: var(--laiton); flex: none; }
.connexion p { color: var(--encre-2); margin: 6px 0 24px; }
.champ { display: grid; gap: 6px; margin-bottom: 14px; }
.champ label { font-size: 13px; font-weight: 600; color: var(--encre-2); }
.champ input, .champ select, .champ textarea {
  width: 100%; border: 1px solid var(--trait); background: var(--surface-2); border-radius: var(--r-petit);
  padding: 10px 12px;
}
.erreur-form { color: var(--rouge); font-size: 14px; min-height: 20px; margin: 0 0 8px; }

/* ---------- Boutons ---------- */
.btn {
  border: 1px solid var(--trait); background: var(--surface); border-radius: 999px; padding: 8px 16px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover { border-color: var(--encre-2); }
.btn-plein { background: var(--encre); color: var(--surface); border-color: var(--encre); }
.btn-plein:hover { opacity: .9; }
.btn-danger { color: var(--rouge); }
.btn-lien { border: 0; background: none; padding: 4px; cursor: pointer; color: var(--encre-2); }
.btn-lien:hover { color: var(--encre); }
.btn[disabled] { opacity: .5; cursor: progress; }
.largeur { width: 100%; justify-content: center; padding: 11px; }

/* ---------- En-tête ---------- */
.entete {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--fond);
  border-bottom: 1px solid var(--trait);
}
.entete-in {
  max-width: 1320px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px;
}
.entete .marque { font-size: 24px; }
.onglets { display: flex; gap: 4px; flex: 1; }
.onglets button {
  border: 0; background: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600;
  color: var(--encre-2);
}
.onglets button[aria-current="page"] { background: var(--surface); color: var(--encre); box-shadow: var(--ombre); }
.utilisateur { color: var(--encre-2); font-size: 13px; }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ---------- Bandeau résumé (filtres) ---------- */
.resume { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; align-items: stretch; }
.resume button {
  border: 1px solid var(--trait); background: var(--surface); border-radius: var(--r-petit);
  padding: 10px 14px; text-align: left; cursor: pointer; display: grid; gap: 2px; min-width: 150px;
}
.resume button strong { font-size: 22px; font-stretch: 80%; font-weight: 700; line-height: 1.1; }
.resume button span { font-size: 13px; color: var(--encre-2); }
.resume button[aria-pressed="true"] { border-color: var(--encre); box-shadow: inset 0 0 0 1px var(--encre); }
.resume .rouge strong { color: var(--rouge); }
.resume .vert strong { color: var(--vert); }
.resume .laiton strong { color: var(--laiton); }
.derniere-veille { margin-left: auto; align-self: center; color: var(--encre-2); font-size: 13px; text-align: right; }

.barre-outils { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.recherche {
  flex: 1; min-width: 220px; border: 1px solid var(--trait); background: var(--surface);
  border-radius: 999px; padding: 9px 16px;
}
.barre-outils select { border: 1px solid var(--trait); background: var(--surface); border-radius: 999px; padding: 9px 14px; }

/* ---------- Tableau ---------- */
.tableau-conteneur {
  background: var(--surface); border-radius: var(--r-grand); box-shadow: var(--ombre); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--encre-2); padding: 12px 14px;
  border-bottom: 1px solid var(--trait); white-space: nowrap; background: var(--surface);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
th.d, td.d { text-align: right; }
.produit { display: flex; gap: 12px; align-items: center; min-width: 240px; }
.vignette {
  width: 44px; height: 44px; border-radius: var(--r-petit); background: var(--surface-2); object-fit: contain;
  flex: none; border: 1px solid var(--trait);
}
.produit b { display: block; font-weight: 600; line-height: 1.25; }
.produit small, .sous { color: var(--encre-2); font-size: 12.5px; }
.prix { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vide { padding: 48px 24px; text-align: center; color: var(--encre-2); }
.vide strong { display: block; color: var(--encre); font-size: 17px; margin-bottom: 6px; }

/* ---------- L'accordeur : écart de prix ---------- */
.accordeur { display: grid; gap: 4px; width: 150px; }
.accordeur-echelle {
  position: relative; height: 18px;
  background:
    repeating-linear-gradient(90deg, var(--trait) 0 1px, transparent 1px 10%) 0 100% / 100% 6px no-repeat,
    linear-gradient(90deg, var(--vert-doux), transparent 45%, transparent 55%, var(--rouge-doux));
  border-radius: 3px;
}
.accordeur-echelle::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--encre-2); opacity: .5;
}
.aiguille {
  position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1.5px; border-radius: 2px;
  background: var(--encre); transition: left .5s cubic-bezier(.3, 1.4, .5, 1);
}
.accordeur.vert .aiguille { background: var(--vert); }
.accordeur.rouge .aiguille { background: var(--rouge); }
.accordeur-texte { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.accordeur.vert .accordeur-texte { color: var(--vert); }
.accordeur.rouge .accordeur-texte { color: var(--rouge); }
.accordeur.juste .accordeur-texte { color: var(--encre-2); }
@media (prefers-reduced-motion: reduce) { .aiguille { transition: none; } }

.pastille {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--laiton-doux); color: var(--laiton); white-space: nowrap;
}
.pastille.rouge { background: var(--rouge-doux); color: var(--rouge); }
.pastille.vert { background: var(--vert-doux); color: var(--vert); }
.pastille.gris { background: var(--surface-2); color: var(--encre-2); }

/* ---------- Tiroir fiche produit ---------- */
.voile { position: fixed; inset: 0; background: rgba(12, 16, 24, .45); z-index: 20; }
.tiroir {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--fond); z-index: 21;
  overflow-y: auto; padding: calc(20px + env(safe-area-inset-top, 0px)) 24px calc(32px + env(safe-area-inset-bottom, 0px));
  box-shadow: -20px 0 40px -20px rgba(0, 0, 0, .35); animation: entree .22s ease-out;
}
@keyframes entree { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tiroir { animation: none; } }
.tiroir-haut { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.tiroir h2 { margin: 0; font-stretch: 80%; font-size: 26px; line-height: 1.1; }
.fiche-tete { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.fiche-tete img { width: 96px; height: 96px; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 20px; }
.chiffre { background: var(--surface); border-radius: var(--r-petit); padding: 10px 12px; }
.chiffre span { display: block; font-size: 12.5px; color: var(--encre-2); }
.chiffre b { font-size: 18px; font-variant-numeric: tabular-nums; }
.bloc { background: var(--surface); border-radius: var(--r-grand); padding: 16px; margin-bottom: 14px; box-shadow: var(--ombre); }
.bloc h3 { margin: 0 0 12px; font-size: 16px; }
.offre {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--trait);
}
.offre:first-of-type { border-top: 0; padding-top: 0; }
.offre-nom { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.offre-nom a { color: inherit; }
.offre-prix { text-align: right; }
.offre-prix s { color: var(--encre-2); font-size: 13px; margin-right: 6px; }
.offre-meta { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--encre-2); }
.ajout-lien { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; margin-top: 12px; }
.ajout-lien select, .ajout-lien input {
  border: 1px solid var(--trait); background: var(--surface-2); border-radius: var(--r-petit); padding: 8px 10px; min-width: 0;
}
.graphe { height: 220px; }
.bloc-accordeur .accordeur { width: 100%; }
.bloc-accordeur .accordeur-echelle { height: 24px; }
.bloc-accordeur .accordeur-texte { font-size: 15px; }
.actions-fiche { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Modale ---------- */
dialog {
  border: 0; border-radius: var(--r-grand); padding: 24px; width: min(560px, calc(100% - 32px));
  background: var(--surface); color: var(--encre); box-shadow: var(--ombre);
}
dialog::backdrop { background: rgba(12, 16, 24, .5); }
dialog h2 { margin: 0 0 16px; font-stretch: 80%; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pied-modale { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.pied-modale .btn-danger { margin-right: auto; }
.apercu-import { font-size: 13.5px; color: var(--encre-2); background: var(--surface-2); border-radius: var(--r-petit); padding: 12px; margin: 10px 0; }
.apercu-import b { color: var(--encre); }

/* ---------- Notifications ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--encre); color: var(--surface); padding: 12px 18px; border-radius: 999px; z-index: 50;
  font-weight: 600; box-shadow: var(--ombre); max-width: calc(100% - 32px);
}
.toast.erreur { background: var(--rouge); color: #fff; }
.demo {
  background: var(--laiton-doux); color: var(--encre); text-align: center; font-size: 13px; padding: 6px 12px;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .entete-in { flex-wrap: wrap; gap: 10px 16px; padding: 10px 16px; }
  .onglets { order: 3; flex-basis: 100%; overflow-x: auto; }
  .utilisateur { display: none; }
  main { padding: 16px; }
  .resume button { min-width: calc(50% - 4px); flex: 1; }
  .derniere-veille { flex-basis: 100%; text-align: left; margin: 0; }
  .grille-2 { grid-template-columns: 1fr; }
  .ajout-lien { grid-template-columns: 1fr; }
}
