/*  ── STRESS-TEST (Shared/StressTestPanel.razor), refonte du 23/10/2026 d'après la maquette validée par Arthur ─────────────────────
    Quatre montures d'un même panneau, préfixe sp- :
      • flottant sur le hub (.stresspanel-flyout) : 288 px, en-tête de 36 px déplaçable, en haut à droite ;
      • docké dans le pilotage (.stresspanel-dock dans .sp-dockwrap, Pages/FinTreePopup.razor) : colonne de 288 px à droite du tableau ;
      • tiroir bas au téléphone (.sp-tiroir, moins de 600 px) : quatre leviers, cinq puces de valeur ;
      • leçon de l'Académie (.stresspanel-side, Shared/AcademiePilotage.razor) : sans en-tête, sans bloc d'effet.
    Couleurs : jetons de l'application uniquement (--ok, --danger, --brand, --o*, --tx*, --mut*), rien d'écrit en dur ; Mat et Papier
    reprennent --mt-carte et --mt-trait (style-mat.css, style-papier.css visent déjà .stresspanel-flyout). Chargée après analyses.css et
    panneaux-flottants.css (la règle de la pile des boutons au-dessus du tiroir doit passer après celle de la valorisation). */

.stresspanel {
  --sp-pos: var(--ok);
  --sp-neg: var(--danger);
  display: flex; flex-direction: column; color: var(--tx1); min-width: 0;
}
html[data-theme="light"] .stresspanel {
  --sp-pos: color-mix(in srgb, var(--ok) 55%, #000);
  --sp-neg: color-mix(in srgb, var(--danger) 52%, #000);
}

/* ── Flottant (hub) ── */
.stresspanel-flyout {
  position: fixed; top: 84px; right: 24px; z-index: 6200; width: 288px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 96px); max-height: calc(100svh - 96px);
  border-radius: 14px; background: linear-gradient(135deg, var(--gl60), var(--gd80));
  border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 30%, rgba(255, 255, 255, .12));
  box-shadow: 0 24px 64px rgba(var(--shadow-col), calc(.55 * var(--shadow-mul))); backdrop-filter: blur(26px) contrast(.85);
}
@media (max-height: 500px) {
  .stresspanel-flyout { top: 8px; max-height: calc(100vh - 16px); max-height: calc(100svh - 16px); }
}
.sp-head { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 3px; border-bottom: 1px solid var(--o12); }
.stresspanel-flyout .sp-head { cursor: move; touch-action: none; }
.sp-grip { flex: 0 0 auto; width: 18px; height: 24px; display: inline-flex; align-items: center; justify-content: center; color: var(--mut3); opacity: .8; }
.sp-grip svg { fill: currentColor; }
.stresspanel-title { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 800; line-height: 1; color: var(--tx1); white-space: nowrap; }
.stresspanel-title .iku-ico { width: 14px; height: 14px; color: var(--brand); }
.sp-esp { flex: 1 1 auto; }
.sp-ep { flex: 0 1 auto; min-width: 0; font-size: 10.5px; font-weight: 700; color: var(--mut2); padding: 2px 7px; border-radius: 999px; background: var(--o5); border: 1px solid var(--o12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* La pastille du scénario piloté (dossier à plusieurs scénarios) : une liste compacte dans l'en-tête */
.sp-scen { flex: 0 1 auto; min-width: 0; }
.sp-scen .custom-dropdown { min-width: 0; }
.sp-scen .custom-dropdown-trigger { min-width: 0; max-width: 128px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 650; }
.sp-scen .custom-dropdown-value { overflow: hidden; text-overflow: ellipsis; }
.sp-x { flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--mut3); background: var(--o5); border: 1px solid var(--o12); cursor: pointer; font-size: 11px; transition: .14s; }
.sp-x:hover { color: var(--tx1); background: var(--o12); border-color: var(--o22); }
.sp-x:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sp-corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 10px; }

