/* Style commun : terminal simulé et page testnet du pilote 1 $.
   Fichier identique dans terminal/web/css/ et pilote-1usd/interface/css/ (copie : terminal/web/outils/synchro-panneaux.sh).
   Sombre, dense, chiffres tabulaires. Toutes les valeurs visuelles sont des jetons. */

@font-face { font-family: "Schibsted Grotesk"; src: url("../assets/fonts/schibsted-grotesk-latin-wght.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url("../assets/fonts/martian-mono-latin-wght.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  /* surfaces : graphite neutre, trois niveaux de relief + bords */
  --fond: #0b0d0f;
  --panneau: #14171a;
  --panneau-2: #1b1f23;
  --panneau-3: #242a2f;
  --bord: #252a2f;
  --bord-fort: #353c43;
  /* texte : contrastes AA sur --panneau (texte 14:1, texte-2 7:1, texte-3 4,6:1) */
  --texte: #e6e7e8;
  --texte-2: #a3a9ae;
  --texte-3: #7f878e;
  /* sens : vert = achat et gain, rouge = vente et perte. Rien d'autre n'utilise ces deux couleurs. */
  --achat: #2bbd86;
  --vente: #f0595c;
  --achat-fond: #13714d;
  --vente-fond: #ad353b;
  --achat-voile: rgba(43, 189, 134, .13);
  --vente-voile: rgba(240, 89, 92, .13);
  /* accent de la firme (surligneur du site [NOM]) : focus, onglet actif, sélection. Jamais pour un chiffre. */
  --accent: #e6ff3d;
  --accent-texte: #10110d;
  --accent-voile: rgba(230, 255, 61, .12);
  --alerte: #e08a3c;
  --alerte-voile: rgba(224, 138, 60, .14);
  --info: #7fa7d6;
  /* type */
  --police: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --police-chiffres: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --t-xs: 10.5px; --t-s: 11.5px; --t-m: 12.5px; --t-l: 14px; --t-xl: 18px; --t-xxl: 26px;
  --chiffres-echelle: .92; /* Martian Mono est large : on la réduit d'un cran pour garder la densité */
  /* structure */
  --r: 3px; --r-2: 5px;
  --h-tete-pn: 28px;
  --h-ligne: 24px;
  --h-champ: 30px;
  --vitesse: 120ms;
  --ombre: 0 10px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte); font: var(--t-m)/1.4 var(--police);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
a { color: var(--texte); text-decoration-color: var(--texte-3); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
.m, .chiffre { font-family: var(--police-chiffres); font-size: calc(1em * var(--chiffres-echelle)); font-variant-numeric: tabular-nums; }
.n { text-align: right; }
.sous, .petit { color: var(--texte-3); font-size: var(--t-xs); }
.gain, .pos, .hausse { color: var(--achat); }
.perte, .neg, .baisse { color: var(--vente); }
.attenue { color: var(--texte-3); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 26px;
  background: var(--panneau-2); border: 1px solid var(--bord-fort); border-radius: var(--r);
  padding: 4px 10px; color: var(--texte); font-size: var(--t-s); white-space: nowrap;
  transition: border-color var(--vitesse), background var(--vitesse), color var(--vitesse);
}
.btn:hover:not(:disabled) { border-color: var(--texte-3); background: var(--panneau-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn-petit { min-height: 22px; padding: 2px 8px; font-size: var(--t-xs); }
.btn-fantome { background: none; border-color: var(--bord-fort); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 600; }
.btn-accent:hover:not(:disabled) { background: #f0ff7a; border-color: #f0ff7a; color: var(--accent-texte); }
.btn-plein {
  width: 100%; min-height: 38px; border: 0; border-radius: var(--r); padding: 9px 10px;
  font-weight: 600; font-size: var(--t-m); color: #fff; background: var(--panneau-3);
  transition: filter var(--vitesse);
}
.btn-plein.achat { background: var(--achat-fond); } .btn-plein.vente { background: var(--vente-fond); }
.btn-plein.accent { background: var(--accent); color: var(--accent-texte); }
.btn-plein:hover:not(:disabled) { filter: brightness(1.12); }
.btn-plein:disabled { filter: grayscale(.8) brightness(.65); }
.btn-alerte { border-color: var(--alerte); color: var(--alerte); background: none; }
.btn-icone {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  background: none; border: 1px solid transparent; border-radius: var(--r); color: var(--texte-2);
}
.btn-icone:hover { border-color: var(--bord-fort); color: var(--texte); }
.lienb { background: none; border: 0; padding: 0; color: var(--texte); text-decoration: underline; text-decoration-color: var(--texte-3); text-underline-offset: 2px; font-size: inherit; }
.lienb:hover { text-decoration-color: var(--accent); }

/* ---------- segments (Achat/Vente, type d'ordre, unité de temps) ---------- */
.seg { display: flex; gap: 2px; background: var(--panneau-2); border: 1px solid var(--bord); border-radius: var(--r); padding: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 4px 6px; border-radius: 2px; color: var(--texte-2); font-size: var(--t-s); white-space: nowrap; }
.seg button:hover { color: var(--texte); }
.seg button[aria-checked="true"], .seg button[aria-pressed="true"] { background: var(--panneau-3); color: var(--texte); }
.seg-cote button { padding: 6px 4px; font-weight: 600; }
.seg-cote button[data-cote="achat"][aria-checked="true"], .seg-cote button[data-cote="achat"][aria-pressed="true"] { background: var(--achat-fond); color: #fff; }
.seg-cote button[data-cote="vente"][aria-checked="true"], .seg-cote button[data-cote="vente"][aria-pressed="true"] { background: var(--vente-fond); color: #fff; }

/* ---------- champs : libellé petit au-dessus, suffixe dans le champ ---------- */
.champ > label, .lbl { display: block; font-size: var(--t-xs); color: var(--texte-3); margin-bottom: 3px; }
.saisie { display: flex; align-items: stretch; min-height: var(--h-champ); background: var(--panneau-2); border: 1px solid var(--bord); border-radius: var(--r); transition: border-color var(--vitesse); }
.saisie:hover { border-color: var(--bord-fort); }
.saisie:focus-within { border-color: var(--accent); }
.saisie input, .saisie select { flex: 1; min-width: 0; background: none; border: 0; padding: 5px 8px; font-family: var(--police-chiffres); font-size: calc(var(--t-m) * var(--chiffres-echelle)); outline: none; }
.saisie select { font-family: var(--police); font-size: var(--t-s); appearance: none; cursor: pointer; }
.saisie input:disabled { color: var(--texte-3); cursor: not-allowed; }
.saisie:has(input:disabled) { background: var(--panneau); border-style: dashed; }
.suffixe { flex: none; display: flex; align-items: center; padding: 0 8px; font-size: var(--t-xs); color: var(--texte-3); background: none; border: 0; border-left: 1px solid var(--bord); font-family: var(--police-chiffres); }
button.suffixe:hover { color: var(--texte); }
.case { display: flex; align-items: center; gap: 6px; font-size: var(--t-s); color: var(--texte-2); cursor: pointer; user-select: none; }
.case input { accent-color: var(--accent); margin: 0; }
input[type="range"] { accent-color: var(--accent); width: 100%; margin: 4px 0 0; }

/* interrupteur (réglages) */
.interrupteur { display: flex; align-items: center; gap: 6px; font-size: var(--t-s); color: var(--texte-2); cursor: pointer; user-select: none; }
.interrupteur input { appearance: none; flex: none; width: 26px; height: 14px; border-radius: 7px; background: var(--panneau-3); position: relative; margin: 0; cursor: pointer; transition: background var(--vitesse); }
.interrupteur input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--texte-2); transition: transform var(--vitesse); }
.interrupteur input:checked { background: var(--accent); }
.interrupteur input:checked::after { transform: translateX(12px); background: var(--accent-texte); }
.interrupteur input:checked + span { color: var(--texte); }

/* ---------- listes libellé / valeur (portefeuille, reçu) ---------- */
.liste { margin: 0; display: grid; gap: 0; }
.liste > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--bord); min-width: 0; }
.liste > div:last-child { border-bottom: 0; }
.liste dt { color: var(--texte-3); font-size: var(--t-s); white-space: nowrap; }
.liste dd { margin: 0; text-align: right; font-family: var(--police-chiffres); font-size: calc(var(--t-m) * var(--chiffres-echelle)); min-width: 0; overflow-wrap: anywhere; }
.liste dd.fort { font-weight: 600; color: var(--texte); }
.liste .unite { color: var(--texte-3); font-size: var(--t-xs); margin-left: 3px; }
.liste-titre { margin: 10px 0 2px; font-size: var(--t-xs); color: var(--texte-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.liste-titre:first-child { margin-top: 0; }

/* ---------- jauges ---------- */
.barre { position: relative; height: 5px; background: var(--panneau-3); border-radius: 3px; overflow: hidden; }
.barre i { display: block; height: 100%; width: 0; background: var(--achat); border-radius: 3px; transition: width var(--vitesse) linear; }

/* ---------- tableaux denses ---------- */
.tab { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
.tab th { position: sticky; top: 0; z-index: 1; background: var(--panneau); font-weight: 500; color: var(--texte-3); font-size: var(--t-xs); text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--bord); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.tab th.n, .tab td.n { text-align: right; }
.tab td { padding: 0 8px; height: var(--h-ligne); border-bottom: 1px solid var(--bord); white-space: nowrap; font-family: var(--police-chiffres); font-size: calc(var(--t-s) * var(--chiffres-echelle)); }
.tab td:first-child { font-family: var(--police); font-size: var(--t-s); font-weight: 600; }
.tab tbody tr:hover td { background: var(--panneau-2); }
.vide { color: var(--texte-3); font-size: var(--t-s); padding: 14px 10px; margin: 0; font-family: var(--police); font-weight: 400; }
td.vide { text-align: left; }

/* pastilles d'état */
.pastille { display: inline-flex; align-items: center; gap: 5px; font-size: var(--t-xs); padding: 2px 7px; border-radius: 10px; background: var(--panneau-3); color: var(--texte-2); white-space: nowrap; }
.pastille::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pastille.ok { background: var(--achat-voile); color: var(--achat); }
.pastille.ko { background: var(--vente-voile); color: var(--vente); }
.pastille.attente { background: var(--accent-voile); color: var(--accent); }

/* onglets d'en-tête de panneau */
.onglets { display: flex; align-items: stretch; gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.onglets::-webkit-scrollbar { display: none; }
.onglets [role="tab"] { flex: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 0 9px; color: var(--texte-3); font-size: var(--t-s); font-weight: 500; white-space: nowrap; }
.onglets [role="tab"]:hover { color: var(--texte); }
.onglets [role="tab"][aria-selected="true"] { color: var(--texte); border-bottom-color: var(--accent); }
.cpt { font-family: var(--police-chiffres); font-size: var(--t-xs); color: var(--texte-3); margin-left: 3px; }

/* ---------- panneaux (widgets) ---------- */
.pn-grille { min-height: 100%; }
.pn { min-width: 0; }
.pn-cadre { display: flex; flex-direction: column; background: var(--panneau); border: 1px solid var(--bord); border-radius: var(--r-2); overflow: hidden; }
.pn-tete {
  flex: none; display: flex; align-items: stretch; gap: 6px; height: var(--h-tete-pn); padding: 0 2px 0 10px;
  border-bottom: 1px solid var(--bord); min-width: 0; user-select: none;
}
.pn-titre { align-self: center; margin: 0; font-size: var(--t-s); font-weight: 600; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-tete .onglets { margin-left: -9px; flex: 1 1 auto; }
.pn-tete .pn-plus { align-self: center; display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.pn-tete .sous { align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-outils { flex: none; display: flex; align-items: center; gap: 0; margin-left: auto; padding-left: 4px; }
.pn-plus + .pn-outils { margin-left: 0; }
.pn-b { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r); background: none; color: var(--texte-3); }
.pn-b svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pn-b:hover { color: var(--texte); background: var(--panneau-3); }
.pn-b[data-pn-action="fermer"]:hover { color: var(--vente); }
.pn-corps { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 10px; scrollbar-width: thin; scrollbar-color: var(--panneau-3) transparent; }
.pn-corps.nu { padding: 0; }
.pn-replie .pn-corps { display: none; }
.pn-replie .pn-tete { border-bottom: 0; }
.pn-ferme { display: none !important; }

/* bureau : glisser par la barre, poignées sur les bords */
[data-mode="bureau"] .pn-grille:not(.grid-stack-static) .pn-tete { cursor: grab; }
[data-mode="bureau"] .pn-grille .ui-draggable-dragging .pn-tete { cursor: grabbing; }
.pn-grille > .grid-stack-item > .pn-cadre { inset: var(--gs-item-margin-top) var(--gs-item-margin-right) var(--gs-item-margin-bottom) var(--gs-item-margin-left); }
.pn-grille .ui-draggable-dragging > .pn-cadre, .pn-grille .ui-resizable-resizing > .pn-cadre { border-color: var(--bord-fort); box-shadow: var(--ombre); }
.pn-grille .grid-stack-placeholder > .placeholder-content { background: var(--accent-voile); border: 1px dashed var(--accent); border-radius: var(--r-2); }
.pn-grille .ui-resizable-handle { opacity: 0; transition: opacity var(--vitesse); }
.pn-grille .grid-stack-item:hover > .ui-resizable-handle, .pn-grille .ui-resizable-resizing > .ui-resizable-handle { opacity: 1; }
.pn-grille .ui-resizable-se { background: none; width: 12px; height: 12px; right: 2px; bottom: 2px; transform: none; border-right: 2px solid var(--texte-3); border-bottom: 2px solid var(--texte-3); border-radius: 0 0 3px 0; }
.pn-grille .ui-resizable-sw { background: none; }

/* agrandi : le panneau couvre l'espace de travail, Échap rétablit */
.pn.pn-max { position: fixed !important; z-index: 40; top: var(--pn-haut, 48px) !important; left: 6px !important; right: 6px !important; bottom: var(--pn-bas, 6px) !important; width: auto !important; height: auto !important; transform: none !important; }
.pn.pn-max > .pn-cadre { position: absolute; inset: 0; box-shadow: var(--ombre); }
.pn.pn-max .pn-corps { display: block; }
.pn.pn-max .pn-corps.nu, .pn.pn-max .pn-corps.colonne { display: flex; }
body.pn-un-max .pn-grille > .pn:not(.pn-max) { visibility: hidden; }
.pn.pn-max > .ui-resizable-handle { display: none !important; }

/* tablette : deux colonnes dans l'ordre de la disposition, sans glisser */
[data-mode="tablette"] .pn-grille { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 6px; height: auto !important; min-height: 0; padding: 6px; }
[data-mode="tablette"] .pn-grille > .pn { position: relative !important; inset: auto !important; top: auto !important; left: auto !important; width: auto !important; height: var(--pn-h-tab, 340px) !important; order: var(--pn-ordre, 0); }
[data-mode="tablette"] .pn-grille > .pn.pn-large { grid-column: 1 / -1; }
[data-mode="tablette"] .pn-grille > .pn > .pn-cadre { position: absolute; inset: 0; }
[data-mode="tablette"] .pn-grille > .pn.pn-replie { height: auto !important; }
[data-mode="tablette"] .pn-grille > .pn.pn-replie > .pn-cadre { position: relative; }
[data-mode="tablette"] .pn-grille .ui-resizable-handle, [data-mode="mobile"] .pn-grille .ui-resizable-handle { display: none !important; }

/* mobile : panneaux empilés à hauteur naturelle ; pas de fermeture ni d'agrandissement */
[data-mode="mobile"] .pn-grille { display: flex !important; flex-direction: column; gap: 6px; height: auto !important; min-height: 0; padding: 6px; }
[data-mode="mobile"] .pn-grille > .pn, [data-mode="mobile"] .pn-grille > .pn.pn-ferme { display: block !important; position: relative !important; inset: auto !important; top: auto !important; left: auto !important; width: auto !important; height: auto !important; order: var(--pn-ordre, 0); }
[data-mode="mobile"] .pn-grille > .pn > .pn-cadre { position: relative; inset: auto; }
[data-mode="mobile"] .pn-grille > .pn[style*="--pn-h-mob"] > .pn-cadre { height: var(--pn-h-mob); }
[data-mode="mobile"] .pn-corps { overflow: visible; }
[data-mode="mobile"] .pn-corps.defile { overflow: auto; }
[data-mode="mobile"] [data-pn-action="fermer"], [data-mode="mobile"] [data-pn-action="agrandir"] { display: none; }

/* menu « Disposition » */
.pn-menu, .menu-ctx {
  position: fixed; z-index: 70; min-width: 230px; max-height: calc(100dvh - 16px); overflow: auto;
  background: var(--panneau-2); border: 1px solid var(--bord-fort); border-radius: var(--r-2); padding: 4px; box-shadow: var(--ombre);
}
.pn-menu-t { margin: 6px 8px 3px; font-size: var(--t-xs); color: var(--texte-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pn-menu button, .menu-ctx button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  padding: 6px 8px; border-radius: var(--r); font-size: var(--t-s); color: var(--texte);
}
.pn-menu button:hover:not(:disabled), .pn-menu button:focus-visible, .menu-ctx button:hover, .menu-ctx button:focus-visible { background: var(--panneau-3); outline: none; }
.pn-menu button:disabled { color: var(--texte-3); cursor: default; }
.pn-coche, .pn-case { flex: none; width: 12px; height: 12px; display: grid; place-items: center; }
.pn-case { border: 1px solid var(--bord-fort); border-radius: 2px; }
[aria-checked="true"] > .pn-case { background: var(--accent); border-color: var(--accent); }
[aria-checked="true"] > .pn-case::after { content: ""; width: 6px; height: 3px; border: solid var(--accent-texte); border-width: 0 0 1.5px 1.5px; transform: translateY(-1px) rotate(-45deg); }
[aria-checked="true"] > .pn-coche::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pn-menu hr { border: 0; border-top: 1px solid var(--bord); margin: 4px 0; }
.pn-menu-aide { margin: 4px 8px 6px; max-width: 240px; font-size: var(--t-xs); color: var(--texte-3); }
.btn-dispo { gap: 6px; }
.btn-dispo svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.btn-dispo b { font-weight: 500; }

/* ---------- notifications ---------- */
.toasts { position: fixed; right: 12px; bottom: 12px; z-index: 75; display: flex; flex-direction: column-reverse; gap: 4px; width: min(320px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: none; background: var(--panneau-2); border: 1px solid var(--bord-fort); border-left: 3px solid var(--texte-3); border-radius: var(--r); padding: 5px 9px; font-size: var(--t-s); line-height: 1.35; box-shadow: var(--ombre); animation: toast-entree 160ms ease-out; }
.toast.ok { border-left-color: var(--achat); } .toast.erreur { border-left-color: var(--vente); } .toast.alerte { border-left-color: var(--alerte); } .toast.info { border-left-color: var(--info); }
.toast small { display: block; color: var(--texte-3); font: var(--t-xs) var(--police-chiffres); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes toast-entree { from { opacity: 0; transform: translateY(6px); } }

/* fenêtres */
.fenetre { background: var(--panneau); color: var(--texte); border: 1px solid var(--bord-fort); border-radius: var(--r-2); padding: 20px; width: min(440px, calc(100% - 24px)); box-shadow: var(--ombre); }
.fenetre::backdrop { background: rgba(6, 7, 8, .72); }
.fenetre h2 { font-size: var(--t-xl); margin: 0 0 8px; }
.fenetre p { color: var(--texte-2); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 760px) {
  .saisie input, .saisie select { font-size: 16px; padding: 8px; } /* 16 px : pas de zoom iOS */
  .btn, .seg button { min-height: 34px; }
  .btn-plein { min-height: 44px; }
  .toasts { left: 8px; right: 8px; width: auto; bottom: calc(62px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
