/* ============================================================
   viz.css — les graphiques (finances, parrainage)
   ============================================================
   Couleurs par RÔLE, validées (scripts/validate_palette.js de la
   charte dataviz) sur la surface claire #FFFFFF et sombre #16162A :
   écart daltonien ≥ 8,4 entre voisins, contraste ≥ 3:1 en sombre.
   En clair, l'aqua et le jaune passent sous 3:1 : chaque graphique a
   donc sa légende et son tableau. Le texte ne prend JAMAIS la couleur
   d'une série : il reste dans les encres du thème. */

:root {
    --viz-1: #2a78d6;      /* hébergement, revenu récurrent */
    --viz-2: #eb6834;      /* achats de bots, scénario « au rythme actuel » */
    --viz-3: #1baf7a;      /* commandes */
    --viz-4: #eda100;      /* autres */
    --viz-gain: #2a78d6;   /* ce qui arrive */
    --viz-perte: #e34948;  /* ce qui part */
    --viz-neutre: #8a8a99; /* dépenses : ni une série, ni une alerte */
    --viz-encre: #1c1b2e;  /* le bénéfice : une courbe d'encre */
}
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500;
        --viz-gain: #3987e5; --viz-perte: #e66767; --viz-neutre: #7c7c92; --viz-encre: #f1f0ff;
    }
}
:root[data-theme="dark"] {
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500;
    --viz-gain: #3987e5; --viz-perte: #e66767; --viz-neutre: #7c7c92; --viz-encre: #f1f0ff;
}

