/* BAT V2 — Vilains-Voisins */
@font-face { font-family: "N27"; src: url("fonts/N27-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "N27"; src: url("fonts/N27-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Roboto Flex"; src: url("fonts/RobotoFlex.ttf") format("truetype-variations"); font-weight: 100 1000; font-display: swap; }

:root {
  --ink: #161412; --paper: #fff; --bg: #f2f2f2; --line: #dddddd; --muted: #777777;
  --yellow: #ffff00; --ok: #0f9d6b; --warn: #f08c00; --err: #d62020;
  --ui: "Roboto Flex", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --brand: "N27", "Roboto Flex", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui); }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--brand); margin: 0 0 12px; line-height: 1.15; }
h1 { font-size: 30px; background: var(--yellow); display: inline-block; padding: 2px 10px; }
h3 { font-size: 17px; }
small, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 6px 0; }
.hint.warn { color: var(--warn); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; word-break: break-all; }
.mt { margin-top: 18px; }
code { background: #f2f2f2; padding: 1px 4px; }

/* En-tête */
header.top { display: flex; align-items: center; gap: 24px; padding: 14px 24px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header.top .brand img { height: 46px; display: block; }
header.top nav { display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: center; margin-left: auto; }
header.top nav a { text-decoration: none; font-weight: 600; padding: 4px 0; border-bottom: 2px solid transparent; }
header.top nav a.on { border-color: var(--ink); }
header.top nav a.muted { color: var(--muted); font-weight: 400; }
header.top nav a.btn-nav { background: var(--ink); color: var(--yellow); padding: 6px 12px; border: 0; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.narrow .wrap { max-width: 640px; }
.card { background: var(--paper); border: 1px solid var(--line); padding: 20px; margin-bottom: 18px; }
.center-card { margin-top: 30px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lead { font-size: 18px; margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2.tight { gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 860px) { .grid2, .row2 { grid-template-columns: 1fr; } }

/* Formulaires */
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid #c8c8c8; background: #fff; color: var(--ink); border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--yellow); outline-offset: 0; border-color: var(--ink); }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; }
.btn { display: inline-block; background: var(--ink); color: var(--yellow); border: 1px solid var(--ink); padding: 11px 20px; font: 700 15px var(--ui); cursor: pointer; text-decoration: none; }
.btn:hover { background: #000; }
.btn.secondary { background: #fff; color: var(--ink); }
.btn.secondary:hover { background: var(--yellow); }
.btn.danger { background: #fff; color: var(--err); border-color: var(--err); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.full { width: 100%; margin-top: 18px; padding: 14px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.inline-form input { margin: 0 !important; max-width: 260px; padding: 6px 8px !important; }
.inline-form input[name=name] { max-width: 180px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.flash { padding: 10px 14px; border-left: 4px solid var(--ink); background: #fff; }
.flash.ok { border-color: var(--ok); background: #fff; }
.flash.err { border-color: var(--err); background: #fff; }
.flash.warn { border-color: var(--warn); background: #fff; }
.err { color: var(--err); }

.badge { display: inline-block; font: 600 12px var(--ui); padding: 2px 8px; border: 1px solid var(--line); background: #fff; vertical-align: middle; }
.badge.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.badge.err { background: var(--err); color: #fff; border-color: var(--err); }
.badge.muted { color: var(--muted); }
.badge.info { background: #2f6fd6; color: #fff; border-color: #2f6fd6; }
.badge.warn { background: #f08c00; color: #fff; border-color: #f08c00; }
.late { color: var(--err); font-weight: 600; }
.tabs a.todo-validated { background: var(--ok); color: #fff; border-color: var(--ok); }
.tabs a.todo-corrections { background: #2f6fd6; color: #fff; border-color: #2f6fd6; }
.tabs a.todo-validated.on { background: var(--ok); color: #fff; }
.tabs a.todo-corrections.on { background: #2f6fd6; color: #fff; }
.tabs a.todo.on { box-shadow: inset 0 -4px 0 var(--ink); }
.todo-n { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.25); padding: 1px 6px; margin-left: 4px; }
.badge.todo-b { background: var(--yellow); color: var(--ink); border-color: var(--ink); margin-top: 4px; }
.todo-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; margin: 0 0 10px; background: #fff; border-left: 4px solid var(--ok); }
.todo-box.info { background: #fff; border-color: #2f6fd6; }
.todo-box span { font-weight: 700; margin-right: auto; }
.btn.ok-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
.done-line { color: var(--ok); font-weight: 600; margin: 0 0 8px; }
.okc { color: var(--ok); }

/* Indicateur de stockage */
.storage { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; margin: -8px 0 14px; color: var(--muted); }
.storage strong { color: var(--ink); }
.sbar { width: 160px; height: 8px; background: #e5e5e5; display: inline-block; }
.sbar i { display: block; height: 100%; background: var(--ok); }
.storage.near .sbar i { background: #f08c00; }
.storage.over .sbar i { background: var(--err); }
.storage.over strong { color: var(--err); }

/* Tableaux */
.tabs { display: flex; gap: 4px; margin: 6px 0 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; text-decoration: none; background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--ink); color: var(--yellow); border-color: var(--ink); }
.search input { min-width: 260px; margin: 0 !important; }
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid #eeeeee; vertical-align: top; }
table.list tbody tr[onclick] { cursor: pointer; }
table.list tbody tr[onclick]:hover { background: #f2f2f2; }
table.list.compact td { padding: 6px 10px; font-size: 13px; }
table.list .empty { text-align: center; color: var(--muted); padding: 30px; }
tr.off td { color: var(--muted); }
@media (max-width: 860px) { table.list { display: block; overflow-x: auto; } }

/* Dépôt */
.drop { position: relative; border: 2px dashed #b5b5b5; padding: 34px 20px; text-align: center; cursor: pointer; background: #fff; }
.drop small { display: block; margin-top: 6px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--ink); background: #ffff00; }
.drop.ready { border-style: solid; border-color: var(--ok); }
details.multi { position: relative; }
details.multi summary { list-style: none; border: 1px solid #c8c8c8; padding: 10px 34px 10px 12px; cursor: pointer; background: #fff; position: relative; }
details.multi summary::after { content: "▾"; position: absolute; right: 12px; top: 9px; }
details.multi summary::-webkit-details-marker { display: none; }
details.multi .multi-list { position: absolute; z-index: 20; left: 0; right: 0; background: #fff; border: 1px solid var(--ink); border-top: 0; padding: 4px 12px 10px; max-height: 320px; overflow: auto; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
details.multi .multi-list label { margin-top: 8px; }
form.busy input, form.busy select, form.busy textarea, form.busy .drop { pointer-events: none; opacity: .6; }
.progress { margin-top: 16px; }
.pbar { height: 10px; background: #f2f2f2; border: 1px solid var(--line); }
.pbar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s; }
.result { margin-top: 16px; padding: 14px; background: #ffff00; border: 1px solid var(--ink); }
.linkbox { display: flex; gap: 6px; margin: 8px 0; }
.linkbox .btn { white-space: nowrap; }
.linkbox input { margin: 0 !important; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* Dossier */
.version h3 { margin: 0; }
.remarks { background: #f2f2f2; padding: 10px 12px; white-space: normal; border-left: 3px solid var(--warn); }
details.clause summary { cursor: pointer; }
details.clause.off { opacity: .6; }
.narrow-form { max-width: 700px; margin-top: 18px; }
.login { margin-top: 40px; }

/* Page client — tient dans l'écran, sans défilement de page (ordinateur) */
.clientpage header.top { padding: 8px 20px; }
.clientpage header.top .brand img { height: 38px; }
button.brand { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 10px; font: inherit; color: var(--muted); }
button.brand .brand-hint { font-size: 12px; border-bottom: 1px dotted var(--muted); }
button.brand:hover .brand-hint { color: var(--ink); border-color: var(--ink); }
.clientpage .wrap { max-width: none; width: 100%; padding: 14px 18px; }
.client-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; gap: 14px; align-items: stretch; }
.client-grid > .card { margin: 0; min-width: 0; }
@media (min-width: 1151px) {
  body.clientpage { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  body.clientpage main.wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .client-grid { flex: 1; min-height: 0; }
  .client-grid > aside { overflow-y: auto; }
  .preview-flash { margin: 0 0 10px; padding: 6px 12px; }
}
@media (max-width: 1150px) { .client-grid { grid-template-columns: 1fr 1fr; } .viewer-card { grid-column: 1 / -1; order: -1; } }
@media (max-width: 720px) { .client-grid { grid-template-columns: 1fr; } .wrap { padding: 12px; } h1 { font-size: 24px; } }
.clientpage h1 { font-size: 24px; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 12px; }
.info dt { color: var(--muted); font-size: 13px; }
.info dd { margin: 0; }
.legal { font-size: 12px; line-height: 1.45; text-align: justify; color: #3a3a3a; }
.notes { background: #ffff00; border: 1px solid var(--ink); padding: 10px 12px; margin-bottom: 12px; }
.notes p { margin: 4px 0 0; }
.clauses-box { border: 2px solid var(--ink); background: #fff; margin: 0 0 14px; }
.clauses-box summary { cursor: pointer; padding: 9px 12px; font-weight: 700; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; background: var(--ink); color: var(--yellow); }
.clauses-box summary::-webkit-details-marker { display: none; }
.clauses-box summary::after { content: "▾"; margin-left: auto; }
.clauses-box[open] summary::after { content: "▴"; }
.cb-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--yellow); color: var(--ink); font-size: 13px; }
.clauses-box summary small { color: var(--yellow); }
.clause-item { background: #fff; padding: 8px 12px; border-top: 1px solid var(--ink); }
.clause-item strong { font-size: 13px; }
.clause-item .legal { margin: 4px 0 0; }

.viewer-card { padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.viewer-wrap { position: relative; flex: 1; min-height: 360px; }
.viewer { position: absolute !important; inset: 0; background: #fff; border: 1px solid var(--line); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media (max-width: 1150px) { .viewer-wrap { flex: none; height: 64vh; } }
.nav-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 44px; height: 64px; border: 1px solid var(--ink); background: rgba(255,255,255,.92); font-size: 38px; line-height: 1; cursor: pointer; color: var(--ink); }
.nav-arrow:hover { background: var(--yellow); }
.nav-arrow:disabled { opacity: .25; cursor: default; background: #fff; }
.nav-arrow.prev { left: 8px; }
.nav-arrow.next { right: 8px; }
.viewer-bar { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.pinfo { margin-left: auto; font-size: 13px; font-weight: 600; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; flex: none; }
.thumbs img { height: 62px; border: 2px solid transparent; cursor: pointer; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.thumbs img.on { border-color: var(--ink); }
.vhint { margin: 6px 0 0; font-size: 12px; }
.decide .choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); padding: 10px 12px; margin-top: 12px; cursor: pointer; font-weight: 400; }
.decide .choice input { margin-top: 5px; }
.decide .choice:has(input:checked) { border-color: var(--ink); background: #ffff00; }
.decide .sub { padding: 0 4px 4px 28px; }
.decide label { margin-top: 10px; }
.forward { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.forward summary { cursor: pointer; font-weight: 600; font-size: 14px; }

/* Plein écran : vue ajustée + miniatures */
.fs { position: fixed; inset: 0; z-index: 100; background: #fff; display: flex; flex-direction: column; padding: 10px 14px 12px; }
.fs[hidden] { display: none; }
body.fs-on { overflow: hidden; }
.fs-top { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fs-close { margin-left: auto; width: 40px; height: 40px; border: 1px solid var(--ink); background: #fff; font-size: 26px; cursor: pointer; }
.fs-close:hover { background: var(--yellow); }
.fs-stage { position: relative; flex: 1; min-height: 0; margin: 8px 0; }
.fs-viewer { position: absolute !important; inset: 0; background: #fff; }
.fs-thumbs { justify-content: center; }

/* Historique client */
dialog.trace { width: min(720px, 94vw); max-height: 86vh; border: 2px solid var(--ink); padding: 18px 22px; }
dialog.trace::backdrop { background: rgba(22,20,18,.45); }
.trace-head { display: flex; align-items: center; gap: 10px; }
.trace-head h2 { font-size: 22px; margin: 0; background: var(--yellow); padding: 2px 8px; }
.trace-close { margin-left: auto; width: 36px; height: 36px; border: 1px solid var(--ink); background: #fff; font-size: 22px; cursor: pointer; }
.trace-v { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.trace-v.current { border-left: 4px solid var(--yellow); padding-left: 10px; }
.trace-v h3 { font-size: 16px; margin: 0 0 6px; }
.trace-v ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.trace-v li { margin: 2px 0; }
.trace-v li span { display: inline-block; min-width: 92px; color: var(--muted); }
.trace-v li.rem { background: #f2f2f2; padding: 8px 10px; margin: 6px 0; border-left: 3px solid #2f6fd6; }
