/* ============================================================================
 * Dashboard démo — feuille de style
 * Esthétique "salle de contrôle" : fond ardoise profond, lecture chiffrée
 * monospace mise en avant, une seule couleur d'accent (pilotée par config.js).
 * ========================================================================== */
:root {
  --bg: #0e141b;
  --panel: #161f2a;
  --panel-2: #1b2733;
  --line: #243140;
  --text: #e8eef5;
  --muted: #8a9bb0;
  --accent: #3ddc97; /* surchargé au runtime depuis config.js */
  --accent-soft: rgba(61, 220, 151, 0.14);
  --danger: #ff5d6c;
  --danger-soft: rgba(255, 93, 108, 0.12);
  --radius: 16px;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo,
    Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(
      1200px 600px at 70% -10%,
      rgba(61, 220, 151, 0.06),
      transparent 60%
    ),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.frame {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Barre du haut --------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  overflow: hidden;
  border: 1px solid var(--line);
  text-align: center;
  line-height: 1.05;
}
body.mode-teaser .brand__mark {
  width: 62px;
  color: #90a0ae;
  background: #202b35;
  font-size: 10px;
  padding: 6px;
}
.brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand__name {
  font-weight: 650;
  font-size: 18px;
  line-height: 1.1;
}
.brand__sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 3px;
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 13px;
  border-radius: 999px;
}
.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent;
}
.status__dot.live {
  background: var(--accent);
  animation: pulse 2s infinite;
}
.status__dot.down {
  background: var(--danger);
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* --- Grille principale ----------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 20px;
  flex: 1;
}
@media (max-width: 820px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

/* --- Lecture principale ---------------------------------------------------- */
.readout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.readout.is-alert {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger), 0 12px 40px -18px var(--danger);
}
.readout__label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.readout__value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: auto 0; /* centre verticalement le grand chiffre */
}
.readout__num {
  font-family: var(--mono);
  font-size: clamp(64px, 13vw, 116px);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.readout.is-alert .readout__num {
  color: var(--danger);
}
.readout__unit {
  font-family: var(--mono);
  font-size: clamp(22px, 4vw, 34px);
  color: var(--muted);
}

.readout__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 92px;
}
.chip__k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip__v {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
}
.alert[hidden] {
  display: none;
}
.alert__icon {
  font-size: 12px;
}

/* --- Graphe ---------------------------------------------------------------- */
.chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chart__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.chart__title {
  font-weight: 600;
  font-size: 15px;
}
.chart__hint {
  color: var(--muted);
  font-size: 12.5px;
  font-family: var(--mono);
}
#chart {
  width: 100%;
  flex: 1;
  min-height: 280px;
}

/* --- Pied ------------------------------------------------------------------ */
.footnote {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.rebrand {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 31, 42, 0.72);
  padding: 16px;
}
.rebrand[hidden] {
  display: none;
}
.rebrand__title {
  font-weight: 650;
}
.rebrand__hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 3px;
}
.rebrand__form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}
.rebrand label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rebrand input[type="text"] {
  width: min(240px, 60vw);
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 0 11px;
  font: inherit;
}
.rebrand input[type="color"] {
  width: 48px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 4px;
}
.rebrand button {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #071018;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
@media (max-width: 720px) {
  .rebrand {
    align-items: stretch;
    flex-direction: column;
  }
  .rebrand__form,
  .rebrand button {
    width: 100%;
  }
}
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
