/* Coinofut — terminal dérivés. Jetons de couleur : clair par défaut, sombre selon l'OS ou le bouton de thème. */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: rgba(11, 11, 11, 0.1);
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #6b6a65;
  --grid: #e9e8e2;
  --axis: #c3c2b7;
  --up: #13875f;
  --down: #d03b3b;
  --oi: #c2527f;
  --cvd-spot: #4a3aa7;
  --cvd-perp: #9a6500;
  --liq-long: #eb6834;
  --liq-short: #2a78d6;
  --good: #08720a;
  --warning: #8a5a00;
  --critical: #b42a2a;
  --good-bg: rgba(12, 163, 12, 0.1);
  --warning-bg: rgba(250, 178, 25, 0.16);
  --critical-bg: rgba(208, 59, 59, 0.1);
  --focus: #2a78d6;
  /* ambre de la marque (logo) : plus foncé en clair pour garder ≥ 3:1 sur le fond */
  --brand: #a86d00;
  --radius: 14px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0b0b0c;
    --surface: #151516;
    --surface-2: #1e1e20;
    --border: rgba(255, 255, 255, 0.1);
    --ink-1: #f5f5f4;
    --ink-2: #c3c2b7;
    --ink-muted: #95938c;
    --grid: #232325;
    --axis: #3a3a37;
    --up: #199e70;
    --down: #e66767;
    --oi: #d55181;
    --cvd-spot: #9085e9;
    --cvd-perp: #c98500;
    --liq-long: #d95926;
    --liq-short: #3987e5;
    --good: #2fbf2f;
    --warning: #fab219;
    --critical: #ef6b6b;
    --good-bg: rgba(12, 163, 12, 0.14);
    --warning-bg: rgba(250, 178, 25, 0.12);
    --critical-bg: rgba(208, 59, 59, 0.16);
    --focus: #6da7ec;
    --brand: #c98500;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0b0b0c;
  --surface: #151516;
  --surface-2: #1e1e20;
  --border: rgba(255, 255, 255, 0.1);
  --ink-1: #f5f5f4;
  --ink-2: #c3c2b7;
  --ink-muted: #95938c;
  --grid: #232325;
  --axis: #3a3a37;
  --up: #199e70;
  --down: #e66767;
  --oi: #d55181;
  --cvd-spot: #9085e9;
  --cvd-perp: #c98500;
  --liq-long: #d95926;
  --liq-short: #3987e5;
  --good: #2fbf2f;
  --warning: #fab219;
  --critical: #ef6b6b;
  --good-bg: rgba(12, 163, 12, 0.14);
  --warning-bg: rgba(250, 178, 25, 0.12);
  --critical-bg: rgba(208, 59, 59, 0.16);
  --focus: #6da7ec;
  --brand: #c98500;
}

* {
  box-sizing: border-box;
}

/* l'attribut hidden doit primer sur les display des composants (.seg, .btn…) */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--ink-muted);
}

.wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
  margin: 0;
  white-space: nowrap;
}

/* ---------- Logo (SVG en ligne : « Coin », anneau traversé par la ligne montante, « Fut ») ---------- */
.logo-svg {
  display: block;
  flex: none;
  overflow: visible;
  /* fond sous le logo : le halo détache la ligne ambre de l'anneau */
  --logo-bg: var(--page);
}

.logo-svg path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-svg .lg-soft {
  stroke: var(--ink-2);
}

.logo-svg .lg-soft-fill {
  fill: var(--ink-2);
}

.logo-svg .lg-ink {
  stroke: var(--ink-1);
}

.logo-svg .lg-halo {
  stroke: var(--logo-bg);
}

.logo-svg .lg-line {
  stroke: var(--brand);
}

.logo {
  display: flex;
  align-items: center;
}

.logo .logo-full {
  height: 30px;
  width: auto;
  aspect-ratio: 120.6 / 32;
}

.logo .logo-mark {
  display: none;
  width: 30px;
  height: 30px;
}

/* ligne montante tracée une fois au chargement (longueur du tracé ≈ 30 unités) */
@media (prefers-reduced-motion: no-preference) {
  .logo .lg-line,
  .logo .lg-halo {
    stroke-dasharray: 31;
    stroke-dashoffset: 31;
    animation: logo-draw 900ms 150ms cubic-bezier(0.3, 0.7, 0.2, 1) forwards;
  }
  @keyframes logo-draw {
    to {
      stroke-dashoffset: 0;
    }
  }
}

.brand select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  /* largeur une fois les marchés chargés par le JavaScript (évite un décalage de l'en-tête) */
  min-width: 115px;
}

