/* ui.css — composants partagés du GUI (une définition par composant).
   Charger tokens.css avant. Les classes historiques (.btn-primary, .badge-green, .stat.green,
   .tab, .modal-overlay…) sont conservées : elles s'appuient désormais sur les tokens. */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: var(--fs-md)/var(--lh) var(--font);
       min-height: 100dvh; padding-bottom: calc(var(--bottom-inset, 0px) + var(--hit) + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; display: inline-block; vertical-align: middle; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

/* ── Nav ── */
nav, .nav { background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 var(--s-5); display: flex; align-items: center; gap: var(--s-6); height: var(--nav-h);
  position: sticky; top: 0; z-index: var(--z-sticky); }
nav a { color: var(--muted); text-decoration: none; font-size: var(--fs-md); white-space: nowrap;
        padding: var(--s-2) 0; border-bottom: 2px solid transparent;
        transition: color var(--d-fast), border-color var(--d-fast); }
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-bottom-color: var(--accent); }
nav .brand { color: var(--accent); font-weight: 700; font-size: var(--fs-lg); }
nav .brand a { color: inherit; border: none; padding: 0; }
nav .nav-highlight { color: var(--brand-2); }
.nav__links { display: flex; align-items: center; gap: var(--s-6); min-width: 0;
              overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; flex: 1; }
.nav__links::-webkit-scrollbar { display: none; }
.nav__links a { scroll-snap-align: start; }
.nav__tools { display: flex; align-items: center; gap: var(--s-1); margin-left: auto; flex-shrink: 0; }
.nav-icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; position: relative;
  min-width: var(--hit-sm); min-height: var(--hit-sm); display: inline-flex; align-items: center;
  justify-content: center; border-radius: var(--r-md); transition: color var(--d-fast), background var(--d-fast); }
.nav-icon-btn:hover { color: var(--text); background: var(--hover); }
.nav-cloche { background: none; border: none; color: var(--muted); cursor: pointer; position: relative;
  min-width: var(--hit-sm); min-height: var(--hit-sm); display: inline-flex; align-items: center;
  justify-content: center; border-radius: var(--r-md); }
.nav-cloche:hover { color: var(--text); background: var(--hover); }
.cloche-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1;
  animation: pop var(--d-slow) var(--e-spring); }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }
@media (max-width: 900px) {
  nav, .nav { padding: 0 var(--s-3); gap: var(--s-3); }
  .nav__links { gap: var(--s-4); }
  nav a { font-size: var(--fs-sm); min-height: var(--hit); display: inline-flex; align-items: center; }
}

/* ── Layout ── */
.container { max-width: 1400px; margin: 0 auto; padding: var(--s-5); }
h1 { font-size: var(--fs-2xl); font-weight: 700; margin-bottom: var(--s-1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-lg); font-weight: 700; }
h3 { font-size: var(--fs-md); font-weight: 600; }
.subtitle { color: var(--muted); font-size: var(--fs-md); margin-bottom: var(--s-5); }
.row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.num { font-variant-numeric: tabular-nums; }
.mono, .fname-mono { font-family: var(--mono); font-size: var(--fs-xs); word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) { .container { padding: var(--s-4) var(--s-3); } }

/* ── Boutons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--hit-sm); padding: 0 var(--s-4); border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; font-size: var(--fs-sm); font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text); text-decoration: none; position: relative;
  transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast),
              transform var(--d-fast), box-shadow var(--d-fast); }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; transform: none; }
.btn-primary, .btn-accent, .btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover, .btn-accent:hover, .btn--primary:hover { background: var(--accent-hover); }
.btn-outline, .btn--outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover, .btn--outline:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-ghost, .btn--ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover, .btn--ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger, .btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover, .btn--danger:hover { background: var(--danger-soft); }
.btn--ok { background: var(--ok); color: #fff; } .btn--ok:hover { filter: brightness(1.1); }
.btn--warn { background: var(--warn); color: #fff; } .btn--warn:hover { filter: brightness(1.1); }
.btn-sm, .btn--sm { min-height: 28px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn--icon { padding: 0; width: var(--hit-sm); }
.btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  color: var(--text); animation: spin .7s linear infinite; }
.btn-primary[aria-busy="true"]::after, .btn--primary[aria-busy="true"]::after { color: var(--accent-fg); }
@media (pointer: coarse) {
  .btn, .tab, .pdf-btn, select, input:not([type=checkbox]):not([type=radio]) { min-height: var(--hit); }
  .btn-sm, .btn--sm { min-height: 36px; }
  .btn-sm::before, .btn--sm::before { content: ""; position: absolute; inset: -4px; }
}

/* ── Stats / KPI ── */
.stats { display: flex; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
        padding: var(--s-3) var(--s-5); min-width: 120px; flex: 1 1 120px;
        transition: border-color var(--d-fast), box-shadow var(--d-fast); }
