:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1d1d1b;
  --ink-2: #5d5c57;
  --line: #e3e1da;
  --accent: #2346d6;
  --accent-soft: #e9edfc;
  --red: #c8263a;
  --red-soft: #fdecee;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --green: #1d7a46;
  --green-soft: #e6f4ec;
  --grey-soft: #efeee9;
  --mark: #e6005a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.link { color: var(--ink-2); text-decoration: none; font-size: 14px; }
.link:hover { color: var(--ink); }

/* ---------- barre du haut */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--ink); color: #fff; font-size: 14px; }
.crumbs { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); flex-wrap: wrap; min-width: 0; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: #b0aea6; }
.top-right { display: flex; align-items: center; gap: 14px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--grey-soft); color: var(--ink-2); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.ko { background: var(--amber-soft); color: var(--amber); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.ko-red { background: var(--red-soft); color: var(--red); font-weight: 600; }
.pill.cost { border: 0; font: inherit; font-size: 12px; text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.pill.cost[href] { cursor: pointer; }
a.pill.cost[href]:hover { filter: brightness(.95); text-decoration: underline; }
.bar-fill.warn, .bar-fill.ko { background: var(--amber); }
.bar-fill.ko-red { background: var(--red); }
.bar-fill.ok { background: var(--green); }

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 80px; }

/* ---------- formulaires */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); }
.panel-head { margin-bottom: 18px; max-width: 820px; }
.drops.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 150px;
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; text-align: center;
  background: var(--surface-2); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.filled { border-style: solid; border-color: var(--accent); }
.drop input { display: none; }
.drop-title { font-weight: 600; }
.drop-hint { font-size: 13px; color: var(--ink-2); }
.files { list-style: none; padding: 0; margin: 8px 0 0; width: 100%; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; margin-top: 6px; font-size: 13px; text-align: left; }
.files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files button { border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 16px; line-height: 1; }
.options { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 18px 0; align-items: center; }
.check, .select { font-size: 14px; display: flex; gap: 8px; align-items: center; }
select { font: inherit; font-size: 14px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }

.btn { font: inherit; font-size: 14px; font-weight: 500; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--ink-2); }
a.btn { display: inline-block; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* ---------- progression */
.progress-card { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; box-shadow: var(--shadow); }
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bar { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.warnings { margin: 10px 0 0; padding-left: 18px; color: var(--amber); font-size: 13px; }

/* ---------- rapport */
#report { margin-top: 24px; }
.report-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--ink-2); }
.stat.red .n { color: var(--red); } .stat.amber .n { color: var(--amber); } .stat.green .n { color: var(--green); }
.verdict { padding: 16px 20px; border-radius: var(--radius); margin-bottom: 18px; font-weight: 500; }
.verdict.ok { background: var(--green-soft); color: var(--green); }
.verdict.ko { background: var(--red-soft); color: var(--red); }
.verdict.warn { background: var(--amber-soft); color: var(--amber); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 14px; box-shadow: var(--shadow); }
table.info { border-collapse: collapse; width: 100%; font-size: 14px; }
table.info th, table.info td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.info th { color: var(--ink-2); font-weight: 500; width: 180px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 14px; font-size: 14px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-grey { background: var(--grey-soft); color: var(--ink-2); }
.b-blue { background: var(--accent-soft); color: var(--accent); }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.view-toggle button.on { background: var(--ink); color: #fff; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair figure { margin: 0; }
.pair figcaption { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.shot { position: relative; border: 1px solid var(--line); background: #fff; line-height: 0; }
.shot img { width: 100%; height: auto; display: block; }
.shot .box { position: absolute; border: 2px solid var(--mark); background: rgba(230,0,90,.08); border-radius: 2px; }
.shot .box.tone { border: 2px dashed #b0aea6; background: rgba(0,0,0,.03); }
.shot .box.dismissed { border: 2px dotted #b0aea6; background: none; }
.shot .box.hl { border-width: 3px; background: rgba(230,0,90,.22); box-shadow: 0 0 0 4px rgba(230,0,90,.25); }
.shot .lbl { position: absolute; left: -2px; top: -15px; background: var(--mark); color: #fff; font: 700 10px/13px system-ui, sans-serif;
  padding: 0 4px; border-radius: 3px; white-space: nowrap; opacity: .92; }
.shot .box.tone .lbl, .shot .box.dismissed .lbl { background: #b0aea6; }

.slider-wrap { position: relative; line-height: 0; border: 1px solid var(--line); }
.slider-wrap img { width: 100%; display: block; }
.slider-wrap .top { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 50% 0 0); }
.slider-wrap input[type=range] { position: absolute; left: 0; right: 0; bottom: 8px; width: calc(100% - 20px); margin: 0 10px; }
.slider-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--mark); left: 50%; pointer-events: none; }

.diff-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 10px; }
.diff { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid;
  grid-template-columns: 34px 1fr; gap: 12px; cursor: pointer; background: var(--surface); }
.diff:hover { border-color: var(--mark); }
.diff.dim { opacity: .6; }
.diff .num { width: 26px; height: 26px; border-radius: 50%; background: var(--mark); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; }
.diff.dim .num { background: #b0aea6; }
.diff-text { font-size: 14px; margin: 6px 0; word-break: break-word; }
del { background: var(--red-soft); color: var(--red); text-decoration: line-through; padding: 0 2px; border-radius: 3px; }
ins { background: var(--green-soft); color: var(--green); text-decoration: none; padding: 0 2px; border-radius: 3px; }
.zooms { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.zooms figure { margin: 0; flex: 1; min-width: 160px; max-width: 340px; }
.zooms figcaption { font-size: 11px; color: var(--ink-2); }
.zooms img { width: 100%; border: 1px solid var(--line); cursor: zoom-in; }
.ai-note { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.ai-note b { color: var(--ink); }
.notes { font-size: 13px; color: var(--amber); margin: 0 0 10px; padding-left: 18px; }

.req { border-left: 4px solid var(--line); padding: 10px 14px; margin: 10px 0; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.req.non_conforme { border-left-color: var(--red); }
.req.partiel { border-left-color: var(--amber); }
.req.conforme { border-left-color: var(--green); }
.err-row { display: grid; grid-template-columns: 1fr 150px; gap: 14px; padding: 10px 0; border-top: 1px dashed var(--line); }
.err-row:first-of-type { border-top: 0; }
.err-row img { width: 100%; border: 1px solid var(--line); cursor: zoom-in; }
.kv { font-size: 14px; margin: 2px 0; }
.kv span { color: var(--ink-2); }
details summary { cursor: pointer; font-weight: 600; margin: 10px 0; }

#lightbox { position: fixed; inset: 0; background: rgba(20,20,20,.85); display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 20px; }
#lightbox img { max-width: 100%; max-height: 100%; background: #fff; }

/* ---------- connexion */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); padding: 32px; border-radius: 14px; width: 100%; max-width: 380px;
  border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 14px; font-weight: 500; margin-top: 6px; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error { color: var(--red); font-size: 14px; margin: 0; }

/* ---------- accueil */
.home-head { margin-bottom: 8px; }
.tool-section { margin-top: 26px; }
.tool-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.tool-head h2 { margin: 0; }
.tool-head p { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; min-height: 104px; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); transform: translateY(-1px); outline: none; }
.tile-admin { background: var(--surface-2); }
.tile-icon { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.tile-admin .tile-icon { background: var(--grey-soft); color: var(--ink); }
.tile-icon.small { width: 34px; height: 34px; border-radius: 8px; }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon.small .ico { width: 20px; height: 20px; }
.tile-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-title { font-weight: 650; font-size: 16px; }
.tile-desc { font-size: 13.5px; color: var(--ink-2); }
.tile-status { font-size: 12.5px; font-weight: 600; margin-top: 4px; min-height: 18px; }
.tile-status.run { color: var(--accent); }
.tile-status.run::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  margin-right: 6px; animation: pulse 1.2s infinite; vertical-align: 1px; }
.tile-status.ok { color: var(--green); }
.tile-status.ok::before { content: "● "; }
.tile-status.err { color: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- vue d'une brique */
.panel-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.panel-title h1 { margin: 0; }
.steps-line { margin: 6px 0 0; }
.notice { padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.notice.ko { background: var(--amber-soft); color: var(--amber); }
.draft-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--amber-soft);
  color: #6b4100; border: 1px solid #f1d29b; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.draft-actions { display: flex; gap: 8px; }
.error-card { margin-top: 20px; background: var(--red-soft); color: var(--red); border: 1px solid #f3c2c9; border-radius: var(--radius); padding: 14px 20px; }
.error-card p { margin: 6px 0; }
.error-card.neutral { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.error-card.credit-out { border-width: 2px; border-color: var(--red); }
.error-card.credit-out h2 { margin: 0 0 6px; font-size: 20px; }
.error-card.credit-out p { color: var(--ink); }
.report { margin-top: 24px; }
.thumb-missing { max-width: 260px; border: 1px solid var(--line); cursor: zoom-in; }
pre.generic { white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 600px; overflow: auto; }
.zooms.text figure { flex: 1 1 420px; max-width: 620px; }

/* ---------- administration */
.admin-head { max-width: 900px; margin-bottom: 18px; }
.admin-grid { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; }
.step-nav { position: sticky; top: 70px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.nav-group + .nav-group { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.nav-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding: 2px 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: 14px; }
.nav-item span:first-child { flex: 1; }
.nav-item:hover { background: var(--grey-soft); }
.nav-item.active { background: var(--ink); color: #fff; }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.nav-item.active .dot { background: #fff; }
.mt0 { margin-top: 0; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
textarea.prompt-text { width: 100%; min-height: 300px; font: 13.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; resize: vertical; background: #fff; color: var(--ink); }
textarea.prompt-text:focus, .text-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.counter { text-align: right; margin-top: 2px; }
.counter.over { color: var(--red); font-weight: 600; }
.locked { margin-top: 14px; border: 1px dashed #c9c6bc; border-radius: 8px; background: var(--surface-2); }
.locked-head { font-size: 14px; font-weight: 600; padding: 8px 12px; border-bottom: 1px dashed #c9c6bc; }
.locked pre { margin: 0; padding: 10px 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); user-select: text; }
.settings { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 14px; }
.text-input { font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; color: var(--ink); }
.text-input.num { width: 120px; }
.select .text-input { width: auto; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.editor-actions .spacer { flex: 1; }
.btn.danger { color: var(--red); }
.msg-ok { color: var(--green); margin-top: 8px; }
.msg-ko { color: var(--red); margin-top: 8px; }
table.history td, table.history th { font-size: 13.5px; }
table.history th { width: 130px; }
.current-row { background: var(--green-soft); }
.nowrap { white-space: nowrap; }
.nowrap .btn + .btn { margin-left: 4px; }
#compare { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; }
.compare-head { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 14px; }
.compare-body { padding: 12px; white-space: pre-wrap; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 480px; overflow: auto; }
code { font-size: 12.5px; background: var(--grey-soft); padding: 1px 5px; border-radius: 4px; }

.credit-figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.credit-figures .l { font-size: 13px; color: var(--ink-2); }
.credit-figures .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lvl-ok { color: var(--green); } .lvl-warn { color: var(--amber); } .lvl-ko-red { color: var(--red); }
.bar.big { height: 14px; margin: 14px 0 8px; }
.bar.mini { height: 6px; margin: 6px 0 0; }
.recharge { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; margin-top: 14px; padding: 14px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; }
.recharge .full { flex-basis: 100%; margin: 0; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
table.info td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; width: 110px; }
table.info td.w40 { width: 40%; }
.card h3 { margin: 14px 0 6px; }

@media (max-width: 960px) {
  .admin-grid, .two-cols { grid-template-columns: 1fr; }
  .step-nav { position: static; }
  .credit-figures { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .drops.two, .pair { grid-template-columns: 1fr; }
  .err-row { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
@media print {
  .topbar, .panel, .report-actions, .progress-card, .filters, .view-toggle, .error-card, #view-home { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; }
}

.inline-form { display: inline; margin: 0; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.link-btn:hover { color: var(--ink); }
.ms-btn { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none;
  padding: 11px 16px; border: 1px solid #8c8c8c; border-radius: 6px; color: #5e5e5e; font-weight: 600; background: #fff; margin-top: 8px; }
.ms-btn:hover { background: #f3f3f3; border-color: #5e5e5e; }
#pw-form { display: flex; flex-direction: column; gap: 10px; }
