/* peabot — feuille de style unique.
   Charte : Evergreen #005E60, Urgency Green #C8FF08 en accent unique par vue,
   Night #212121, blanc chaud #FAFAF7. Rayons 14 / 11 / 8. Contrôles à 44 px.
   Icônes en trait 1,6. Aucun emoji. */

:root {
  --evergreen: #005E60;
  --evergreen-fonce: #00494B;
  --evergreen-doux: #E6F0F0;
  --accent: #C8FF08;
  --nuit: #212121;
  --blanc-chaud: #FAFAF7;
  --surface: #FFFFFF;
  --surface-creuse: #F4F4F1;
  --filet: #E2E2DD;
  --encre: #212121;
  --encre-2: #55554F;
  --encre-3: #8A8A82;
  --hausse: #1B7F5A;
  --baisse: #C53A37;
  --hausse-doux: #E8F5EF;
  --baisse-doux: #FBE9E8;

  --r-carte: 14px;
  --r-controle: 11px;
  --r-puce: 8px;
  --h-controle: 44px;

  --police: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --police-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ombre: 0 1px 2px rgba(33, 33, 33, .06), 0 4px 12px rgba(33, 33, 33, .05);
  --ombre-haute: 0 8px 28px rgba(33, 33, 33, .14);
  --transition: 140ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.5;
  color: var(--encre);
  background: var(--blanc-chaud);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; font-weight: 600; }
h1 { font-size: 26px; letter-spacing: -0.015em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
a { color: var(--evergreen); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--police-mono); font-variant-numeric: tabular-nums; }
.discret { color: var(--encre-3); font-size: 13px; }

/* ── En-tête ───────────────────────────────────────────────── */
.entete {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 20px;
  background: var(--evergreen);
  color: #FFFFFF;
}
.marque {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  color: #FFFFFF; text-decoration: none; flex: none;
}
.marque:hover { text-decoration: none; }
.marque em { font-style: normal; color: var(--accent); }

.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px;
  color: rgba(255, 255, 255, .82); font-size: 14px; font-weight: 500;
  border-radius: var(--r-puce); white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .12); color: #FFFFFF; text-decoration: none; }
.nav a.actif { background: rgba(255, 255, 255, .18); color: #FFFFFF; }
.nav svg { flex: none; }

.entete-fin { display: flex; align-items: center; gap: 10px; flex: none; }
.entete-fin .qui { font-size: 13px; color: rgba(255, 255, 255, .8); }

/* ── Contenu ───────────────────────────────────────────────── */
.page { max-width: 1120px; margin: 0 auto; padding: 26px 20px 60px; }
.page-tete {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}

/* ── Cartes ────────────────────────────────────────────────── */
.carte {
  background: var(--surface);
  border: 1px solid var(--filet);
  border-radius: var(--r-carte);
  box-shadow: var(--ombre);
}
.carte + .carte { margin-top: 18px; }
.carte-tete {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--filet);
}
.carte-corps { padding: 18px; }