.stat:hover { border-color: var(--border-strong); }
.stat .val { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: var(--lh-tight); }
.stat .lbl { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.stat .stat__delta { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-1); }
.stat.green .val, .stat--ok .val { color: var(--ok); }
.stat.yellow .val, .stat--warn .val { color: var(--warn); }
.stat.blue .val, .stat--info .val { color: var(--info); }
.stat.red .val, .stat--danger .val { color: var(--danger); }
.stat.orange .val { color: var(--orange); }
.stat.gray .val, .stat--muted .val { color: var(--muted); }
.stat.purple .val, .stat--brand .val { color: var(--brand-2); }
.stat.accent .val { background: linear-gradient(135deg, var(--accent), var(--brand-2));
                    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
@media (max-width: 600px) { .stats { gap: var(--s-2); } .stat { padding: var(--s-2) var(--s-3); min-width: 0; flex-basis: calc(50% - var(--s-2)); } .stat .val { font-size: var(--fs-xl); } }

/* ── Onglets ── */
.tabs { display: flex; gap: var(--s-1); margin-bottom: var(--s-4); border-bottom: 1px solid var(--border);
        overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted);
       font-size: var(--fs-md); padding: var(--s-2) var(--s-3); margin-bottom: -1px; white-space: nowrap;
       scroll-snap-align: start; min-height: var(--hit-sm);
       transition: color var(--d-fast), border-color var(--d-base) var(--e-out); }
.tab:hover { color: var(--text); }
.tab.active, .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .n, .tabs__n { font-size: var(--fs-xs); opacity: .8; font-variant-numeric: tabular-nums; margin-left: 2px; }

/* ── Recherche / formulaires ── */
.search-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
                padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4);
                display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.search-wrap { flex: 1; min-width: 220px; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: .6rem; width: 16px; height: 16px; color: var(--muted); pointer-events: none; z-index: 1; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-md); padding: .4rem .6rem; font-size: var(--fs-sm); min-height: var(--hit-sm);
  transition: border-color var(--d-fast), box-shadow var(--d-fast); }
.search-wrap > input:not([type=checkbox]):not([type=radio]):not([type=range]) { width: 100%; padding-left: 2.4rem; padding-right: 2rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
textarea { resize: vertical; min-height: 80px; line-height: var(--lh); }
label { font-size: var(--fs-sm); color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: var(--s-1); }
.field > label { font-size: var(--fs-xs); color: var(--muted); }
.field__hint { font-size: var(--fs-xs); color: var(--muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger); }
.date-group { display: flex; align-items: center; gap: .4rem; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); flex-wrap: wrap; align-items: center; }

