:root {
  --bg: #F9F8F5;
  --bg2: #F1F0EC;
  --card: #FFFFFF;
  --border: #E2E0DA;
  --border2: #C8C6BF;
  --text: #1A1916;
  --text2: #5A584F;
  --text3: #9A9890;
  --accent: #1A6B42;
  --accent-bg: #EBF5EF;
  --danger: #C0392B;
  --danger-bg: #FDECEA;
  --font: -apple-system, 'Segoe UI', system-ui, sans-serif;
  --r: 8px;
  --r-sm: 5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.cache { display: none !important; }

/* ── Connexion ──────────────────────────────────────── */
.ecran-connexion {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.boite-connexion {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, .05);
}

.boite-connexion h1 { font-size: 18px; margin-bottom: .35rem; }
.boite-connexion .sous-titre { font-size: 12.5px; color: var(--text3); margin-bottom: 1.5rem; }

/* ── Champs ─────────────────────────────────────────── */
.champ { margin-bottom: .85rem; }

.champ label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}

.obligatoire { color: var(--danger); }

input[type=password], input[type=text], input[type=number], input[type=search], select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .grille-2 { grid-template-columns: 1fr; } }

/* ── Boutons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border2);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .12s, background .12s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-compact { padding: 7px 12px; font-size: 12.5px; }

.btn-primaire { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primaire:hover:not(:disabled) { background: var(--accent); opacity: .88; }
.boite-connexion .btn-primaire { width: 100%; padding: 9px 14px; }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }

.btn-mini {
  padding: 3px 8px;
  font-size: 11.5px;
  border-color: transparent;
  background: transparent;
  color: var(--text2);
}
.btn-mini:hover { background: var(--bg2); }

/* ── Messages ───────────────────────────────────────── */
.message { font-size: 12.5px; margin-top: .6rem; min-height: 18px; }
.message.erreur { color: var(--danger); }
.message.ok { color: var(--accent); }

.notification {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .18);
  background: var(--accent);
  color: #fff;
  transition: opacity .2s;
}
.notification.visible { visibility: visible; opacity: 1; }
.notification.erreur { background: var(--danger); }

/* ── Application ────────────────────────────────────── */
.app { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.entete { display: flex; align-items: baseline; gap: 10px; margin-bottom: 1.75rem; }
.entete .titre { font-size: 20px; font-weight: 700; }
.entete .version { font-size: 11px; color: var(--text3); }
.entete .btn { margin-left: auto; }

.section-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: .85rem;
}
.section-entete h2 { font-size: 15px; font-weight: 700; }

.barre-outils { display: flex; gap: 8px; margin-bottom: .75rem; flex-wrap: wrap; }
.barre-outils .recherche { flex: 2; min-width: 180px; }
.barre-outils select { flex: 1; min-width: 150px; }

.compteur { font-size: 11.5px; color: var(--text3); margin-bottom: .6rem; }

/* ── Liste de produits ──────────────────────────────── */
.produit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 6px;
}

.produit-infos { flex: 1; min-width: 0; }
.produit-nom { font-weight: 600; font-size: 13.5px; }
.produit-detail { font-size: 11.5px; color: var(--text3); margin-top: 2px; }

.etiquette {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg2);
  color: var(--text2);
}