.quote {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.quote-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.price {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.quote-sub {
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

.chip.up {
  color: var(--good);
  background: var(--good-bg);
}

.chip.down {
  color: var(--critical);
  background: var(--critical-bg);
}

.status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.status[data-state='live'] .dot,
.status[data-state='ok'] .dot {
  background: var(--good);
}

.status[data-state='reconnecting'] .dot,
.status[data-state='connecting'] .dot,
.status[data-state='loading'] .dot,
.status[data-state='partial'] .dot,
.status[data-state='stale'] .dot {
  background: var(--warning);
}

.status[data-state='down'] .dot {
  background: var(--critical);
}

.status[data-state='demo'] .dot {
  background: var(--cvd-spot);
}

.status[hidden],
#liq-coverage[hidden],
.btn[hidden],
.card[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

/* bouton de langue FR / EN */
.seg.lang {
  padding: 2px;
}

.seg.lang .btn {
  min-height: 26px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}

.btn:hover {
  background: var(--surface-2);
}

.btn[aria-pressed='true'] {
  background: var(--ink-1);
  color: var(--surface);
  border-color: var(--ink-1);
}

.btn.icon {
  width: 32px;
  padding: 0;
}

.btn.primary {
  background: var(--ink-1);
  color: var(--surface);
  border-color: var(--ink-1);
}

/* ---------- Bannières ---------- */
.banner {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}

.banner[data-tone='warning'] {
  background: var(--warning-bg);
}

.banner[data-tone='critical'] {
  background: var(--critical-bg);
}

.banner[data-tone='demo'] {
  border-color: var(--cvd-spot);
}

.banner strong {
  font-weight: 650;
}

.banner .spacer {
  flex: 1;
}

/*
 * Réservation d'espace (Core Web Vitals, CLS) : l'en-tête et les contrôles sont remplis par le
 * JavaScript après le premier affichage (prix, statuts, boutons). Sans ces minimums, le prix et les
 * statuts s'élargissent à l'arrivée des données, les boutons passent à la ligne et toute la page
 * descend. Valeurs mesurées sur l'interface remplie (BTC, français et anglais).
 */
@media (min-width: 701px) {
  .quote {
    min-width: 430px;
  }
  .status-list {
    min-width: 387px;
    justify-content: flex-end;
  }
  /* indicateurs sur plusieurs colonnes : sous-titre et variation remplis tiennent souvent sur deux
     lignes ; hauteur de la carte remplie réservée (le contenu reste en haut, comme à l'état stable) */
  .kpi {
    min-height: 172px;
  }
}

@media (max-width: 700px) {
  /* mobile : prix et statuts sur leur propre ligne dès le premier affichage */
  .quote,
  .status-list {
    flex-basis: 100%;
  }
}

@media (max-width: 520px) {
  /* statuts remplis (« Futures : en direct »…, historique sur la page servie) : deux lignes */
  .status-list {
    min-height: 52px;
    align-content: flex-start;
  }
}

@media (max-width: 460px) {
  /* ligne « Mark · Index · Spot · Prime » remplie : deux lignes sur petit écran */
  .quote-sub {
    min-height: calc(2em * 1.45);
  }
}

/* boutons d'unité de temps et de fenêtre, seuil d'alerte : taille des contrôles remplis */
.seg:empty {
  min-height: 36px;
}

#tf-seg:empty {
  min-width: 220px;
}

#lb-seg:empty {
  min-width: 368px;
}

@media (max-width: 520px) {
  /* mobile : jamais plus large que l'écran (les boutons remplis passent sous le libellé) */
  #lb-seg:empty {
    min-width: min(368px, 100%);
  }
}

#liq-alert:empty {
  min-width: 88px;
}

/* ---------- Contrôles ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 14px 0;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.seg .btn {
  border: 0;
  min-height: 28px;
  padding: 2px 10px;
  background: transparent;
}

.seg .btn[aria-pressed='true'] {
  background: var(--ink-1);
  color: var(--surface);
}

.control-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-right: 6px;
}

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.card h2 {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 10px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.kpi .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.kpi .swatch {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--sw);
}

.kpi .value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi .sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.kpi .delta {
  font-size: 13px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.tone-up {
  color: var(--good);
}

.tone-down {
  color: var(--critical);
}

.tone-warn {
  color: var(--warning);
}

.tone-neutral {
  color: var(--ink-2);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* chaque carte garde sa hauteur : sans cela, la plus courte (le graphique, hauteur fixe) s'étire
     à celle de la plus longue (la lecture) et laisse un grand vide sous « Afficher le tableau » */
  align-items: start;
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 1100px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
  }
}

