/* Feuille de style commune : administration centrale et environnements clients.
   Aucun style n'est écrit dans les pages elles-mêmes. */

:root {
  color-scheme: light;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --line: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #3355dd;
  --accent-strong: #2742b8;
  --accent-soft: #edf1ff;
  --danger: #b42318;
  --ok: #18794e;
  --warn: #b25e09;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 1px 3px rgb(16 24 40 / 6%);
  --sidebar: 16.5rem;
}

* { box-sizing: border-box; }
/* Un élément masqué le reste, quel que soit son style d'affichage. */
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5; color: var(--text); background: var(--bg); }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 1.25rem; }
h2 { font-size: 1rem; font-weight: 650; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .95em; word-break: break-all; background: var(--bg); padding: .1rem .3rem; border-radius: 4px; }

/* --- Structure ----------------------------------------------------------- */

/* Page seule : connexion, activation, messages, administration centrale. */
body.bare { padding: 3rem 1rem; }
.sheet { max-width: 30rem; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; }
.sheet:has(table) { max-width: 68rem; }
.sheet > nav { margin: -.5rem 0 1.25rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.sheet .card { border: 0; padding: 0; margin: 1.5rem 0 0; max-width: none; }

/* Application : menu à gauche, contenu à droite. */
body.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem .9rem; background: linear-gradient(180deg, #ffffff, #f8f9ff); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .6rem; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand::before { content: ""; width: 1.6rem; height: 1.6rem; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #7c8cf8); flex: none; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu.end { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.menu h2 { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .35rem; padding: 0 .6rem; }
.menu a, .menu .locked { display: block; padding: .45rem .6rem; border-radius: 8px; color: #344054; font-weight: 500; }
.menu a:hover { background: var(--bg); text-decoration: none; }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 3px 0 0 var(--accent); }
.menu a.sub { padding-left: 1.6rem; font-weight: 400; font-size: .95em; }
.menu .locked { color: #98a2b3; cursor: not-allowed; }
.menu .locked::after { content: "accès fermé"; float: right; font-size: .72rem; font-weight: 400; }
.content { padding: 2rem 2.5rem 4rem; max-width: 88rem; width: 100%; }

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: flex-start; border-right: 0; border-bottom: 1px solid var(--line); }
  .menu.end { margin-top: 0; padding-top: 0; border-top: 0; }
  .content { padding: 1.25rem 1rem 3rem; }
}

/* --- Éléments ------------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; max-width: 42rem; }
.card.danger { border-color: #fecdca; }
.card.danger h2 { color: var(--danger); }
.card:has(table), .card.wide { max-width: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.cards .card { margin: 0; max-width: none; display: flex; flex-direction: column; gap: .35rem; }
.cards .card.locked { background: transparent; border-style: dashed; color: var(--muted); }
.cards .card p { margin: 0; }
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem 1.6rem; margin: 0 0 1.5rem; }
.hero h2 { font-size: 1.15rem; }
.hero textarea { margin: 0 0 .75rem; }
h2.group { margin: 1.75rem 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.muted { color: var(--muted); }
.ok { color: var(--ok); }
.ko, .error { color: var(--danger); }
p.error { background: #fef3f2; border: 1px solid #fecdca; border-radius: 8px; padding: .6rem .8rem; }
p.warning { color: #93370d; background: #fffaeb; border: 1px solid #fedf89; border-radius: 8px; padding: .6rem .8rem; }

table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 0 0 1.25rem; }
tbody tr:hover td { background: #fafbff; }
.card table { box-shadow: none; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form.inline, td.actions a.button { margin: 0 0 0 .35rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
.card table { border: 0; border-radius: 0; margin: 0; }
.card th { background: transparent; }

label { display: block; margin: .9rem 0; font-weight: 500; font-size: .93rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select { display: block; width: 100%; margin-top: .35rem; padding: .55rem .7rem; font: inherit; color: inherit; background: var(--surface); border: 1px solid #d0d5dd; border-radius: 8px; }
select { width: auto; display: inline-block; margin-top: 0; padding: .4rem .5rem; }
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

button, a.button { display: inline-block; font: inherit; font-weight: 550; padding: .55rem 1rem; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s; }
button:hover, a.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
.files-path { margin: 0 0 .75rem; }
.files-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 1rem; }
.files-bar form.inline, .files-bar a.button { margin: 0; }
a.folder::before { content: "▸ "; color: var(--muted); }

/* Onglet Documents : liste tenue à jour par son script. */
.docs { position: relative; }
.docs-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0 0 1rem; }
.docs-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; font-weight: 550; margin-right: auto; }
.docs-crumbs a { padding: .2rem .45rem; border-radius: 6px; color: var(--muted); }
.docs-crumbs a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.docs-crumbs a[aria-current] { color: var(--text); }
.docs-sep { color: #c0c5d0; }
.docs input.docs-filter { width: 14rem; max-width: 100%; margin: 0; padding: .35rem .7rem; }
.docs-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.docs-actions .button, .docs-actions button { margin: 0; }
.docs label.docs-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.docs label.docs-primary:hover { background: var(--accent-strong); }
.docs-drop { transition: opacity .15s; min-height: 6rem; }
.docs-drop[aria-busy] { opacity: .55; }
.docs-table { table-layout: fixed; }
.docs-table th { padding-top: 0; }
.docs-table td { vertical-align: middle; padding-top: .45rem; padding-bottom: .45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-table tbody tr:hover { background: var(--bg); }
.docs-table .docs-num { width: 6.5rem; text-align: right; color: var(--muted); }
.docs-table .docs-date { width: 11rem; color: var(--muted); }
.docs-table th:last-child, .docs-table td.docs-tools { width: 9rem; text-align: right; text-overflow: clip; }
/* Pendant « Confirmer ? », la confirmation occupe seule la colonne. */
.docs-tools:has([data-armed]) button:not([data-armed]) { display: none; }
.docs-tools button[data-armed]::before { display: none; }
.docs-tools button { margin: 0 0 0 .35rem; opacity: 0; transition: opacity .1s; }
.docs-table tr:hover .docs-tools button, .docs-tools button:focus-visible, .docs-tools button[data-armed] { opacity: 1; }
@media (hover: none) { .docs-tools button { opacity: 1; } }
button.docs-sort { all: unset; cursor: pointer; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
button.docs-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button.docs-sort[data-way="up"]::after { content: " ↑"; }
button.docs-sort[data-way="down"]::after { content: " ↓"; }
.docs-name { font-weight: 500; }
.docs-icon { display: inline-block; width: 2.1rem; margin-right: .6rem; padding: .22rem 0; border-radius: 5px; background: #667085; color: #fff; font-size: .62rem; font-weight: 700; letter-spacing: .03em; text-align: center; vertical-align: middle; }
.docs-icon.docs-doc { background: #2b6cd9; } .docs-icon.docs-sheet { background: #1f9254; } .docs-icon.docs-slide { background: #d9702b; }
.docs-icon.docs-pdf { background: #d92d20; } .docs-icon.docs-image { background: #7a5af8; } .docs-icon.docs-video { background: #c11574; }
.docs-icon.docs-audio { background: #0e9384; } .docs-icon.docs-web { background: #344054; } .docs-icon.docs-archive { background: #93370d; }
.docs-icon.docs-folder { height: 1.15rem; padding: 0; background: #f5b83d; border-radius: 2px 5px 5px 5px; position: relative; top: .1rem; }
.docs-icon.docs-folder::before { content: ""; position: absolute; left: 0; top: -.28rem; width: .95rem; height: .35rem; background: #f5b83d; border-radius: 3px 3px 0 0; }
.docs input.docs-input { width: min(26rem, 60%); margin: 0; padding: .25rem .5rem; }
.docs-pending { opacity: .45; }
.docs-empty { padding: 2.2rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.docs-over::after { content: "Déposez pour ajouter à ce dossier"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; color: var(--accent); background: rgb(255 255 255 / 88%); border: 2px dashed var(--accent); border-radius: var(--radius); pointer-events: none; }
.docs-uploads { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .35rem; }
.docs-uploads li { display: flex; align-items: center; gap: .75rem; padding: .4rem .7rem; background: var(--bg); border-radius: 8px; font-size: .92em; }
.docs-uploads li.ok { color: var(--ok); } .docs-uploads li.ko { color: var(--danger); }
.docs-uploads li.ok .muted, .docs-uploads li.ko .muted { color: inherit; }
.docs-upload-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24rem; }
.docs-uploads progress { flex: 1; max-width: 16rem; height: .45rem; accent-color: var(--accent); }
.docs-help { margin: 1rem 0 0; font-size: .87em; }
button:disabled { opacity: .55; cursor: progress; }
button.quiet, a.button.quiet { background: var(--surface); color: #344054; border-color: #d0d5dd; font-weight: 500; padding: .35rem .75rem; }
button.quiet:hover, a.button.quiet:hover { background: var(--bg); }
a.button { margin: 0 .5rem .5rem 0; }
form.inline { display: inline-block; margin: 0 .35rem .35rem 0; }
form.inline input[type="text"] { display: inline-block; width: 11rem; margin: 0; padding: .35rem .5rem; }

/* Onglets (espaces, administration) : une ligne de liens, l'onglet courant
   souligné en couleur d'accent. Sur un écran étroit, la ligne défile au lieu
   de se replier. La ligne de base est une ombre : le soulignement passe dessus. */
.tabs { display: flex; gap: .25rem; margin: 0 0 1.5rem; overflow-x: auto; box-shadow: inset 0 -1px 0 var(--line); }
.tabs a { flex: none; padding: .55rem .85rem; border-bottom: 2px solid transparent; color: #344054; font-weight: 500; font-size: .93rem; white-space: nowrap; }
.tabs a:hover { color: var(--accent-strong); border-bottom-color: #d0d5dd; text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* États d'une conversation. */
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 550; background: var(--bg); color: #344054; white-space: nowrap; }
.chip.waiting { background: #fff4e5; color: var(--warn); }
.chip.running { background: var(--accent-soft); color: var(--accent-strong); }
.chip.closed { background: var(--bg); color: var(--muted); }
.chip.ok { background: #e7f6ee; color: var(--ok); }
.chip.ko { background: #fef3f2; color: var(--danger); }
/* Une pastille de couleur devant l'état : il se lit d'un coup d'œil. */
.chip.ok::before, .chip.ko::before, .chip.waiting::before, .chip.running::before { content: ""; display: inline-block; width: .45rem; height: .45rem; margin-right: .4rem; border-radius: 50%; background: currentColor; vertical-align: .08em; }

/* Administration : chiffres clés, barres de titre, journaux. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin: 0 0 1.75rem; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.stats strong { display: block; font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.stats span { color: var(--muted); font-size: .9rem; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .9rem; }
.bar h1, .bar h2, .bar p { margin: 0 auto 0 0; }
.bar h2 .chip { margin-left: .4rem; vertical-align: .1em; }
.bar form.inline, .bar a.button { margin: 0; }
pre.log { margin: 0 0 1.25rem; padding: 1rem 1.1rem; max-height: 70vh; overflow: auto; background: #0f172a; color: #e2e8f0; border-radius: var(--radius); font: .82rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
meter { width: 7rem; height: .45rem; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #912018; border-color: #912018; }

/* Conversation. */
.message { background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: .8rem 1rem; margin: .75rem 0; white-space: pre-wrap; max-width: 48rem; }
.message.user { background: var(--accent-soft); border-color: #d9e0ff; border-radius: 14px 14px 4px 14px; margin-left: auto; width: fit-content; }
.message .sources { display: block; margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--line); white-space: normal; font-size: .87em; color: var(--muted); }
.card .message { background: var(--bg); border: 0; border-radius: 8px; }

/* Un module occupe toute la largeur de l'écran et se fond dans la page :
   son cadre n'a ni bord ni fond, et son propre titre remplace celui de la page. */
iframe.module { display: block; width: 100%; height: 24rem; border: 0; background: transparent; }
.content:has(iframe.module) { max-width: none; }
.content:has(iframe.module) > h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.content .frame-note { margin: 1rem 0 0; font-size: .85em; }
.qr svg { width: 11rem; height: 11rem; }
.cards .card .chip { align-self: flex-start; }
.frame-note { font-size: .85rem; margin: 0 0 .4rem; }
.content form { margin-bottom: .75rem; }

/* Pièces jointes, capture d'écran et annotation. */
.attachments { margin: 0 0 .75rem; }
.thumbs { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 .6rem; }
.thumbs:empty { display: none; }
.thumbs figure { margin: 0; display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.thumbs img { display: block; max-width: 11rem; max-height: 7.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.message .thumbs { margin: 0 0 .5rem; }
.message .thumbs img { max-width: 16rem; max-height: 11rem; }
.tools { margin: 0; font-size: .9rem; }
.tools label.button { margin: 0; cursor: pointer; }
.menu.end button { width: 100%; text-align: left; margin-bottom: .35rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 30; max-width: 26rem; padding: .8rem 1rem; background: #101828; color: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgb(16 24 40 / 25%); }
.toast a { color: #b8c5ff; font-weight: 600; }
.editor { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: rgb(16 24 40 / 92%); }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.editor-bar button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.editor-gap { flex: 1; }
.editor-text { width: 17rem; margin: 0; }
.editor-target { max-width: 16rem; }
.swatch { width: 1.6rem; height: 1.6rem; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px #d0d5dd; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.editor-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.editor-stage canvas { max-width: 100%; max-height: 100%; background: #fff; border-radius: 6px; cursor: crosshair; touch-action: none; }
.editor-hint { margin: 0; padding: .6rem 1rem; color: #e4e7ec; font-size: .9rem; text-align: center; }
.editor-hint.error { color: #ffb4ab; }
label.button { display: inline-block; margin: 0; padding: .35rem .75rem; font-size: inherit; font-weight: 500; border: 1px solid #d0d5dd; border-radius: 8px; background: var(--surface); color: #344054; cursor: pointer; }
label.button:hover { background: var(--bg); }
.editor-bar .editor-text { display: inline-block; width: 17rem; margin: 0; }
.editor-bar select { margin: 0; }

/* Onglets d'une page : tous les panneaux sont dans la page, seul celui que
   désigne l'adresse (#etat, #ia…) s'affiche ; sans désignation, le premier.
   Aucun script. Les cartes d'un panneau se rangent en colonnes égales. */
.panel { display: none; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1.25rem; align-items: start; }
.panel:target, .tabbed:not(:has(.panel:target)) > .panel:first-of-type { display: grid; }
.panel > .card { margin: 0; max-width: none; }
.panel > .card.wide, .panel > .card:has(table), .panel > .error { grid-column: 1 / -1; }
.panel > .card:only-child { max-width: 42rem; }
.panel > .card.wide:only-child { max-width: none; }
.tabbed:not(:has(.panel:target)) .tabs a:first-child,
.tabbed:has(#etat:target) .tabs a[href="#etat"], .tabbed:has(#ia:target) .tabs a[href="#ia"],
.tabbed:has(#comptes:target) .tabs a[href="#comptes"], .tabbed:has(#sauvegardes:target) .tabs a[href="#sauvegardes"],
.tabbed:has(#reglages:target) .tabs a[href="#reglages"], .tabbed:has(#cle:target) .tabs a[href="#cle"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1.25rem; }
.fields select { display: block; width: 100%; margin-top: .35rem; }
.nowrap { white-space: nowrap; }
/* Un formulaire de ligne (saisie de confirmation + bouton) tient sur une ligne. */
td form.inline { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: 0; }

/* Icônes : un attribut data-icon pose l'icône devant le texte ; avec la classe
   icon-only, elle le remplace (le texte reste lu par les lecteurs d'écran). */
[data-icon]::before { content: ""; display: inline-block; width: 1.1em; height: 1.1em; margin-right: .45em; vertical-align: -.18em; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.icon-only { font-size: 0 !important; padding: .4rem .5rem !important; line-height: 1; }
.icon-only::before { font-size: 1rem; margin: 0; vertical-align: middle; }
button.icon-only.quiet:hover[data-icon="trash"], button.icon-only.quiet:hover[data-icon="x"] { color: var(--danger); border-color: var(--danger); }
[data-icon="trash"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
[data-icon="x"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
[data-icon="check"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); }
[data-icon="plus"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
[data-icon="send"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2L11 13M22 2l-7 20-4-9-9-4z'/%3E%3C/svg%3E"); }
[data-icon="search"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 4a7 7 0 1 0 0 14a7 7 0 0 0 0-14zM21 21l-4.3-4.3'/%3E%3C/svg%3E"); }
[data-icon="camera"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h3l2-3h6l2 3h3v11H4zM12 10a3.5 3.5 0 1 0 0 7a3.5 3.5 0 0 0 0-7z'/%3E%3C/svg%3E"); }
[data-icon="image"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v14H4zM4 16l5-5 4 4 3-3 4 4M9 8.5a1 1 0 1 0 0 2a1 1 0 0 0 0-2z'/%3E%3C/svg%3E"); }
[data-icon="download"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 11l5 5 5-5M5 20h14'/%3E%3C/svg%3E"); }
[data-icon="upload"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V5M7 9l5-5 5 5M5 20h14'/%3E%3C/svg%3E"); }
[data-icon="refresh"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 5v6h-6M4 19v-6h6M5.5 9a7 7 0 0 1 12-2.5L20 11M18.5 15a7 7 0 0 1-12 2.5L4 13'/%3E%3C/svg%3E"); }
[data-icon="restore"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5v6h6M5 11a8 8 0 1 1 2 6'/%3E%3C/svg%3E"); }
[data-icon="stop"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7h10v10H7z'/%3E%3C/svg%3E"); }
[data-icon="pause"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6v12M15 6v12'/%3E%3C/svg%3E"); }
[data-icon="play"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 5l12 7-12 7z'/%3E%3C/svg%3E"); }
[data-icon="logout"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 4H5v16h5M15 8l4 4-4 4M19 12H9'/%3E%3C/svg%3E"); }
[data-icon="mic"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM6 11a6 6 0 0 0 12 0M12 17v4'/%3E%3C/svg%3E"); }
[data-icon="pencil"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20l1-5L16 4l4 4L9 19zM14 6l4 4'/%3E%3C/svg%3E"); }
[data-icon="folder"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h6l2 2h10v11H3z'/%3E%3C/svg%3E"); }
[data-icon="folder-plus"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h6l2 2h10v11H3zM12 11v5M9.5 13.5h5'/%3E%3C/svg%3E"); }
[data-icon="external"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v6H4V6h6'/%3E%3C/svg%3E"); }
[data-icon="home"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 11l8-7 8 7M6 10v10h12V10'/%3E%3C/svg%3E"); }
[data-icon="chat"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H9l-5 4z'/%3E%3C/svg%3E"); }
[data-icon="book"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4h13v16H5zM9 4v16M12 9h3'/%3E%3C/svg%3E"); }
[data-icon="users"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 0 0 0 7zM2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 6.5M18 14a6.5 6.5 0 0 1 3.5 6'/%3E%3C/svg%3E"); }
[data-icon="sliders"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h10M18 7h2M4 17h2M10 17h10M16 5v4M8 15v4'/%3E%3C/svg%3E"); }
[data-icon="grid"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z'/%3E%3C/svg%3E"); }
[data-icon="user"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 12a4 4 0 1 0 0-8a4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }
[data-icon="key"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.5 12a3.5 3.5 0 1 0 0 7a3.5 3.5 0 0 0 0-7zM10 13l9-9M16 7l3 3'/%3E%3C/svg%3E"); }
[data-icon="panel"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18v14H3zM15 5v14'/%3E%3C/svg%3E"); }
[data-icon="shield"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l8 3v6c0 5-3.5 8-8 9c-4.5-1-8-4-8-9V6z'/%3E%3C/svg%3E"); }
[data-icon="server"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4h16v7H4zM4 13h16v7H4zM8 7.5h.01M8 16.5h.01'/%3E%3C/svg%3E"); }
[data-icon="list"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01'/%3E%3C/svg%3E"); }
[data-icon="back"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12H4M10 6l-6 6 6 6'/%3E%3C/svg%3E"); }
[data-icon="archive"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18v4H3zM5 9v10h14V9M10 13h4'/%3E%3C/svg%3E"); }
/* Dans le menu, un bouton a l'allure d'un lien du menu. */
.menu button, .menu.end button { display: block; width: 100%; margin: 0; padding: .45rem .6rem; border: 0; border-radius: 8px; background: none; box-shadow: none; color: #344054; font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.menu button:hover { background: var(--bg); }
/* Une aide placée sous un bouton ne s'y colle pas. */
form > button + p, form > button + .muted { margin-top: .8rem; }
form.search input[type="text"] { width: min(26rem, 60vw); }
/* Les actions d'une ligne tiennent sur une ligne. */
td:has(> form.inline) { white-space: nowrap; width: 1%; }

/* Cartes de modules. */
a.module-card { color: var(--text); transition: border-color .1s, box-shadow .1s; }
a.module-card::before { color: var(--accent); width: 1.4em; height: 1.4em; margin: 0 0 .3rem; }
a.module-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 4px 14px rgb(51 85 221 / 12%); }
/* Confirmation repliée derrière une icône. */
details.confirm { display: inline-block; position: relative; text-align: left; }
details.confirm > summary { list-style: none; cursor: pointer; border: 1px solid #d0d5dd; border-radius: 8px; color: #344054; background: var(--surface); }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm > summary:hover, details.confirm[open] > summary { color: var(--danger); border-color: var(--danger); }
details.confirm > form { width: 20rem; margin-top: .5rem; padding: .9rem 1rem; white-space: normal; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
details.confirm[open] { display: block; text-align: right; }
details.confirm[open] > form { display: inline-block; text-align: left; }
/* Le titre reçoit le focus après un changement de page, sans cadre visible. */
h1[tabindex="-1"]:focus { outline: none; }
details.confirm > form input[type="text"] { margin: 0 0 .6rem; }
/* Dans l'application, le menu ramène déjà à l'accueil. */
body.app .back { display: none; }
/* Une liste déroulante sous son libellé, comme un champ. */
form:not(.inline) > label > select { display: block; width: 100%; margin-top: .35rem; padding: .55rem .7rem; }
time { white-space: nowrap; }

/* --- Petit écran : le menu devient un bandeau qui défile, les tableaux
   défilent dans leur carte au lieu d'élargir la page. ---------------------- */
@media (max-width: 860px) {
  body.app { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar { position: sticky; top: 0; z-index: 20; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: .25rem; height: auto; padding: .45rem .6rem; overflow-x: auto; background: var(--surface); scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { flex: none; padding: 0 .5rem 0 0; font-size: 1rem; }
  .menu, .menu.end { flex: none; flex-direction: row; align-items: center; gap: 2px; margin: 0; padding: 0; border: 0; }
  .menu + .menu { margin-left: .35rem; padding-left: .35rem; border-left: 1px solid var(--line); }
  .menu h2 { display: none; }
  .menu a, .menu .locked, .menu button, .menu.end button, .menu a.sub { width: auto; padding: .4rem .55rem; white-space: nowrap; font-size: .93rem; }
  .menu a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .menu .locked::after { content: none; }
  .content { padding: 1rem .75rem 3rem; }
  h1 { font-size: 1.25rem; margin-bottom: .9rem; }
  .card { padding: 1rem; overflow-x: auto; }
  /* Un tableau trop large défile dans son cadre, sans élargir la page. */
  main table:not(.docs-table) { display: block; overflow-x: auto; }
  main table:not(.docs-table) td:first-child { min-width: 13rem; }
  .docs-table .docs-num, .docs-table .docs-date { display: none; }
  .docs-table th:last-child, .docs-table td.docs-tools { width: 8.5rem; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .docs-tools button { opacity: 1; }
  details.confirm > form { width: min(20rem, 80vw); }
  form.search input[type="text"] { width: 55vw; }
}
