/* =====================================================================
   GridBot Dashboard — charte « Précision Suisse »
   Maquette validée par Marco : ne pas dériver sans son accord.

   fond #F7F6F2 · panneaux #FFFFFF bordures #E3E0D8 · texte #1A1A1A
   accent rouge #D22B2B · vert #2E7D4F · ambre #B8860B · muted #8A877E
   Inter pour les titres (800 pour le logo), IBM Plex Mono pour TOUS les
   chiffres — c'est ce qui donne l'alignement des colonnes.
   ===================================================================== */

:root {
    --fond: #F7F6F2;
    --panneau: #FFFFFF;
    --bordure: #E3E0D8;
    --texte: #1A1A1A;
    --rouge: #D22B2B;
    --vert: #2E7D4F;
    --ambre: #B8860B;
    --muted: #8A877E;

    --trait-fort: 3px;
    --trait-titre: 2px;
    --rayon: 2px;   /* quasi nul : la charte est anguleuse, pas arrondie */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Tous les chiffres en mono, sans exception : c'est la règle qui fait tenir
   l'alignement des tableaux et la lisibilité des montants. */
.num, table td, table th, .metrique-valeur, .mono {
    font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    font-variant-numeric: tabular-nums;
}

a { color: var(--texte); }

/* ---------------------------------------------------------------- bannière */
.bandeau-testnet {
    background: #000;
    color: #FFF;
    text-align: center;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
}

/* ------------------------------------------------------------------ entête */
.entete {
    background: var(--panneau);
    border-bottom: var(--trait-fort) solid #000;
    padding: 20px 24px 18px;
}

.entete-grille {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 32px;
}

.logo {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1;
}

.entete-solde { display: flex; flex-direction: column; }
.entete-solde .valeur { font-size: 34px; font-weight: 700; line-height: 1.05; }
.entete-solde .sous { font-size: 13px; color: var(--muted); margin-top: 2px; }

.entete-bloc { display: flex; flex-direction: column; gap: 2px; }
.entete-bloc .etiquette {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
.entete-bloc .contenu { font-size: 16px; font-weight: 600; }

.entete-fin { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.lien-discret {
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--bordure);
    padding-bottom: 1px;
}
.lien-discret:hover { color: var(--texte); border-bottom-color: var(--texte); }

/* ------------------------------------------------------- indicateur LIVE */
.live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    color: var(--muted);
    border: 1px solid var(--bordure);
    padding: 4px 9px;
}
.live-point {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    flex: 0 0 7px;
}
.live.connecte { color: var(--vert); border-color: rgba(46, 125, 79, .35); }
.live.connecte .live-point {
    background: var(--vert);
    animation: pouls 2s ease-in-out infinite;
}
@keyframes pouls {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: .35; transform: scale(.82); }
}
/* Un utilisateur qui a demandé « moins d'animations » ne doit pas subir un
   point qui clignote en permanence dans son champ de vision. */
@media (prefers-reduced-motion: reduce) {
    .live.connecte .live-point { animation: none; }
}

/* Transition douce sur les valeurs mises à jour en direct : un chiffre qui
   change brutalement se remarque moins qu'un chiffre qui s'estompe une
   demi-seconde. La charte est sobre, l'animation aussi. */
.maj {
    transition: color .45s ease, background-color .45s ease;
}
.maj-flash { background: rgba(26, 26, 26, .06); }