.lower-grid .main-grid {
  /* flux et funding : colonne unique qui suit la hauteur de la carte voisine (carte des liquidations) */
  align-items: stretch;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 900px) {
  .lower-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  }
}

/* ---------- Graphique ---------- */
.chart-box {
  position: relative;
  height: 600px;
  border-radius: 10px;
  overflow: hidden;
  touch-action: pan-y;
}

@media (max-width: 700px) {
  .chart-box {
    height: 520px;
  }
}

.chart-canvas {
  display: block;
  cursor: crosshair;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  min-width: 190px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.chart-tip .tip-title {
  font-weight: 650;
  margin-bottom: 4px;
}

.chart-tip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--ink-2);
}

.chart-tip .tip-row span:last-child {
  color: var(--ink-1);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--sw);
}

.legend .mark.line {
  height: 3px;
}

.legend .mark.dot {
  border-radius: 50%;
}

.legend .mark.hollow {
  background: transparent;
  border: 1.5px solid var(--sw);
}

.chart-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-2);
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

table.data th,
table.data td {
  padding: 5px 8px;
  text-align: right;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

table.data th {
  color: var(--ink-muted);
  font-weight: 600;
}

/* ---------- Lecture du marché ---------- */
.reading .regime {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  margin: 2px 0 6px;
}

.reading p {
  margin: 0 0 10px;
  color: var(--ink-2);
}

.pill-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.pill {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}

.pill .k {
  color: var(--ink-muted);
  white-space: nowrap;
}

.pill .v {
  text-align: right;
  font-weight: 600;
}

.notice {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--warning-bg);
  font-size: 13px;
  margin-bottom: 8px;
}

.notice .icon {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--warning);
}

.reading ul {
  margin: 6px 0 12px;
  padding-left: 18px;
  color: var(--ink-2);
}

.reading li {
  margin-bottom: 4px;
}

.quality {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  margin: 10px 0 4px;
  font-size: 13px;
}

.quality-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.quality-head .k {
  color: var(--ink-muted);
}

.quality .badge {
  font-weight: 700;
  font-size: 15px;
}

.quality-driver {
  margin-top: 4px;
  color: var(--ink-2);
}

.reading .quality ul {
  margin: 6px 0 0;
}

.horizons {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 10px 0 6px;
  font-size: 12px;
}

.horizons .k {
  color: var(--ink-muted);
}

.horizons .h {
  display: inline-flex;
  gap: 5px;
  min-width: 0;
}

.horizons .h.main {
  font-weight: 700;
}

.horizons .lb {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.reading .fact {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 6px 0 4px;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--ink-2);
  border-radius: 999px;
}

.small {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Note de méthode : repliée par défaut, même style que « Comment ce modèle est calculé » (details.assumptions) */
details.reading-method {
  margin-top: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--grid);
  font-size: 12px;
  color: var(--ink-2);
}

details.reading-method summary {
  cursor: pointer;
  color: var(--ink-2);
  /* cible d'au moins 24 px de haut (WCAG 2.5.8), y compris au doigt sur mobile */
  padding: 4px 0;
}

details.reading-method p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- Carte des liquidations ---------- */
.liqmap svg {
  display: block;
  width: 100%;
  height: auto;
}

