/* Identité Monceau Assurances (site monceauassurances.com) : marine #0F223B (couleur principale),
   orange #EE7F01 (secondaire), vert #71B62C (accent), gris du sigle #8E99A6 / #C3CAD2, Open Sans. */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #dde2e9;
  --text: #0f1b2b;
  --muted: #5d6878;
  --brand: #0F223B;
  --brand-hover: #213a5c;
  --brand-2: #8E99A6;
  --accent: #0F223B;
  --orange: #EE7F01;
  --orange-bg: #fdf1e4;
  --select: #eceff4;
  --green: #71B62C;
  --teal: #EE7F01;
  --cyan: #8E99A6;
  --grey-mark: #C3CAD2;
  --crit: #c0392b;
  --major: #EE7F01;
  --minor: #a16207;
  --prev: #4f8a1f;
  --ia: #7c3aed;
  --crm: #0F223B;
  --calc: #0e7c78;
  --conf: #6b7684;
  --todo: #b45309;
  --todo-bg: #fdf3e6;
  --radius: 10px;
  font-family: "Open Sans", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); height: 100vh; overflow: hidden; }
.app { height: 100vh; display: flex; flex-direction: column; }
button, .btn {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 6px 14px; border-radius: 99px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
button:hover, .btn:hover { border-color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-hover); }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--bg); color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.muted { color: var(--muted); }

/* Bandeau : marine Monceau, avec la touche orange de la charte */
.brand-bar { height: 4px; background: linear-gradient(90deg, var(--brand) 0%, var(--brand) 78%, var(--orange) 78%, var(--orange) 100%); }
.brand-bar.thick { height: 6px; }

