/* ------------------------------------------------------------------
   Back-office Rolin Bainson — prototype statique
   HTML / CSS / JS classiques, aucun build.
   ------------------------------------------------------------------ */

:root {
  --brand-50: #fdf5f1;
  --brand-100: #fae8dd;
  --brand-200: #f4ccb6;
  --brand-400: #e98f62;
  --brand-500: #e5703a;
  --brand-600: #cf5a28;
  --brand-700: #a9471f;

  --ink-900: #16151a;
  --ink-800: #211f27;
  --ink-700: #3b3942;
  --ink-500: #6b6875;
  --ink-400: #8e8b98;
  --ink-300: #b5b2bd;

  --surface: #ffffff;
  --surface-muted: #f7f6f8;
  --surface-sunken: #edebf0;
  --line: #e2dfe6;

  /* Barre latérale */
  --nav-bg: #16151a;
  --nav-bg-soft: #1e1c23;
  --nav-line: rgb(255 255 255 / 0.08);
  --nav-fg: #a5a1b0;
  --nav-fg-strong: #ffffff;
  --nav-fg-dim: #67636f;

  --ok-bg: #e8f5ec; --ok-fg: #1c6b36;
  --warn-bg: #fdf3dc; --warn-fg: #8a5a06;
  --err-bg: #fdeceb; --err-fg: #a32019;
  --info-bg: #e9effb; --info-fg: #23498f;

  --radius: 8px;
  --sidebar-w: 256px;
  --rail-w: 64px;

  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-700);
  background: var(--surface-muted);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); }
h1, h2, h3 { margin: 0; color: var(--ink-900); font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }

svg { flex: none; }

/* ==================================================================
   Barre latérale
   ================================================================== */

.layout { display: flex; min-height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--nav-bg);
  color: var(--nav-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.16s ease, flex-basis 0.16s ease;
}

.sidebar.is-rail { width: var(--rail-w); flex-basis: var(--rail-w); }

/* ---- En-tête ---- */

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--nav-line);
  min-height: 57px;
}

.nav-brand__mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--brand-500); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: -0.02em;
  flex: none;
}

.nav-brand__text { min-width: 0; flex: 1; }
.nav-brand__text strong { display: block; color: var(--nav-fg-strong); font-size: 14px; font-weight: 600; white-space: nowrap; }
.nav-brand__text span { display: block; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--nav-fg-dim); }

.nav-toggle {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--nav-fg-dim);
  cursor: pointer;
}
.nav-toggle:hover { background: rgb(255 255 255 / 0.07); color: var(--nav-fg-strong); }

/* En mode rail, le logo cède la place au bouton : sans lui, impossible de
   redéplier la barre. */
.sidebar.is-rail .nav-brand { justify-content: center; padding: 14px 8px; }
.sidebar.is-rail .nav-brand__text,
.sidebar.is-rail .nav-brand__mark { display: none; }
.sidebar.is-rail .nav-toggle { width: 32px; height: 32px; }
.sidebar.is-rail .nav-toggle svg { transform: rotate(180deg); }

/* ---- Recherche ---- */

.nav-search { padding: 10px 12px; border-bottom: 1px solid var(--nav-line); position: relative; }

.nav-search input {
  width: 100%; height: 32px;
  padding: 0 46px 0 30px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 7px;
  background: var(--nav-bg-soft);
  color: var(--nav-fg-strong);
  font: inherit; font-size: 13px;
}
.nav-search input::placeholder { color: var(--nav-fg-dim); }
.nav-search input:focus { outline: 0; border-color: var(--brand-500); background: #26232c; }

.nav-search__icon { position: absolute; left: 21px; top: 50%; transform: translateY(-50%); color: var(--nav-fg-dim); pointer-events: none; }

.nav-search__kbd {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px;
  color: var(--nav-fg-dim);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 4px; padding: 1px 4px;
  pointer-events: none;
}

.sidebar.is-rail .nav-search { display: none; }

/* ---- Liste ---- */

.nav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; }
.nav-scroll::-webkit-scrollbar { width: 8px; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.1); border-radius: 4px; }
.nav-scroll::-webkit-scrollbar-track { background: transparent; }

.nav-group { margin-bottom: 4px; }

.nav-group__head {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 8px;
  border: 0; background: transparent;
  color: var(--nav-fg-dim);
  font: inherit; font-size: 10px; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}
.nav-group__head:hover { color: var(--nav-fg); }
.nav-group__head .chev { margin-left: auto; transition: transform 0.15s ease; }
.nav-group__head[aria-expanded="false"] .chev { transform: rotate(-90deg); }