/* ── Cartes ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4);
        transition: border-color var(--d-fast), box-shadow var(--d-fast), transform var(--d-fast); }
.card--interactive { cursor: pointer; }
.card--interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.card--accent-left { border-left: 3px solid var(--accent); }
.banner { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid; font-size: var(--fs-sm); }
.banner--info { background: var(--info-soft); color: var(--info-fg); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner--warn { background: var(--warn-soft); color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner--danger { background: var(--danger-soft); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
     padding: .625rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap;
     position: sticky; top: 0; z-index: 1; }
td { padding: .625rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--d-fast); }
tbody tr:hover td { background: var(--hover); }
tr.previewing td, tr.selected td { background: var(--selected); }
.table--dense th, .table--dense td { padding: .4rem .6rem; }
tr.is-entering { animation: row-in var(--d-base) var(--e-out); }
tr.is-leaving { animation: row-out var(--d-base) var(--e-in-out) forwards; }
tr.flash td { animation: flash 600ms var(--e-out); }
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes row-out { to { opacity: 0; transform: translateX(8px); } }
@keyframes flash { 0% { background: var(--accent-soft); } }
@media (max-width: 600px) {
  .table--cards thead { display: none; }
  .table--cards tr { display: block; border-bottom: 1px solid var(--border); padding: var(--s-2) 0; }
  .table--cards td { display: flex; gap: var(--s-3); border: none; padding: .25rem 1rem; }
  .table--cards td::before { content: attr(data-th); color: var(--muted); font-size: var(--fs-xs);
                             text-transform: uppercase; letter-spacing: .06em; min-width: 6rem; flex-shrink: 0; }
  .col--secondary { display: none; }
}

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: .3em; font-size: var(--fs-xs); font-weight: 600;
         padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap; line-height: 1.4;
         transition: background var(--d-fast), color var(--d-fast); }
.badge-green, .badge--ok { background: var(--ok-soft); color: var(--ok-fg); }
.badge-yellow, .badge--warn { background: var(--warn-soft); color: var(--warn-fg); }
.badge-red, .badge--danger { background: var(--danger-soft); color: var(--danger-fg); }
.badge-blue, .badge--info { background: var(--info-soft); color: var(--info-fg); }
.badge-gray, .badge--muted { background: var(--surface-2); color: var(--muted); }
.badge-purple, .badge--brand { background: var(--brand-2-soft); color: var(--brand-2-fg); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── États ── */
.empty { padding: var(--s-8) var(--s-4); text-align: center; color: var(--muted); }
.empty__title { font-weight: 600; color: var(--text-2); margin-bottom: var(--s-1); }
.error { padding: var(--s-4); text-align: center; color: var(--danger-fg); background: var(--danger-soft);
         border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s-2); align-items: center; }
.spin { display: none; animation: spin .7s linear infinite; }
.spinning .spin { display: inline-block; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong);
           border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
            background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-sm); min-height: 1em; }
.skeleton--line { height: .9em; margin: .3em 0; }
.skeleton--block { height: 6rem; }
@keyframes shimmer { to { background-position: -200% 0; } }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
            margin-right: .4rem; vertical-align: middle; animation: pulse-live 2s ease-in-out infinite; }
@keyframes pulse-live { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Progression ── */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress > .progress__fill, .progress::before { content: ""; display: block; height: 100%; background: var(--accent);
  border-radius: inherit; width: calc(var(--value, 0) * 1%); transition: width 400ms var(--e-out); }
.progress--ok::before, .progress--ok > .progress__fill { background: var(--ok); }
.progress--indeterminate::before { width: 40%; animation: indeterminate 1.4s var(--e-in-out) infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.bar { height: 8px; background: var(--color, var(--serie-1)); border-radius: var(--r-sm);
       width: calc(var(--value, 0) * 1%); transition: width 400ms var(--e-out); }

/* ── Modales et tiroirs ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: var(--backdrop); z-index: var(--z-modal);
                 align-items: center; justify-content: center; padding: var(--s-4); }
.modal-overlay.open { display: flex; animation: fade-in var(--d-base) var(--e-out); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5);
         width: 100%; max-width: 480px; box-shadow: var(--shadow-3); max-height: 90dvh; overflow: auto; }
.modal-overlay.open .modal { animation: modal-in var(--d-base) var(--e-out); }
.modal h2 { font-size: var(--fs-xl); margin-bottom: var(--s-4); }
.modal label { display: block; font-size: var(--fs-xs); color: var(--muted); margin: var(--s-3) 0 var(--s-1); }
.modal input, .modal select, .modal textarea { width: 100%; }
.modal-footer { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-5); flex-wrap: wrap; }
.modal-erreur { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--s-2); min-height: 1.2em; }
dialog.modal, dialog.drawer { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
dialog.modal { margin: auto; }
dialog::backdrop { background: var(--backdrop); animation: fade-in var(--d-base) var(--e-out); }
dialog[open].modal { animation: modal-in var(--d-base) var(--e-out); }
dialog.drawer { position: fixed; inset: 0 0 0 auto; height: 100dvh; max-height: none; width: min(420px, 92vw);
                margin: 0; padding: 0; border-radius: 0; display: flex; flex-direction: column;
                box-shadow: var(--shadow-3); }
dialog.drawer--md { width: min(560px, 92vw); }
dialog[open].drawer { animation: drawer-in var(--d-slow) var(--e-out); }
@media (max-width: 900px) { dialog.drawer, dialog.drawer--md { width: 100vw; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: scale(.98) translateY(6px); } }
@keyframes drawer-in { from { transform: translateX(100%); } }

/* ── Toasts (remplacent alert) ── */
.toasts { position: fixed; bottom: calc(var(--s-4) + var(--bd-h, calc(var(--hit) + env(safe-area-inset-bottom)))); right: var(--s-4); z-index: var(--z-toast);
          display: flex; flex-direction: column; gap: var(--s-2); max-width: min(420px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border);
         border-left: 3px solid var(--info); border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
         box-shadow: var(--shadow-2); display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm);
         animation: toast-in var(--d-slow) var(--e-spring); }
.toast--ok { border-left-color: var(--ok); } .toast--warn { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }
.toast.is-leaving { animation: toast-out var(--d-base) var(--e-in-out) forwards; }
.toast__msg { flex: 1; }
.toast__action { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: var(--s-1) var(--s-2); }
.toast__close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 var(--s-1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 600px) { .toasts { right: var(--s-3); left: var(--s-3); max-width: none; } }

/* ── Zone fixe basse (batch, job, FAB empilés) ── */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: var(--bd-h, calc(var(--hit) + env(safe-area-inset-bottom)));
              z-index: var(--z-bar); display: flex; flex-direction: column; pointer-events: none;
              transition: bottom var(--d-slow) var(--e-out); }
