:root {
  --fond: #f4f6fb;
  --carte: #ffffff;
  --texte: #1c2333;
  --doux: #6b7385;
  --bord: #e3e7ef;
  --accent: #2f5bea;
  --accent-fonce: #2148c4;
  --accent-clair: #e9efff;
  --vert: #18a058;
  --rouge: #d64545;
  --ombre: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --rayon: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--texte);
  background: var(--fond);
}

header.barre {
  display: flex;
  flex-wrap: wrap;            /* tablette / téléphone : la barre passe à la ligne au lieu de déborder */
  align-items: center;
  gap: 4px 24px;
  padding: 6px 28px;
  min-height: 60px;
  background: var(--carte);
  border-bottom: 1px solid var(--bord);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.barre .logo { white-space: nowrap; font-weight: 700; font-size: 16px; color: var(--texte); text-decoration: none; }
header.barre .logo span { color: var(--accent); }
header.barre nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 440px; }
header.barre nav a {
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--doux);
  text-decoration: none;
  font-weight: 500;
}
header.barre nav a:hover { background: var(--fond); color: var(--texte); }
header.barre nav a.actif { background: var(--accent-clair); color: var(--accent); }

main { max-width: 1400px; margin: 0 auto; padding: 28px; }

h1 { font-size: 22px; margin: 0 0 4px; }
p.sous-titre { color: var(--doux); margin: 0 0 22px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
  margin-bottom: 20px;
}

.grille-outils { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
a.outil {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .12s, box-shadow .12s;
}
a.outil:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(20, 30, 60, .12); }
.outil .icone {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-clair); color: var(--accent);
  font-size: 22px; margin-bottom: 14px;
}
.outil h2 { font-size: 17px; margin: 0 0 6px; }
.outil p { margin: 0; color: var(--doux); line-height: 1.5; }
.outil.bientot { opacity: .55; pointer-events: none; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--fond); color: var(--doux); margin-left: 6px; vertical-align: middle; }

label.titre-champ { display: block; font-weight: 600; margin-bottom: 8px; }
textarea, input[type=text], input[type=search], input[type=password] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-clair); }
textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; }

.ligne { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ligne.espace { justify-content: space-between; }
.aide { color: var(--doux); font-size: 13px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--bord);
  background: #fff;
  color: var(--texte);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--fond); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
button.principal:hover:not(:disabled) { background: var(--accent-fonce); }
button.petit { padding: 4px 10px; font-size: 12px; font-weight: 500; }

.case { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }

.progression { height: 8px; background: var(--fond); border-radius: 99px; overflow: hidden; }
.progression > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progression.indetermine > div { width: 30%; animation: aller-retour 1.2s ease-in-out infinite; }
@keyframes aller-retour { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

details.journal summary { cursor: pointer; color: var(--doux); margin-top: 12px; }
pre.journal {
  max-height: 220px; overflow: auto;
  background: #111827; color: #d1d5db;
  border-radius: 8px; padding: 12px; font-size: 12px; margin: 8px 0 0;
  white-space: pre-wrap;
}

.etat { margin: 12px 0 0; color: var(--doux); }
.etat.erreur { color: var(--rouge); }
.etat.ok { color: var(--vert); }

.outils-tableau { margin-bottom: 12px; }
.outils-tableau input[type=search] { max-width: 320px; }

.tableau-conteneur { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--bord); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--bord); white-space: nowrap; }
td.long { white-space: normal; min-width: 280px; max-width: 520px; }
th {
  position: sticky; top: 0;
  background: #f8f9fc; font-weight: 600; font-size: 12px; color: var(--doux);
  text-transform: none; cursor: pointer; user-select: none;
}
th:hover { color: var(--texte); }
th .tri { color: var(--accent); margin-left: 4px; }
tbody tr:hover { background: #fafbff; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ean { font-family: ui-monospace, Menlo, Consolas, monospace; }
td.ean .cellule-ean { display: inline-flex; align-items: center; gap: 8px; }
button.copier {
  padding: 2px 8px; font-size: 12px; font-weight: 500;
  border-radius: 6px; color: var(--accent); border-color: var(--accent-clair); background: var(--accent-clair);
}
button.copier.fait { color: var(--vert); background: #e7f7ee; border-color: #e7f7ee; }
td a { color: var(--accent); }
.vide { padding: 40px; text-align: center; color: var(--doux); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; transition: all .2s; pointer-events: none; z-index: 100;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

h2.titre-section { font-size: 15px; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; margin: 28px 0 12px; }
button.outil { font: inherit; text-align: left; width: 100%; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
button.outil:hover:not(:disabled) { background: var(--carte); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(20, 30, 60, .12); }
button.outil:disabled { opacity: .6; }

/* Page de connexion */
main.connexion { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
main.connexion .carte { display: flex; flex-direction: column; padding: 28px; }
main.connexion .logo { font-weight: 700; font-size: 16px; color: var(--texte); text-decoration: none; }
main.connexion .logo span { color: var(--accent); }
main.connexion h1 { margin: 14px 0 20px; }
main.connexion button.principal { margin-top: 20px; padding: 10px 14px; }
.erreur { color: var(--rouge); font-size: 13px; margin: 12px 0 0; }
main.connexion label.case { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--doux); font-size: 13px; }
main.connexion label.case input { width: auto; }
main.connexion input[name=code] { font-size: 20px; letter-spacing: .3em; text-align: center; }
main.connexion [hidden] { display: none !important; }

/* Liens « Mon compte » / « Administration » à droite de la barre */
header.barre a.lien-compte { white-space: nowrap; padding: 6px 10px; border-radius: 8px; color: var(--doux); text-decoration: none; font-weight: 500; font-size: 13px; }
header.barre a.lien-compte:hover { background: var(--fond); color: var(--texte); }
header.barre a.lien-compte.actif { background: var(--accent-clair); color: var(--accent); }
