:root {
  --paper: #eef1f4;
  --sheet: #ffffff;
  --ink: #17233a;
  --ink-2: #4b5670;
  --line: #cfd6df;
  --scan: #d92d3a;
  --ok: #1f7a4d;
  --font: "Archivo", system-ui, sans-serif;
  --display: "Archivo Narrow", "Archivo", sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.45; }
a { color: var(--ink); }
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 1.2em 0 0.5em; }
h1 { font-size: 2rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.1rem; margin-top: 1.4em; }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
pre { background: var(--ink); color: #dfe6f2; padding: 14px 16px; overflow: auto; border-radius: 4px; }
.muted { color: var(--ink-2); }

/* barcode mark */
.bars { display: inline-block; width: 34px; height: 18px; vertical-align: -3px; margin-right: 10px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 7px, transparent 7px 9px, var(--ink) 9px 10px, transparent 10px 13px); }
.bars.big { width: 120px; height: 44px; display: block; margin: 0 0 18px; }

/* header */
.top { display: flex; align-items: center; gap: 28px; padding: 14px 20px; background: var(--sheet); border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.top nav { display: flex; gap: 18px; flex: 1; }
.top nav a { text-decoration: none; color: var(--ink-2); padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current] { color: var(--ink); border-color: var(--scan); }
.mode { font-size: 0.8rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); }
.mode-mock { border-color: var(--scan); color: var(--scan); }

