:root {
  --bg: #0b0d12;
  --surface: #12151b;
  --panel: #161a21;
  --panel-2: #1c212b;
  --border: #262c36;
  --border-soft: #1d222b;
  --text: #e8ebf1;
  --text-dim: #b7bfcc;
  --muted: #7c8494;
  --accent: #4f8cff;
  --accent-dim: rgba(79, 140, 255, 0.14);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.14);
  --red: #f0546b;
  --red-dim: rgba(240, 84, 107, 0.14);
  --amber: #f0b429;
  --amber-dim: rgba(240, 180, 41, 0.14);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 240px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 26px -14px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333b48; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

a { color: inherit; text-decoration: none; }

/* ================================================================ shell */

.shell { display: flex; min-height: 100vh; }

.backdrop {
  position: fixed; inset: 0; background: rgba(4, 5, 8, 0.6);
  backdrop-filter: blur(2px); z-index: 30;
}

/* --------------------------------------------------------------- sidebar */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { padding: 20px 18px 14px; border-bottom: 1px solid var(--border-soft); }
.brand h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.accent { color: var(--accent); }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; overflow-y: auto; }

.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}
.navlink:hover { background: var(--panel); color: var(--text); }
.navlink .nav-icon { color: var(--muted); flex: 0 0 auto; }
.navlink:hover .nav-icon { color: var(--text-dim); }
.navlink.active { background: var(--accent-dim); color: var(--text); }
.navlink.active .nav-icon { color: var(--accent); }
.navlink span:first-of-type { flex: 1; }

.navbadge {
  background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 700;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
}
.navbadge[hidden] { display: none; }

.nav-icon {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

.sidebar-foot {
  border-top: 1px solid var(--border-soft);
  padding: 14px 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}

.field-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 600;
}

.verdict-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 12.5px; font-weight: 550;
}
.verdict-pill:hover { border-color: #333b48; }
.vp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.verdict-pill.state-good .vp-dot { background: var(--green); }
.verdict-pill.state-good .vp-text { color: var(--green); }
.verdict-pill.state-bad .vp-dot { background: var(--red); }
.verdict-pill.state-bad .vp-text { color: var(--red); }
.vp-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot-ok { background: var(--green); }
.dot-down { background: var(--red); }

/* --------------------------------------------------------------- topbar */

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: none;
  align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(11, 13, 18, 0.9);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.view-title { margin: 0; font-size: 15px; font-weight: 600; }

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: var(--radius-sm); padding: 7px; display: flex;
}
.icon-btn:hover { color: var(--text); border-color: #333b48; }
.icon-btn .nav-icon { width: 18px; height: 18px; }

main#content { padding: 22px 28px 44px; max-width: 1180px; width: 100%; margin: 0 auto; flex: 1; }

.view[hidden] { display: none; }

/* ------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: 18px; }

.panel h2 { margin: 0 0 6px; font-size: 15.5px; font-weight: 600; }

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

.section-lede { color: var(--text-dim); font-size: 13px; margin: 16px 2px 14px; }

/* --- Le verdict : c'est lui qui commande l'essai ------------------- */
.verdict {
  border-radius: var(--radius);
  padding: 16px 20px 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-1);
}
.verdict-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.verdict p { margin: 8px 0 10px; font-size: 13.5px; color: var(--text-dim); max-width: 68ch; }

.verdict-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 650; font-size: 14.5px;
}
.verdict-badge::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
}
.verdict-unknown .verdict-badge::before { background: var(--muted); }
.verdict-bad .verdict-badge { color: var(--red); }
.verdict-bad .verdict-badge::before { background: var(--red); }
.verdict-good .verdict-badge { color: var(--green); }
.verdict-good .verdict-badge::before { background: var(--green); }

/* --- Chiffres ------------------------------------------------------ */
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 10px 14px;
  min-width: 110px;
}
.stat .label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat .value { display: block; font-size: 19px; font-weight: 620; margin-top: 3px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }

/* --- Liens rapides (vue d'ensemble) --------------------------------- */
.quicklinks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.quickcard {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.quickcard:hover { border-color: var(--accent); background: var(--panel-2); transform: translateY(-1px); }
.quickcard .nav-icon { width: 19px; height: 19px; color: var(--accent); margin-top: 2px; flex: 0 0 auto; }
.quickcard h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; }
.quickcard p { margin: 0; }

/* --- Tables -------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 11px; text-transform: uppercase; letter-spacing: 0.045em; }
td { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--panel-2); }

/* --- Formulaire ---------------------------------------------------- */
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); font-size: 12.5px; padding: 7px 12px; }
button.ghost:hover { color: var(--text); border-color: var(--accent); }
button.small-btn { padding: 6px 11px; font-size: 12.5px; }
button.danger { background: var(--red); }

.mode-switch { display: flex; gap: 6px; }
.sidebar-modeswitch { width: 100%; }
.sidebar-modeswitch .mode { flex: 1; }
.mode {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 12.5px; padding: 7px 12px;
}
.mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Resultat d'evaluation ----------------------------------------- */
.result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--panel-2);
}
.result h3 { margin: 0 0 5px; font-size: 15px; }
.result .verdict-line { font-size: 13.5px; margin: 9px 0 4px; }
.bar { height: 7px; border-radius: 4px; background: var(--border); overflow: hidden; margin: 9px 0 4px; }
.bar > div { height: 100%; background: var(--accent); }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
}
.pill-go { background: var(--green-dim); color: var(--green); }
.pill-no { background: var(--red-dim); color: var(--red); }
.pill-warn { background: var(--amber-dim); color: var(--amber); }

.pending-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 11px 14px; margin-top: 9px; background: var(--panel-2);
}
.pending-item .who { font-weight: 550; }

canvas { width: 100%; margin: 8px 0 4px; }

footer { padding: 22px 28px 34px; max-width: 1180px; margin: 0 auto; width: 100%; }

/* ================================================================ mobile */

@media (max-width: 900px) {
  .topbar { display: flex; }

  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-1); }
  .backdrop[hidden] { display: none; }

  main#content { padding: 18px 16px 36px; }
  footer { padding: 0 16px 26px; }

  .quicklinks { grid-template-columns: 1fr; }
}