/* ── Chiffres clés ─────────────────────────────────────────── */
.chiffres {
  display: grid; gap: 14px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.chiffre {
  padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--filet); border-radius: var(--r-carte);
  box-shadow: var(--ombre);
}
.chiffre .etiquette {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--encre-3);
}
.chiffre .valeur {
  margin-top: 6px; font-size: 26px; font-weight: 650;
  font-family: var(--police-mono); font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.chiffre .sous { margin-top: 3px; font-size: 12.5px; color: var(--encre-3); }

/* L'accent ne sert qu'une fois par vue : la valeur totale de la poche.
   Le diluer sur plusieurs éléments lui ferait perdre sa fonction. */
.chiffre--phare {
  background: var(--nuit); border-color: var(--nuit); color: var(--blanc-chaud);
}
.chiffre--phare .etiquette { color: rgba(250, 250, 247, .62); }
.chiffre--phare .valeur { color: var(--accent); }
.chiffre--phare .sous { color: rgba(250, 250, 247, .72); }

.hausse { color: var(--hausse); }
.baisse { color: var(--baisse); }

/* ── Tableaux ──────────────────────────────────────────────── */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th {
  padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--encre-3);
  border-bottom: 1px solid var(--filet); white-space: nowrap;
}
.tableau td { padding: 11px 12px; border-bottom: 1px solid var(--filet); }
.tableau tr:last-child td { border-bottom: none; }
.tableau .num {
  text-align: right; font-family: var(--police-mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tableau tbody tr:hover { background: var(--surface-creuse); }
.enveloppe-tableau { overflow-x: auto; }

/* ── Boutons ───────────────────────────────────────────────── */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h-controle); padding: 0 18px;
  font-family: inherit; font-size: 14.5px; font-weight: 600;
  color: #FFFFFF; background: var(--evergreen);
  border: 1px solid var(--evergreen); border-radius: var(--r-controle);
  cursor: pointer; transition: var(--transition);
  -webkit-appearance: none; appearance: none; text-decoration: none;
}
.bouton:hover { background: var(--evergreen-fonce); border-color: var(--evergreen-fonce);
  color: #FFFFFF; text-decoration: none; }
.bouton:disabled { opacity: .5; cursor: default; }
.bouton--second { background: var(--surface); color: var(--evergreen); }
.bouton--second:hover { background: var(--evergreen-doux); color: var(--evergreen); }
.bouton--danger { background: var(--surface); color: var(--baisse); border-color: #E8C4C3; }
.bouton--danger:hover { background: var(--baisse-doux); color: var(--baisse); }
.bouton--petit { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-puce); }

/* ── Champs ────────────────────────────────────────────────── */
.champ { display: block; margin-bottom: 14px; }
.champ span {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--encre-2);
}
.champ input, .champ select {
  width: 100%; height: var(--h-controle); padding: 0 13px;
  font-family: inherit;
  /* 16 px : en dessous, iOS zoome à la mise au point. */
  font-size: 16px;
  color: var(--encre); background: var(--surface);
  border: 1px solid var(--filet); border-radius: var(--r-controle);
  -webkit-appearance: none; appearance: none;
}
.champ input:focus, .champ select:focus {
  outline: 2px solid var(--evergreen); outline-offset: -1px; border-color: var(--evergreen);
}
.champ .aide { margin-top: 5px; font-size: 12px; color: var(--encre-3); font-weight: 400; }
.ligne-champs { display: flex; gap: 12px; flex-wrap: wrap; }
.ligne-champs .champ { flex: 1; min-width: 110px; }