/* scan field — the one bold element */
.scan { margin-top: 28px; }
.field { position: relative; border: 2px solid var(--ink); background: var(--sheet); }
.field input { width: 100%; border: 0; background: transparent; font: 500 2rem/1.2 var(--display); padding: 22px 24px; color: var(--ink); letter-spacing: 0.04em; outline: none; }
.field input:focus { box-shadow: inset 0 0 0 2px var(--scan); }
.scanline { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--scan); opacity: 0; pointer-events: none; }
.scanline.htmx-request { opacity: 1; animation: scan 0.9s linear infinite; }
@keyframes scan { from { top: 0 } to { top: calc(100% - 2px) } }
@media (prefers-reduced-motion: reduce) { .scanline.htmx-request { animation: none; top: 50%; } }
.options { display: flex; gap: 18px; align-items: end; margin-top: 12px; flex-wrap: wrap; }
.options label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ink-2); }
.options label.check { flex-direction: row; align-items: center; padding-bottom: 8px; }
select, input[type=text], input[type=search], input[type=password], textarea, input[type=file] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); background: var(--sheet); color: var(--ink); border-radius: 3px; }
button { font: 600 0.95rem var(--font); background: var(--ink); color: #fff; border: 0; padding: 10px 18px; border-radius: 3px; cursor: pointer; }
button:hover { background: #0d1526; } button:focus-visible { outline: 3px solid var(--scan); outline-offset: 2px; }
button.small { padding: 4px 10px; font-size: 0.8rem; }
.hint { color: var(--ink-2); font-size: 0.9rem; max-width: 70ch; }

/* cards */
.card { background: var(--sheet); border: 1px solid var(--line); padding: 20px 24px; margin-top: 20px; }
.err-card { border-left: 4px solid var(--scan); }
.err { color: var(--scan); }

/* product */
.product { background: var(--sheet); border: 1px solid var(--line); margin-top: 20px; padding: 24px 28px 28px; display: grid; gap: 22px;
  grid-template-columns: minmax(280px, 420px) 1fr; grid-template-areas: "head head" "gallery facts" "gallery actions" "tabs tabs"; }
@media (max-width: 860px) { .product { grid-template-columns: 1fr; grid-template-areas: "head" "gallery" "facts" "actions" "tabs"; padding: 16px; } }
.p-head { grid-area: head; }
.p-ids { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; font-size: 0.78rem; }
.p-ids span { padding: 2px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink-2); }
.p-ids .src { border-color: var(--ok); color: var(--ok); }
.p-head h2 { margin: 0 0 4px; font-size: 1.6rem; line-height: 1.2; max-width: 60ch; }
.p-head .brand { margin: 0; color: var(--ink-2); }

.p-gallery { grid-area: gallery; }
.p-main { margin: 0; border: 1px solid var(--line); background: #fff; }
.p-main img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.p-main figcaption { font-size: 0.75rem; color: var(--ink-2); padding: 6px 10px; border-top: 1px solid var(--line); }
.p-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { padding: 0; background: #fff; border: 2px solid var(--line); border-radius: 3px; cursor: pointer; aspect-ratio: 1; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb.active, .thumb:hover { border-color: var(--ink); }
.thumb:focus-visible { outline: 3px solid var(--scan); outline-offset: 1px; }
.p-imgactions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 0.85rem; }

.p-facts { grid-area: facts; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; }
@media (max-width: 1000px) { .p-facts { grid-template-columns: repeat(2, 1fr); } }
.fact { background: var(--paper); padding: 12px 14px; border-radius: 4px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.fact .lbl { font-size: 0.75rem; color: var(--ink-2); }
.fact strong { font-family: var(--display); font-size: 1.35rem; line-height: 1.15; }
.fact small { color: var(--ink-2); font-size: 0.75rem; }

.p-actions { grid-area: actions; display: flex; gap: 8px; flex-wrap: wrap; align-items: start; }
.p-actions a { text-decoration: none; font-size: 0.85rem; font-weight: 600; padding: 7px 12px; border: 1.5px solid var(--ink); border-radius: 3px; }
.p-actions a:hover { background: var(--ink); color: #fff; }
.p-actions a.primary { background: var(--ink); color: #fff; }
.p-actions a.primary:hover { background: var(--scan); border-color: var(--scan); }

.tabs { grid-area: tabs; border-top: 1px solid var(--line); padding-top: 4px; }
.tablist { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tablist [role=tab] { background: none; color: var(--ink-2); padding: 10px 14px; border-radius: 0; font-weight: 600; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.tablist [role=tab]:hover { color: var(--ink); background: none; }
.tablist [role=tab][aria-selected=true] { color: var(--ink); border-bottom-color: var(--scan); }
.tabpanel h3:first-child { margin-top: 0.4em; }
.tag { padding: 1px 6px; border: 1px solid var(--ok); color: var(--ok); border-radius: 3px; font-size: 0.75rem; }
.bullets { padding-left: 18px; max-width: 75ch; } .bullets li { margin: 4px 0; }
.desc { max-width: 75ch; white-space: pre-line; }
table.kv { border-collapse: collapse; font-size: 0.9rem; }
table.kv th, table.kv td { text-align: left; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv th { color: var(--ink-2); font-weight: 500; white-space: nowrap; }
table.kv.two th + td + th { padding-left: 28px; }
details { margin-top: 14px; } summary { cursor: pointer; font-weight: 600; }
.velocity-form { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.velocity-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ink-2); }
.velocity-form input { width: 140px; }

/* recent grid */
.grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.grid em { display: block; font-style: normal; font-weight: 600; margin-top: 4px; font-size: 0.9rem; }
.grid a { display: block; text-decoration: none; background: var(--sheet); border: 1px solid var(--line); padding: 10px; height: 100%; }
.grid a:hover { border-color: var(--ink); }
.grid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; }
.grid strong { display: block; font-size: 0.85rem; font-weight: 500; margin-top: 8px; line-height: 1.3; max-height: 3.9em; overflow: hidden; }
.grid small { color: var(--ink-2); font-size: 0.75rem; }

/* lists */
table.list { width: 100%; border-collapse: collapse; background: var(--sheet); font-size: 0.9rem; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list th { color: var(--ink-2); font-weight: 500; }
.st-found, .st-done { color: var(--ok); } .st-not_found, .st-error, .st-failed { color: var(--scan); }
.search { display: flex; gap: 8px; margin: 10px 0 20px; }
.search input { flex: 1; max-width: 420px; }
.batchform textarea { width: 100%; font-family: ui-monospace, monospace; }
.batchform label { display: block; margin-bottom: 12px; }
progress { width: 120px; vertical-align: middle; accent-color: var(--ink); }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { background: var(--sheet); border: 2px solid var(--ink); padding: 36px 40px; width: min(420px, 92vw); }
.login h1 { margin: 0 0 4px; } .login p { margin: 0 0 18px; color: var(--ink-2); }
.login label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 14px; }
.login input { width: 100%; margin-top: 4px; }

.chart { width: 100%; height: auto; background: var(--sheet); border: 1px solid var(--line); margin: 6px 0 4px; }
.velocity { margin-top: 10px; }

/* chat */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-side h3 { margin-top: 1em; } .chat-side select, .chat-side button { width: 100%; margin-top: 6px; }
.chat-side progress { width: 100%; margin-top: 8px; }
.pick, .loaded { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.pick li, .loaded li { padding: 4px 0; border-bottom: 1px solid var(--line); }
button.link { background: none; color: var(--ink); padding: 0; text-align: left; font-weight: 500; }
button.link:hover { color: var(--scan); background: none; }
.log { min-height: 380px; max-height: 65vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.msg { padding: 10px 14px; border-radius: 4px; white-space: pre-wrap; max-width: 85%; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; }
.msg.bot { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); }
.msg.sys { align-self: center; font-size: 0.8rem; color: var(--ink-2); }
.askform { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.askform textarea { flex: 1; }

/* vérification / confiance */
.verifyform .options label { flex: 1; min-width: 160px; } .verifyform .options input { width: 100%; }
.vgrid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .vgrid { grid-template-columns: 1fr; } }
.vgrid h3 { margin-top: 0.3em; }
.vmatch { display: flex; gap: 14px; align-items: start; }
.vmatch img { width: 110px; height: 110px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.conf { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.conf .bar { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; max-width: 220px; }
.conf .bar span { display: block; height: 100%; background: var(--ok); }
.conf-moyenne .bar span { background: #c98a1a; } .conf-faible .bar span { background: var(--scan); }
.conf small { color: var(--ink-2); }
.reasons { margin: 6px 0 0; padding-left: 18px; font-size: 0.82rem; color: var(--ink-2); }