.viz { position: relative; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grille { stroke: var(--trait); stroke-width: 1; shape-rendering: crispEdges; }
.viz-grille.zero { stroke: var(--label-3); }
.viz-axe { fill: var(--label-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.viz-fin { fill: var(--label-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-ligne { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-ligne.pointille { stroke-dasharray: 5 5; }
.viz-aire { opacity: .1; }
.viz-point { stroke: var(--surface); stroke-width: 2; }
.viz-separation { stroke: var(--label-3); stroke-width: 1; }
.viz-reticule { stroke: var(--label-2); stroke-width: 1; opacity: 0; pointer-events: none; }
.viz-svg.survol .viz-reticule { opacity: .5; }
.viz-zone { fill: transparent; cursor: default; outline: none; }
.viz-zone:focus-visible { fill: var(--survol); }
.viz-col { transition: opacity .15s var(--ease); }
.viz-svg.survol .viz-col:not(.actif) { opacity: .45; }

.viz-legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 12.5px; color: var(--label-2); }
.viz-legende > span { display: inline-flex; align-items: center; gap: 7px; }
.viz-cle { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz-cle-ligne { width: 16px; height: 0; border-top: 2px solid var(--c); flex: none; }
.viz-cle-ligne.pointille { border-top-style: dashed; }

/* La bulle de survol : la valeur d'abord, la série ensuite. */
.viz-tip {
    position: fixed; z-index: 200; pointer-events: none; min-width: 170px; max-width: 300px;
    padding: 10px 12px; border-radius: 12px;
    background: var(--surface); color: var(--label);
    box-shadow: 0 0 0 1px var(--trait), 0 12px 32px -10px rgba(0, 0, 0, .35);
    font-size: 12.5px;
}
.viz-tip[hidden] { display: none; }
.viz-tip-titre { font-weight: 650; margin-bottom: 6px; color: var(--label-2); font-size: 12px; }
.viz-tip-ligne { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.viz-tip-ligne strong { font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.viz-tip-ligne span { color: var(--label-2); }
.viz-tip-cle { width: 12px; height: 0; border-top: 2px solid; flex: none; }
.viz-tip-cle.pointille { border-top-style: dashed; }
.viz-tip-note { color: var(--label-2); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--trait); line-height: 1.4; }

/* Le tableau sous chaque graphique : les mêmes chiffres, sans survoler. */
.viz-tableau { margin-top: 10px; }
.viz-tableau > summary { cursor: pointer; font-size: 12.5px; color: var(--label-2); width: max-content; }
.viz-tableau table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.viz-tableau th, .viz-tableau td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--trait); white-space: nowrap; }
.viz-tableau th:first-child, .viz-tableau td:first-child { text-align: left; }
.viz-tableau-defile { overflow-x: auto; }

/* Carte de cohortes : une teinte, du clair au foncé. */
.cohortes { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cohortes th { font-weight: 550; color: var(--label-2); text-align: left; padding: 4px 6px; white-space: nowrap; }
.cohortes td { text-align: center; padding: 7px 4px; border-radius: 6px; min-width: 38px; color: var(--label); }
.cohortes td.fonce { color: #fff; }
.cohortes td.vide { background: transparent; }

/* Jauges (objectif, seuils) : la piste est un pas plus clair de la même teinte. */
.jauge-f { position: relative; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--c, var(--viz-1)) 16%, transparent); overflow: hidden; }
.jauge-f > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--c, var(--viz-1)); }
.jauge-f > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--label-2); }

/* ─── Page Finances ───────────────────────────────────────── */
.fin-kpis { margin-top: 16px; }
.fin-kpis .stat-value { font-size: 26px; }
.stat-unite { font-size: 14px; font-weight: 550; color: var(--label-2); }
.hausse { color: color-mix(in srgb, var(--green) 80%, var(--label)); font-weight: 600; }
.baisse { color: color-mix(in srgb, var(--red) 82%, var(--label)); font-weight: 600; }
.lien-btn { border: 0; padding: 0; background: none; color: var(--marque); font: inherit; cursor: pointer; }
.lien-btn:hover { text-decoration: underline; }
a.bandeau-lien { color: var(--label); text-decoration: none; align-items: center; }
a.bandeau-lien > span { flex: 1; }
a.bandeau-lien:hover { text-decoration: none; filter: brightness(1.03); }
.barre-ligne { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(80px, 2fr) auto; align-items: center; gap: 12px; padding: 5px 0; font-size: 13.5px; }
.barre-nom { color: var(--label-2); }
.barre-val { font-weight: 600; text-align: right; min-width: 64px; }
.form-depense {
    display: grid; gap: 12px;
    grid-template-columns: 2fr 1fr 1.2fr 1fr 1fr auto;
    grid-template-areas: "lib mnt cat dat rec act";
}
@media (max-width: 900px) {
    .form-depense { grid-template-columns: 1fr 1fr; grid-template-areas: "lib lib" "mnt cat" "dat rec" "act act"; }
}
.kv-ligne { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--trait); }
.kv-ligne > span:first-child { color: var(--label-2); }
.kv-ligne.total { font-weight: 650; border-bottom: 0; }
.kv-ligne.total > span:first-child { color: var(--label); }

/* Téléphone : un graphique de 12 mois ne rétrécit pas jusqu'à l'illisible,
   il défile de côté. */
@media (max-width: 700px) {
    .viz { overflow-x: auto; }
    .viz > .viz-svg { min-width: 640px; }
}

