/* =========================================================================
   SDS 66 — feuille de style
   Parti pris : console technique. Fond graphite mat, aucune ombre portee,
   hierarchie portee par des filets 1px, des libelles condenses en capitales
   et un unique accent rouge SDIS utilise avec parcimonie.
   ========================================================================= */

:root {
  --bg: #0b0c0f;
  --bg-2: #101318;
  --bg-3: #161a20;
  --bg-4: #1c212a;
  --line: #22272f;
  --line-soft: #191d24;
  --line-hi: #333b46;

  --txt: #e8ebef;
  --txt-2: #99a2ad;
  --txt-3: #656e7a;

  --red: #e5383b;
  --red-hi: #ff5054;
  --red-dim: #3a1618;
  --amber: #f0a93b;
  --green: #3dd68c;

  --r: 6px;
  --r-lg: 10px;
  --nav-w: 268px;
  --top-h: 58px;
  --tab-h: 62px;

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', var(--sans);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* halo rouge tres diffus en haut a gauche : donne de la profondeur au fond
   sans ombre ni degrade visible */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(900px 520px at 8% -10%, rgba(229, 56, 59, 0.07), transparent 70%);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: rgba(229, 56, 59, 0.3); }

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

/* barres de defilement discretes (desktop) */
* {
  scrollbar-width: thin;
  scrollbar-color: #2a313a transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: #262d36;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: #333b46; background-clip: content-box; }

/* =======================================================================
   Coque
   ======================================================================= */

#app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
}

/* ------- colonne de navigation (desktop) ------- */

#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(12, 14, 17, 0.82);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--top-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  position: relative;
}
.brand-mark::before,
.brand-mark::after {
  content: '';
  position: absolute;
  background: var(--red);
  border-radius: 1.5px;
}
.brand-mark::before { left: 0; right: 0; top: 33%; height: 34%; }
.brand-mark::after { top: 0; bottom: 0; left: 33%; width: 34%; }

.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.1em;
  line-height: 1.05;
  text-transform: uppercase;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-3);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 10px 20px;
}

.nav-label {
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 16px 10px 7px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.nav-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--r);
  color: var(--txt-2);
  font-size: 14.5px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item .ic { flex: 0 0 auto; opacity: 0.75; transition: opacity 0.12s, color 0.12s; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--bg-3); color: var(--txt); }
.nav-item:hover .ic { opacity: 1; }
.nav-item.is-active { background: var(--bg-3); color: var(--txt); font-weight: 500; }
.nav-item.is-active .ic { color: var(--red); opacity: 1; }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--red);
}
.nav-item .ext {
  margin-left: auto;
  flex: 0 0 auto;
  opacity: 0.45;
}

.nav-foot {
  flex: 0 0 auto;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--txt-3);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.13);
}
.dot.off { background: var(--amber); box-shadow: 0 0 0 3px rgba(240, 169, 59, 0.13); }
.net { display: flex; align-items: center; gap: 7px; letter-spacing: 0.04em; }

/* ------- barre haute ------- */

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

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 15, 0.86);
  backdrop-filter: blur(10px);
}

.topbar-brand { display: none; align-items: center; gap: 10px; min-width: 0; }

.crumb {
  font-family: var(--cond);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--txt-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.crumb b { color: var(--txt); font-weight: 600; }
.crumb i { font-style: normal; color: var(--txt-3); padding: 0 7px; }

.spacer { flex: 1 1 auto; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  color: var(--txt-2);
  border: 1px solid transparent;
  flex: 0 0 auto;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--txt); border-color: var(--line); }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 11px;
  min-width: 230px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--txt-3);
  font-size: 13.5px;
  transition: border-color 0.12s, background 0.12s;
}
.search-trigger:hover { border-color: var(--line-hi); background: var(--bg-3); }
.search-trigger kbd {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--txt-3);
  background: var(--bg);
}

/* ------- zone de contenu ------- */

#view {
  flex: 1 1 auto;
  padding: 26px 26px 60px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

/* ------- barre d'onglets (mobile) ------- */