.bottom-bar > * { pointer-events: auto; }

/* ── Timeline (« métro ») : verticale par défaut, horizontale sur grand écran ── */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 0; position: relative; padding-left: var(--s-5); }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--border-strong); }
.timeline__step { position: relative; padding: var(--s-2) 0 var(--s-3); }
.timeline__step::before { content: ""; position: absolute; left: calc(-1 * var(--s-5) + 2px); top: .8rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); transition: border-color var(--d-base), background var(--d-base); }
.timeline__step--ok::before { border-color: var(--ok); background: var(--ok); }
.timeline__step--warn::before { border-color: var(--warn); background: var(--warn); }
.timeline__step--danger::before { border-color: var(--danger); background: var(--danger); }
.timeline__step--current::before { box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.timeline__date { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline__label { font-weight: 600; }
@media (min-width: 900px) {
  .timeline--h { flex-direction: row; padding-left: 0; padding-top: var(--s-5); }
  .timeline--h::before { left: 8px; right: 8px; top: 7px; bottom: auto; height: 2px; width: auto; }
  .timeline--h .timeline__step { flex: 1; padding: var(--s-2) var(--s-2) 0 0; }
  .timeline--h .timeline__step::before { left: 2px; top: calc(-1 * var(--s-5) + 1px); }
}

/* ── Cloche + tiroir alertes ── */
.alert-drawer { position: fixed; top: var(--nav-h); right: 0; bottom: 0; width: min(420px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border); transform: translateX(100%);
  transition: transform var(--d-slow) var(--e-out); z-index: var(--z-drawer); display: flex; flex-direction: column;
  box-shadow: var(--shadow-3); visibility: hidden; }
.alert-drawer.open { transform: translateX(0); visibility: visible; }
.ad-head { display: flex; align-items: center; gap: var(--s-2); padding: .6rem .875rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ad-titre { font-weight: 700; font-size: var(--fs-md); }
.ad-onglet { background: none; border: none; color: var(--muted); cursor: pointer; font-size: var(--fs-sm);
             padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); min-height: 32px; }
.ad-onglet.actif { color: var(--text); background: var(--surface-2); font-weight: 600; }
.ad-onglet:hover:not(.actif) { color: var(--text); }
.ad-fermer { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem;
             padding: .2rem .4rem; border-radius: var(--r-sm); min-width: var(--hit-sm); min-height: var(--hit-sm); }
.ad-fermer:hover { color: var(--text); background: var(--hover); }
.ad-corps { flex: 1; overflow-y: auto; padding: var(--s-2); }
.ad-carte { padding: .6rem .75rem; border-radius: var(--r-md); border-left: 3px solid var(--border);
            background: var(--bg); margin-bottom: .4rem; position: relative; transition: opacity var(--d-base);
            animation: row-in var(--d-base) var(--e-out); }
.ad-carte.urgent { border-left-color: var(--danger); }
.ad-carte.attention { border-left-color: var(--warn); }
.ad-carte.info { border-left-color: var(--info); }
.ad-carte .ad-lib { font-size: var(--fs-sm); line-height: 1.35; padding-right: var(--s-6); }
.ad-carte .ad-meta { display: flex; gap: var(--s-2); align-items: center; margin-top: .3rem; font-size: var(--fs-xs); color: var(--muted); flex-wrap: wrap; }
.ad-niv { font-size: var(--fs-xs); padding: .08rem .4rem; border-radius: var(--r-pill); font-weight: 600; }
.ad-niv-urgent { background: var(--danger-soft); color: var(--danger-fg); }
.ad-niv-attention { background: var(--warn-soft); color: var(--warn-fg); }
.ad-niv-info { background: var(--info-soft); color: var(--info-fg); }
.ad-carte .ad-arch { position: absolute; top: .35rem; right: .35rem; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: var(--fs-sm); min-width: 32px; min-height: 32px; border-radius: var(--r-sm); opacity: .55;
  transition: opacity var(--d-fast), background var(--d-fast); }
.ad-carte:hover .ad-arch, .ad-carte .ad-arch:focus-visible { opacity: 1; }
.ad-carte .ad-arch:hover { color: var(--text); background: var(--hover); }
.ad-vide { text-align: center; color: var(--muted); padding: var(--s-6) var(--s-2); font-size: var(--fs-sm); }

/* ── Visionneuse (panneau latéral partagé) ── */
.pdf-panel { position: fixed; top: var(--nav-h); right: 0; bottom: 0; width: var(--panel-w);
  background: var(--surface); border-left: 1px solid var(--border); transform: translateX(100%);
  transition: transform var(--d-slow) var(--e-out); z-index: var(--z-panel); overflow: auto; box-shadow: var(--shadow-3); }
.pdf-panel.open { transform: translateX(0); }
.pdf-head { position: sticky; top: 0; z-index: 2; height: 60px; display: flex; align-items: center; gap: var(--s-2);
            padding: 0 .875rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.pdf-title { flex: 1; font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600; color: var(--text);
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pdf-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: .3rem .6rem;
           font-size: var(--fs-xs); border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; text-decoration: none;
           display: inline-flex; align-items: center; flex-shrink: 0; min-height: 28px;
           transition: border-color var(--d-fast), color var(--d-fast); }
.pdf-btn:hover { border-color: var(--accent); color: var(--accent); }
.pdf-zoom-val { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; flex-shrink: 0; }
.pdf-close { background: transparent; border: none; color: var(--muted); font-size: 1rem; cursor: pointer;
             padding: .25rem .45rem; border-radius: var(--r-sm); flex-shrink: 0; min-width: var(--hit-sm); min-height: var(--hit-sm); }
.pdf-close:hover { color: var(--text); background: var(--hover); }
#pdf-frame { width: 100%; height: calc(100% - 60px); border: none; display: block; background: var(--bg);
             transform-origin: top left; transition: transform var(--d-fast) ease, opacity var(--d-fast) ease; }
#pdf-frame.md-mode { background: #fff; color-scheme: light; }
#preview-img { width: 100%; height: calc(100% - 60px); object-fit: contain; display: none; background: var(--bg);
               padding: .5rem; transition: opacity var(--d-fast) ease; }
.zoom-controls { display: flex; align-items: center; gap: var(--s-2); }
@keyframes vis-pulse { 0%, 100% { background: var(--surface); } 50% { background: var(--accent-soft); } }
.vis-goto-row { display: none; position: fixed; right: var(--panel-w); top: 50%; transform: translateY(-50%);
  z-index: calc(var(--z-panel) + 1); width: 28px; height: 48px; border-radius: 6px 0 0 6px; border: 1px solid var(--border);
  border-right: none; background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; line-height: 0;
  transition: color var(--d-fast); animation: vis-pulse 2.5s ease-in-out infinite; }
.vis-goto-row:hover { color: var(--accent); }
.vis-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: calc(var(--z-panel) + 2); background: var(--surface);
           color: var(--accent); border: 2px solid var(--accent); font-size: 2rem; font-weight: 700; line-height: 1;
           padding: .7rem .5rem; cursor: pointer; border-radius: var(--r-md); display: none; box-shadow: var(--shadow-2);
           transition: background var(--d-fast), color var(--d-fast); }