.nav-group__note {
  display: block;
  margin: -2px 8px 6px;
  font-size: 9.5px; letter-spacing: 0; text-transform: none;
  color: #4e4a57;
}

.nav-group--system { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--nav-line); }

.nav-group__items { display: grid; gap: 1px; }
.nav-group[aria-collapsed="true"] .nav-group__items,
.nav-group[aria-collapsed="true"] .nav-group__note { display: none; }

/* ---- Entrée ---- */

.nav-item { position: relative; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border: 0; width: 100%;
  border-radius: 7px;
  background: transparent;
  color: var(--nav-fg);
  font: inherit; font-size: 13.5px;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.nav-link:hover { background: rgb(255 255 255 / 0.06); color: var(--nav-fg-strong); }
.nav-link:focus-visible { outline: 2px solid var(--brand-400); outline-offset: -2px; }

.nav-link__icon { color: inherit; opacity: 0.72; }
.nav-link__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-link[aria-current="page"],
.nav-link.is-active {
  background: var(--brand-500);
  color: #fff;
  font-weight: 500;
}
.nav-link[aria-current="page"] .nav-link__icon { opacity: 1; }

/* Parent dont un enfant est actif */
.nav-link.is-trail { color: var(--nav-fg-strong); background: rgb(255 255 255 / 0.05); }

.nav-link.is-todo { color: #5f5b68; }
.nav-link.is-todo .nav-link__icon { opacity: 0.4; }
.nav-link.is-todo:hover { color: var(--nav-fg); }

.nav-count {
  font-size: 10.5px; font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 999px;
  background: rgb(255 255 255 / 0.09);
  color: var(--nav-fg);
}
.nav-link[aria-current="page"] .nav-count { background: rgb(0 0 0 / 0.22); color: #fff; }
.nav-count.is-loading { width: 22px; height: 15px; background: rgb(255 255 255 / 0.07); color: transparent; }
.nav-count--alert { background: var(--err-fg); color: #fff; }

.nav-dot {
  width: 6px; height: 6px; border-radius: 50%;
  border: 1px solid currentColor; opacity: 0.45;
}

.nav-link .chev { opacity: 0.55; transition: transform 0.15s ease; }
.nav-link[aria-expanded="true"] .chev { transform: rotate(90deg); }

/* ---- Sous-menu ---- */

.nav-sub { display: grid; gap: 1px; margin: 2px 0 4px 17px; padding-left: 10px; border-left: 1px solid rgb(255 255 255 / 0.1); }
.nav-item[aria-expanded="false"] .nav-sub { display: none; }

.nav-sub a, .nav-sub span {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: #8d899a;
  text-decoration: none;
}
.nav-sub a:hover { background: rgb(255 255 255 / 0.06); color: var(--nav-fg-strong); }
.nav-sub a[aria-current="page"] { color: var(--brand-400); font-weight: 500; }
.nav-sub .nav-count { margin-left: auto; font-size: 10px; }
.nav-sub span { color: #5f5b68; }

/* ---- Mode rail ---- */

.sidebar.is-rail .nav-scroll { padding: 10px 8px; }
.sidebar.is-rail .nav-group__head,
.sidebar.is-rail .nav-group__note,
.sidebar.is-rail .nav-link__label,
.sidebar.is-rail .nav-count,
.sidebar.is-rail .nav-link .chev,
.sidebar.is-rail .nav-sub { display: none; }
.sidebar.is-rail .nav-group[aria-collapsed="true"] .nav-group__items { display: grid; }
.sidebar.is-rail .nav-link { justify-content: center; padding: 9px 0; }
.sidebar.is-rail .nav-group { margin-bottom: 10px; }

.sidebar.is-rail .nav-link::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  padding: 5px 9px; border-radius: 6px;
  background: var(--ink-900); color: #fff;
  font-size: 12px; white-space: nowrap;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
  opacity: 0; pointer-events: none;
  z-index: 60;
}
.sidebar.is-rail .nav-link:hover::after,
.sidebar.is-rail .nav-link:focus-visible::after { opacity: 1; }

/* ---- Pied ---- */

.nav-foot {
  border-top: 1px solid var(--nav-line);
  padding: 10px 12px;
  display: grid; gap: 7px;
  font-size: 11.5px;
}

.nav-status { display: flex; align-items: center; gap: 7px; color: var(--nav-fg-dim); }
.nav-status__dot { width: 7px; height: 7px; border-radius: 50%; background: #4e4a57; flex: none; }
.nav-status.is-up .nav-status__dot { background: #35c26a; box-shadow: 0 0 0 3px rgb(53 194 106 / 0.16); }
.nav-status.is-down .nav-status__dot { background: #e5484d; box-shadow: 0 0 0 3px rgb(229 72 77 / 0.16); }

.nav-legend { display: flex; align-items: center; gap: 7px; color: #4e4a57; }

.sidebar.is-rail .nav-foot { padding: 10px 8px; justify-items: center; }
.sidebar.is-rail .nav-status span:not(.nav-status__dot),
.sidebar.is-rail .nav-legend { display: none; }

/* ---- Recherche : filtrage ---- */

.sidebar.is-filtering .nav-group__head .chev { visibility: hidden; }
.nav-item[hidden], .nav-group[hidden] { display: none !important; }

.nav-empty { padding: 18px 10px; text-align: center; color: var(--nav-fg-dim); font-size: 12.5px; }

/* ==================================================================
   Zone principale
   ================================================================== */

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

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  height: 57px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.topbar__burger {
  display: none;
  width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink-700);
  cursor: pointer;
  place-items: center;
}

.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-400); min-width: 0; }
.crumbs b { color: var(--ink-900); font-weight: 600; }
.crumbs svg { opacity: 0.5; }

.topbar__spacer { flex: 1; }

.env-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-fg);
  font-size: 11.5px; font-weight: 500;
}

.topbar__link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ink-500); text-decoration: none;
}
.topbar__link:hover { color: var(--brand-700); }

.topbar__user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-500); }
.topbar__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}

