:root {
  --ink: #0d0d0d;
  --mut: #5c5f66;
  --line: #e4e7ec;
  --line2: #eef1f4;
  --paper: #fff;
  --panel: #f7f8fa;
  --accent: #0a59f7;
  --good: #37c871;
  --warn: #f7a100;
  --bad: #e84026;
  --info: #5e5ce6;
  --disp: 'Fraunces', Georgia, serif;
  --body: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --shadow: 0 8px 24px -16px rgba(13, 20, 40, 0.22);
  --shadow-pop: 0 20px 50px -18px rgba(13, 20, 40, 0.34);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3f4f6;
    --mut: #9aa0a8;
    --line: #2a2c30;
    --line2: #222428;
    --paper: #1c1d20;
    --panel: #161719;
    --accent: #317af7;
    --info: #7b78f0;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--body);
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
h3 {
  font-family: var(--disp);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
button {
  font-family: inherit;
}

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}
.side {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  padding: 6px 8px 20px;
}
.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(150deg, #0a59f7, #5d4ef7);
  display: grid;
  place-items: center;
}
.brand .logo svg {
  width: 17px;
  height: 17px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--mut);
  font-family: var(--body);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--mut);
  font-weight: 500;
  cursor: pointer;
  font-size: 13.5px;
}
.nav a:hover {
  background: var(--panel);
  color: var(--ink);
}
.nav a.on {
  background: rgba(10, 89, 247, 0.1);
  color: var(--accent);
  font-weight: 600;
}
.nav a svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}
.side .foot {
  margin-top: auto;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
}
.side .who {
  font-size: 12.5px;
  color: var(--mut);
  margin-bottom: 8px;
}
.side .who b {
  color: var(--ink);
  display: block;
  font-size: 13px;
}
.logout {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.logout:hover {
  border-color: var(--bad);
  color: var(--bad);
}

.main {
  overflow-y: auto;
  padding: 26px 30px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.topbar h1 {
  font-size: 24px;
}
.topbar .sub {
  color: var(--mut);
  font-size: 13.5px;
  margin-top: 2px;
}
.search {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  width: 260px;
}
.search:focus {
  outline: 0;
  border-color: var(--accent);
}

/* ---------- cards / grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px;
  box-shadow: var(--shadow);
}
.stat .l {
  font-size: 12px;
  color: var(--mut);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat .v {
  font-size: 27px;
  font-weight: 700;
  margin-top: 7px;
  font-family: var(--disp);
  letter-spacing: -0.02em;
}
.stat .d {
  font-size: 12px;
  color: var(--mut);
  margin-top: 3px;
}
/* DA : pas de bloc saturé pleine largeur. Une statistique mise en avant se
   distingue par un liseré d'accent sur fond neutre, valeur en encre de texte,
   comme dans l'espace de travail. */
.stat.accent {
  border-left: 3px solid var(--accent);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card .hd {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card .hd h2 {
  font-size: 16px;
}
.card .bd {
  padding: 6px 0;
}

/* ---------- table ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th {
  text-align: left;
  padding: 10px 18px;
  color: var(--mut);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line2);
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr {
  cursor: default;
}
tbody tr.clickable {
  cursor: pointer;
}
tbody tr.clickable:hover {
  background: var(--panel);
}
.mono {
  font-variant-numeric: tabular-nums;
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge.green {
  background: rgba(55, 200, 113, 0.14);
  color: #1f7a45;
}
.badge.blue {
  background: rgba(10, 89, 247, 0.12);
  color: var(--accent);
}
.badge.orange {
  background: rgba(247, 161, 0, 0.16);
  color: #a86a00;
}
.badge.red {
  background: rgba(232, 64, 38, 0.12);
  color: var(--bad);
}
.badge.gray {
  background: var(--line2);
  color: var(--mut);
}
.badge.purple {
  background: rgba(94, 92, 230, 0.14);
  color: var(--info);
}

/* ---------- buttons ---------- */
.btn {
  padding: 8px 15px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(1.06);
}
.btn.ghost {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}
.btn.sm {
  padding: 5px 11px;
  font-size: 12px;
}
.btn.danger {
  background: var(--bad);
}

/* ---------- drawer ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(13, 20, 40, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 40;
}
.scrim.on {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 94vw);
  background: var(--paper);
  z-index: 50;
  box-shadow: var(--shadow-pop);
  transform: translateX(100%);
  transition: transform 0.25s;
  display: flex;
  flex-direction: column;
}
.drawer.on {
  transform: none;
}
.drawer .dh {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.drawer .dh h2 {
  font-size: 19px;
}
.drawer .dh .x {
  border: 0;
  background: transparent;
  font-size: 22px;
  color: var(--mut);
  cursor: pointer;
  line-height: 1;
}
.drawer .db {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.section-t {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 22px 0 10px;
}
.section-t:first-child {
  margin-top: 0;
}
.kvrow {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line2);
  font-size: 13.5px;
}
.kvrow .k {
  color: var(--mut);
}

/* ---------- forms ---------- */
.field {
  margin-bottom: 13px;
}
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mut);
  margin-bottom: 5px;
}
.field input,
.field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
}
.field input:focus,
.field select:focus {
  outline: 0;
  border-color: var(--accent);
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.formmsg {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 9px;
  margin-bottom: 12px;
  display: none;
}
.formmsg.err {
  display: block;
  background: rgba(232, 64, 38, 0.1);
  color: var(--bad);
}
.formmsg.ok {
  display: block;
  background: rgba(55, 200, 113, 0.12);
  color: #1f7a45;
}

/* Attestation d'effacement, lue telle qu'elle sera remise. */
.attest {
  white-space: pre-wrap;
  font: 12.5px/1.55 var(--mono, ui-monospace, monospace);
  background: var(--soft, rgba(127, 127, 127, 0.08));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 14px;
}

/* ---------- login overlay ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(130% 130% at 12% 8%, #dfe9ff, #aec8ff);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
@media (prefers-color-scheme: dark) {
  .login-overlay {
    background: radial-gradient(130% 130% at 12% 8%, #16203a, #090b12);
  }
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
  padding: 34px 32px;
}
.login-card .brand {
  padding: 0 0 18px;
  justify-content: center;
}
.login-card h2 {
  font-size: 21px;
  text-align: center;
  margin-bottom: 4px;
}
.login-card .sub {
  text-align: center;
  color: var(--mut);
  font-size: 13.5px;
  margin-bottom: 22px;
}
.hide {
  display: none !important;
}
.muted {
  color: var(--mut);
}
.empty {
  padding: 30px;
  text-align: center;
  color: var(--mut);
  font-size: 13.5px;
}
.loading-page {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--mut);
}

/* ---------- skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--line2) 25%, var(--line) 37%, var(--line2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 10px;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* ---------- barre mobile ---------- */
.mobile-bar {
  display: none;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.mobile-bar .burger {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}
.mobile-bar .burger svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.mobile-bar .mb-title {
  font-weight: 600;
  font-size: 15px;
  font-family: var(--disp);
}
.nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(13, 20, 40, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 34;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    z-index: 36;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .side {
    transform: none;
  }
  body.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .mobile-bar {
    display: flex;
  }
  .main {
    padding: 18px 16px;
  }
  .drawer {
    width: 100vw;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .search {
    width: 100%;
  }
}
.card .bd {
  overflow-x: auto;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Menu réorganisable par glisser-déposer (ordre mémorisé) */
#nav a[draggable='true'] {
  user-select: none;
}
#nav a.nav-dragging {
  opacity: 0.45;
  outline: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  outline-offset: -1.5px;
  border-radius: 10px;
}
