/* Eno — administration. Couleurs de Grena (DESIGN_SYSTEM.md d'eno-app) : fond crème, encre, lie de vin, bourgeon. */

:root {
  --fond: #F2F0ED;
  --surface: #FFFFFF;
  --surface-2: #F8F6F3;
  --encre: #1B1418;
  --encre-2: #4A4044;
  --gris: #7A7075;
  --bordure: #E2DDD8;
  --vin: #7F1734;
  --vin-pale: #F3E3E8;
  --bourgeon: #D6F35E;
  --bourgeon-encre: #3D4A0C;
  --succes: #2F7D4F;
  --succes-pale: #E3F2E8;
  --alerte: #A86400;
  --alerte-pale: #FBEFD9;
  --erreur: #B3261E;
  --erreur-pale: #FBE4E2;
  --menu: #1B1418;
  --menu-texte: #EDE8E4;
  --menu-actif: #D6F35E;
  --damier-a: #EEEAE6;
  --damier-b: #FFFFFF;
  --ombre: 0 1px 2px rgba(27, 20, 24, .06), 0 2px 8px rgba(27, 20, 24, .04);
  --rayon: 12px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #161113;
    --surface: #211A1D;
    --surface-2: #2A2225;
    --encre: #F0EAE6;
    --encre-2: #CFC5C1;
    --gris: #9C9195;
    --bordure: #3A3034;
    --vin: #D9637F;
    --vin-pale: #3A1C25;
    --bourgeon-encre: #D6F35E;
    --succes: #6CC48F;
    --succes-pale: #1C3326;
    --alerte: #E6A64A;
    --alerte-pale: #3A2C14;
    --erreur: #F08A80;
    --erreur-pale: #3E1D1A;
    --menu: #0F0B0D;
    --damier-a: #2A2225;
    --damier-b: #332A2E;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--fond); color: var(--encre); font-family: var(--police); line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--vin); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; font-weight: 650; }
h3 { font-size: 1.08rem; margin: 0 0 .5rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--bordure); margin: 1rem 0; }
.vide { color: var(--gris); }
.discret { color: var(--gris); }
.petit { font-size: .92rem; }
.gras { font-weight: 650; }
.droite { text-align: right; }
.nowrap { white-space: nowrap; }
.cache { display: none !important; }

/* Mise en page ---------------------------------------------------------------------------------------------------- */

