:root {
  --ground: #EEF0F3; --panel: #FFFFFF; --lane: #E3E6EB; --ink: #16181D; --muted: #4A505C; --soft: #5B6270;
  --line: #D5DAE1; --line2: #E3E6EB; --field: #C9CFD8; --accent: #1F4FD8; --accent-ink: #163A9F; --accent-bg: #F5F8FF; --accent-line: #C7D5FB;
  --warn-bg: #FFF1DC; --warn: #D97706; --warn-ink: #B45309; --crit-bg: #FDE8E8; --crit: #DC2626; --crit-ink: #B91C1C;
  --ok: #16A34A; --ok-bg: #ECFDF3; --ok-line: #A7E3BF; --note-bg: #FFF8DB; --note-line: #E6CF6E; --ai: #5B3FD1; --ai-bg: #F3F0FF; --ai-line: #D6CCFA; --ai-ink: #3B2A8F;
  --head: #16181D; --head2: #2A2D35; --head-muted: #B8BEC9; --shopify: #5E8E3E;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 14px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); } a:hover { color: var(--accent-ink); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.loading { padding: 80px; text-align: center; color: var(--soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* En-tête */
header.top { background: var(--head); color: #fff; padding: 10px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--head-muted); margin-left: 8px; font-size: 12px; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
nav.tabs a.on { background: var(--head2); font-weight: 600; }
.search { flex: 1 1 200px; max-width: 340px; display: flex; align-items: center; gap: 8px; background: var(--head2); border-radius: 8px; padding: 0 12px; height: 38px; }
.search input { flex: 1; background: transparent; border: 0; color: #fff; outline: none; font-size: 13px; min-width: 0; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 15px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.avatar.light { background: #fff; color: var(--ink); }
.avatar.empty { background: transparent; border: 1.5px dashed #8A919E; color: var(--soft); }
.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--field); background: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #9AA2AF; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; color: #fff; border-color: #4A505C; }
.btn.ai { background: var(--ai); border-color: var(--ai); color: #fff; font-weight: 600; }
.btn.ai2 { background: #fff; border-color: #B9A9F2; color: var(--ai-ink); }
.btn.danger { color: var(--crit-ink); border-color: #F3B4B4; }
.btn:disabled { opacity: .55; cursor: default; }
.chip { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--field); background: #fff; font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.label { font-size: 12px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.pad { padding: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); } .soft { color: var(--soft); font-size: 12px; }
input.field, textarea.field, select.field { border: 1px solid var(--field); border-radius: 8px; padding: 9px 12px; background: #fff; width: 100%; }
textarea.field { resize: vertical; line-height: 1.5; min-height: 120px; }
main.page { padding: 18px 20px 28px; }
h1 { margin: 0; font-size: 21px; font-weight: 600; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }

/* Tableau */
.boardbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.count { font-family: 'IBM Plex Mono', monospace; font-size: 13px; background: #DDE1E7; padding: 3px 8px; border-radius: 6px; }
.lanes { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.lane { flex: 1 0 250px; min-width: 250px; background: var(--lane); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 120px; }
.lane.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.lanehead { display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px; }
.lanehead h2 { flex: 1; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: 0 0 auto; }
.tile { display: flex; flex-direction: column; gap: 7px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%; }
.tile:hover { border-color: #9AA2AF; }
.tile.warn { background: var(--warn-bg); border: 1.5px solid var(--warn); }
.tile.crit { background: var(--crit-bg); border: 1.5px solid var(--crit); }
.tile .subj { font-weight: 600; line-height: 1.3; flex: 1; overflow-wrap: anywhere; }
.tile .prev { font-size: 13px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.tile .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--soft); }
.tile .age { font-size: 12px; font-weight: 600; }
.tile .watch { font-size: 12px; color: #9A3412; font-weight: 500; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: #E8EBF0; color: var(--muted); }
.badge.client { background: #DBEAFE; color: #1E3A8A; }
.aging { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 13px; margin-left: auto; }
.aging .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: -1px; margin-right: 4px; }
.aging button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--field); background: #fff; }

/* Ticket */
.tgrid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.tmain { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.tside { flex: 1 1 330px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.banner { background: #FFEDD5; color: #7C2D12; border-radius: 8px; padding: 10px 14px; font-size: 13px; font-weight: 500; }
.thread { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; border-radius: 12px; padding: 11px 14px; display: flex; flex-direction: column; gap: 5px; border: 1px solid var(--line2); background: #F6F7F9; align-self: flex-start; }
.msg.agent { align-self: flex-end; background: #EEF3FF; border-color: var(--accent-line); }
.msg.auto { align-self: flex-end; background: var(--ok-bg); border-color: var(--ok-line); }
.msg.note { align-self: stretch; max-width: none; background: var(--note-bg); border-color: var(--note-line); }
.msg .who { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.msg .who strong { color: var(--ink); font-size: 13px; }
.msg .txt { white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; }
.msg .txt.clamp { max-height: 220px; overflow: hidden; position: relative; }
.att { display: flex; flex-wrap: wrap; gap: 6px; }
.att a { font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; text-decoration: none; }
.composer { border-top: 1px solid var(--line2); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.aibox { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--ai-bg); border: 1px solid var(--ai-line); border-radius: 10px; padding: 10px 12px; }
.aibox .soft { color: var(--ai-ink); flex: 1 1 200px; }
.composer textarea.note { background: #FFFDF2; border-color: var(--note-line); }
.sig { border: 1px dashed var(--field); border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.picker { border: 1px solid var(--accent-line); background: var(--accent-bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow: auto; }
.picker button.rep { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.picker button.rep:hover { border-color: var(--accent); }
.formcard { margin: 14px 16px 0; border: 1px solid var(--accent-line); background: var(--accent-bg); border-radius: 10px; padding: 10px 14px; font-size: 13px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats div { background: #F3F5F8; border-radius: 8px; padding: 7px 9px; }
.stats b { display: block; font-size: 15px; }
.order { border: 1px solid var(--line2); border-radius: 10px; padding: 11px; display: flex; flex-direction: column; gap: 6px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.pill.paid { background: #DCFCE7; color: #14532D; } .pill.ship { background: #DBEAFE; color: #1E3A8A; } .pill.todo { background: #FFEDD5; color: #7C2D12; } .pill.grey { background: #EEF0F3; color: var(--muted); }
.log { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.log .who { flex: 0 0 auto; min-width: 28px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--lane); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.log .when { color: var(--soft); font-size: 12px; white-space: nowrap; }

/* Réponses / réglages */
.cols2 { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols2 > .a { flex: 999 1 520px; min-width: 0; } .cols2 > .b { flex: 1 1 320px; min-width: 0; }
.replyitem { border-top: 1px solid var(--line2); padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.replyitem .txt { white-space: pre-wrap; font-size: 13px; color: var(--muted); max-height: 120px; overflow: hidden; }
.toggle { display: flex; align-items: flex-start; gap: 10px; background: none; border: 0; padding: 4px 0; text-align: left; line-height: 1.4; }
.toggle .tr { flex: 0 0 auto; width: 36px; height: 20px; border-radius: 10px; background: var(--field); position: relative; margin-top: 1px; }
.toggle .tr::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 8px; background: #fff; transition: left .15s; }
.toggle.on .tr { background: var(--ok); } .toggle.on .tr::after { left: 18px; }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--crit-ink); font-size: 13px; font-weight: 500; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

@media (max-width: 700px) {
  header.top { padding: 8px 12px; }
  main.page { padding: 12px; }
  .lanes { scroll-snap-type: x mandatory; }
  .lane { width: 86vw; flex-basis: 86vw; scroll-snap-align: start; }
  .msg { max-width: 100%; }
  .aging { margin-left: 0; }
}

.pill.theme { background: #F3F0FF; color: #3B2A8F; }

/* Panneau de droite (Shopify / réponses) : défilement indépendant sur grand écran */
@media (min-width: 900px) {
  .tside { position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
  .tside > .row:first-child { position: sticky; top: 0; z-index: 2; background: var(--ground); padding-bottom: 6px; }
}

/* Zone de texte avec images intégrées */
rich-edit.field { display: block; border: 1px solid var(--field); border-radius: 8px; padding: 9px 12px; background: #fff; width: 100%; line-height: 1.5; min-height: 120px; max-height: 60vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word; outline: none; cursor: text; }
rich-edit.field:focus { border-color: var(--accent, #6b4fd8); box-shadow: 0 0 0 3px rgba(107,79,216,.12); }
rich-edit.field:empty::before { content: attr(placeholder); color: var(--muted); pointer-events: none; }
rich-edit img { display: inline-block; max-width: min(100%, 420px); max-height: 280px; border-radius: 6px; margin: 4px 0; vertical-align: bottom; cursor: pointer; }
rich-edit img:hover { outline: 2px solid rgba(107,79,216,.35); }
.composer rich-edit.note { background: #FFFDF2; border-color: var(--note-line); }
rich-edit img:has(+ img), rich-edit img + img { max-width: calc(50% - 4px); margin-right: 4px; vertical-align: top; }
.filechip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; margin: 4px 0; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2, #f3f4f6); color: inherit; text-decoration: none; font-size: 13px; }
.imgrow { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.imgrow img { display: block; max-width: 100%; max-height: 300px; border-radius: 6px; min-width: 0; }
.imgrow img:not(:only-child) { flex: 1 1 0; max-width: calc(50% - 4px); object-fit: contain; height: auto; }

/* ---------- Version mobile ---------- */
.m-only, .mtabs { display: none; }
@media (max-width: 700px) {
  .m-only { display: inline-flex; }
  .d-only { display: none !important; }
  /* Bandeau compact */
  header.top { padding: 8px 12px; gap: 8px; position: static; }
  header.top .brand { font-size: 15px; }
  header.top .brand small { display: none; }
  nav.tabs a { padding: 6px 10px; }
  header.top .me > span:not(.avatar) { display: none; }
  header.top .me .btn { height: 30px; padding: 0 10px; font-size: 12px; }
  header.top .me { margin-left: auto; }
  form.search { order: 10; flex: 1 1 100%; }
  main.page { padding: 10px; }
  h1 { font-size: 19px; }
  /* Tableau : une colonne à la fois, choisie par onglets */
  .boardbar { gap: 8px; }
  .boardbar .count { margin-right: auto; }
  .aging { display: none; }
  .lanes { flex-wrap: wrap; overflow: visible; gap: 10px; }
  .mtabs { display: flex; gap: 6px; overflow-x: auto; flex: 1 1 100%; padding-bottom: 2px; scrollbar-width: none; }
  .mtabs button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
  .mtabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
  .mtabs .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
  .lane { display: none; width: 100%; flex: 1 1 100%; min-width: 0; }
  .lane.cur { display: flex; }
  .lane .lanehead { display: none; }
  /* Ticket : le message d'abord, réglages repliés, boutons toujours accessibles */
  .thead .btn:first-child { height: 34px; }
  .thead h1 { flex-basis: 100% !important; order: -1; }
  .tctl { display: none; }
  body.ctl-open .tctl { display: block; }
  .tctl .card { padding: 12px; }
  .tactions { position: sticky; top: 0; z-index: 5; background: #fff; display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px !important; box-shadow: 0 4px 12px rgba(0,0,0,.06); padding: 8px 10px !important; }
  .tactions .btn { min-width: 0; width: 100%; justify-content: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 38px; padding: 0 8px; font-size: 13px; display: block; line-height: 38px; text-align: center; }
  rich-edit.field { max-height: 50vh; }
  .composer .row { flex-wrap: wrap; }
}

/* Badge « Powered by Netlify » : masqué (le compte Netlify n'est pas en offre gratuite, le masquage est autorisé) */
#nl-badge-frame { display: none !important; }

/* Administration */
.admwrap { display: flex; gap: 20px; align-items: flex-start; }
.admtabs { display: flex; flex-direction: column; gap: 4px; flex: 0 0 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; position: sticky; top: 70px; }
.admtabs a { text-decoration: none; color: inherit; border-radius: 8px; padding: 9px 12px; font-size: 14px; white-space: nowrap; }
.admtabs a:hover { background: var(--ground); }
.admtabs a.on { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
@media (max-width: 700px) {
  .admwrap { flex-direction: column; gap: 12px; }
  .admtabs { flex-direction: row; flex: none; width: 100%; overflow-x: auto; position: static; padding: 6px; }
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 14px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; }
.urow { gap: 10px 14px; padding: 10px 0; border-bottom: 1px solid var(--line2); align-items: flex-start; }
.urow:last-child { border-bottom: 0; }
.urow.off { opacity: .6; }
.btn.sm { height: 30px; font-size: 12px; padding: 0 10px; }
/* Recherche */
.sfilters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.sfilters select.field, .sfilters input[type=date] { width: auto; }
.bulkbar { gap: 8px; padding: 6px 0 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.sres { gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); flex-wrap: nowrap; }
.sres input[type=checkbox], .bulkbar input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 auto; }
@media (max-width: 700px) { #boardq { width: 100% !important; order: 5; } .sfilters > * { flex: 1 1 100% !important; } }

/* Recherche prédictive */
form.search { position: relative; }
.qsug { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 320px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 40; overflow: hidden; max-height: 70vh; overflow-y: auto; }
.qsug .sg { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line2); }
.qsug .sg .mono { color: var(--soft); padding-top: 1px; }
.qsug .sgt { display: flex; flex-direction: column; min-width: 0; }
.qsug .sgt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qsug .sgt small { color: var(--soft); font-size: 12px; }
.qsug .sg:hover, .qsug .sg.on { background: var(--accent-bg); }
.qsug .sg.all { color: var(--accent-ink); font-weight: 600; font-size: 13px; border-bottom: 0; }
.qsug .sgnone { padding: 10px 12px; color: var(--soft); }
.qsug mark { background: #FFF1A8; color: inherit; border-radius: 2px; }
@media (max-width: 700px) { .qsug { min-width: 0; } }

/* Email affiché comme dans une messagerie */
.mailframe { width: 100%; border: 1px solid var(--line2); border-radius: 8px; background: #fff; height: 160px; display: block; }
.mailframe.cut { box-shadow: inset 0 -12px 12px -12px rgba(0,0,0,.25); }
.msg.hashtml { max-width: 100%; width: 100%; }

/* Retour visuel au clic */
.btn, .chip, .admtabs a, .mtabs button, nav.tabs a { transition: background-color .12s, transform .08s, filter .12s; }
.btn:active, .chip:active, .mtabs button:active, nav.tabs a:active { transform: scale(.97); filter: brightness(.9); }
.btn.pressing, .chip.pressing { filter: brightness(.88); background-image: linear-gradient(90deg, rgba(0,0,0,.06) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,.06) 75%); background-size: 200% 100%; animation: pressing 0.9s linear infinite; }
.btn.primary.pressing { filter: brightness(.82); }
@keyframes pressing { from { background-position: 200% 0; } to { background-position: 0 0; } }
.sig img { max-width: 360px; height: auto; display: block; margin-top: 4px; }

/* Apprentissage IA */
.msgfoot { gap: 8px; margin-top: 6px; }
.btn.star.on { background: #FFF7D6; border-color: #F2D27A; color: #7A5A00; font-weight: 600; }
.bar { flex: 1; height: 8px; background: var(--lane); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; }
.bar .ok, .chg.ok { background: #DDF3E4; color: #17603A; } .bar .ok { background: #3BA769; }
.bar .mid, .chg.mid { background: #FFF1D6; color: #8A5A00; } .bar .mid { background: #E9A23B; }
.bar .bad, .chg.bad { background: #FDE2E2; color: #9B1C1C; } .bar .bad { background: #D64545; }
.chg { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; min-width: 64px; text-align: center; }
.chg.grey { background: var(--lane); color: var(--soft); }
.lrow { padding: 10px 0; border-bottom: 1px solid var(--line2); }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.cmptxt { background: var(--ground); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.55; }
.cmptxt del { background: #FDE2E2; color: #9B1C1C; text-decoration: line-through; }
.cmptxt ins { background: #DDF3E4; color: #17603A; text-decoration: none; }
.tips summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.tips ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }
@media (max-width: 700px) { .cmp { grid-template-columns: 1fr; } }

/* Fenêtre « Expliquer / dicter » */
.modal { position: fixed; inset: 0; background: rgba(22,24,29,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modalbox { background: #fff; border-radius: 14px; width: min(620px, 100%); padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modalbox h2 { font-size: 17px; }
#dict-mic.rec { background: #D64545; color: #fff; border-color: #D64545; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 6px rgba(214,69,69,.25); } }
@media (max-width: 700px) { .modal { align-items: flex-end; padding: 0; } .modalbox { border-radius: 14px 14px 0 0; } #dict-text { min-height: 120px; } }

/* Bouton rose « Expliquer / dicter » et micro à maintenir */
.btn.pink { background: #EC4D8B; border-color: #EC4D8B; color: #fff; font-weight: 600; }
.btn.pink:hover { background: #DB3A79; border-color: #DB3A79; }
.btn .ico { vertical-align: -3px; margin-right: 4px; flex: 0 0 auto; }
.btn.mic { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; min-height: 44px; padding: 0 16px; }
#dict-mic.rec { background: #C2185B; border-color: #C2185B; color: #fff; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 8px rgba(236,77,139,.25); } }
.trk { font-size: 13px; font-weight: 600; color: #8A5A00; background: #FFF6E0; border-radius: 6px; padding: 4px 8px; margin: 2px 0; }
.trk.done { color: #17603A; background: #E3F5EA; }

/* Réactivité : tuile cliquée, sablier, barre de chargement */
.tile { transition: background-color .12s, border-color .12s, transform .08s, box-shadow .12s; }
.tile:active { transform: scale(.985); }
.tile.opening { background: var(--accent-bg) !important; border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-line); position: relative; }
.tile.opening::after { content: ''; position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-line); border-top-color: var(--accent); animation: spin .7s linear infinite; background: #fff; }
.tile.opening .avatar { visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }
#topbusy { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .15s; background: linear-gradient(90deg, transparent 0, #EC4D8B 30%, var(--accent) 60%, transparent 100%); background-size: 50% 100%; background-repeat: no-repeat; }
#topbusy.on { opacity: 1; animation: busybar 1s linear infinite; }
@keyframes busybar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
body.waiting, body.waiting * { cursor: progress !important; }

/* Application installée sur Android : bande sombre sous les boutons système (retour, accueil) pour qu'ils restent visibles */
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  body::after { content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: env(safe-area-inset-bottom); background: #16181D; z-index: 90; pointer-events: none; }
}
@media (display-mode: standalone) { html { background: #16181D; } }

/* Couleurs des membres */
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chip.on .cdot { background: #fff !important; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.colorpick { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }

/* Statistiques */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi b { font-size: 28px; line-height: 1.1; }
.trg { color: #17603A; font-size: 12px; font-weight: 700; } .trb { color: #9B1C1C; font-size: 12px; font-weight: 700; } .trw { color: #8A5A00; font-weight: 700; } .tr0 { color: var(--soft); font-size: 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart .gl { stroke: var(--line2); stroke-width: 1; } .chart .ax { font-size: 11px; fill: var(--soft); }
.chart .l1 { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; } .chart .l2 { fill: none; stroke: #16A34A; stroke-width: 2.5; stroke-linejoin: round; stroke-dasharray: 5 4; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); } .legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.cols2s { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.hb { gap: 10px; flex-wrap: nowrap; } .hbl { flex: 0 0 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .hb .bar { height: 12px; } .hb b { flex: 0 0 36px; text-align: right; }
.heat { display: grid; grid-template-columns: 38px repeat(24, 1fr); gap: 3px; font-size: 11px; color: var(--soft); }
.heat .hc { height: 18px; border-radius: 3px; } .heat .hd { align-self: center; } .heat .hh { text-align: left; white-space: nowrap; }
@media (max-width: 700px) { .cols2s { grid-template-columns: 1fr; } .hbl { flex-basis: 100px; } .heat { grid-template-columns: 30px repeat(24, 1fr); gap: 1px; } }
.banner.warnb { background: #FFF4E5; color: #7A4B00; border: 1px solid #F3C98B; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Assistant de réponse (workflows) ---------- */
.wf { margin: 12px 16px 0; border: 1.5px solid #C7D2FE; background: #F5F7FF; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.wf.wfmini, .wf.wfload { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; background: #F8F9FC; border-color: var(--line); }
.wf.wfload { color: #3730A3; animation: wfpulse 1.4s ease-in-out infinite; }
@keyframes wfpulse { 50% { opacity: .55; } }
.wfhead { gap: 8px; }
.wfsteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.wfs { display: flex; gap: 8px; align-items: flex-start; }
.wfs .ic { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; background: #E5E7EB; color: #6B7280; font-weight: 700; }
.wfs.ok .ic { background: #DCFCE7; color: #15803D; } .wfs.warn .ic { background: #FEF3C7; color: #B45309; } .wfs.bad .ic { background: #FEE2E2; color: #B42318; }
.wfitems { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.wfi { font-size: 12px; color: #6B7280; } .wfi.ok { color: #15803D; } .wfi.todo { color: #B45309; }
.wfwarn { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.wfok { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.wfq { font-weight: 700; font-size: 14px; margin-top: 4px; }
.wtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.wtile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; min-height: 76px; height: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #D6DBE6; background: #fff; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); transition: transform .08s, box-shadow .15s, background .15s; }
.wtile:hover { box-shadow: 0 3px 10px rgba(30,41,59,.1); border-color: #A5B4FC; }
.wtile:active { transform: scale(.98); }
.wtile small { font-weight: 400; font-size: 11.5px; color: #6B7280; } .wtile small.w { color: #B45309; }
.wtile.primary { border-color: #4F46E5; background: #EEF2FF; }
.wtile.vip { border-color: var(--vip); background: color-mix(in srgb, var(--vip) 13%, #fff); box-shadow: inset 0 0 0 1px var(--vip); }
.wtile[disabled] { opacity: .6; cursor: wait; }
.wtile.in { align-items: stretch; gap: 5px; padding: 8px 10px; cursor: default; }
.wtile.in .btn { align-self: flex-start; }
.wtile.manual { border-style: dashed; background: #FAFAFB; color: #374151; }
.wtile.in .field { width: 100%; }
.vipb { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: #fff; background: var(--vip); border-radius: 999px; padding: 2px 9px; vertical-align: middle; }
.wfdef { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.wftab { border-collapse: collapse; font-size: 14px; } .wftab td, .wftab th { padding: 5px 12px 5px 0; text-align: left; border-bottom: 1px solid var(--line2); }
@media (max-width: 700px) { .wf { margin: 10px 10px 0; } .wtiles { grid-template-columns: 1fr; grid-auto-rows: auto; } .wtile { min-height: 60px; } }
.pill.wfb { font-weight: 600; } .pill.wfb.missing { background: #FFF7ED; color: #C2410C; } .pill.wfb.ready { background: #EEF2FF; color: #3730A3; } .pill.wfb.done { background: #F0FDF4; color: #15803D; }
.wfico { vertical-align: -4px; }
.wft { display: inline-flex; align-items: center; gap: 6px; }
.tabs a .wfico { width: 16px; height: 16px; margin-right: 2px; vertical-align: -3px; }
.wf .wfhead .wft { color: #3730A3; }
.wtlist { display: flex; flex-direction: column; gap: 8px; }
.wtcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.wtcard.off { opacity: .6; }
.wtcard.edit { border-color: #A5B4FC; background: #F8F9FF; }
.wtcard .kind { flex: none; font-size: 11px; font-weight: 700; color: var(--k); border: 1px solid var(--k); border-radius: 999px; padding: 1px 8px; margin-top: 2px; white-space: nowrap; }
.wtcard details summary { cursor: pointer; margin-top: 2px; }
.wtcard .instr { white-space: pre-wrap; font-size: 13px; background: #F8F9FC; border-radius: 8px; padding: 8px 10px; margin-top: 4px; color: var(--ink); }
.healthb { background: #B42318; color: #fff; padding: 10px 20px; font-size: 14px; font-weight: 600; }

/* ---------- Photos : miniatures + visionneuse ---------- */
.thumbs { display: flex; flex-direction: column; gap: 4px; }
.trow { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.thumb { flex: none; width: 88px; height: 88px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #F3F4F6; cursor: zoom-in; scroll-snap-align: start; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: #818CF8; box-shadow: 0 2px 8px rgba(30,41,59,.15); }
.imgrow img { max-height: 220px; cursor: zoom-in; }
.lb { position: fixed; inset: 0; z-index: 80; background: rgba(12,14,18,.92); display: flex; flex-direction: column; color: #fff; }
.lbbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; }
.lbbar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.lbmain { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 10px; }
.lbmain img { max-width: calc(100% - 120px); max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lbnav { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.lbnav:hover { background: rgba(255,255,255,.3); }
.lbstrip { display: flex; gap: 6px; justify-content: center; padding: 10px; overflow-x: auto; }
.lbstrip .thumb { width: 60px; height: 60px; opacity: .6; border-color: transparent; }
.lbstrip .thumb.on { opacity: 1; border: 2px solid #fff; }
@media (max-width: 700px) { .lbmain img { max-width: calc(100% - 20px); } .lbnav { position: absolute; top: 50%; } .lbnav[data-action=lb-prev] { left: 6px; } .lbnav[data-action=lb-next] { right: 6px; } .thumb { width: 72px; height: 72px; } }
.sigdots { align-self: flex-start; border: 1px solid var(--line); background: #F3F4F6; color: #6B7280; border-radius: 6px; padding: 0 8px; height: 18px; line-height: 14px; font-size: 13px; letter-spacing: 1px; cursor: pointer; }
.sigdots:hover { background: #E5E7EB; }
.tnum { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 18px; font-weight: 700; background: var(--head, #16181D); color: #fff; border-radius: 8px; padding: 4px 10px; letter-spacing: .5px; white-space: nowrap; }
[hidden] { display: none !important; }

.match{border:1px solid var(--line,#e5e7eb);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:6px;background:#fffbea;font-size:13px}
.match.high{background:#ecfdf5;border-color:#a7f3d0}
.match .signs{display:flex;flex-wrap:wrap;gap:4px 10px}.match .signs .ok{color:#047857;font-weight:600}.match .signs .no{color:#9ca3af}
.linked{font-size:12px;background:#eef2ff;color:#3730a3;border-radius:8px;padding:6px 8px}
.lnk{background:none;border:0;padding:0;color:inherit;text-decoration:underline;cursor:pointer;font:inherit}

.attopt{display:flex;gap:10px;align-items:flex-start;border:1px solid var(--line,#e5e7eb);border-radius:10px;padding:8px 10px;cursor:pointer;font-size:13px}
.attopt:has(input:checked){border-color:#2563eb;background:#eff6ff}
.attopt .tag{display:inline-block;font-size:11px;border-radius:6px;padding:1px 6px;margin-left:4px}.attopt .tag.ok{background:#d1fae5;color:#065f46}.attopt .tag.no{background:#fee2e2;color:#991b1b}

.kpimain{border:1.5px solid #2563eb}
.dbk{display:grid;grid-template-columns:1fr 130px 36px;gap:8px;align-items:center;font-size:13px}.dbk .bar{height:10px;background:#f1f5f9;border-radius:5px;overflow:hidden}.dbk .bar div{height:100%}
.dlong{display:grid;grid-template-columns:52px 1fr auto;gap:8px;font-size:13px;color:inherit;text-decoration:none;padding:3px 0;border-bottom:1px solid #f1f5f9}.dlong:hover{background:#f8fafc}.dls{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dtab{width:100%;border-collapse:collapse;font-size:13px}.dtab th{text-align:left;font-weight:500;color:#6b7280;font-size:12px;padding:4px}.dtab td{padding:4px;border-top:1px solid #f1f5f9}.dtab .dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px}
.pill.wfb.merci { background: #FDF2F8; color: #BE185D; }

.banner.incb{background:#FFF7ED;color:#7C2D12;display:flex;gap:8px;align-items:center;flex-wrap:wrap}.banner.incb.ok{background:#F1F5F9;color:#334155}
.pill.inc{background:#FFF7ED;color:#C2410C;font-weight:600}.pill.inc.suggested{background:#FFFBEB;color:#B45309}
.ctab{width:100%;border-collapse:collapse;font-size:13px}.ctab th{text-align:left;font-weight:500;color:#6b7280;font-size:12px;padding:6px 4px}.ctab td{padding:6px 4px;border-top:1px solid #f1f5f9}.ctab .hi{color:#b91c1c;font-weight:700}

.eve{display:flex;gap:6px;align-items:flex-end;overflow-x:auto;padding:4px 0}.evd{display:flex;flex-direction:column;align-items:center;gap:4px;min-width:34px;font-size:10px;color:#6b7280}
.evb{height:90px;width:18px;display:flex;flex-direction:column;justify-content:flex-end;background:#f8fafc;border-radius:4px;overflow:hidden}.evo{background:#DC2626}.evo.ok{background:#059669}.evl{background:#FCA5A5}
.fmtbar { display: inline-flex; gap: 4px; align-items: center; }
.fmtbar .btn { min-width: 32px; padding: 0 8px; justify-content: center; }
.fmtbar .swatch span { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.banner.sumb { background: #F4F1FB; color: var(--ink); border: 1px solid #DDD3F3; }