.liqmap text {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.liqmap .lbl-strong {
  fill: var(--ink-1);
  font-weight: 650;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.clusters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

@media (max-width: 520px) {
  .clusters {
    grid-template-columns: 1fr;
  }
}

.clusters h3 {
  font-size: 12px;
  font-weight: 650;
  margin: 0 0 6px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.clusters ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clusters li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.clusters li:last-child {
  border-bottom: 0;
}

.clusters .fragile {
  color: var(--ink-muted);
  font-style: italic;
}

.liqmap-meta {
  margin: 6px 0 0;
  color: var(--ink-2);
}

details.assumptions {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-2);
}

details.assumptions summary {
  cursor: pointer;
  color: var(--ink-2);
}

details.assumptions ul {
  padding-left: 18px;
}

/* ---------- Flux de liquidations ---------- */
.liq-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.liq-stats .cell {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
}

.liq-stats .k {
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.liq-stats .v {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.liq-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.liq-list li {
  display: grid;
  grid-template-columns: 64px 74px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 2px;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.liq-list .side {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.liq-list .side::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sw);
}

.liq-list .px {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.liq-list .px .sym {
  font-weight: 650;
}

.liq-list li.cur .px .sym {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.liq-top {
  margin: 0 0 8px;
}

.liq-list .usd {
  text-align: right;
  font-weight: 650;
}

.liq-list li.big .usd {
  color: var(--ink-1);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.empty {
  padding: 18px 4px;
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------- Funding ---------- */
.funding-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.funding-chart text {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Données agrégées (toutes plateformes) ---------- */
.agg {
  margin-top: 12px;
}

.agg svg {
  display: block;
  width: 100%;
  height: auto;
}

.agg text {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.agg .lbl {
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.agg .hatch-line {
  stroke: var(--axis);
  stroke-width: 1;
}

.agg-credit a {
  color: var(--ink-2);
}

/* ---------- Glossaire & pied de page ---------- */
.glossary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.glossary-title {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.glossary h3 {
  font-size: 13px;
  margin: 0 0 6px;
}

.glossary p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* Cibles des ancres : sous la barre supérieure collante */
#price-chart,
#reading,
#liquidation-map,
#liqmap-method,
#liquidation-feed,
#funding-history,
#definitions {
  scroll-margin-top: 84px;
}

/* ---------- Pied de page ---------- */
.site-footer {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
}

.site-footer .logo-svg {
  --logo-bg: var(--surface);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: 28px 40px;
  padding-top: 32px;
  padding-bottom: 28px;
}

.footer-grid p {
  margin: 0 0 8px;
}

.footer-grid .footer-logo {
  margin-bottom: 12px;
}

.footer-logo .logo-full {
  height: 26px;
  width: auto;
  aspect-ratio: 120.6 / 32;
}

.footer-brand p:not(.footer-logo) {
  max-width: 42ch;
}

.footer-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-1);
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer li {
  margin: 0 0 8px;
}

.site-footer a {
  color: var(--ink-1);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink-1) 30%, transparent);
  text-underline-offset: 3px;
}

.site-footer a:hover {
  text-decoration-color: var(--brand);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  padding-bottom: 20px;
  font-size: 12px;
  color: var(--ink-muted);
}

.footer-bottom p {
  margin: 0;
}

@media (max-width: 1000px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

/* ---------- Notifications ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
  font-size: 13px;
}

.toast strong {
  display: block;
  margin-bottom: 2px;
}

.toast[data-tone='critical'] {
  border-left: 4px solid var(--critical);
}

.toast[data-tone='warning'] {
  border-left: 4px solid var(--warning);
}

.toast[data-tone='info'] {
  border-left: 4px solid var(--ink-2);
}

@media (max-width: 700px) {
  .topbar {
    position: static;
  }
  .price {
    font-size: 22px;
  }
  .status-list {
    margin-left: 0;
  }
}

/* Mobile : symbole seul dans l'en-tête */
@media (max-width: 520px) {
  .logo .logo-full {
    display: none;
  }
  .logo .logo-mark {
    display: block;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 180ms ease-out;
  }
  @keyframes toast-in {
    from {
      transform: translateY(8px);
      opacity: 0;
    }
  }
}

.clusters .mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--sw);
}

/* ---------- Diagnostic ---------- */
.diag-card {
  margin-top: 12px;
}

.diag-card summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.diag-card summary h2 {
  display: inline;
  margin: 0;
}

table.diag {
  margin: 12px 0;
}

table.diag caption {
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-2);
  padding-bottom: 4px;
}

table.diag th[scope='row'] {
  text-align: left;
  font-weight: 500;
  color: var(--ink-1);
}

table.diag tr.zero td {
  color: var(--critical);
}

table.diag td.url {
  white-space: normal;
  word-break: break-all;
  text-align: left;
  min-width: 200px;
}

#diag-body {
  overflow-x: auto;
}

.diag-verdict {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-1);
  font-size: 13px;
}

.diag-verdict[data-tone='warning'] {
  background: var(--warning-bg);
}

.diag-verdict[data-tone='critical'] {
  background: var(--critical-bg);
}

.diag-verdict[data-tone='good'] {
  background: var(--good-bg);
}

.diag-dump {
  max-height: 240px;
  overflow: auto;
  font-size: 11px;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Liquidations : choix de la bourse et comparaison (audit N6) */
.liq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.liq-compare-wrap {
  overflow-x: auto;
  margin-bottom: 8px;
}

table.liq-compare th,
table.liq-compare td {
  vertical-align: top;
  text-align: left;
  white-space: normal;
}

@media (max-width: 520px) {
  table.liq-compare th,
  table.liq-compare td {
    padding: 5px 4px;
  }
}

table.liq-compare caption {
  text-align: left;
  color: var(--ink-muted);
  font-size: 12px;
  padding-bottom: 4px;
}