#tabbar { display: none; }

/* =======================================================================
   Elements de page
   ======================================================================= */

.page-head { margin: 4px 0 26px; }
.page-kicker {
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 7px;
}
.page-title {
  font-family: var(--cond);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.04;
  text-transform: uppercase;
  margin: 0;
}
.page-sub { color: var(--txt-2); margin-top: 8px; font-size: 14.5px; max-width: 68ch; }

.section-label {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 34px 0 14px;
  font-family: var(--cond);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--txt-2);
}
.section-label::before {
  content: '';
  width: 3px;
  height: 13px;
  background: var(--red);
  border-radius: 2px;
  flex: 0 0 auto;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.section-label .count {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--txt-3);
  font-variant-numeric: tabular-nums;
}

/* ------- bandeau astreinte ------- */

.ast {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  overflow: hidden;
  margin-bottom: 8px;
}
.ast.is-stale { border-color: #4a3a18; }

.ast-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-3);
}
.ast-head::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--red);
  flex: 0 0 auto;
  margin-left: -4px;
}
.ast-title {
  font-family: var(--cond);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--txt-2);
}
.ast-date {
  font-size: 12px;
  color: var(--txt-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.ast-meta { font-size: 12px; color: var(--txt-3); }
.ast-head .icon-btn { width: 30px; height: 30px; }

.ast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
}
.ast-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--bg-2);
  min-width: 0;
}
.ast-cell.is-call { transition: background 0.12s; }
.ast-cell.is-call:hover { background: var(--bg-3); }
.ast-label {
  font-family: var(--cond);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-3);
}
.ast-name {
  font-family: var(--cond);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.12;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ast-name.is-empty { color: var(--txt-3); }
.ast-tel {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.ast-sub {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  align-items: baseline;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
}
.ast-sub-label {
  font-family: var(--cond);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-3);
  flex: 0 0 auto;
}
.ast-sub-vals { display: flex; gap: 18px; flex-wrap: wrap; }
.ast-slot { display: flex; align-items: baseline; gap: 7px; font-size: 13.5px; }
.ast-slot i {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-3);
}
.ast-slot b { font-weight: 500; }
.ast-slot a { color: var(--txt); border-bottom: 1px solid rgba(61, 214, 140, 0.35); }
.ast-slot a:hover { border-bottom-color: var(--green); }

.spin {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line-hi);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------- grille d'acces rapide ------- */

.quick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 15px 14px;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  text-align: left;
  overflow: hidden;
  transition: border-color 0.14s, background 0.14s, transform 0.14s;
}
.tile::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--red);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.18s ease;
}
.tile:hover { border-color: var(--line-hi); background: var(--bg-3); transform: translateY(-1px); }
.tile:hover::after { transform: scaleY(1); }
.tile:active { transform: translateY(0); }
.tile .ic { color: var(--red); opacity: 0.9; }
.tile-title {
  font-family: var(--cond);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
}
.tile-note {
  font-size: 12px;
  color: var(--txt-3);
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ------- listes ------- */

.list {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-2);
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.12s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg-3); }
.row-body { min-width: 0; flex: 1 1 auto; }
.row-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.row-meta {
  font-size: 12px;
  color: var(--txt-3);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.row-meta .sep { color: var(--line-hi); }
.row .chev { color: var(--txt-3); flex: 0 0 auto; }
.row:hover .chev { color: var(--txt-2); }

.thumb {
  width: 76px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-4);
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ------- grille de dossiers / rubriques ------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  text-align: left;
  transition: border-color 0.14s, background 0.14s;
}
.card:hover { border-color: var(--line-hi); background: var(--bg-3); }
.card .ic { color: var(--txt-2); flex: 0 0 auto; }
.card:hover .ic { color: var(--red); }
.card-thumb {
  width: 42px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-4);
  border: 1px solid var(--line);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.card-title {
  font-family: var(--cond);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
}
.card-note { font-size: 11.5px; color: var(--txt-3); letter-spacing: 0.04em; }

/* ------- galerie de fiches ------- */

.gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.gal-item {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-2);
  transition: border-color 0.14s, transform 0.14s;
}
.gal-item:hover { border-color: var(--red); transform: translateY(-2px); }
.gal-img {
  aspect-ratio: 3 / 4;
  background: var(--bg-4);
  overflow: hidden;
}
.gal-img img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.gal-cap {
  padding: 9px 11px 11px;
  font-size: 12.5px;
  color: var(--txt-2);
  border-top: 1px solid var(--line-soft);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------- annuaire ------- */

.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line-soft);
}
.contact-row:last-child { border-bottom: 0; }
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-4);
  border: 1px solid var(--line);
  font-family: var(--cond);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--txt-2);
}
.contact-name {
  display: block;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.3;
}
.contact-tel {
  display: block;
  font-size: 12.5px;
  color: var(--txt-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.contact-note {
  display: block;
  font-size: 11.5px;
  color: var(--txt-3);
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-name .tag { vertical-align: 1px; margin-left: 4px; }
.call-btn {
  margin-left: auto;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--green);
  transition: border-color 0.12s, background 0.12s;
}
.call-btn:hover { border-color: var(--green); background: rgba(61, 214, 140, 0.08); }

/* Separateur alphabetique : volontairement NON sticky — .list est en
   overflow:hidden, un position:sticky s'y comporte mal et chevauche la
   premiere ligne du groupe. */
.alpha-head {
  padding: 6px 15px;
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--txt-3);
  background: var(--bg-3);
  border-bottom: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
}
.list > .alpha-head:first-child { border-top: 0; }

/* ------- filtre local ------- */

.filter {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
  margin-bottom: 14px;
  transition: border-color 0.12s;
}
.filter:focus-within { border-color: var(--line-hi); }
.filter input {
  flex: 1;
  background: none;
  border: 0;
  outline: 0;
  font-size: 14.5px;
}
.filter input::placeholder { color: var(--txt-3); }
.filter .ic { color: var(--txt-3); flex: 0 0 auto; }

/* ------- article ------- */

.article { max-width: 78ch; }
.article-date {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin-bottom: 10px;
}
.prose { font-size: 15.5px; line-height: 1.72; color: #d3d8de; }
.prose p { margin: 0 0 1em; }
.prose ol, .prose ul { margin: 0 0 1em; padding-left: 1.4em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--txt-3); }
.prose a {
  color: var(--red-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(229, 56, 59, 0.4);
}
.prose a:hover { text-decoration-color: var(--red-hi); }
.prose strong { color: var(--txt); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

.article-gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 24px;
}
.article-gal button {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg-2);
  transition: border-color 0.14s;
}
.article-gal button:hover { border-color: var(--red); }
.article-gal img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.article-gal.single { grid-template-columns: 1fr; max-width: 560px; }
.article-gal.single img { aspect-ratio: auto; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg-3);
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--line-hi); background: var(--bg-4); }
.btn-primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--red-hi); border-color: var(--red-hi); }
.btn-ghost { background: none; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-dim); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ------- etats ------- */

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--txt-3);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty strong { display: block; color: var(--txt-2); font-weight: 500; margin-bottom: 5px; }

.skel {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: sk 1.3s linear infinite;
}
@keyframes sk { to { background-position: -200% 0; } }

/* =======================================================================
   Superpositions
   ======================================================================= */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(7, 8, 10, 0.78);
  backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  width: min(680px, 100%);
  margin: min(9vh, 90px) auto 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 680px);
  animation: rise 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.sheet-search {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sheet-search input {
  flex: 1;
  background: none;
  border: 0;
  outline: 0;
  font-size: 16px;
}
.sheet-search input::placeholder { color: var(--txt-3); }
.sheet-results { overflow-y: auto; padding: 6px; }
.sheet-hint {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--txt-3);
  display: flex;
  gap: 16px;
  flex: 0 0 auto;
}