.vis-nav.visible { display: block; }
.vis-nav.visible:hover { background: var(--accent); color: var(--accent-fg); }
.vis-nav:disabled { display: none !important; }
.vis-nav-prev { left: 10px; right: auto; }
.vis-nav-next { right: 10px; }
@media (max-width: 900px) {
  .pdf-panel { width: 100%; top: 0; z-index: var(--z-lightbox); box-shadow: none; }
  .vis-goto-row { display: none !important; }
}

/* ── Tiroir bas des tâches (global) : fermé, seule la poignée de 44 px dépasse ── */
.bottom-drawer { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tray);
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(calc(100% - var(--hit) - env(safe-area-inset-bottom, 0px)));
  transition: transform var(--d-slow) var(--e-out); }
.bottom-drawer.is-open { transform: translateY(0); }
.bottom-drawer > * { pointer-events: auto; }
.bottom-drawer__poignee { position: relative; height: var(--hit); min-width: 72px; padding: 0 var(--s-4);
  display: flex; align-items: center; justify-content: center; gap: var(--s-2); cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0; box-shadow: var(--shadow-2); }
.bottom-drawer__poignee:hover { color: var(--text); }
.bottom-drawer__chevron { transition: transform var(--d-base) var(--e-out); }
.bottom-drawer.is-open .bottom-drawer__chevron { transform: rotate(180deg); }
.bottom-drawer__point { width: 8px; height: 8px; border-radius: 50%; background: var(--disabled); }
/* Le point ne pulse QUE sous .is-active (posée par le JS quand une tâche tourne). */
.bottom-drawer__point.is-active { background: var(--accent); animation: bd-pulse 1.8s ease-in-out infinite; }
@keyframes bd-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
                      50% { opacity: .5; box-shadow: 0 0 0 5px transparent; } }