/* Barre du haut */
.topbar-wrap { flex-shrink: 0; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.nav-logo { height: 30px; width: auto; }
.sep { width: 1px; height: 24px; background: var(--line); }
.app-title { font-family: Roboto, "Open Sans", sans-serif; font-size: 15px; font-weight: 500; white-space: nowrap; color: var(--brand); }
.mode { font-size: 12px; padding: 4px 12px; border-radius: 99px; white-space: nowrap; cursor: help; }
.mode.live { background: #eaf7ed; color: #2f7d4a; }
.mode.rejeu { background: var(--todo-bg); color: #92400e; }
.actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.progress { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Connexion */
.login { height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { width: 100%; max-width: 380px; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.login-inner { padding: 32px; text-align: center; }
.login-logo { height: 42px; margin-bottom: 22px; }
.login h1 { font-family: Roboto, "Open Sans", sans-serif; font-size: 19px; font-weight: 500; margin: 0; color: var(--brand); }
.login p.muted { font-size: 13px; margin: 6px 0 22px; }
.login form { text-align: left; display: flex; flex-direction: column; }
.login label { font-size: 12px; font-weight: 500; color: var(--muted); margin: 0 0 4px; }
.login input { font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; outline: none; }
.login input:focus { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.login button.wide { border-radius: 8px; padding: 10px; font-size: 14px; }
.login-error { background: #fdecea; color: var(--crit); font-size: 12px; padding: 8px 12px; border-radius: 8px; margin: 0 0 12px; }
.login-foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 16px; }

/* Trois colonnes */
.layout { flex: 1; display: grid; grid-template-columns: 275px 370px 1fr; min-height: 0; }
.folders, .list, .reader { overflow-y: auto; min-height: 0; }
.folders { background: #f8fafc; border-right: 1px solid var(--line); padding: 10px 0; }
.folder {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 14px; cursor: pointer; border-left: 3px solid transparent; user-select: none;
}
.folder:hover { background: #eef2f6; }
.folder.active { background: var(--select); border-left-color: var(--orange); font-weight: 600; }
.folder.l1 { padding-left: 26px; }
.folder.l2 { padding-left: 42px; }
.folder.group { font-weight: 600; margin-top: 6px; }
.folder .count { color: var(--accent); font-weight: 600; font-size: 12px; }
.folder .count.zero { visibility: hidden; }
.folder.bump .count { animation: bump .6s; }
@keyframes bump { 30% { transform: scale(1.6); color: var(--teal); } }

.list { background: var(--panel); border-right: 1px solid var(--line); }
.list-head { position: sticky; top: 0; background: var(--panel); padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; z-index: 1; }
.list-head .folder-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head .muted { font-weight: 500; font-size: 12px; white-space: nowrap; }
.list-search { padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.list-search input { width: 100%; font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #f8fafc; }
.list-search input:focus { border-color: var(--brand); background: #fff; }
.item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.item:hover { background: #f8fafc; }
.item.active { background: var(--select); }
.item.leaving { animation: leave .45s forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(-30px); } }
.item .row { display: flex; justify-content: space-between; gap: 8px; }
.item .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .subj { color: var(--brand); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .ext { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #eef2f6; color: #374151; white-space: nowrap; }
.tag.real { background: #dbeafe; color: #1e40af; }
.tag.draft { background: #ede9fe; color: #5b21b6; }
.tag.warn { background: var(--todo-bg); color: var(--todo); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.dot.Urgente { background: var(--crit); } .dot.Normale { background: var(--orange); } .dot.Basse { background: var(--grey-mark); }

/* Lecture */
.reader { padding: 18px 22px 40px; }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; line-height: 1.6; }
.mail-head h2 { margin: 0 0 6px; font-size: 19px; }
.mail-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.mail-meta b { color: var(--text); font-weight: 600; }
.strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); }
.strip .path { font-weight: 600; color: var(--brand); }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); }
.pill.src-règles { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.pill.src-live { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }
.pill.src-exemple { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-top: 8px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; color: var(--muted); }
.tabs button.active { border-bottom-color: var(--orange); color: var(--text); font-weight: 600; }
.tabs .badge { background: var(--todo-bg); color: var(--todo); font-size: 11px; border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.pane { padding-top: 14px; }

.body { white-space: pre-wrap; line-height: 1.55; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.att { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.att summary { padding: 8px 12px; cursor: pointer; }
.att pre { margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; white-space: pre-wrap; max-height: 280px; overflow: auto; background: #fafbfc; }
.fwd { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card p { margin: 4px 0; line-height: 1.45; }
.card ul { margin: 4px 0; padding-left: 18px; }
.card li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.alert { background: var(--todo-bg); color: #78350f; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.check { font-size: 12px; margin-top: 8px; color: var(--muted); }
.check .ok { color: var(--prev); } .check .ko { color: var(--crit); }

/* Brouillon */
.draft-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.draft-bar select { font: inherit; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); }
.draft-info { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.src-demo { color: var(--todo); }
.compose { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.compose .field { display: flex; border-bottom: 1px solid var(--line); align-items: center; }
.compose .field label { width: 64px; padding: 8px 12px; color: var(--muted); font-size: 13px; }
.compose .field input { flex: 1; border: none; padding: 8px 12px 8px 0; font: inherit; outline: none; background: transparent; }
.editor { white-space: pre-wrap; padding: 14px 16px; line-height: 1.6; min-height: 260px; outline: none; }
.editor .sig { color: var(--muted); font-size: 13px; }
.f { border-radius: 4px; padding: 0 3px; border-bottom: 2px solid; }
.f.ia { background: #f5f3ff; border-color: var(--ia); }
.f.crm { background: #eff6ff; border-color: var(--crm); }
.f.calcul { background: #f0fdfa; border-color: var(--calc); }
.f.config { background: #f3f4f6; border-color: #cbd5e1; }
.f.a_completer { background: var(--todo-bg); border-color: var(--todo); color: var(--todo); font-weight: 600; cursor: text; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.legend .f { font-size: 11px; }
.next { font-size: 12px; margin-top: 12px; color: var(--muted); }
.next button { font-size: 12px; padding: 2px 8px; margin-left: 4px; }
.noreply { padding: 30px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Modale */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border-radius: 10px; padding: 22px 26px; width: min(900px, 94vw); max-height: 88vh; overflow: auto; position: relative; }
.modal-close { position: absolute; right: 12px; top: 12px; border: none; }
.scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0; }
.score { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.score .v { font-size: 26px; font-weight: 700; color: var(--brand); font-family: Roboto, "Open Sans", sans-serif; }
.score .l { font-size: 12px; color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 70; pointer-events: none; max-width: 92vw; }
.toast { background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; text-align: center; animation: pop .25s ease-out; }
.filtre { display: flex; gap: 4px; align-items: center; padding: 0 14px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.filtre button { font-size: 12px; padding: 2px 8px; }
.filtre button.on { background: var(--select); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ── Animation du tri ─────────────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

/* Barre de progression sous le bandeau de marque */
.sortbar { height: 3px; background: transparent; overflow: hidden; }
.sortbar #sortbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--orange)); transition: width .35s ease; }
.sortbar.on #sortbar-fill { box-shadow: 0 0 10px var(--teal); }

/* Mail en cours d'analyse : balayage lumineux + liseré aux couleurs Monceau */
.item.scanning { background: linear-gradient(100deg, #fff 20%, var(--orange-bg) 40%, #eceff4 55%, #fff 75%); background-size: 250% 100%; animation: scan 1.1s linear infinite; box-shadow: inset 3px 0 0 var(--teal); }
@keyframes scan { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.item.scanned { background: var(--select); box-shadow: inset 3px 0 0 var(--brand); }
.verdict { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--brand); animation: pop .3s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Carte fantôme qui vole vers le dossier */
.ghost-card { position: fixed; z-index: 50; pointer-events: none; transform-origin: left center;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 10px;
  padding: 8px 12px; box-shadow: 0 10px 30px rgba(15, 34, 59, .22); font-size: 13px; display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
.ghost-card span:last-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* Dossier qui reçoit un mail */
.folder.hit { animation: hit .7s ease-out; }
.folder.hit .count { animation: bump .6s; }
@keyframes hit { 0% { background: var(--orange-bg); box-shadow: inset 3px 0 0 var(--teal); } 100% { background: transparent; box-shadow: none; } }
.folder.active.hit { animation: none; }

/* Récapitulatif après le tri */
.summary { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.summary-in { padding: 14px 18px; }
.summary h4 { margin: 0 0 10px; font-size: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.summary-grid div { background: var(--bg); border-radius: 8px; padding: 10px; }
.summary-grid b { display: block; font-size: 22px; color: var(--brand); }
.summary-grid span { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .item.scanning { animation: none; } .ghost-card { display: none; } }

/* ── Fil de discussion ────────────────────────────────────────── */
.small { font-size: 12px; }
button.link { border: none; background: none; color: var(--brand); padding: 0 4px; font-size: 12px; text-decoration: underline; }
.thread-head { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 6px; align-items: center; }
.thread { display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.msg.latest { border-color: #c3cad2; box-shadow: 0 1px 4px rgba(15, 34, 59, .08); }
.msg.internal { border-left: 3px solid var(--teal); }
.msg-head { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; cursor: pointer; }
.msg-head:hover { background: #f8fafc; }
.avatar { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--select); color: var(--brand); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.msg.internal .avatar { background: var(--orange-bg); color: var(--brand-2); }
.msg-who { flex: 1; min-width: 0; }
.msg-who .tag { margin-left: 6px; }
.msg-date { font-size: 12px; white-space: nowrap; }
.msg-preview { font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.open .msg-preview { display: none; }
.msg-body { display: none; white-space: pre-wrap; line-height: 1.55; padding: 4px 16px 14px 60px; }
.msg.open .msg-body { display: block; }
.sig-block { margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.sig-block summary { cursor: pointer; font-size: 12px; }

/* ── Pièces jointes ───────────────────────────────────────────── */
.pjs { margin-top: 16px; }
.pjs h4 { margin: 0 0 8px; font-size: 13px; }
.pj-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.pj { margin: 0; width: 150px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; cursor: zoom-in; transition: box-shadow .15s, transform .15s; }
.pj:hover { box-shadow: 0 4px 14px rgba(15, 34, 59, .15); transform: translateY(-1px); }
.pj-thumb { height: 105px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pj-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pj-icon { font-weight: 700; color: var(--crit); font-size: 18px; border: 2px solid currentColor; border-radius: 6px; padding: 8px 10px; }
.pj figcaption { padding: 6px 8px; font-size: 11.5px; display: flex; flex-direction: column; }
.pj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume { font-weight: 600; }

/* Visionneuse plein écran */
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .82); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #fff; }
.viewer-bar #viewer-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar a.btn { text-decoration: none; }
.viewer-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 20px 20px; min-height: 0; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.viewer-body iframe { width: min(1000px, 100%); height: 100%; border: none; border-radius: 6px; background: #fff; }
.viewer-file { color: #fff; }

/* ── Icônes, étiquettes et pastilles (lisibilité) ─────────────── */
svg { width: 14px; height: 14px; flex: 0 0 auto; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 6px; background: #eef2f6; color: #3b4756; border: 1px solid #dfe5ec; }
.tag svg { width: 12px; height: 12px; }
.tag.real { background: #eceff4; color: #0F223B; border-color: #cfd6df; }
.tag.fake { background: #f4f5f7; color: #6b7684; border-color: #e3e6ea; font-weight: 500; }
.tag.draft { background: #f1ecfb; color: #5b21b6; border-color: #ddd0f5; }
.tag.warn { background: #fdf2dd; color: #8a5a00; border-color: #f3d9a4; }
.tag.done { background: #eaf7ed; color: #2f7d4a; border-color: #cbe9d3; }
.item .tags { gap: 5px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: #3b4756; }
.pill svg { width: 13px; height: 13px; }
.pill.prio-Urgente { background: #fdecea; border-color: #f3c2bc; color: #a8281b; }
.pill.prio-Normale { background: var(--orange-bg); border-color: #f5cf9f; color: #9a4f00; }
.pill.prio-Basse { background: #f1f3f6; border-color: #dde2e9; color: #5d6878; }
.pill.manuscrit { background: #f6f1fb; border-color: #e2d4f3; color: #5b21b6; }
.pill.conf-faible { background: #fdf2dd; border-color: #f3d9a4; color: #8a5a00; }
.pill.draft { background: #f1ecfb; border-color: #ddd0f5; color: #5b21b6; }
.strip .path { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.strip .path svg { width: 16px; height: 16px; }
.alert { display: flex; gap: 8px; align-items: flex-start; }
.alert svg { margin-top: 2px; }
.pjs h4, .thread-head { display: flex; align-items: center; gap: 6px; }

/* Bille rouge sur un dossier qui contient une demande urgente */
.fcount { display: inline-flex; align-items: center; gap: 6px; }
.folder .dot.Urgente { width: 9px; height: 9px; margin: 0; box-shadow: 0 0 0 3px rgba(192, 57, 43, .18); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(192, 57, 43, .08); } }

/* ── Barre d'outils du brouillon ──────────────────────────────── */
.draft-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.dt-model { display: flex; flex-direction: column; gap: 4px; min-width: 280px; flex: 1; max-width: 520px; }
.dt-model label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.dt-model select, .noreply select { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.dt-model select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 1px var(--brand); }
.dt-meta { font-size: 12px; color: var(--muted); }
.dt-actions { display: flex; gap: 8px; }
.dt-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 13px; }
.next { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 0 0 10px 2px; }
.next span { margin-right: 2px; }
.chip { font-size: 12px; padding: 3px 10px; border-color: #cfd6df; color: var(--brand); background: #f3f5f8; }
.chip:hover { background: var(--select); }
.compose-head { display: flex; justify-content: flex-end; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.todo-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--todo); background: var(--todo-bg); border-radius: 99px; padding: 3px 10px; }
.todo-pill.ok { color: #2f7d4a; background: #eaf7ed; }
.compose .field .subject { flex: 1; padding: 8px 12px 8px 0; outline: none; white-space: nowrap; overflow-x: auto; font-weight: 600; }
.noreply-pick { margin-top: 14px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.folder > span:first-child { margin-right: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Accueil du lecteur, bandeau « traité », suite du récapitulatif ────── */
.welcome { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; max-width: 720px; }
.welcome h3 { margin: 0 0 10px; font-size: 15px; }
.welcome ol { margin: 0; padding-left: 20px; line-height: 1.55; }
.welcome li { margin: 6px 0; }
.welcome p { margin: 12px 0 0; }
.done-banner { display: flex; align-items: center; gap: 8px; margin: 12px 0; padding: 8px 12px; border-radius: 8px; background: #eaf7ed; color: #2f7d4a; font-weight: 600; font-size: 13px; }
.summary-next { margin: 12px 0 0; font-size: 13px; }
.summary-next button.link { font-size: 13px; }
.item.active { box-shadow: inset 3px 0 0 var(--brand); }
.item:focus-visible, .folder:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.only-narrow, .only-mobile { display: none; }
.back { display: none; align-items: center; gap: 4px; margin: -6px 0 8px -8px; padding: 6px 10px; }
.folders-head { display: none; align-items: center; justify-content: space-between; padding: 6px 8px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.folders-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 29; }

/* ── Écrans étroits ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 340px 1fr; }
  .folders { position: fixed; top: 0; bottom: 0; left: 0; width: 290px; max-width: 86vw; z-index: 30; box-shadow: 4px 0 24px rgba(0,0,0,.15);
    transform: translateX(-100%); transition: transform .2s ease-out; padding-top: 0; }
  .layout.show-folders .folders { transform: none; }
  .folders-head, .only-narrow { display: inline-flex; }
  .folders-head { display: flex; }
  .list-head .only-narrow { padding: 4px 8px; margin-left: -6px; font-size: 16px; line-height: 1; }
  .topbar .app-title { display: none; }
  .topbar .sep { display: none; }
  .reader { padding: 14px 16px 40px; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .reader { display: none; }
  .layout.show-reader .reader { display: block; }
  .layout.show-reader .list { display: none; }
  .only-mobile, .back { display: inline-flex; }
  .topbar { padding: 6px 10px; }
  .actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .actions button { padding: 5px 10px; font-size: 12.5px; }
  #btn-logout { margin-left: auto; }
  .mode { display: none; }
  .cards { grid-template-columns: 1fr; }
  .scores { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .msg-body { padding-left: 16px; }
  .draft-toolbar { align-items: stretch; }
  .dt-model { min-width: 0; max-width: none; }
  .dt-actions { justify-content: flex-end; }
  .mail-head h2 { font-size: 17px; }
  .modal-box { padding: 16px; width: 96vw; }
  .viewer-body iframe { width: 100%; }
}

/* ── Réponse réelle de Monceau (référence) ────────────────────────── */
.draft-compare { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1400px) { .draft-compare { grid-template-columns: 1fr; } }
.draft-col { min-width: 0; }
.real-reply { background: #f3faf5; border: 1px solid #cbe9d3; border-left: 4px solid var(--prev); border-radius: var(--radius); padding: 12px 16px; position: sticky; top: 0; }
.real-reply h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #2f7d4a; }
.rr-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.rr-body { white-space: pre-wrap; line-height: 1.55; font-size: 13.5px; }
.rr-note { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; }
.rr-banner { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: #2f7d4a; background: #f3faf5; border: 1px solid #cbe9d3; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.rr-banner svg { margin-top: 2px; }

/* Pièces à joindre par le gestionnaire (annoncées par « ci-joint » dans le texte) */
.pj-field { align-items: center; }
.pj-todos { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 6px 0; }
.pj-todo { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; border-radius: 6px; padding: 4px 10px;
  background: var(--todo-bg); border: 1px dashed var(--todo); color: #8a5a00; font-weight: 600; cursor: pointer; }
.pj-todo .pj-todo-label { font-size: 11px; letter-spacing: .4px; }
.pj-todo[aria-pressed="true"] { background: #eaf7ed; border: 1px solid #cbe9d3; color: #2f7d4a; }

/* ── Monceau : courriers numérisés et texte lu par OCR ─────────── */
.tag.scan { background: #eceff4; color: #0F223B; border-color: #cfd6df; }
.tag.ocr { background: var(--orange-bg); color: #9a4f00; border-color: #f5cf9f; }
.tag.hand { background: #f6f1fb; color: #5b21b6; border-color: #e2d4f3; }
.courrier { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 14px; align-items: start; }
.courrier .scan-img { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; cursor: zoom-in; position: sticky; top: 0; }
.courrier .scan-img img { width: 100%; display: block; }
.courrier .scan-img figcaption { font-size: 11.5px; color: var(--muted); padding: 6px 10px; border-top: 1px solid var(--line); }
.ocr-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ocr-text { white-space: pre-wrap; line-height: 1.55; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: var(--radius); padding: 12px 16px; font-size: 13.5px; }
.pj-ocr { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.pj-ocr summary { padding: 8px 12px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.pj-ocr summary .muted { margin-left: auto; font-size: 12px; }
.pj-ocr pre { margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); font: 12.5px/1.5 "Open Sans", sans-serif; white-space: pre-wrap; max-height: 340px; overflow: auto; background: #fafbfc; }
.pj-badge { position: absolute; top: 6px; left: 6px; font-size: 10.5px; font-weight: 700; background: var(--orange); color: #fff; border-radius: 4px; padding: 2px 6px; }
.pj-thumb { position: relative; }
.pj-thumb img.page { object-fit: cover; object-position: top; }
@media (max-width: 1100px) { .courrier { grid-template-columns: 1fr; } .courrier .scan-img { position: static; max-width: 420px; } }

/* Visionneuse : pages d'un PDF rendues en images, les unes sous les autres */
.viewer-body.pages { flex-direction: column; justify-content: flex-start; overflow-y: auto; gap: 14px; padding-top: 4px; }
.viewer-body.pages img { max-width: min(1000px, 100%); max-height: none; width: 100%; height: auto; flex: 0 0 auto; }
