/* Éléments communs au Bureau BRVM et à la page Fiabilité :
   en-tête fixe, menu déroulant des rubriques, bouton flottant vers l'assistant,
   et passage des tableaux en cartes sur téléphone. Utilise les couleurs (variables) de chaque page. */

/* Rien ne doit jamais dépasser de l'écran */
html, body { max-width: 100%; overflow-x: clip; }
p, li, dd, td, .detail, .what { overflow-wrap: anywhere; }
img, canvas, svg { max-width: 100%; }

/* ---------- en-tête ---------- */
html { scroll-padding-top: 80px; }

.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, calc((100% - 1180px) / 2 + 16px)); background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); min-width: 0; flex: 1; }
.brand .mark { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--surface); }
.brand .mark svg { width: 20px; height: 20px; }
.brand b { display: block; font-size: 15px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.brand small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > span:last-child { min-width: 0; }

.menu { position: relative; flex: none; }
.menu-btn { font: inherit; font-size: 14px; font-weight: 700; color: var(--fg); display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.menu-btn:hover { border-color: var(--accent); }
.menu-btn .cur { color: var(--accent); max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn svg { width: 16px; height: 16px; transition: transform .18s; }
.menu-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu-btn:focus-visible, .menu-panel a:focus-visible, .fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(340px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  display: grid; gap: 2px; transform-origin: top right; animation: menu-in .16s ease-out; }
[hidden] { display: none !important; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-panel .grp { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; margin: 0; }
.menu-panel a { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 2px 10px; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: var(--fg); }
.menu-panel a:hover { background: var(--sunken); }
.menu-panel a[aria-current="true"] { background: var(--accent-soft); }
.menu-panel a .ic { grid-row: span 2; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--sunken); color: var(--accent); }
.menu-panel a[aria-current="true"] .ic { background: var(--accent); color: var(--surface); }
.menu-panel a .ic svg { width: 18px; height: 18px; }
.menu-panel a b { font-size: 14.5px; font-weight: 700; }
.menu-panel a small { font-size: 12.5px; color: var(--muted); }
.menu-scrim { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .25); }
@media (max-width: 720px) {
  .menu { position: static; }
  .menu-panel { left: 12px; right: 12px; width: auto; top: calc(100% + 6px); transform-origin: top center; }
}

/* ---------- bouton flottant ---------- */
.fab { position: fixed; z-index: 25; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 18px; border-radius: 28px; text-decoration: none;
  background: var(--accent); color: var(--surface); font-weight: 800; font-size: 15px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 6px rgba(0, 0, 0, .25);
  transition: padding .2s ease, gap .2s ease, transform .15s ease; }
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(.97); }
.fab svg { width: 24px; height: 24px; flex: none; }
.fab .lbl { overflow: hidden; white-space: nowrap; max-width: 160px; transition: max-width .2s ease, opacity .2s ease; }
.fab.small { padding: 0 16px; gap: 0; }
.fab.small .lbl { max-width: 0; opacity: 0; }
.fab .dot { position: absolute; top: 9px; right: 11px; width: 9px; height: 9px; border-radius: 50%; background: #ffd166; box-shadow: 0 0 0 2px var(--accent); }
.fab.small .dot { right: 9px; }
@media (prefers-reduced-motion: reduce) { .fab, .fab .lbl, .menu-panel, .menu-btn svg { transition: none; animation: none; } }

/* ---------- tableaux -> cartes sur téléphone ---------- */
@media (max-width: 720px) {
  body .table-scroll { overflow: visible; max-height: none !important; border: 0; background: transparent; display: grid; gap: 10px; }
  body .table-scroll table, .table-scroll tbody { display: grid; gap: 10px; }
  body .table-scroll thead { display: none; }
  body .table-scroll tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  body .table-scroll td { display: grid; gap: 2px; padding: 0; border: 0; white-space: normal; text-align: left !important; align-content: start; }
  body .table-scroll td::before { content: attr(data-l); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
  body .table-scroll td:first-child { grid-column: 1 / -1; }
  body .table-scroll td:first-child::before, .table-scroll td[data-l=""]::before, .table-scroll td[colspan]::before { display: none; }
  body .table-scroll td[colspan] { grid-column: 1 / -1; }
  body .wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important; }
}