.bottom-drawer__badge { position: absolute; top: 4px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-fg); font-size: var(--fs-xs); font-weight: 700; line-height: 1; }
.bottom-drawer__corps { width: 100%; max-height: min(50vh, 480px); display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-3); }
.bottom-drawer__tete { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-5);
  border-bottom: 1px solid var(--border); }
.bottom-drawer__titre { font-weight: 600; flex: 1; }
.bottom-drawer__liste { overflow: auto; padding: var(--s-3) var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.bd-vide { color: var(--muted); font-size: var(--fs-sm); }
.bd-tache { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2); background: var(--bg); }
.bd-tache--en_cours { border-color: var(--accent); }
.bd-tache--erreur, .bd-tache--interrompu { border-color: var(--warn); }
.bd-tache__tete { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.bd-tache__libelle { font-weight: 600; flex: 1; min-width: 12rem; }
.bd-tache__etat { font-size: var(--fs-sm); color: var(--muted); }
.bd-tache--en_cours .bd-tache__etat { color: var(--accent); }
.bd-tache--erreur .bd-tache__etat, .bd-tache--interrompu .bd-tache__etat { color: var(--warn); }
.bd-tache--termine .bd-tache__etat { color: var(--ok); }
.bd-tache__actions { display: flex; gap: var(--s-2); margin-left: auto; }
.bd-tache__chiffres { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted);
  font-variant-numeric: tabular-nums; }
.bd-err { color: var(--danger); }
.bd-details { list-style: none; max-height: 200px; overflow: auto; border-top: 1px solid var(--border);
  padding-top: var(--s-2); font-size: var(--fs-xs); font-family: var(--mono); }
.bd-res { display: grid; grid-template-columns: minmax(6rem, 1fr) 4.5rem 2fr; gap: var(--s-3); padding: 2px 0; }
.bd-res__cle, .bd-res__detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-res--ok .bd-res__statut { color: var(--ok); }
.bd-res--ignore .bd-res__statut { color: var(--muted); }
.bd-res--erreur .bd-res__statut { color: var(--danger); }
@media (max-width: 600px) { .bottom-drawer__liste { padding: var(--s-3); } .bd-res { grid-template-columns: 1fr 4rem; } .bd-res__detail { grid-column: 1 / -1; } }

/* ── Bascule de thème ── */
.theme-toggle .ico { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-dark { display: inline; }
:root[data-theme="light"] .theme-toggle .ico-light { display: inline; }
:root:not([data-theme]) .theme-toggle .ico-auto { display: inline; }