.content { padding: 24px; max-width: 1400px; width: 100%; }

.page-head { margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: var(--ink-500); max-width: 68ch; }

.proto-banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 24px;
  background: var(--info-bg); color: var(--info-fg);
  border-bottom: 1px solid #cfdcf5;
  font-size: 12.5px;
}

/* ---- Voile mobile ---- */

.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.45);
  z-index: 40;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 0 0 40px rgb(0 0 0 / 0.3);
  }
  .sidebar.is-open { transform: translateX(0); }
  /* En tiroir, le mode rail n'a pas de sens : on affiche la barre complète. */
  .sidebar.is-rail { width: var(--sidebar-w); flex-basis: var(--sidebar-w); }
  .sidebar.is-rail .nav-brand__mark,
  .sidebar.is-rail .nav-brand__text,
  .sidebar.is-rail .nav-search,
  .sidebar.is-rail .nav-group__head,
  .sidebar.is-rail .nav-link__label,
  .sidebar.is-rail .nav-count { display: revert; }
  .sidebar.is-rail .nav-toggle { display: none; }
  .sidebar.is-rail .nav-link { justify-content: flex-start; padding: 7px 8px; }
  .sidebar.is-rail .nav-link::after { content: none; }

  .topbar__burger { display: grid; }
  body.nav-open .scrim { display: block; }
  .content { padding: 16px; }
}

/* Barre haute à l'étroit : on garde le fil d'Ariane et l'avatar, le reste
   passe à la trappe plutôt que de se chevaucher. */
@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__link, .env-badge { display: none; }
  .topbar__user { font-size: 0; }
  .crumbs { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .proto-banner { padding: 10px 14px; }
}

/* ==================================================================
   Composants
   ================================================================== */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.card__head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card__head h2 { flex: 1; }
.card__body { padding: 16px; }
.card__foot {
  padding: 10px 16px; border-top: 1px solid var(--line);
  background: var(--surface-muted);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12.5px; color: var(--ink-500);
}

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--main { grid-template-columns: 2fr 1fr; align-items: start; }

@media (max-width: 1150px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--main, .grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) { .grid--4, .grid--2 { grid-template-columns: 1fr; } }

.stat { padding: 15px 16px; }
.stat__label { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }
.stat__value { margin-top: 6px; font-size: 26px; font-weight: 600; color: var(--ink-900); line-height: 1; }
.stat__hint { margin-top: 6px; font-size: 12px; color: var(--ink-500); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-400); background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap; font-weight: 600;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--brand-50); }
table.data tr.subhead td {
  background: var(--surface-sunken);
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-500); font-weight: 600;
}
table.data tr.subhead:hover td { background: var(--surface-sunken); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-400); }
.nowrap { white-space: nowrap; }