.appli { display: flex; min-height: 100vh; }
.menu {
  width: 240px; flex: none; background: var(--menu); color: var(--menu-texte); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.marque { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; padding: 0 10px 14px; color: #fff; }
.marque span { color: var(--bourgeon); }
.marque small { display: block; font-size: .72rem; font-weight: 500; color: var(--gris); letter-spacing: .04em; text-transform: uppercase; }
.menu a {
  color: var(--menu-texte); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between;
  align-items: center; gap: 8px; font-size: 1rem;
}
.menu a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.menu a.actif { background: rgba(214, 243, 94, .12); color: var(--menu-actif); font-weight: 600; }
.menu .groupe { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #8C8186; padding: 14px 10px 4px; }
.menu .pied { margin-top: auto; padding: 12px 10px 0; font-size: .85rem; color: #A99EA3; }
.menu .pied form { display: inline; }
.menu .pied button { background: none; border: 0; color: var(--bourgeon); padding: 0; cursor: pointer; font: inherit; }
.badge {
  background: var(--bourgeon); color: #1B1418; border-radius: 99px; font-size: .8rem; font-weight: 700;
  padding: 1px 7px; min-width: 20px; text-align: center;
}
.contenu { flex: 1; min-width: 0; padding: 26px 32px 56px; max-width: 1600px; }
.entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.entete .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fil { font-size: .85rem; color: var(--gris); margin-bottom: 4px; }
.fil a { color: var(--gris); }

@media (max-width: 860px) {
  .appli { flex-direction: column; }
  .menu {
    width: auto; height: auto; position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    padding: 10px 12px; align-items: center;
  }
  .marque { padding: 0 10px 0 0; font-size: 1.1rem; }
  .marque small, .menu .groupe { display: none; }
  .menu a { white-space: nowrap; padding: 6px 10px; }
  .menu .pied { margin: 0 0 0 8px; padding: 0; white-space: nowrap; }
  .contenu { padding: 16px 16px 40px; }
}

/* Cartes, grilles --------------------------------------------------------------------------------------------------- */

.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 16px 18px; box-shadow: var(--ombre); margin-bottom: 16px; }
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }
.carte.serree { padding: 0; overflow: hidden; }
.carte.serree > h2 { padding: 14px 16px 0; }
.grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grille-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.grille-fiche { display: grid; gap: 16px; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
@media (max-width: 1000px) { .grille-2, .grille-fiche { grid-template-columns: 1fr; } }

.chiffres { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.chiffre { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 12px 14px; }
.chiffre .valeur { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.chiffre .libelle { color: var(--gris); font-size: .85rem; }
.chiffre a { color: inherit; }

/* Messages ----------------------------------------------------------------------------------------------------------- */

.message { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid; }
.message.ok { background: var(--succes-pale); border-color: var(--succes); color: var(--encre); }
.message.erreur { background: var(--erreur-pale); border-color: var(--erreur); color: var(--encre); }
.message.info { background: var(--alerte-pale); border-color: var(--alerte); color: var(--encre); }

/* Boutons et champs --------------------------------------------------------------------------------------------------- */

.bouton, button.bouton {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--encre); background: var(--encre);
  color: var(--fond); padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.bouton:hover { text-decoration: none; filter: brightness(1.15); }
.bouton.vin { background: var(--vin); border-color: var(--vin); color: #fff; }
.bouton.contour { background: transparent; color: var(--encre); border-color: var(--bordure); }
.bouton.contour:hover { border-color: var(--encre-2); filter: none; }
.bouton.danger { background: transparent; color: var(--erreur); border-color: var(--erreur); }
.bouton.danger:hover { background: var(--erreur-pale); filter: none; }
.bouton.petit { padding: 5px 12px; font-size: .92rem; }
.bouton:disabled { opacity: .45; cursor: not-allowed; }

label { display: block; font-size: .92rem; color: var(--encre-2); margin-bottom: 3px; font-weight: 550; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=url],
input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--encre); background: var(--surface); border: 1px solid var(--bordure);
  border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vin); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { accent-color: var(--vin); width: 16px; height: 16px; vertical-align: -3px; }
.case { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--encre); margin: 0 12px 6px 0; cursor: pointer; font-size: .93rem; }
.champs { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.champs .large { grid-column: 1 / -1; }
.champ { position: relative; }
.champ .aide { font-size: .8rem; color: var(--gris); margin-top: 3px; }
.ligne-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.ligne-form > * { flex: 1 1 160px; }
.ligne-form > .bouton, .ligne-form > button { flex: 0 0 auto; }
.formulaire-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* Filtres ------------------------------------------------------------------------------------------------------------ */

.filtres { display: grid; gap: 10px 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); align-items: end; }
.filtres .recherche { grid-column: 1 / -1; display: flex; gap: 8px; }
.filtres details { grid-column: 1 / -1; }
details summary { cursor: pointer; color: var(--encre-2); font-weight: 600; font-size: .92rem; }
details[open] summary { margin-bottom: 8px; }

/* Tableaux ----------------------------------------------------------------------------------------------------------- */

.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--bordure); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; }
th a { color: inherit; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .vignette { width: 46px; height: 62px; }
table.cles th { width: 34%; text-transform: none; letter-spacing: 0; font-size: .9rem; background: none; position: static; color: var(--encre-2); }
table.cles td, table.cles th { border-bottom-color: var(--bordure); }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 0; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 6px; }

/* Pastilles, étiquettes de statut ---------------------------------------------------------------------------------- */

.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; margin-right: 5px; border: 1px solid rgba(0,0,0,.12); }
.pastille-rouge { background: #8E1B3A; }
.pastille-blanc { background: #EADFA6; }
.pastille-rose { background: #F0A3B4; }
.pastille-orange { background: #E3923F; }
.pastille-ambre { background: #C0862A; }
.pastille-autre { background: #9A9094; }

.statut { display: inline-block; font-size: .8rem; font-weight: 650; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--bordure); color: var(--encre-2); background: var(--surface-2); white-space: nowrap; vertical-align: 1px; }
.statut.verifie, .statut.terminee, .statut.identifie, .statut.ajoute, .statut.ok { background: var(--succes-pale); border-color: transparent; color: var(--succes); }
.statut.estime, .statut.en_attente, .statut.a_traiter, .statut.inconnues, .statut.manuel { background: var(--alerte-pale); border-color: transparent; color: var(--alerte); }
.statut.echec, .statut.rejete, .statut.conteste, .statut.erreur { background: var(--erreur-pale); border-color: transparent; color: var(--erreur); }
.statut.en_cours { background: var(--bourgeon); border-color: transparent; color: #1B1418; }
.statut.genere, .statut.annulee, .statut.ia { background: var(--vin-pale); border-color: transparent; color: var(--vin); }

.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bordure); margin-bottom: 16px; flex-wrap: wrap; }
.onglets a { padding: 9px 14px; color: var(--encre-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.onglets a:hover { text-decoration: none; color: var(--encre); }
.onglets a.actif { color: var(--vin); border-bottom-color: var(--vin); }
.onglets .badge { margin-left: 4px; background: var(--surface-2); color: var(--encre-2); border: 1px solid var(--bordure); }

/* Photos ------------------------------------------------------------------------------------------------------------- */

.damier {
  background-color: var(--damier-b);
  background-image: linear-gradient(45deg, var(--damier-a) 25%, transparent 25%), linear-gradient(-45deg, var(--damier-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--damier-a) 75%), linear-gradient(-45deg, transparent 75%, var(--damier-a) 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.vignette { display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; overflow: hidden; border: 1px solid var(--bordure); }
.vignette img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.vignette.sans { color: var(--gris); font-size: .7rem; text-align: center; }
.photo-fiche { width: 100%; aspect-ratio: 3 / 4; border-radius: var(--rayon); }
.galerie { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tuile { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.tuile .image { aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; }
.tuile .image img { max-width: 92%; max-height: 92%; object-fit: contain; }
.tuile .texte { padding: 8px 10px 4px; font-size: .95rem; line-height: 1.3; }
.tuile .texte .nom { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tuile .outils { display: flex; gap: 4px; padding: 6px 8px 8px; flex-wrap: wrap; }
.tuile .outils .bouton { padding: 4px 10px; font-size: .88rem; }
.tuile.faite { opacity: .45; }
.tuile.faite::after { content: attr(data-fait); position: absolute; top: 8px; left: 8px; background: var(--encre); color: var(--fond); font-size: .75rem; padding: 2px 8px; border-radius: 99px; }
.tuile .coin { position: absolute; top: 6px; right: 6px; }

/* Fusion ------------------------------------------------------------------------------------------------------------- */

.comparaison td { width: 38%; }
.comparaison td:first-child { width: 24%; color: var(--encre-2); font-weight: 550; }
.comparaison tr.different td { background: var(--alerte-pale); }
.comparaison tr.different td:first-child { background: transparent; }
.comparaison label.choix { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--encre); margin: 0; cursor: pointer; }
.comparaison .vignette { width: 90px; height: 120px; }
.cote { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); font-weight: 650; }

/* Journal de tâche --------------------------------------------------------------------------------------------------- */

pre.console {
  background: #141012; color: #E8E2DE; border-radius: var(--rayon); padding: 14px 16px; font-size: .9rem; line-height: 1.5;
  max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
}

/* Listes de choix (suggestions) ------------------------------------------------------------------------------------- */

.suggestions {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 2px; background: var(--surface);
  border: 1px solid var(--bordure); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 320px; overflow-y: auto;
}
.suggestions button {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px;
  font: inherit; color: var(--encre); cursor: pointer; border-bottom: 1px solid var(--bordure);
}
.suggestions button:last-child { border-bottom: 0; }
.suggestions button:hover, .suggestions button.survol { background: var(--surface-2); }
.suggestions .detail { display: block; font-size: .8rem; color: var(--gris); }
.suggestions img { width: 26px; height: 34px; object-fit: contain; }
.choisi { margin-top: 4px; font-size: .85rem; color: var(--succes); }

/* Étiquettes envoyées ----------------------------------------------------------------------------------------------- */

.envoi { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; }
.envoi .photo-envoi { width: 100%; border-radius: 10px; background: var(--surface-2); min-height: 200px; display: flex; align-items: center; justify-content: center; }
.envoi .photo-envoi img { width: 100%; border-radius: 10px; }
@media (max-width: 760px) { .envoi { grid-template-columns: 1fr; } }
.resultats { margin-top: 8px; display: grid; gap: 6px; }
.resultat { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--bordure); border-radius: 10px; }
.resultat .vignette { width: 30px; height: 40px; flex: none; }
.resultat .quoi { flex: 1; min-width: 0; }
.resultat form { margin: 0; }

/* Barres (complétude) ------------------------------------------------------------------------------------------------ */

.barre { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 3px; min-width: 40px; }
.barre span { display: block; height: 100%; background: var(--vin); }
.barre.bien span { background: var(--succes); }

/* Connexion ---------------------------------------------------------------------------------------------------------- */

.connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.connexion .carte { width: 100%; max-width: 380px; padding: 28px; }
.connexion .marque { color: var(--encre); padding: 0 0 18px; font-size: 1.8rem; }
.connexion .marque span { color: var(--vin); }

/* Fiches comparées (doublons) ---------------------------------------------------------------------------------------- */

.comparees { align-items: start; }
.fiche-comparee .fiche-tete { display: flex; gap: 16px; align-items: flex-start; margin: 8px 0 12px; }
.fiche-comparee h2 { margin: 0 0 4px; font-size: 1.3rem; }
.fiche-comparee table.cles th { width: 38%; }
.fiche-comparee tr.different th, .fiche-comparee tr.different td { background: var(--alerte-pale); }
.fiche-comparee tr.different th { box-shadow: inset 3px 0 0 var(--alerte); }
.millesime-bloc { border: 1px solid var(--bordure); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.millesime-bloc.commun { border-color: var(--alerte); box-shadow: inset 3px 0 0 var(--alerte); }
.millesime-tete { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.grand { font-size: 1.15rem; }
.offre { padding: 6px 0 6px; border-top: 1px dashed var(--bordure); }
.offre a { font-weight: 600; margin: 0 6px; }
.decision { border: 2px solid var(--vin); }

/* Doublons : groupes ------------------------------------------------------------------------------------------------- */

.groupe-doublon { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 10px 0 12px; }
.mini-fiche { border: 1px solid var(--bordure); border-radius: 10px; padding: 10px 12px; display: flex; gap: 12px; background: var(--surface-2); }
.mini-fiche .titre { font-weight: 650; }
.actions-doublon { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Référentiel ---------------------------------------------------------------------------------------------------------- */

.signaler { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.signaler input[name=note] { flex: 1 1 260px; }
.oui { color: var(--succes); font-weight: 600; }
.non { color: var(--erreur); font-weight: 600; }

/* Nouvelle photo --------------------------------------------------------------------------------------------------- */

.depot { border: 2px dashed var(--bordure); border-radius: var(--rayon); padding: 18px 14px; text-align: center; color: var(--encre-2); background: var(--surface-2); min-height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.depot.survol { border-color: var(--vin); background: var(--vin-pale); }
.depot img { max-width: 100%; max-height: 220px; border-radius: 8px; }
.lien { display: inline; color: var(--vin); font-weight: 600; cursor: pointer; text-decoration: underline; margin: 0; font-size: inherit; }
.attente { border: 1px solid var(--alerte); background: var(--alerte-pale); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.apercu-source { margin-top: 8px; border-radius: 8px; height: 180px; display: flex; align-items: center; justify-content: center; }
.apercu-source img { max-height: 170px; max-width: 100%; }