.pastille { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.pastille::before {
    content: '●';
    font-size: 13px;
}
.pastille.marche::before { color: var(--vert); }
.pastille.arret::before  { color: var(--rouge); }
.pastille.inconnu::before { color: var(--muted); }

/* ------------------------------------------------------------------ pages */
.page { max-width: 1400px; margin: 0 auto; padding: 24px; }

section { margin-bottom: 34px; }

h2 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin: 0 0 14px;
    padding-bottom: 7px;
    border-bottom: var(--trait-titre) solid #000;
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
h2 .h2-note {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
    margin-left: auto;
}

.panneau {
    background: var(--panneau);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 18px;
}

.grille-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.metrique { background: var(--panneau); border: 1px solid var(--bordure); padding: 14px 16px; }
.metrique-etiquette {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.metrique-valeur { font-size: 23px; font-weight: 600; line-height: 1.15; }
.metrique-sous { font-size: 12px; color: var(--muted); margin-top: 3px; }

.pos { color: var(--vert); }
.neg { color: var(--rouge); }
.avert { color: var(--ambre); }
.muted { color: var(--muted); }

/* ------------------------------------------------------------- sélecteurs */
.selecteur { display: inline-flex; border: 1px solid var(--bordure); background: var(--panneau); }
.selecteur button {
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-right: 1px solid var(--bordure);
}
.selecteur button:last-child { border-right: none; }
.selecteur button.actif { background: #000; color: #FFF; }

/* --------------------------------------------------------------- graphiques */
.graphe { position: relative; width: 100%; }
.graphe.grand  { height: 380px; }
.graphe.moyen  { height: 240px; }
.graphe.petit  { height: 190px; }

@media (max-width: 720px) {
    .graphe.grand { height: 260px; }
    .graphe.moyen { height: 200px; }
}

/* ---------------------------------------------------------------- heatmap */
.heatmap { display: grid; grid-template-columns: 74px repeat(24, 1fr); gap: 2px; min-width: 640px; }
.heatmap .hm-coin, .heatmap .hm-heure, .heatmap .hm-jour {
    font-size: 9.5px;
    color: var(--muted);
    font-weight: 600;
    display: flex;
    align-items: center;
}
.heatmap .hm-heure { justify-content: center; }
.heatmap .hm-case {
    aspect-ratio: 1 / 1;
    border: 1px solid var(--bordure);
    min-height: 15px;
}
.defilement-x { overflow-x: auto; }

/* --------------------------------------------------------------- la grille */
.echelle-grille { position: relative; border-left: 2px solid #000; padding-left: 16px; }
.niveau {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    padding: 2px 0;
    position: relative;
}
.niveau .puce { width: 9px; height: 9px; flex: 0 0 9px; }
.niveau .puce.buy  { background: var(--vert); }
.niveau .puce.sell { background: var(--rouge); }
.niveau.prix-courant { font-weight: 700; }
.niveau.prix-courant::before {
    content: '';
    position: absolute;
    left: -18px;
    right: 0;
    height: 2px;
    background: #000;
    top: 50%;
}
.barre-usage { height: 8px; background: var(--bordure); }
.barre-usage span { display: block; height: 100%; background: var(--texte); }

/* --------------------------------------------------------------- tableaux */
/* Hauteur bornée avec défilement interne : sans elle, 400 lignes de cycles
   font un mur de plusieurs écrans qui repousse les sections suivantes hors de
   portée. L'en-tête reste collé en haut pendant le défilement. */
.tableau-enveloppe {
    overflow: auto;
    max-height: 460px;
    border: 1px solid var(--bordure);
    background: var(--panneau);
}
.tableau-enveloppe thead th {
    position: sticky;
    top: 0;
    background: var(--panneau);
    z-index: 1;
}
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
thead th {
    text-align: right;
    padding: 9px 12px;
    border-bottom: 2px solid #000;
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    font-family: 'Inter', sans-serif;
}
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.tri-asc::after  { content: ' ▲'; }
thead th.tri-desc::after { content: ' ▼'; }
tbody td { text-align: right; padding: 7px 12px; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: #FCFBF9; }

/* Lignes regroupées : un ordre rempli en plusieurs morceaux tient sur une
   ligne, dépliable. Le chevron indique qu'il y a quelque chose dessous. */
tbody tr.groupe { cursor: pointer; }
tbody tr.groupe:hover { background: #F4F2ED; }
tbody tr.groupe td:first-child::before {
    content: '▸';
    display: inline-block;
    width: 12px;
    color: var(--muted);
    transition: transform .15s ease;
}
tbody tr.groupe.ouvert td:first-child::before { transform: rotate(90deg); }
tbody tr.detail { background: #F7F6F2 !important; font-size: 11.5px; color: var(--muted); }
tbody tr.detail td:first-child { padding-left: 30px; }
.compteur-morceaux {
    font-size: 10px;
    color: var(--muted);
    border: 1px solid var(--bordure);
    padding: 0 5px;
    margin-left: 6px;
    font-family: 'Inter', sans-serif;
}

/* ------------------------------------------------------------------- VIP */
.barre-progression { height: 12px; background: var(--bordure); border: 1px solid var(--bordure); }
.barre-progression span { display: block; height: 100%; background: #000; }

/* ------------------------------------------------------------------ login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-carte {
    background: var(--panneau);
    border: 1px solid var(--bordure);
    border-top: var(--trait-fort) solid #000;
    padding: 34px;
    width: 100%;
    max-width: 380px;
}
.login-carte .logo { margin-bottom: 4px; }
.login-carte label {
    display: block;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    margin: 18px 0 5px;
}
.login-carte input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--bordure);
    background: var(--fond);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: var(--texte);
}
.login-carte input:focus { outline: 2px solid #000; outline-offset: -2px; }
.login-carte button {
    width: 100%;
    margin-top: 22px;
    padding: 12px;
    background: #000;
    color: #FFF;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    cursor: pointer;
}
.erreur {
    margin-top: 16px;
    padding: 9px 12px;
    border-left: var(--trait-fort) solid var(--rouge);
    background: #FDF3F3;
    font-size: 13px;
}

/* -------------------------------------------------------------- pied/note */
.note {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 10px;
    line-height: 1.55;
}
.pied {
    border-top: 1px solid var(--bordure);
    margin-top: 40px;
    padding: 18px 0 40px;
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.pied form { display: inline; }
.pied button {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    background: none;
    border: 1px solid var(--bordure);
    padding: 5px 12px;
    cursor: pointer;
    color: var(--muted);
}

@media (max-width: 720px) {
    .page { padding: 16px; }
    .entete { padding: 16px; }
    .entete-grille { gap: 18px; }
    .entete-solde .valeur { font-size: 27px; }
    .entete-fin { margin-left: 0; width: 100%; }
    section { margin-bottom: 26px; }
}