/* ── Docké (pilotage) ── */
.sp-dockwrap { flex: 0 0 288px; width: 288px; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--o10); background: transparent; backdrop-filter: blur(8px); }
html[data-theme="light"] .sp-dockwrap { background: #fff; }
html[data-style="mat"] .sp-dockwrap { background: var(--mt-carte); border-left-color: var(--mt-trait); backdrop-filter: none; }
.stresspanel-dock { flex: 1 1 auto; min-height: 0; }
.stresspanel-dock .sp-head { height: 38px; padding: 0 8px 0 12px; }
.stresspanel-dock .sp-corps { padding: 12px; }
.sp-dock-note { margin: 0; font-size: 11px; line-height: 1.4; color: var(--mut2); }
.sp-dock-note b { color: var(--tx2); }
@media (max-width: 1120px) {
  .sp-dockwrap { flex: 0 0 auto; width: 100%; max-height: 46vh; max-height: 46svh; border-left: 0; border-top: 1px solid var(--o14); }
}

/* ── Leçon de l'Académie : le panneau posé dans la page ── */
.stresspanel-side { background: var(--o4); border: 1px solid var(--o12); border-radius: 14px; }
.stresspanel-side .sp-titre-side { padding: 10px 10px 0; }
.stresspanel-side .sp-scen-side { padding: 8px 10px 0; }
.stresspanel-side .sp-scen-side .custom-dropdown { width: 100%; }
.stresspanel-side .sp-scen-side .custom-dropdown-trigger { min-width: 0; width: 100%; padding: 5px 9px; font-size: 11px; border-radius: 8px; }

/* ── Le bloc d'effet : une ligne, qui se déplie en tendance ── */
.sp-ef { flex: 0 0 auto; display: flex; flex-direction: column; border-radius: 10px; background: var(--o5); border: 1px solid var(--o8); }
.sp-ef-l1 { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; padding: 0 7px 0 10px; border: 0; border-radius: 10px; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.sp-ef-l1:hover { background: var(--o5); }
.sp-ef-l1:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sp-ef-l1 > span:first-child { flex: 1 1 auto; min-width: 0; font-size: 11.5px; color: var(--mut2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-ef-l1 b { flex: 0 0 auto; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--tx1); white-space: nowrap; }
.sp-ef-l1 .sp-e { flex: 0 0 auto; }
.sp-chev { flex: 0 0 auto; width: 13px; height: 13px; fill: none; stroke: var(--mut2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.sp-ef.is-ouvert .sp-ef-l1 .sp-chev { transform: rotate(180deg); }
.sp-ef-d { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 9px; }
.sp-ef-note { margin: 0; font-size: 10.5px; line-height: 1.35; color: var(--mut3); }
/*  LA TENDANCE (refonte du 23/10, « améliore design du chart ») : aucun texte dans le tracé, valeurs de fin dans la gouttière droite,
    point bas en anneau sur la courbe et en pastille dessous. Couleurs : jetons seulement (clair, sombre, Mat, Papier). */
.sp-ef-svg { display: block; width: 100%; height: auto; overflow: visible; }
.sp-ef-svg .gr { stroke: var(--o12); stroke-width: 1; shape-rendering: crispEdges; }
.sp-ef-svg .z0 { stroke: color-mix(in srgb, var(--danger) 55%, transparent); stroke-width: 1; stroke-dasharray: 2 3; }
.sp-ef-svg .g0 { stop-color: var(--brand); stop-opacity: .22; }
.sp-ef-svg .g1 { stop-color: var(--brand); stop-opacity: 0; }
.sp-ef-svg .zn { fill: var(--danger); fill-opacity: .3; }
.sp-ef-svg .zp { fill: var(--ok); fill-opacity: .3; }
html[data-theme="light"] .sp-ef-svg .zn, html[data-theme="light"] .sp-ef-svg .zp { fill-opacity: .24; }
html[data-theme="light"] .sp-ef-svg .g0 { stop-opacity: .16; }
.sp-ef-svg .cb { fill: none; stroke: var(--mut3); stroke-width: 1.2; stroke-dasharray: 2 3; stroke-linecap: round; opacity: .85; }
.sp-ef-svg .cs { fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.sp-ef-svg .db { fill: var(--mut3); stroke: none; }
.sp-ef-svg .ds { fill: var(--brand); stroke: none; }
.sp-ef-svg .pb { fill: var(--brand); stroke: none; }
.sp-ef-svg .pbh { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-opacity: .4; }
.sp-ef-svg text { font-size: 10px; font-weight: 700; fill: var(--tx1); font-variant-numeric: tabular-nums; }
.sp-ef-svg text.vs { fill: var(--brand-text); font-weight: 800; }
.sp-ef-svg text.vb { fill: var(--mut2); font-weight: 650; }
.sp-ef-svg text.ax { fill: var(--mut3); font-weight: 600; font-size: 9px; opacity: .85; }
.sp-ef-svg .hv { fill: transparent; }
.sp-ef-svg .hv:hover { fill: var(--o6); }
/*  Le point bas, sous le graphique : la pastille « avec chocs » et, plus discret, celui « sans chocs ». */
.sp-ef-rep { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 10px; color: var(--mut2); font-variant-numeric: tabular-nums; }
.sp-pb { display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 7px 0 6px; border-radius: 999px; background: var(--o5); border: 1px solid var(--o8); white-space: nowrap; }
.sp-pb i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.sp-pb b { color: var(--tx1); font-weight: 800; }
.sp-pb-b { white-space: nowrap; color: var(--mut3); }
.sp-ef-val { display: flex; align-items: center; gap: 4px; padding-top: 6px; border-top: 1px solid var(--o8); font-size: 11px; color: var(--mut2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-ef-val b { color: var(--tx1); font-weight: 800; }
.sp-ef-val .sp-e { margin-left: auto; height: 18px; padding: 0 6px; font-size: 10.5px; }
.sp-e { display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sp-e.neg { color: var(--sp-neg); background: color-mix(in srgb, var(--danger) 15%, transparent); }
.sp-e.pos { color: var(--sp-pos); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.sp-e.nul { color: var(--mut3); background: var(--o5); }
.sp-calc { color: var(--mut3); font-weight: 700; }

/* ── Quand : deux menus sur une ligne ── */
.sp-lbl { font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--mut3); white-space: nowrap; }
.sp-qd { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.sp-qd .sp-lbl { width: 40px; flex: 0 0 auto; }
.sp-qd .custom-dropdown { flex: 1 1 0; min-width: 0; }
.sp-qd .custom-dropdown:first-of-type { flex-grow: 1.3; }   /* « Dès juin 2025 » tient sur sa ligne */
.sp-qd .custom-dropdown-trigger { min-width: 0; width: 100%; height: 28px; padding: 0 6px 0 9px; border-radius: 8px; font-size: 12px; font-weight: 650; }
.sp-qd .custom-dropdown-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Sélecteur segmenté des deux groupes ── */
.sp-seg2 { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 10px; border: 1px solid var(--o12); background: var(--o5); }
.sp-seg2 button { height: 28px; padding: 0 6px; border: 0; border-radius: 7px; background: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--mut2); white-space: nowrap; cursor: pointer; }
.sp-seg2 button:hover { color: var(--tx1); }
.sp-seg2 button.on, .sp-seg4 button.on { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--tx1); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 60%, transparent); }
.sp-seg2 button:focus-visible, .sp-seg4 button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sp-seg2 i { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: var(--brand-contrast, #06141a); font-size: 10.5px; font-weight: 800; line-height: 17px; font-style: normal; text-align: center; }

/* ── Une ligne par levier, un pas ── */
.sp-grp { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; }
.sp-lev { display: flex; align-items: center; gap: 8px; min-height: 31px; }
.sp-lev-n { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sp-lev-n b { font-size: 12.5px; font-weight: 700; color: var(--tx1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-lev-n small { font-size: 10.5px; color: var(--mut2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-stp { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; }
.sp-stp-b { width: 26px; height: 26px; padding: 0; border-radius: 7px; border: 1px solid var(--o16); background: var(--o6); font: inherit; font-size: 15px; font-weight: 700; line-height: 1; color: var(--tx1); cursor: pointer; transition: .14s; }
.sp-stp-b:hover { background: var(--o12); border-color: var(--o22); }
.sp-stp-b:disabled { opacity: .32; cursor: not-allowed; pointer-events: none; }
.sp-stp-v { width: 62px; height: 26px; padding: 0 4px; border-radius: 7px; border: 1px solid transparent; background: none; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--mut3); white-space: nowrap; cursor: default; }
.sp-stp-v.neg, .sp-stp-v.pos { cursor: pointer; }
.sp-stp-v.neg { color: var(--sp-neg); background: color-mix(in srgb, var(--danger) 13%, transparent); border-color: color-mix(in srgb, var(--danger) 38%, transparent); }
.sp-stp-v.pos { color: var(--sp-pos); background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: color-mix(in srgb, var(--ok) 38%, transparent); }
.sp-stp-v .iku-ico { width: 9px; height: 9px; opacity: .7; }
.sp-stp-v:focus-visible, .sp-stp-b:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ── Chocs posés, toutes dates ── */
.sp-po { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--o8); }
.sp-po-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-po-x { padding: 0; border: 0; background: none; font: inherit; font-size: 11.5px; font-weight: 700; color: var(--brand-text); cursor: pointer; white-space: nowrap; }
.sp-po-x:hover { text-decoration: underline; }
.sp-po-l { display: flex; flex-wrap: wrap; gap: 5px; }
.sp-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 24px; padding: 0 5px 0 9px; border-radius: 999px; border: 1px solid var(--o12); background: var(--o5);
  font-size: 11px; font-weight: 650; color: var(--tx2); white-space: nowrap; }
.sp-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sp-chip b { color: var(--tx1); font-weight: 800; }
.sp-chip button { flex: 0 0 auto; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: var(--o8); display: grid; place-items: center; color: var(--mut2); cursor: pointer; font-size: 8px; }
.sp-chip button:hover { color: var(--tx1); background: var(--o16); }
.sp-chip button .iku-ico { width: 8px; height: 8px; }

/* ── Téléphone : le tiroir bas (moins de 600 px) ── */
.sp-tiroir {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6200; max-height: 82dvh;
  border-radius: 16px 16px 0 0; background: linear-gradient(135deg, var(--gl60), var(--gd80));
  border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 30%, rgba(255, 255, 255, .12)); border-bottom: 0;
  box-shadow: 0 -12px 40px rgba(var(--shadow-col), calc(.5 * var(--shadow-mul))); backdrop-filter: blur(26px) contrast(.85);
  animation: sp-monte .2s ease-out;
}
html[data-style="mat"] .sp-tiroir { background: var(--mt-carte); border-color: var(--mt-trait); box-shadow: 0 -8px 24px rgba(0, 0, 0, .3); backdrop-filter: none; }
@keyframes sp-monte { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sp-tir-poignee { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; height: 14px; }
.sp-tir-poignee i { width: 36px; height: 4px; border-radius: 2px; background: var(--o16); }
.sp-tir-head { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px 0 14px; }
.sp-tir-head .stresspanel-title { font-size: 13px; }
.sp-tir-corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 4px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
.sp-tiroir .sp-ef { border-radius: 12px; }
.sp-tiroir .sp-ef-l1 { min-height: 44px; padding: 0 8px 0 12px; border-radius: 12px; gap: 8px; }
.sp-tiroir .sp-ef-l1 > span:first-child { font-size: 12px; }
.sp-tiroir .sp-ef-l1 b { font-size: 16px; }
.sp-tiroir .sp-ef-l1 .sp-e { height: 22px; font-size: 12px; }
.sp-tiroir .sp-ef-d { padding: 0 12px 10px; }
.sp-seg4 { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: 12px; border: 1px solid var(--o12); background: var(--o5); }
.sp-seg4 button { height: 44px; padding: 0 2px; border: 0; border-radius: 9px; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--mut2); font: inherit; cursor: pointer; }
.sp-seg4 button b { max-width: 100%; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-seg4 button small { font-size: 10.5px; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 12px; }
.sp-seg4 button small.neg { color: var(--sp-neg); }
.sp-seg4 button small.pos { color: var(--sp-pos); }
.sp-puces { flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.sp-puce { height: 40px; padding: 0; border-radius: 10px; border: 1px solid var(--o16); background: var(--o6); font: inherit; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--tx1); cursor: pointer; }
.sp-puce.on.neg { color: var(--sp-neg); background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: var(--danger); }
.sp-puce.on.pos { color: var(--sp-pos); background: color-mix(in srgb, var(--ok) 16%, transparent); border-color: var(--ok); }
.sp-puce.on.zero { background: color-mix(in srgb, var(--brand) 20%, transparent); border-color: var(--brand); }
.sp-puce:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sp-tir-pied { margin: 0; font-size: 11px; line-height: 1.4; color: var(--mut2); }
/*  Le bouton rond (menu ⊞) remonte au-dessus du tiroir : --sp-tiroir-h est posée sur <body> par ikuStressTiroir (app.js), hauteur réelle. */
@media (max-width: 599px) {
  body:has(.sp-tiroir) .fab-stack-r { bottom: calc(var(--sp-tiroir-h, 270px) + 12px); transition: bottom .22s cubic-bezier(.33, 1, .68, 1); }
  .sp-dockwrap { flex: 0 0 0; width: 0; max-height: none; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-tiroir { animation: none; }
  .sp-chev { transition: none; }
}
@media print { .stresspanel-flyout, .sp-tiroir, .sp-dockwrap { display: none !important; } }
