/* Palette (oct. 2026) : fond noir, texte blanc, vert et rouge comme sur un
   graphique boursier. Aucun bleu, aucun jaune, aucun brun : c'est la palette
   commune a tous les outils de Joel. Le vert sert d'accent (barres, boutons,
   graphiques) ; le rouge signale ce qui baisse ou ce qui pose probleme ; les
   niveaux intermediaires sont en blanc ou en rouge pale. Le theme ne suit pas
   le reglage de l'appareil : il est sombre partout. */
:root {
  color-scheme: dark;
  --plan: #000000;        /* fond de page */
  --surface: #0f0f10;     /* cartes */
  --surface2: #1b1b1d;    /* elements en relief sur une carte */
  --encre: #ffffff;       /* texte de lecture */
  --encre2: #b8b8bc;      /* texte secondaire */
  --encre3: #8c8c92;      /* legendes, axes */
  --grille: #26262a;
  --axe: #3a3a3e33;
  --bord: rgba(255, 255, 255, 0.12);
  --hausse: #22c55e;      /* vert : hausse, bon, a faire */
  --baisse: #ff4d4f;      /* rouge : baisse, probleme */
  --s1: #22c55e;          /* accent : barres, courbes, boutons */
  --s2: #ffffff;          /* grands chiffres et titres */
  --s3: #22c55e;
  --bon: #22c55e;
  --attention: #ffb3b3;   /* rouge pale : a surveiller */
  --serieux: #ff7b7b;
  --critique: #ff4d4f;
  /* Echelle sequentielle de la carte de correlation, en vert, assez sombre
     pour que le texte blanc reste lisible par-dessus. */
  --seq100: #0d1610;
  --seq250: #112a1a;
  --seq400: #154226;
  --seq550: #195a32;
  --seq700: #1d723e;
  --ombre: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 22px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--plan);
  color: var(--encre);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 76px;
}
h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.02em; color: var(--s2); }
h2 { font-size: 17px; margin: 26px 0 10px; letter-spacing: -.01em; color: var(--s2); }
h3 {
  font-size: 12px; margin: 0 0 8px; color: var(--encre2);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
}
a { color: var(--s1); }
button { font: inherit; }

.page { max-width: 1040px; margin: 0 auto; padding: 0 14px; }

/* ----------------------------------------------------------------- entete */
.entete {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--plan) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bord);
  padding: 10px 0 9px;
}
.entete .page { display: flex; gap: 10px; align-items: center; }
.marque { font-weight: 650; font-size: 15px; white-space: nowrap; letter-spacing: -.01em; color: var(--s2); }
.marque span { color: var(--encre3); font-weight: 400; }
@media (max-width: 620px) { .marque span { display: none; } }

/* --------------------------------------------------------------- recherche */
.recherche { position: relative; flex: 1; min-width: 0; }
.recherche input {
  width: 100%; padding: 10px 12px; font-size: 16px; /* 16px : evite le zoom iOS */
  border: 1px solid var(--bord); border-radius: 9px;
  background: var(--surface); color: var(--encre);
}
.recherche input:focus { outline: 2px solid var(--s1); outline-offset: -1px; }
.suggestions {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: 10px; box-shadow: var(--ombre);
  max-height: 62vh; overflow-y: auto; padding: 4px;
}
.suggestions:empty { display: none; }
.suggestion {
  display: flex; gap: 10px; align-items: baseline; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 7px; text-align: left;
  background: none; color: inherit; cursor: pointer;
}
.suggestion:hover, .suggestion[aria-selected="true"] { background: var(--surface2); }
.suggestion b { font-size: 14px; white-space: nowrap; }
.suggestion i { font-style: normal; color: var(--encre2); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.suggestion em {
  font-style: normal; font-size: 11px; color: var(--encre3);
  border: 1px solid var(--bord); border-radius: 20px; padding: 1px 7px; white-space: nowrap;
}
.entete-suggestion {
  padding: 7px 10px 3px; font-size: 11px; color: var(--encre3);
  text-transform: uppercase; letter-spacing: .06em;
}

/* ------------------------------------------------------------- navigation */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--bord); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; padding: 8px 4px; border: 0; background: none; border-radius: 9px;
  color: var(--encre2); font-size: 12px; cursor: pointer; line-height: 1.25;
}
.nav button[aria-current="true"] { background: var(--surface2); color: var(--s2); font-weight: 650; }
.nav button span { display: block; font-size: 17px; margin-bottom: 1px; }