/* ── Puces d'état ──────────────────────────────────────────── */
.puce {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600;
  border-radius: var(--r-puce); border: 1px solid transparent; white-space: nowrap;
}
.puce--attente { color: #8A6D00; background: #FFF6DB; border-color: #F0DFA6; }
.puce--ok { color: var(--hausse); background: var(--hausse-doux); border-color: #BFE3D3; }
.puce--refus { color: var(--encre-3); background: var(--surface-creuse); border-color: var(--filet); }
.puce--cours { color: var(--evergreen); background: var(--evergreen-doux); border-color: #BFD8D8; }
.puce--achat { color: var(--hausse); background: var(--hausse-doux); border-color: #BFE3D3; }
.puce--vente { color: var(--baisse); background: var(--baisse-doux); border-color: #E8C4C3; }

/* ── Messages ──────────────────────────────────────────────── */
.message {
  display: flex; gap: 10px; padding: 13px 16px; margin-bottom: 16px;
  border-radius: var(--r-controle); border: 1px solid; font-size: 14px;
}
.message--ok { color: var(--hausse); background: var(--hausse-doux); border-color: #BFE3D3; }
.message--erreur { color: var(--baisse); background: var(--baisse-doux); border-color: #E8C4C3; }
.message--alerte { color: #8A6D00; background: #FFF6DB; border-color: #F0DFA6; }

.vide {
  padding: 34px 20px; text-align: center; color: var(--encre-3);
  background: var(--surface-creuse); border: 1px dashed var(--filet);
  border-radius: var(--r-controle);
}

/* ── Courbe ────────────────────────────────────────────────── */
.courbe-enveloppe { position: relative; }
.courbe { display: block; width: 100%; height: auto; }
.courbe-infobulle {
  position: absolute; pointer-events: none; opacity: 0;
  padding: 7px 10px; font-size: 12.5px; line-height: 1.35;
  color: var(--blanc-chaud); background: var(--nuit);
  border-radius: var(--r-puce); box-shadow: var(--ombre-haute);
  transition: opacity 90ms ease; white-space: nowrap;
}
.courbe-infobulle b { font-family: var(--police-mono); font-weight: 600; }

/* ── Journal d'exécution ───────────────────────────────────── */
.journal {
  max-height: 460px; overflow: auto; padding: 15px;
  font-family: var(--police-mono); font-size: 12.5px; line-height: 1.55;
  color: #D8D8D2; background: var(--nuit);
  border-radius: var(--r-controle); white-space: pre-wrap; word-break: break-word;
}

/* ── Connexion ─────────────────────────────────────────────── */
.ecran-connexion {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px; background: var(--evergreen);
}
.boite-connexion {
  width: 100%; max-width: 380px; padding: 30px;
  background: var(--surface); border-radius: var(--r-carte); box-shadow: var(--ombre-haute);
}
.boite-connexion .marque-grande {
  font-size: 27px; font-weight: 700; letter-spacing: -0.02em; color: var(--evergreen);
}
.boite-connexion .marque-grande em { font-style: normal; color: var(--evergreen); }
.boite-connexion .accroche { margin: 5px 0 22px; font-size: 13.5px; color: var(--encre-3); }
.boite-connexion .bouton { width: 100%; margin-top: 6px; }

/* ── Avertissement ─────────────────────────────────────────── */
.avertissement {
  margin-top: 26px; padding: 13px 16px;
  font-size: 12.5px; line-height: 1.5; color: var(--encre-2);
  background: var(--surface-creuse); border: 1px solid var(--filet);
  border-radius: var(--r-controle);
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .entete { gap: 12px; padding: 0 14px; }
  .entete-fin .qui { display: none; }
  .nav a { padding: 0 10px; }
  .nav a span { display: none; }      /* les libellés cèdent, pas les icônes */
  .page { padding: 18px 14px 48px; }
  h1 { font-size: 22px; }
  .chiffre .valeur { font-size: 22px; }
  .tableau { font-size: 13px; }
  .tableau th, .tableau td { padding: 9px 8px; }
}

/* ── Rectification d'un ordre déjà tranché ────────────────────
   Le formulaire occupe une LIGNE ENTIÈRE sous celle qu'il corrige,
   pas une cellule. Logé dans la dernière colonne, il se retrouvait
   coupé par le défilement horizontal du tableau. */

.rectif-ligne > td {
  padding: 0;
  background: var(--surface-creuse);
  border-bottom: 1px solid var(--filet);
}
/* La ligne dépliée ne doit pas réagir au survol comme une ligne de
   données : elle n'est pas cliquable. */
.tableau--rectif tbody tr.rectif-ligne:hover > td { background: var(--surface-creuse); }

.rectif-boite {
  /* Collée au bord gauche de la zone visible même si le tableau
     déborde : le formulaire reste lisible sans défiler. */
  position: sticky;
  left: 0;
  width: min(760px, 100%);
  padding: 16px 18px 18px;
}

.rectif-boite .champ { margin-bottom: 12px; }
.rectif-boite .champ input { height: 40px; font-size: 15px; }
.rectif-boite .champ span { font-size: 11.5px; }
.rectif-boite .ligne-champs .champ { min-width: 130px; }

.rectif-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Le déclencheur ouvert change de libellé ET d'aspect : on doit voir
   d'un coup d'œil quelle ligne est en cours d'édition. */
.declencheur[aria-expanded="true"] {
  background: var(--evergreen);
  color: #FFFFFF;
}

@media (max-width: 720px) {
  .rectif-boite { width: 100%; padding: 14px; }
  .rectif-boite .ligne-champs { flex-direction: column; gap: 0; }
  .rectif-actions .bouton { flex: 1; min-width: 0; }
}

/* ── Menus déroulants ──────────────────────────────────────────
   Composant repris tel quel de CartoHub (src/dropdown.js et les
   règles .dd de son style.css), variables de couleur remappées sur
   la palette peabot. Les <select> natifs qui traînaient ici
   ouvraient une roulette système sur iOS et ne ressemblaient à rien
   d'autre sur le site.

   `--ring` n'existait pas côté peabot : on le définit ici plutôt que
   dans :root, pour que tout le composant tienne dans un bloc. */
:root { --ring: 0 0 0 3px var(--evergreen-doux); }

/* --- Composant .dd (dropdown JS custom pour cas avancés) --- */
.dd { position: relative; display: inline-block; }

.dd__trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: var(--h-controle);
  padding: 0 14px;
  min-width: 210px;
  background: var(--surface);
  color: var(--encre);
  border: 1px solid var(--filet);
  border-radius: var(--r-controle);
  font: 400 15px var(--police);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dd__trigger:hover { border-color: var(--encre-3); }
.dd__trigger[aria-expanded="true"],
.dd__trigger:focus-visible {
  outline: none;
  border-color: var(--evergreen);
  box-shadow: var(--ring);
}
.dd__trigger:disabled {
  background: var(--surface-creuse);
  color: var(--encre-3);
  cursor: not-allowed;
}

.dd__value {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd__value.is-placeholder { color: var(--encre-3); }

.dd__caret {
  flex: none;
  color: var(--encre-3);
  transition: transform 0.18s;
}
.dd__trigger[aria-expanded="true"] .dd__caret {
  transform: rotate(180deg);
  color: var(--evergreen);
}

.dd__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: 280px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--filet);
  border-radius: var(--r-controle);
  box-shadow: var(--ombre-haute);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.dd.is-open .dd__panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dd__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-puce);
  font: 400 14px var(--police);
  color: var(--encre);
  cursor: pointer;
  transition: background 0.12s;
}
.dd__item:hover,
.dd__item.is-active { background: var(--surface-creuse); }
.dd__item.is-selected {
  background: var(--evergreen-doux);
  color: var(--evergreen);
  font-weight: 500;
}
.dd__item[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.dd__item[aria-disabled="true"]:hover { background: transparent; }

.dd__tick {
  margin-left: auto;
  flex: none;
  color: var(--evergreen);
  opacity: 0;
}
.dd__item.is-selected .dd__tick { opacity: 1; }

.dd__meta {
  margin-left: auto;
  font-family: var(--police-mono);
  font-size: 12px;
  color: var(--encre-3);
}


/* ── Menus déroulants dans un formulaire ──────────────────────
   Le composant est prévu pour vivre seul, en `inline-block` avec
   une largeur minimale de 210 px. Dans une ligne de champs il doit
   au contraire se comporter comme un <input> : occuper toute la
   largeur de son étiquette, ni plus ni moins.

   Sans ces règles, le déclencheur débordait de son conteneur ou se
   tassait, selon la place — d'où un bouton minuscule à côté des
   autres champs. */
.champ [data-dd], .champ .dd { display: block; width: 100%; }

.champ .dd__trigger {
  display: flex;
  width: 100%;
  /* Le 210 px du composant devient un plancher gênant ici : la ligne
     de champs répartit déjà la place. */
  min-width: 0;
  height: var(--h-controle);
  /* Aligné sur .champ input : même hauteur, même retrait, même
     taille de texte — sinon les contrôles voisins ne s'alignent pas. */
  padding: 0 13px;
  font-size: 16px;
}
.champ .dd__value { text-align: left; }

/* L'état « ouvert » se voit au liseré ; le focus, lui, ne doit pas
   laisser le bouton allumé une fois le choix fait.

   `selectOption()` rend le focus au déclencheur après la sélection —
   nécessaire au clavier, mais le style fort de :focus-visible restait
   alors affiché, donnant un bouton perpétuellement « activé ». On
   réserve donc le liseré à l'état ouvert, et on laisse au focus un
   contour de mise au point normal. */
.dd__trigger:focus-visible {
  outline: 2px solid var(--evergreen);
  outline-offset: 2px;
  box-shadow: none;
  border-color: var(--filet);
}
.dd__trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--evergreen);
  box-shadow: var(--ring);
}

/* Le panneau suit la largeur du déclencheur plutôt qu'une valeur fixe. */
.champ .dd__panel { width: 100%; min-width: 0; }