/* ─── Réseau de parrainage : la constellation 3D ──────────── */
.reseau3d { position: relative; height: var(--h, 460px); border-radius: var(--r-md); overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--viz-1) 7%, transparent), transparent 70%); }
.reseau3d canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; outline: none; }
.reseau3d canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--marque); }
.r3d-outils { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.r3d-outils .btn { min-width: 32px; justify-content: center; }
.r3d-bulle { position: absolute; z-index: 5; pointer-events: none; max-width: 240px; padding: 10px 12px; border-radius: 12px;
    background: var(--surface); color: var(--label-2); font-size: 12.5px; line-height: 1.5;
    box-shadow: 0 0 0 1px var(--trait), 0 12px 32px -10px rgba(0, 0, 0, .35); }
.r3d-bulle strong { display: block; color: var(--label); font-size: 13.5px; margin-bottom: 2px; }
.r3d-bulle[hidden] { display: none; }
.r3d-legende { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 10px 4px 2px; font-size: 12.5px; color: var(--label-2); }
.r3d-legende > span { display: inline-flex; align-items: center; gap: 7px; }
.r3d-legende i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.r3d-legende i.creux { border: 1.5px solid var(--label-3); }
.r3d-aide { margin-left: auto; color: var(--label-3); }
@media (max-width: 700px) { .r3d-aide { margin-left: 0; } .reseau3d { height: 380px; } }

/* Le classement des ambassadeurs */
.amb { display: inline-flex; align-items: center; gap: 10px; color: var(--label); text-decoration: none; font-weight: 600; }
.amb img, .amb-ini { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }
.amb-ini { display: grid; place-items: center; background: var(--creux, var(--survol)); color: var(--label-2); font-size: 12px; }

/* L'arbre 2D d'une personne */
.arbre-defile { overflow-x: auto; padding: 4px 2px; }
.arbre-svg { display: block; }
.arbre-lien { fill: none; stroke: var(--label-3); stroke-width: 1.5; opacity: .5; }
.arbre-lien.client { stroke: var(--viz-1); opacity: .8; }
.arbre-noeud circle { fill: var(--surface); stroke: var(--viz-3); stroke-width: 2; }
.arbre-noeud.client circle { fill: var(--viz-1); stroke: var(--surface); }
.arbre-noeud.parti circle { stroke: var(--label-3); stroke-dasharray: 2 2; }
.arbre-noeud.racine circle { stroke: var(--viz-2); stroke-width: 3; }
.arbre-noeud:hover .arbre-nom { text-decoration: underline; }
.arbre-nom { fill: var(--label); font-size: 13px; font-weight: 600; }
.arbre-sous { fill: var(--label-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.lignee { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--label-2); margin-bottom: 12px; }
.lignee a { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--survol); color: var(--label); text-decoration: none; font-weight: 550; }
.lignee a .amb-ini, .lignee a img { width: 20px; height: 20px; font-size: 10px; }
.mini-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r-md); background: var(--survol); }
.mini-kpi span { font-size: 12px; color: var(--label-2); font-weight: 550; }
.mini-kpi strong { font-size: 20px; font-weight: 700; }
.mini-kpi em { font-style: normal; font-size: 11.5px; color: var(--label-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ─── Diffusion ───────────────────────────────────────────── */
.diff-grille { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.diff-apercu-col { position: sticky; top: 90px; }
@media (max-width: 960px) { .diff-grille { grid-template-columns: 1fr; } .diff-apercu-col { position: static; } }
.diff-form { display: flex; flex-direction: column; gap: 12px; }
.diff-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.diff-programmer { display: inline-flex; gap: 6px; }
.diff-programmer .input { width: auto; height: 36px; padding-block: 0; }
.diff-en > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; padding: 4px 0; }
.diff-en[open] { display: flex; flex-direction: column; gap: 10px; }
.diff-vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.diff-var { font: 500 12.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 6px 9px; border-radius: 999px; border: 1px solid var(--separator); background: var(--creux); color: var(--label-2); cursor: pointer; }
.diff-var:hover { color: var(--label); border-color: var(--accent); }
.diff-var:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.diff-vide { display: flex; gap: 12px; align-items: flex-start; padding: 16px; }
.diff-vide > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.diff-vide-icone { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--creux); color: var(--label-2); }
.diff-dest-tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; min-height: 34px; }
.diff-filtre { max-width: 180px; height: 32px; padding: 4px 10px; font-size: 13px; }
.diff-dest { display: flex; flex-direction: column; padding: 6px; }
.diff-dest-liste { display: flex; flex-direction: column; gap: 1px; max-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
.diff-dest-ligne { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; color: var(--label); text-decoration: none; }
.diff-dest-ligne:hover { background: var(--survol); text-decoration: none; }
.diff-dest-ligne[hidden] { display: none; }
.diff-av { width: 28px; height: 28px; font-size: 12px; }
.diff-dest-qui { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.diff-dest-nom { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-dest-info { font-size: 12.5px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-exclus { border-top: 1px solid var(--trait); margin-top: 6px; padding-top: 8px; display: flex; flex-direction: column; gap: 1px; }
.diff-exclus-titre { font-size: 12.5px; font-weight: 600; color: var(--label-2); padding: 0 8px 4px; }
.diff-exclus .diff-dest-ligne { opacity: .78; }

/* L'aperçu imite Discord, en clair comme en sombre. */
.discord { --d-fond: #ffffff; --d-texte: #313338; --d-doux: #5c5e66; --d-embed: #f2f3f5; --d-lien: #006ce7; --d-bouton: #e3e5e8;
    border-radius: 14px; padding: 14px 16px; background: var(--d-fond); color: var(--d-texte); font-size: 14.5px; line-height: 1.4;
    box-shadow: 0 0 0 1px var(--trait); font-family: "gg sans", "Noto Sans", system-ui, sans-serif; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .discord { --d-fond: #313338; --d-texte: #dbdee1; --d-doux: #949ba4; --d-embed: #2b2d31; --d-lien: #00a8fc; --d-bouton: #4e5058; } }
:root[data-theme="dark"] .discord { --d-fond: #313338; --d-texte: #dbdee1; --d-doux: #949ba4; --d-embed: #2b2d31; --d-lien: #00a8fc; --d-bouton: #4e5058; }
.discord-msg { display: flex; gap: 14px; }
.discord-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: linear-gradient(135deg, #5145CD, #8B5CF6); }
.discord-corps { min-width: 0; flex: 1; }
.discord-auteur { font-weight: 600; margin-bottom: 4px; }
.discord-bot { font-size: 10px; font-weight: 700; background: #5865f2; color: #fff; border-radius: 3px; padding: 1px 4px; vertical-align: 2px; margin-left: 2px; }
.discord-heure { font-size: 12px; font-weight: 400; color: var(--d-doux); margin-left: 4px; }
.discord-mention { display: inline-block; background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 3px; margin-bottom: 4px; font-weight: 500; }
:root:not([data-theme="dark"]) .discord-mention { color: #505cdc; background: rgba(88, 101, 242, .15); }
.discord-mention[hidden] { display: none; }
.discord-embed { max-width: 432px; background: var(--d-embed); border-left: 4px solid #4A3DC4; border-radius: 4px; padding: 10px 14px 12px 12px; }
.discord-embed-titre { font-weight: 700; margin-bottom: 6px; }
.discord-embed-titre[hidden] { display: none; }
.discord-embed-texte { font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
.discord-embed-texte a, .discord-texte a { color: var(--d-lien); }
.discord-embed-texte code, .discord-texte code { background: rgba(0, 0, 0, .15); border-radius: 3px; padding: 0 3px; font-size: 13px; }
.discord-embed-image { display: block; max-width: 100%; border-radius: 4px; margin-top: 10px; }
.discord-embed-image[hidden] { display: none; }
.discord-embed-pied { font-size: 12px; color: var(--d-doux); margin-top: 8px; }
.discord-boutons { display: flex; gap: 8px; margin-top: 6px; }
.discord-bouton { display: inline-flex; align-items: center; height: 32px; padding: 0 16px; border-radius: 3px; background: var(--d-bouton); font-size: 14px; font-weight: 500; }
.discord-bouton.drapeau-btn { padding: 0 10px; }
.discord-bouton[hidden] { display: none; }
.discord-texte { overflow-wrap: anywhere; }

/* ── Réponses toutes faites : les variables ───────────────── */
.rep-var-groupe { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px solid var(--trait); }
.rep-var-groupe:first-of-type { border-top: 0; padding-top: 0; }
.rep-var-titre { font-size: 12.5px; font-weight: 650; color: var(--label-2); margin-bottom: 2px; }
.rep-var { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.rep-var code { flex: none; min-width: 108px; font-size: 12.5px; color: var(--label); }
.rep-var span { color: var(--label-2); }