/* ------------------------------------------------------------------ cartes */
.carte {
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: 11px; padding: 15px 16px; margin-bottom: 12px;
}
.rangee { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tuile {
  flex: 1 1 148px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 11px; padding: 12px 14px;
}
.tuile .lib {
  font-size: 11px; color: var(--encre2); text-transform: uppercase; letter-spacing: .06em; opacity: .85;
}
.tuile .val {
  display: block; font-size: 23px; font-weight: 650; letter-spacing: -.025em;
  margin-top: 2px; color: var(--s2);
}
.tuile .note { display: block; font-size: 11.5px; color: var(--encre3); margin-top: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--grille); vertical-align: top; }
th { font-size: 11px; color: var(--encre2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; opacity: .85; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.enveloppe { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.barre { height: 7px; background: var(--surface2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.barre > span { display: block; height: 100%; border-radius: 4px; background: var(--s1); }

.etiq {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; border: 1px solid var(--bord);
}

.drapeau { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grille); }
.drapeau:last-child { border-bottom: 0; }
.pastille { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.drapeau b { display: block; font-size: 14px; }
.drapeau p { margin: 2px 0 0; font-size: 13px; color: var(--encre2); }

.notes { font-size: 13px; color: var(--encre2); padding-left: 17px; margin: 8px 0 0; }
.notes li { margin-bottom: 5px; }
.sous { color: var(--encre2); font-size: 13.5px; margin: 0 0 14px; }

.avert {
  background: var(--surface2);
  border: 1px solid color-mix(in srgb, var(--baisse) 45%, var(--bord));
  border-radius: 9px; padding: 11px 13px; font-size: 13px; margin-bottom: 12px;
}
.erreur {
  background: color-mix(in srgb, var(--critique) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--critique) 42%, var(--bord));
  border-radius: 9px; padding: 13px 15px; font-size: 14px; margin-bottom: 12px;
}

/* ------------------------------------------------------------- formulaires */
.champs { display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end; }
label.champ { display: block; font-size: 11px; color: var(--encre2);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
select, input[type="number"], input[type="text"] {
  padding: 8px 10px; font-size: 15px; border: 1px solid var(--bord);
  border-radius: 8px; background: var(--surface); color: var(--encre);
}
.bouton {
  padding: 9px 15px; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--encre); cursor: pointer; font-size: 14px;
}
.bouton:hover { background: var(--surface2); }
.bouton.principal { background: var(--s1); color: var(--plan); border-color: transparent; font-weight: 650; }
.bouton.principal:hover { filter: brightness(1.08); }
.bouton.discret { color: var(--encre2); font-size: 13px; padding: 6px 10px; }

input[type="range"] { width: 100%; accent-color: var(--s1); }

.ligne-position {
  display: grid; grid-template-columns: 1fr 110px 96px 66px 34px;
  gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--grille);
}
.ligne-position:last-of-type { border-bottom: 0; }
.ligne-position .nom { min-width: 0; }
.ligne-position .nom b { display: block; font-size: 14px; }
.ligne-position .nom small { color: var(--encre2); font-size: 12px;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-position input[type="number"] { width: 100%; }
.ligne-position .part { text-align: right; font-variant-numeric: tabular-nums;
  color: var(--encre2); font-size: 13px; }
@media (max-width: 560px) {
  .ligne-position { grid-template-columns: 1fr 96px 60px 34px; }
  .ligne-position .curseur { grid-column: 1 / -1; }
}

.puces { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; }
.puce {
  padding: 6px 12px; border: 1px solid var(--bord); border-radius: 20px;
  background: var(--surface); font-size: 13px; cursor: pointer; color: var(--encre);
}
.puce[aria-pressed="true"] { background: var(--s1); color: var(--plan); border-color: transparent; font-weight: 650; }

.chargement { color: var(--encre2); font-size: 14px; padding: 22px 2px; }
.vide { color: var(--encre2); font-size: 14px; padding: 8px 0 2px; }

svg { display: block; max-width: 100%; height: auto; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--encre2); margin-top: 7px; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.pied { color: var(--encre3); font-size: 11.5px; margin: 26px 0 8px;
  border-top: 1px solid var(--grille); padding-top: 12px; }

.masque { display: none !important; }

/* ------------------------------------------------- regle de deploiement
   Palette propre a cet ecran : texte blanc, vert pour ce qui est fait ou a
   acheter, rouge pour le recul du marche. Aucun bleu ni jaune ici. */
#vue-plan h1 { color: var(--encre); }
#vue-plan .tuile .lib { color: var(--encre2); opacity: 1; }
#vue-plan .tuile .val { color: var(--encre); }
#vue-plan th { color: var(--encre2); opacity: 1; }
#vue-plan input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--hausse); cursor: pointer; }
#vue-plan .etiq.ok { color: var(--hausse); border-color: color-mix(in srgb, var(--hausse) 45%, transparent); }
#vue-plan .etiq.agir { color: var(--plan); background: var(--hausse); border-color: transparent; }
#vue-plan svg { margin-top: 14px; }
#vue-plan td, #vue-plan th { white-space: nowrap; }
#vue-plan .enveloppe table { min-width: 340px; }
#vue-plan summary { cursor: pointer; font-weight: 600; color: var(--encre); }
#vue-plan input[type="date"] {
  padding: 8px 10px; font-size: 15px; border: 1px solid var(--bord);
  border-radius: 8px; background: var(--surface); color: var(--encre); color-scheme: dark;
}
.plan-agir { border-color: color-mix(in srgb, var(--hausse) 55%, var(--bord)); }
.plan-action {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--grille); font-size: 14.5px;
}
.plan-action:last-of-type { border-bottom: 0; }
.plan-action b { color: var(--hausse); white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan-rien { margin: 0; font-size: 14.5px; }
.plan-barre { height: 10px; background: var(--surface2); border-radius: 5px; overflow: hidden; }
.plan-barre > span { display: block; height: 100%; background: var(--hausse); border-radius: 5px; }
.plan-case { display: flex; gap: 10px; align-items: center; font-size: 14.5px; }

/* -------------------------------------------------- sauvegarde en ligne */
.synchro { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grille); font-size: 13.5px; color: var(--encre2); }
.carte > h3 + .synchro { margin-top: 0; padding-top: 0; border-top: 0; }
.synchro b { color: var(--encre); }
.code-perso { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.synchro-note { margin-top: 6px; color: var(--encre); }
#vue-plan .plan-montant { width: 104px; padding: 5px 7px; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
#vue-plan .plan-montant.manuel { border-color: color-mix(in srgb, var(--hausse) 60%, var(--bord)); }
@media (max-width: 480px) {
  #vue-plan th, #vue-plan td { padding: 6px 4px; }
  #vue-plan .plan-montant { width: 82px; font-size: 13px; padding: 4px 5px; }
  #vue-plan .etiq { font-size: 10.5px; padding: 1px 6px; }
  #vue-plan .enveloppe table { min-width: 0; }
}

/* --------------------------------------------------- tarte des secteurs */
.tarte { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.tarte svg { width: 180px; flex: 0 0 auto; }
.tarte-legende { list-style: none; margin: 0; padding: 0; flex: 1 1 220px; font-size: 13.5px; }
.tarte-legende li { display: flex; gap: 9px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--grille); }
.tarte-legende li:last-child { border-bottom: 0; }
.tarte-legende i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.tarte-legende span { flex: 1; }
.tarte-legende b { font-variant-numeric: tabular-nums; }
