:root {
  --sbi-brand: #1d4f91;

  /* Graphiques : palette catégorielle validée (ordre fixe, jamais recyclée). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --chart-muted: #898781;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
}

/* Mode sombre : mêmes teintes, pas ajustés pour le fond sombre des cartes (#262626),
   palette validée (contraste ≥ 3:1, séparation daltonisme). */
[data-bs-theme="dark"] {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --chart-muted: #9a9890;
  --chart-grid: #363636;
  --chart-axis: #4a4a48;
}

[data-bs-theme="dark"] .brand-mark {
  background: #2f6fc0;
}

/* --- Jauges d'occupation (mémoire, disques) --- */
.gauge + .gauge {
  margin-top: 0.875rem;
}

.gauge-label {
  font-weight: 600;
}

.gauge-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gauge-track {
  position: relative;
  height: 0.5rem;
  margin-top: 0.25rem;
  border-radius: 4px;
  background: var(--tblr-bg-surface-secondary, #eef0f3);
}

.gauge-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 4px;
  transition: width 0.3s;
}

/* Repère de seuil : trait vertical qui dépasse légèrement de la piste. */
.gauge-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  box-shadow: 0 0 0 1px var(--tblr-bg-surface, #fff);
}

.gauge-mark-warning {
  background: var(--status-warning);
}

.gauge-mark-critical {
  background: var(--status-critical);
}

.gauge-detail {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--tblr-secondary, #667382);
  font-variant-numeric: tabular-nums;
}

/* --- Résumé des ressources (cartes serveur) et vue liste --- */
.res-summary {
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.4rem;
  font-size: 0.8125rem;
}

.res-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tblr-secondary);
}

.res-label.text-danger,
.res-label.text-warning {
  font-weight: 600;
}

.res-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.mini-bar {
  display: inline-block;
  vertical-align: middle;
  width: 100%;
  min-width: 3rem;
  height: 0.375rem;
  border-radius: 3px;
  overflow: hidden;
  background: var(--tblr-bg-surface-secondary, #eef0f3);
}

.servers-table .mini-bar {
  width: 5rem;
}

.mini-bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 3px;
}

/* --- Rapports : contenu en styles intégrés (partagé avec l'email), lisible en sombre --- */
[data-bs-theme="dark"] .report-card {
  background: #fff;
  color: #0b0b0b;
}

@media print {
  .navbar,
  .page-header .btn-list {
    display: none !important;
  }

  .report-card {
    border: 0;
    box-shadow: none;
  }
}

/* --- 2FA --- */
.totp-qr {
  background: #fff;
  padding: 8px;
  border-radius: 6px;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 0.35rem 2rem;
  font-size: 1.05rem;
}

/* --- Historique (uPlot) --- */
#charts.is-loading {
  opacity: 0.5;
  transition: opacity 0.15s;
}

.chart-plot {
  width: 100%;
  min-height: 200px;
}

.chart-plot .uplot {
  font-family: inherit;
}

.chart-plot .u-legend {
  font-size: 0.75rem;
  text-align: left;
  margin-top: 0.25rem;
}