.res {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--r);
  text-align: left;
}
.res:hover, .res.is-cursor { background: var(--bg-3); }
.res .ic { color: var(--txt-3); flex: 0 0 auto; }
.res.is-cursor .ic { color: var(--red); }
.res-body { min-width: 0; flex: 1; display: block; }
.res-title {
  display: block;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.res-path {
  display: block;
  font-size: 11.5px;
  color: var(--txt-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--cond);
}
mark { background: rgba(229, 56, 59, 0.22); color: var(--txt); border-radius: 2px; padding: 0 1px; }

/* ------- visionneuse de fiches ------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #06070a;
  display: flex;
  flex-direction: column;
  animation: fade 0.14s ease;
}
.viewer-bar {
  height: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 15, 0.9);
}
.viewer-title {
  font-family: var(--cond);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* flex plutot que grid : une piste de grille auto grandit a la taille de
   l'image et `max-height:100%` se resout alors contre cette hauteur, ce qui
   laissait la fiche deborder au lieu de tenir dans l'ecran. */
.viewer-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  display: grid;
  place-items: center;
  background: rgba(16, 19, 24, 0.85);
  border: 1px solid var(--line);
  color: var(--txt-2);
  border-radius: var(--r);
}
.viewer-nav:hover { color: var(--txt); border-color: var(--line-hi); }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-foot {
  flex: 0 0 auto;
  padding: 9px 14px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--txt-3);
  display: flex;
  align-items: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}

/* ------- bandeau d'installation ------- */

.install {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 180;
  width: min(520px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-lg);
  background: rgba(20, 24, 30, 0.97);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
  animation: rise 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.install-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  position: relative;
}
.install-icon::before,
.install-icon::after {
  content: '';
  position: absolute;
  background: var(--red);
  border-radius: 1.5px;
}
.install-icon::before { left: 22%; right: 22%; top: 43%; height: 14%; }
.install-icon::after { top: 22%; bottom: 22%; left: 43%; width: 14%; }
.install-body { flex: 1; min-width: 0; }
.install-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.install-note { font-size: 12px; color: var(--txt-3); line-height: 1.35; }

/* ------- boite de dialogue ------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 8, 10, 0.8);
  backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
  overflow-y: auto;
}
.modal-panel {
  width: min(520px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-title {
  font-family: var(--cond);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  flex: 1;
}
.modal-body { padding: 17px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 17px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-steps { counter-reset: s; margin: 0; padding: 0; list-style: none; }
.modal-steps li {
  counter-increment: s;
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--txt-2);
}
.modal-steps li:last-child { border-bottom: 0; }
.modal-steps li::before {
  content: counter(s);
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-4);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--txt-2);
  font-weight: 600;
}

/* ------- champs de formulaire ------- */

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 14.5px;
  outline: 0;
  transition: border-color 0.12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--red); }
.textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 13px; line-height: 1.6; }
.hint { font-size: 12px; color: var(--txt-3); margin-top: 5px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ------- pave numerique ------- */

.pin-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 18px;
}
.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  transition: background 0.12s, border-color 0.12s;
}
.pin-dot.on { background: var(--red); border-color: var(--red); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.pin-key {
  height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-3);
  font-family: var(--cond);
  font-size: 22px;
  font-weight: 600;
  transition: background 0.1s, border-color 0.1s;
}
.pin-key:hover { background: var(--bg-4); border-color: var(--line-hi); }
.pin-key:active { background: var(--red); border-color: var(--red); }
.pin-err { color: var(--red); font-size: 13px; text-align: center; min-height: 20px; margin-top: 12px; }

/* ------- espace admin ------- */