.etiquette-fruits { background: #EAF3DE; color: #3B6D11; }
.etiquette-legumes { background: #E1F5EE; color: #0F6E56; }
.etiquette-viandes { background: #FAECE7; color: #993C1D; }
.etiquette-poissons { background: #E6F1FB; color: #185FA5; }
.etiquette-produits-laitiers { background: #EEEDFE; color: #3C3489; }
.etiquette-epicerie-seche { background: #FAEEDA; color: #854F0B; }
.etiquette-surgeles { background: #E0F4FF; color: #145DA0; }
.etiquette-boissons { background: #EEEDFE; color: #3C3489; }
.etiquette-snacks { background: #FBEAF0; color: #993556; }

.vide {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text3);
  font-size: 13px;
  background: var(--card);
  border: 1px dashed var(--border2);
  border-radius: var(--r);
}
.vide .icone { font-size: 30px; display: block; margin-bottom: 8px; opacity: .6; }

/* ── Modale ─────────────────────────────────────────── */
.fond-modale {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.fond-modale.ouverte { display: flex; }

.modale {
  background: var(--card);
  border-radius: 12px;
  padding: 1.4rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .22);
}

.modale-titre { font-size: 15px; font-weight: 700; margin-bottom: 1.1rem; }
.separateur { height: 1px; background: var(--border); margin: 1rem 0 .85rem; }

.aide { font-size: 11.5px; color: var(--text3); margin-bottom: .85rem; line-height: 1.45; }

.apercu {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  min-height: 17px;
  margin-top: .3rem;
}

.actions-modale { display: flex; gap: 8px; align-items: center; margin-top: 1.1rem; }
.actions-modale .espace { flex: 1; }

/* ── Listes de courses ──────────────────────────────── */
.carte-liste {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .12s;
}
.carte-liste:hover { border-color: var(--border2); background: var(--bg2); }
.carte-liste-nom { font-weight: 600; font-size: 14px; }
.carte-liste-meta { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.carte-liste-compte { text-align: right; font-weight: 700; font-size: 15px; }
.carte-liste-compte .sous { font-size: 10px; font-weight: 400; color: var(--text3); }

.liste-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: .9rem 0 1rem;
}
.liste-entete h2 { font-size: 17px; }
.liste-cible { font-size: 11.5px; color: var(--text3); margin-top: 3px; }

/* Estimé : la réponse à « combien ça va coûter » */
.panneau-estime {
  background: var(--accent-bg);
  border: 1px solid #A7D8BC;
  border-radius: var(--r);
  padding: .9rem 1.1rem;
  margin-bottom: 1rem;
}
.estime-montant { display: flex; gap: 2rem; align-items: baseline; }
.estime-valeur { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.estime-reste .estime-valeur { color: var(--text); font-size: 20px; }
.estime-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text2);
  margin-top: 3px;
}
.estime-notes { font-size: 11px; color: var(--text2); margin-top: .6rem; }
.note-alerte { color: var(--danger); font-weight: 600; }

.ligne-liste {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 5px;
}
.ligne-liste.cochee { opacity: .55; }
.ligne-liste.cochee .ligne-titre { text-decoration: line-through; }

.case {
  width: 24px; height: 24px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 2px solid var(--border2);
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, border-color .12s;
}
.ligne-liste.cochee .case { background: var(--accent); border-color: var(--accent); color: #fff; }

.ligne-corps { flex: 1; min-width: 0; }
.ligne-titre { font-size: 13.5px; font-weight: 500; }
.ligne-titre .qte { color: var(--text3); font-weight: 400; margin-left: 4px; }

.etiquette-libre {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--bg3, #E7E5DF);
  color: var(--text2);
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}

.ligne-source { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
.ligne-source.prix-approche { color: #8A6D1F; }
.ligne-source.prix-inconnu { color: var(--danger); }

.ligne-montants { text-align: right; white-space: nowrap; }
.ligne-total { font-weight: 700; font-size: 14px; }
.ligne-unitaire { font-size: 10px; color: var(--text3); }

.ligne-boutons { display: flex; gap: 2px; flex-shrink: 0; }

/* Ajout d'un article */
.ajout-ligne {
  margin-top: 1.2rem;
  padding: .9rem 1rem;
  background: var(--bg2);
  border-radius: var(--r);
}
.ajout-titre {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}

.ajout-catalogue { width: 100%; font-size: 14px; padding: 10px 11px; }

.ajout-ou {
  text-align: center;
  font-size: 10.5px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: .5rem 0;
  position: relative;
}
.ajout-ou::before, .ajout-ou::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--border);
}
.ajout-ou::before { left: 0; }
.ajout-ou::after { right: 0; }

.resultat-ajout {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12.5px;
  text-align: left;
}
.resultat-ajout:hover { border-color: var(--accent); background: var(--accent-bg); }
.resultat-nom { flex: 1; }
.resultat-nom .sous { color: var(--text3); font-size: 11px; }
.resultat-plus { color: var(--accent); font-weight: 700; font-size: 16px; }

#ajout-libre {
  margin-top: .6rem;
  padding: .7rem .8rem;
  background: var(--card);
  border: 1px dashed var(--border2);
  border-radius: var(--r-sm);
}
.ajout-libre-texte { font-size: 12.5px; margin-bottom: .6rem; }
.ajout-libre-champs { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.ajout-libre-champs label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ajout-libre-champs input { width: 110px; }

/* ── Rapprochement ──────────────────────────────────── */
.doublons {
  background: #FEF9E7;
  border: 1px solid #F0DDA0;
  border-radius: var(--r);
  margin-bottom: .85rem;
}

.doublons summary {
  cursor: pointer;
  padding: .7rem .95rem;
  font-size: 12.5px;
  list-style: none;
}
.doublons summary::-webkit-details-marker { display: none; }
.doublons summary::before { content: '▸ '; color: #8A6D1F; }
.doublons[open] summary::before { content: '▾ '; }
.doublons summary strong { color: #6B5314; }
.doublons summary .sous { color: #8A6D1F; margin-left: 6px; font-size: 11.5px; }

.doublons-corps { padding: 0 .95rem .8rem; }

.paire {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .7rem .8rem;
  margin-bottom: 6px;
}

.paire-fiches { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 520px) { .paire-fiches { grid-template-columns: 1fr; gap: .4rem; } }

.paire-nom { font-weight: 600; font-size: 13px; }
.paire-detail { font-size: 11px; color: var(--text3); margin-top: 2px; }

.paire-magasins { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }

.puce-magasin {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg2);
  color: var(--text2);
  font-weight: 600;
  white-space: nowrap;
}

.paire-raisons {
  font-size: 11px;
  color: #8A6D1F;
  margin: .55rem 0;
  padding-top: .5rem;
  border-top: 1px dashed var(--border);
}

.paire-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.paire-actions .btn-mini { border: 1px solid var(--border2); }

/* ── Onglets ────────────────────────────────────────── */
.onglets {
  display: flex;
  gap: 2px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 1.5rem;
}

.onglet {
  flex: 1;
  padding: 8px;
  font-size: 12.5px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text2);
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
}
.onglet.actif { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.onglet:hover:not(.actif) { background: rgba(0, 0, 0, .04); }

.vue { display: none; }
.vue.active { display: block; }

/* ── Import ─────────────────────────────────────────── */
.zone-depot {
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  padding: 1.6rem 1.2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: .75rem;
}
.zone-depot:hover, .zone-depot.survol { border-color: var(--accent); background: var(--accent-bg); }

.depot-icone { font-size: 28px; margin-bottom: 6px; }
.depot-titre { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.depot-aide { font-size: 11.5px; color: var(--text3); }

.lien {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  font-family: var(--font);
  text-decoration: underline;
}

.repliable { margin-bottom: 1rem; }
.repliable summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text3);
  padding: 5px 0;
}
.repliable textarea {
  width: 100%;
  font-family: 'Consolas', monospace;
  font-size: 11.5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg2);
  color: var(--text);
  resize: vertical;
  margin: .5rem 0;
}

/* ── Rapport d'import ───────────────────────────────── */
.rapport {
  border-radius: var(--r);
  padding: .9rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--card);
}
.rapport.succes { border-color: #A7D8BC; background: var(--accent-bg); }
.rapport.probleme { border-color: #F0B9B2; background: var(--danger-bg); }

.rapport h3 { font-size: 13px; margin-bottom: .5rem; }
.rapport ul { margin: .4rem 0 0 1.1rem; }
.rapport li { margin-bottom: 2px; line-height: 1.45; }
.rapport .sous { color: var(--text2); font-size: 11.5px; }

/* ── Suggestions de rattachement à l'import ─────────── */
.suggestions-import {
  margin-top: .8rem;
  padding-top: .7rem;
  border-top: 1px solid var(--border);
}

.suggestion-import {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .6rem .7rem;
  margin-top: .5rem;
}

.etiquette-neuve {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
}

.suggestion-raisons {
  font-size: 11px;
  color: var(--text3);
  margin: .55rem 0 .5rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--border);
}
.suggestion-actions { display: flex; gap: 6px; }
.suggestion-actions .btn-mini { border: 1px solid var(--border2); }

/* ── Liste de factures ──────────────────────────────── */
.facture {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 6px;
  overflow: hidden;
}
.facture.signalee { border-color: #F0B9B2; }

.facture-tete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
}
.facture-tete:hover { background: var(--bg2); }

.facture-magasin { font-weight: 600; font-size: 13.5px; }
.facture-meta { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.facture-total { font-weight: 700; font-size: 14px; white-space: nowrap; }

.alerte {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  background: var(--danger-bg);
  color: var(--danger);
  white-space: nowrap;
}

.facture-corps { border-top: 1px solid var(--border); padding: .85rem 1.1rem; }
.facture-corps.cachee { display: none; }

.ligne-article {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.ligne-article:last-child { border-bottom: none; }
.ligne-nom { flex: 1; min-width: 0; }
.ligne-brut { font-size: 10.5px; color: var(--text3); }
.ligne-prix { font-weight: 600; white-space: nowrap; }
.ligne-mode { font-size: 10px; color: var(--text3); }

.canal {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
  background: #EDE9FE;
  color: #5B21B6;
  vertical-align: middle;
  margin-left: 3px;
}

.bloc-frais {
  margin-top: .85rem;
  padding: .7rem .85rem;
  background: var(--bg2);
  border-radius: var(--r-sm);
}
.bloc-frais-titre {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .45rem;
}
.ligne-frais {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
  color: var(--text2);
}
.ligne-frais.total {
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border2);
  margin-top: 4px;
  padding-top: 5px;
}
.bloc-frais-note {
  font-size: 11px;
  color: var(--danger);
  margin-top: .45rem;
}

.rappel-ecart {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 11.5px;
  margin-bottom: .75rem;
  line-height: 1.45;
}

/* ── Diagnostic ─────────────────────────────────────── */
.diagnostic { margin-top: 2rem; font-size: 12px; }
.diagnostic summary {
  cursor: pointer;
  color: var(--text3);
  font-size: 11.5px;
  padding: 4px 0;
}
.diagnostic[open] summary { margin-bottom: .6rem; }

.tableau-etat { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.tableau-etat td { padding: 5px 0; border-top: 1px solid var(--border); }
.tableau-etat td:last-child { text-align: right; font-weight: 600; }
.tableau-etat tr:first-child td { border-top: none; }