/* Le texte reste en encre de texte ; seule la clé porte la couleur de la série. */
.chart-plot .u-legend .u-series th,
.chart-plot .u-legend .u-label {
  font-weight: normal;
  color: var(--tblr-secondary, #52514e) !important;
}

.chart-plot .u-legend .u-series td {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Légende : cliquable seulement s'il y a plusieurs courbes ; la ligne "Date" ne l'est jamais. */
.chart-plot:not(.chart-toggle) .u-legend .u-series,
.chart-plot .u-legend .u-series:first-child {
  pointer-events: none;
}

.chart-toggle .u-legend .u-series:not(:first-child) {
  cursor: pointer;
}

.chart-toggle .u-legend .u-series.u-off {
  opacity: 0.4;
}

.chart-plot .u-inline.u-live th::after {
  content: "";
}

.chart-plot .u-legend .u-series td {
  padding-left: 0.4em;
}

/* Clé de légende en trait (comme la marque), pas en carré. */
.chart-plot .u-legend .u-marker {
  width: 0.9em;
  height: 0 !important;
  border-left-width: 0 !important;
  border-right-width: 0 !important;
  border-bottom-width: 0 !important;
  background: none !important;
  margin-right: 0.35em;
  vertical-align: middle;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--sbi-brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brand-mark-lg {
  font-size: 1.5rem;
  padding: 0.3rem 0.8rem;
}

.ping-body-preview {
  max-width: 22rem;
}

.ping-body {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  font-size: 0.8rem;
}

/* Fiche serveur à onglets : les cartes réutilisées (mt-3 ailleurs) ne décalent pas le haut de l'onglet. */
.server-tabs .tab-pane > .card.mt-3:first-child,
.server-tabs .tab-pane > .row > [class*="col"] > .card.mt-3:first-child {
  margin-top: 0 !important;
}
.nav-tabs .nav-link .badge { vertical-align: text-top; }

/* Fiche serveur : en-tête, cartes de synthèse, barre d'onglets, statistiques des graphiques. */
.server-meta span + span::before {
  content: "·";
  margin: 0 0.5rem;
}
.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--tblr-border-radius);
  background: var(--tblr-primary-lt);
  color: var(--tblr-primary);
}
.kpi-label { font-weight: 500; }
.kpi-value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi-max { font-weight: 600; font-variant-numeric: tabular-nums; }
.server-tabbar { border-bottom: var(--tblr-border-width) solid var(--tblr-border-color); }
.server-tabbar .nav-tabs { margin-bottom: -1px; }
.chart-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: var(--tblr-border-width) solid var(--tblr-border-color);
}
.chart-stat-label {
  font-size: 0.75rem;
  color: var(--tblr-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-stat-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spark svg { display: block; }
.disk-pct { min-width: 2.75rem; text-align: right; font-variant-numeric: tabular-nums; }
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.quick-actions .btn { width: 100%; }
.info-grid { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.quick-actions .btn { --tblr-btn-padding-x: 0.5rem; }
.quick-actions-wide { grid-column: 1 / -1; }

/* Graphiques style RRDtool (menu utilisateur → Graphiques) : l'image rrdgraph d'origine,
   fond BACK gris, relief SHADEA / SHADEB, titre centré, légende façon GPRINT.
   Volontairement identique en thème sombre (les PNG RRDtool sont clairs). */
:root[data-chart-style="rrd"] [data-charts] .card {
  --rrd-mono: "DejaVu Sans Mono", Consolas, "Courier New", monospace;
  background: #f0f0f0;
  color: #000;
  border: 2px solid;
  border-color: #cbcbcb #999 #999 #cbcbcb;
  border-radius: 0;
  box-shadow: none;
}
:root[data-chart-style="rrd"] [data-charts] .card-body { padding: 0.5rem 0.5rem 0.75rem; }
:root[data-chart-style="rrd"] [data-charts] .card-title {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #000;
  margin-bottom: 0.25rem !important;
}
:root[data-chart-style="rrd"] [data-charts] .chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.875rem;
  border-top: 0;
  padding: 0.375rem 0 0 1.25rem;
  position: relative;
  font-family: var(--rrd-mono);
  font-size: 0.6875rem;
}
:root[data-chart-style="rrd"] [data-charts] .chart-stats::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.55rem;
  width: 0.625rem;
  height: 0.625rem;
  background: #00cc00;
  border: 1px solid #000;
}
:root[data-chart-style="rrd"] [data-charts] .chart-stats > div { display: flex; gap: 0.25rem; }
:root[data-chart-style="rrd"] [data-charts] .chart-stat-label,
:root[data-chart-style="rrd"] [data-charts] .chart-stat-value {
  font-size: inherit;
  font-weight: normal;
  color: #000;
}
:root[data-chart-style="rrd"] [data-charts] .chart-stat-label::after { content: ":"; }
:root[data-chart-style="rrd"] .chart-plot .u-legend {
  font-family: "DejaVu Sans Mono", Consolas, "Courier New", monospace;
  font-size: 0.6875rem;
}
:root[data-chart-style="rrd"] .chart-plot .u-legend .u-series th,
:root[data-chart-style="rrd"] .chart-plot .u-legend .u-label,
:root[data-chart-style="rrd"] .chart-plot .u-legend .u-value { color: #000 !important; }
:root[data-chart-style="rrd"] .chart-plot .u-legend .u-marker { border-radius: 0; }
.kpi-spark { height: 28px; }
.kpi-spark svg { display: block; height: 28px; }