.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.admin-tab {
  padding: 10px 14px;
  font-family: var(--cond);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--txt-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.admin-tab:hover { color: var(--txt-2); }
.admin-tab.is-active { color: var(--txt); border-bottom-color: var(--red); }

.admin-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
}
.admin-row:last-child { border-bottom: 0; }
.admin-row .handle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
}
.admin-row .handle button {
  width: 22px;
  height: 16px;
  display: grid;
  place-items: center;
  color: var(--txt-3);
  border-radius: 3px;
}
.admin-row .handle button:hover { color: var(--txt); background: var(--bg-4); }
.admin-row .grow { flex: 1; min-width: 0; display: block; }
.admin-row .name {
  display: block;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-row .sub { display: block; font-size: 11.5px; color: var(--txt-3); letter-spacing: 0.04em; }
.admin-row .acts { display: flex; gap: 5px; flex: 0 0 auto; }
/* contenu masque : la ligne reste lisible mais visiblement en retrait */
.admin-row.is-hidden .thumb,
.admin-row.is-hidden .avatar { opacity: 0.4; }
.admin-row.is-hidden .name { color: var(--txt-3); }
.admin-row.is-hidden .name .tag { color: var(--txt-3); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--bg-4);
  border: 1px solid var(--line);
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--txt-3);
}
.tag.red { color: var(--red); border-color: var(--red-dim); background: rgba(229, 56, 59, 0.08); }

.thumbs-edit { display: flex; flex-wrap: wrap; gap: 9px; }
.thumbs-edit figure {
  position: relative;
  margin: 0;
  width: 92px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg);
}
.thumbs-edit img { width: 100%; height: 72px; object-fit: cover; }
.thumbs-edit button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: rgba(7, 8, 10, 0.85);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--red);
}

.drop {
  border: 1px dashed var(--line-hi);
  border-radius: var(--r);
  padding: 20px;
  text-align: center;
  color: var(--txt-3);
  font-size: 13.5px;
  transition: border-color 0.12s, background 0.12s;
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--red); background: rgba(229, 56, 59, 0.05); color: var(--txt-2); }

/* ------- notification breve ------- */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 400;
  padding: 11px 17px;
  border-radius: var(--r);
  border: 1px solid var(--line-hi);
  background: rgba(20, 24, 30, 0.97);
  font-size: 14px;
  animation: rise 0.18s ease;
  max-width: calc(100vw - 32px);
}
.toast.err { border-color: var(--red); color: #ffd7d8; }

/* ------- lecteur QR ------- */

.qr-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  max-width: 560px;
}
.qr-stage video { width: 100%; height: 100%; object-fit: cover; }
.qr-reticle {
  position: absolute;
  inset: 16%;
  border: 2px solid rgba(229, 56, 59, 0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(6, 7, 10, 0.55);
}

/* =======================================================================
   Mobile
   ======================================================================= */

@media (max-width: 899px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }

  .topbar-brand { display: flex; }
  .crumb { display: none; }
  .search-trigger { min-width: 0; padding: 0; width: 36px; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }

  #topbar {
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--top-h) + env(safe-area-inset-top));
  }

  #view {
    padding: 20px 14px calc(var(--tab-h) + env(safe-area-inset-bottom) + 30px);
  }

  #tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: rgba(11, 12, 15, 0.94);
    backdrop-filter: blur(12px);
  }
  .tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--txt-3);
    font-family: var(--cond);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: color 0.12s;
  }
  .tab.is-active { color: var(--txt); }
  .tab.is-active .ic { color: var(--red); }
  .tab.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24%;
    right: 24%;
    height: 2px;
    background: var(--red);
    border-radius: 0 0 2px 2px;
  }

  .install { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); }
  .toast { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); }

  .sheet-panel {
    margin: 0;
    width: 100%;
    max-height: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .sheet-search { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .sheet-hint { display: none; }

  .ast-grid { grid-template-columns: 1fr 1fr; }
  .ast-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ast-name { font-size: 18px; }
  .ast-sub { grid-template-columns: 1fr; gap: 7px; }
  .ast-sub-vals { gap: 6px 16px; }

  .row-2 { grid-template-columns: 1fr; }
  .quick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .tile { min-height: 96px; padding: 13px; }
  .tile-title { font-size: 15px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .gal { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 9px; }
  .thumb { width: 62px; height: 44px; }
  .viewer-nav { display: none; }
  .modal-panel { width: 100%; }
}

@media (max-width: 380px) {
  .tab { font-size: 10px; letter-spacing: 0.04em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* impression d'une fiche protocole */
@media print {
  #sidebar, #topbar, #tabbar, .install, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  #view { padding: 0; }
}