.cell-title { display: block; color: var(--ink-900); font-weight: 500; }
.cell-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-400); }
.col-bien { min-width: 230px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge--err { background: var(--err-bg); color: var(--err-fg); }
.badge--info { background: var(--info-bg); color: var(--info-fg); }
.badge--neutral { background: var(--surface-sunken); color: var(--ink-500); }
.badge--brand { background: var(--brand-100); color: var(--brand-700); }
.badge--readonly::before { content: "🔒"; font-size: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 7px;
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--brand-500); color: #fff; }
.btn--primary:hover { background: var(--brand-600); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink-700); }
.btn--ghost:hover { border-color: var(--brand-200); color: var(--brand-700); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }
.field input, .field select {
  height: 32px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 13px; color: var(--ink-900);
  background: var(--surface); min-width: 140px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand-200); outline-offset: 1px; border-color: var(--brand-500); }

/* ---- Filtres actifs ---- */

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.chips__label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); margin-right: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--brand-200); border-radius: 999px;
  background: var(--brand-50); color: var(--brand-700);
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { background: var(--brand-100); }
.chip__key { color: var(--ink-400); }
.chip--clear { border-style: dashed; border-color: var(--line); background: transparent; color: var(--ink-500); }
.chip--clear:hover { color: var(--brand-700); border-color: var(--brand-200); }

/* ---- Pagination ---- */

.pager { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.pager__btn {
  min-width: 26px; height: 26px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink-700);
  font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
.pager__btn:hover:not(:disabled) { border-color: var(--brand-300, var(--brand-200)); color: var(--brand-700); }
.pager__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager__page { padding: 0 6px; font-variant-numeric: tabular-nums; color: var(--ink-500); }

.card__foot--pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- Tri par colonne ---- */

.th-sort {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; padding: 0;
  font: inherit; font-size: inherit; letter-spacing: inherit; text-transform: inherit;
  color: inherit; font-weight: inherit; cursor: pointer;
}
.th-sort:hover { color: var(--ink-700); }
.th-sort.is-active { color: var(--brand-700); }
.th-sort__arrow { font-size: 11px; opacity: 0.6; }
.th-sort.is-active .th-sort__arrow { opacity: 1; }

/* ---- Lignes cliquables ---- */

tr.is-clickable { cursor: pointer; }
tr.is-clickable:hover .cell-title { color: var(--brand-700); text-decoration: underline; }

/* ---- Fiche détaillée ---- */

.detail-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
}
.detail-head__main { flex: 1; min-width: 240px; }
.detail-head__meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
  font-size: 12.5px; color: var(--ink-500); text-decoration: none;
}
.back-link:hover { color: var(--brand-700); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; }
.gallery__thumb {
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: 6px;
  background: var(--surface-muted);
  color: var(--ink-300); font-size: 11px; text-align: center; padding: 8px;
  overflow: hidden;
}
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery figcaption { margin-top: 5px; font-size: 11px; color: var(--ink-400); word-break: break-all; }

.dpe-scale { display: flex; gap: 3px; }
.dpe-scale span {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 4px; font-size: 11px; font-weight: 600;
  background: var(--surface-sunken); color: var(--ink-400);
}
.dpe-scale span.is-on { background: var(--ink-900); color: #fff; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 3px 9px; border-radius: 6px;
  background: var(--surface-muted); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-700);
}

/* ---- Formulaires d'édition ---- */

.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; gap: 5px; margin-bottom: 15px; }
.form-row:last-child { margin-bottom: 0; }
.form-row > label { font-size: 12px; font-weight: 500; color: var(--ink-700); }
.form-row .hint { font-size: 11.5px; color: var(--ink-400); line-height: 1.45; }

.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="email"],
.form-row input[type="tel"],
.form-row input[type="date"],
.form-row input[type="datetime-local"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit; font-size: 13.5px; color: var(--ink-900);
  background: var(--surface);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid var(--brand-200); outline-offset: 1px; border-color: var(--brand-500);
}
.form-row textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.form-row textarea.tall { min-height: 320px; font-family: var(--mono); font-size: 12.5px; }

.form-check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 13px; }
.form-check:last-child { margin-bottom: 0; }
.form-check input { margin-top: 2px; }
.form-check span { font-size: 13px; }
.form-check .hint { display: block; font-size: 11.5px; color: var(--ink-400); }

