/* Banc de test Organova — pensé pour une tablette en paysage, doigts compris. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --line: #2a3440;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --ok: #22c55e;
  --ok-dim: #15803d;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar h1 span { color: var(--muted); font-weight: 400; }

.topbar__meta { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge--muted { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.badge--ok    { background: rgba(34, 197, 94, 0.15);  color: #6ee7a0; border-color: rgba(34, 197, 94, 0.35); }
.badge--warn  { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.35); }
.badge--err   { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }

/* ----------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.step {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

/* ----------------------------------------------------------- flash: carte */

.firmware {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.firmware__title { font-weight: 600; font-size: 15px; }

.firmware__meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.row .btn { flex: 1 1 0; }

/* --------------------------------------------------------------- boutons */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:hover:not(:disabled) { border-color: #3d4c5c; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) { background: #2f74e6; border-color: #2f74e6; }

.btn--xl { width: 100%; padding: 18px; font-size: 17px; border-radius: 12px; }
.btn--sm { padding: 7px 11px; font-size: 13px; }
.btn--ghost { background: transparent; }

.select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  max-width: 260px;
}

/* ------------------------------------------------------------ progression */

.progress { margin-top: 14px; }

.progress__bar {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}

.progress__fill.is-done { background: var(--ok); }

.progress__label {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- options */

.advanced { margin-top: 14px; }

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
  user-select: none;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}

.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

.log {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  background: #0a0e14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: 11.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9fb3c8;
  white-space: pre-wrap;
  word-break: break-word;
}

.log .l-err { color: #fca5a5; }
.log .l-ok  { color: #6ee7a0; }

/* ------------------------------------------------------------- test: grid */

.scoreline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.score { font-size: 15px; color: var(--muted); }
.score strong { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }

.lastevent {
  color: var(--muted);
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

.board {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.board__count { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.board__pads {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pad {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #11161d;
  transition: background 0.05s, border-color 0.05s, transform 0.05s;
}

.pad__cap { font-size: 22px; font-weight: 700; line-height: 1; }
.pad__note { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.pad.is-ok {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.4);
}

.pad.is-ok .pad__cap { color: #6ee7a0; }

.pad.is-active {
  background: var(--ok);
  border-color: #4ade80;
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.pad.is-active .pad__cap,
.pad.is-active .pad__note { color: #04140a; }

.pad.is-na { opacity: 0.32; background: repeating-linear-gradient(45deg, #11161d, #11161d 5px, #161d26 5px, #161d26 10px); }

/* --------------------------------------------------------------- légende */

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid var(--line);
}

.dot--idle   { background: #11161d; }
.dot--active { background: var(--ok); border-color: #4ade80; }
.dot--ok     { background: rgba(34, 197, 94, 0.3); }
.dot--na     { background: repeating-linear-gradient(45deg, #11161d, #11161d 4px, #232c37 4px, #232c37 8px); }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 13px 18px;
  border-radius: 12px;
  background: #21262d;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  z-index: 50;
}

.toast--err { border-color: rgba(239, 68, 68, 0.5); background: #2a1618; }
.toast--ok  { border-color: rgba(34, 197, 94, 0.5); background: #10231a; }
