/* Identité Winncare (reprise des démos demo_veille-*) : bleu #20639b / #0c4da2, vert #6ac17b,
   turquoise #00b8b2, cyan #00aeef, Open Sans. */
:root {
  --bg: #f4f7fa;
  --panel: #ffffff;
  --line: #dde4ec;
  --text: #1c2733;
  --muted: #5f6b7a;
  --brand: #20639b;
  --brand-hover: #0c4da2;
  --brand-2: #0e7c78;
  --accent: #20639b;
  --select: #e8f0f8;
  --green: #6ac17b;
  --teal: #00b8b2;
  --cyan: #00aeef;
  --crit: #c0392b;
  --major: #c2410c;
  --minor: #a16207;
  --prev: #3f9d55;
  --ia: #7c3aed;
  --crm: #20639b;
  --calc: #0e7c78;
  --conf: #6b7684;
  --todo: #b7791f;
  --todo-bg: #fdf6e7;
  --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 dégradé aux trois couleurs du sigle Winncare */
.brand-bar { height: 4px; background: linear-gradient(90deg, var(--cyan) 0%, var(--teal) 50%, var(--green) 100%); }
.brand-bar.thick { height: 6px; }

/* Barre du haut */
.topbar-wrap { flex-shrink: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.nav-logo { height: 28px; width: auto; }
.sep { width: 1px; height: 24px; background: var(--line); }
.app-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.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; gap: 8px; align-items: center; }
.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: 32px; margin-bottom: 20px; }
.login h1 { font-size: 18px; margin: 0; }
.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: 250px 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(--accent); 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: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; z-index: 1; }
.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(--accent); 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.Critique { background: var(--crit); } .dot.Majeur { background: var(--major); }
.dot.Mineur { background: var(--minor); } .dot.Préventif { background: var(--prev); }

/* Lecture */
.reader { padding: 18px 22px 40px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }
.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.Critique { border-color: var(--crit); color: var(--crit); }
.pill.Majeur { border-color: var(--major); color: var(--major); }
.pill.Mineur { border-color: var(--minor); color: #854d0e; }
.pill.Préventif { border-color: var(--prev); color: var(--prev); }
.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(--accent); 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(4, 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); }
.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; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 20; }
.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(--cyan), var(--teal), var(--green)); 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 Winncare */
.item.scanning { background: linear-gradient(100deg, #fff 20%, #e3f7f6 40%, #e8f0f8 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(12, 77, 162, .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: #e3f7f6; 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; } }