.form-actions {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 13px 16px; border-top: 1px solid var(--line);
  background: var(--surface-muted); border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions .spacer { flex: 1; }

.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
  display: inline-flex; align-items: center; padding: 0 9px;
  border: 1px solid var(--line); border-right: 0; border-radius: 7px 0 0 7px;
  background: var(--surface-muted); color: var(--ink-400);
  font-family: var(--mono); font-size: 12px;
}
.input-prefix input { border-radius: 0 7px 7px 0 !important; }

.counter { font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--err-fg); font-weight: 600; }

.state { padding: 36px 16px; text-align: center; color: var(--ink-400); font-size: 13px; }
.state--error { color: var(--err-fg); }

.skeleton {
  display: block; height: 11px; border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-sunken) 25%, #f3f1f5 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .sidebar, .nav-link .chev, .nav-group__head .chev { transition: none; }
}

.note { display: flex; gap: 9px; padding: 11px 13px; border-radius: var(--radius); font-size: 12.5px; line-height: 1.5; }
.note--warn { background: var(--warn-bg); color: var(--warn-fg); }
.note--info { background: var(--info-bg); color: var(--info-fg); }
.note--err { background: var(--err-bg); color: var(--err-fg); }

.list-reset { margin: 0; padding: 0; list-style: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-400); }
.kv dd { margin: 0; color: var(--ink-900); }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-400); font-size: 12px; white-space: nowrap; }

/* --- Boutons et actions de ligne ------------------------------------- */

.btn--danger { background: var(--err-bg); border-color: #f3c5c2; color: var(--err-fg); }
.btn--danger:hover { background: #fbdedc; border-color: #e9a19c; }

/* Petits boutons carrés posés dans une cellule de tableau : monter,
   descendre, supprimer. Discrets au repos, lisibles au survol. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; margin-left: 2px;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--ink-400);
  font: inherit; font-size: 14px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--ink-800); }
.icon-btn--danger:hover { background: var(--err-bg); color: var(--err-fg); }

/* --- Formulaires en ligne -------------------------------------------- */

.inline-form { display: grid; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .row2 { grid-template-columns: 1fr; } }

/* Une définition par bloc, pour les valeurs longues : un message de
   formulaire ne tient pas dans une colonne de 200 pixels. */
.kv--stack { grid-template-columns: 1fr; gap: 2px 0; }
.kv--stack dt { margin-top: 10px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.kv--stack dt:first-child { margin-top: 0; }
.kv--stack dd { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.kv--stack dd:last-child { border-bottom: 0; }

/* --- Médiathèque ----------------------------------------------------- */

.media-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.media-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; text-decoration: none;
}
.media-card:hover { border-color: var(--brand-200); }
.media-card__thumb {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; background: var(--surface-sunken); overflow: hidden;
}
.media-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-card__doc {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.08em; color: var(--ink-400);
}
.media-card__body { display: grid; gap: 3px; padding: 9px 11px 11px; }
.media-card__name {
  font-size: 12.5px; font-weight: 500; color: var(--ink-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-card__meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 11.5px; color: var(--ink-400); }

.dropzone {
  display: grid; gap: 6px; place-items: center;
  padding: 22px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: var(--surface-muted); text-align: center; cursor: pointer;
  font-size: 13px; color: var(--ink-500);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-700); }
.dropzone input[type="file"] { display: none; }

/* `hidden` doit l'emporter sur les `display` des composants : sans cette
   règle, un bloc en `display: grid` reste visible malgré l'attribut. */
[hidden] { display: none !important; }

/* --- Constructeur de formulaire -------------------------------------- *
   L'ancien back-office réordonnait les champs à la souris ; on garde le
   geste, et on l'accompagne de flèches qui fonctionnent sans JavaScript. */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.builder { margin: 0; padding: 0; list-style: none; }

.builder__item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px;
  padding: 9px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.builder__item:last-child { border-bottom: 0; }
.builder__item:hover { background: var(--surface-muted); }
.builder__item.is-editing { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-500); }
.builder__item.is-dragging { opacity: 0.4; }
.builder__item.is-over { box-shadow: inset 0 -2px 0 var(--brand-500); }
.builder__item.is-locked { background: var(--surface-muted); }

.builder__handle {
  display: grid; place-items: center; width: 24px; height: 24px;
  color: var(--ink-300); cursor: grab; border-radius: 5px;
}
.builder__handle:active { cursor: grabbing; }
.builder__item:hover .builder__handle { color: var(--ink-500); background: var(--surface-sunken); }
.builder__item.is-locked .builder__handle { cursor: default; background: none; }

.builder__main { display: grid; gap: 2px; min-width: 0; }
.builder__label {
  font-size: 13.5px; font-weight: 500; color: var(--ink-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.builder__sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; }

.builder__width select {
  padding: 4px 7px; font: inherit; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink-700);
}
.builder__width select:disabled { color: var(--ink-300); }
.builder__tools { display: flex; gap: 2px; justify-content: flex-end; }

@media (max-width: 760px) {
  .builder__item { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .builder__width { grid-column: 2 / -1; }
}

/* --- Aperçu de la grille du formulaire -------------------------------- */

.preview { display: grid; gap: 12px; }
.preview__row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.preview__cell { grid-column: span var(--w, 4); display: grid; gap: 4px; align-content: start; }

.preview__label, .preview__heading { font-size: 11.5px; color: var(--ink-500); }
.preview__heading {
  margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--ink-900);
  padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.preview__box {
  display: block; min-height: 30px; padding: 6px 9px;
  border: 1px dashed var(--line); border-radius: 6px;
  background: var(--surface-muted); color: var(--ink-300);
  font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview__box--tall { min-height: 58px; }
.preview__check { display: flex; gap: 7px; align-items: flex-start; font-size: 12.5px; color: var(--ink-700); }
.preview__help { font-size: 11px; color: var(--ink-400); }
.preview__submit {
  display: inline-block; padding: 7px 14px; border-radius: 6px;
  background: var(--brand-500); color: #fff; font-size: 12.5px; font-weight: 500;
}

@media (max-width: 720px) {
  .preview__row { grid-template-columns: 1fr; }
  .preview__cell { grid-column: 1; }
}

/* --- Bureau des réponses : liste + volet ------------------------------ */

.filters--desk { align-items: flex-end; }
.field--grow { flex: 1 1 260px; }
.filters__actions { display: flex; gap: 8px; }

.desk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
.desk__pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.desk__pane[aria-busy="true"] { opacity: 0.5; }

@media (max-width: 1150px) {
  .desk { grid-template-columns: 1fr; }
  .desk__pane { position: static; max-height: none; }
}

.replies { margin: 0; padding: 0; list-style: none; }

.reply {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.reply:hover { background: var(--surface-muted); }
.reply.is-selected { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-500); }
.replies li:last-child .reply { border-bottom: 0; }

.reply__main { display: grid; gap: 2px; min-width: 0; }
.reply__name {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-900);
}
.reply__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); }
.reply__sub, .reply__excerpt {
  font-size: 11.5px; color: var(--ink-400);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reply__side { display: grid; gap: 3px; justify-items: end; text-align: right; }
.reply__form { font-size: 11.5px; color: var(--ink-500); }
.reply__date { font-size: 11.5px; color: var(--ink-400); white-space: nowrap; }
.reply__tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

/* --- Aperçu d'une réponse -------------------------------------------- */

.apercu { display: grid; }
.apercu__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.apercu__title { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--ink-900); }
.apercu__meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 0; font-size: 12px; }
.apercu__actions { padding: 12px 16px 0; }

.apercu__block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.apercu__block h3 {
  display: flex; align-items: center; gap: 7px; margin: 0 0 9px;
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-400);
}
.apercu__files { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.apercu__files li {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-muted); font-size: 12px;
}
.apercu__file-name { flex: 1 1 160px; font-weight: 500; color: var(--ink-900); }
.apercu__note { margin: 9px 0 0; font-size: 11.5px; color: var(--ink-400); }

.apercu__foot {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; justify-content: space-between;
  padding: 13px 16px; background: var(--surface-muted);
}
.apercu__status { display: flex; gap: 8px; align-items: center; }
.apercu__status label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }
.apercu__status select {
  padding: 5px 8px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.card--apercu .apercu__head { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }

/* --- Permissions ------------------------------------------------------ */

.perm-group {
  margin: 14px 0 5px; font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-400);
}
.perm-group:first-child { margin-top: 0; }

.perm-list { margin: 0; padding: 0 0 0 16px; font-size: 12.5px; color: var(--ink-700); }
.perm-list li { margin-bottom: 3px; }

.perm-block { margin: 0 0 18px; padding: 0; border: 0; }
.perm-block:last-child { margin-bottom: 0; }
.perm-block legend {
  display: grid; gap: 2px; padding: 0 0 8px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-900);
}
.perm-block__help { font-size: 11.5px; font-weight: 400; color: var(--ink-400); }
.perm-block .form-check { margin-bottom: 5px; }
.perm-block .form-check .hint { display: block; }
