/* ---------- design tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f3f5f9; --card: #fff; --ink: #17222e; --muted: #64748b;
  --line: #e3e8f0; --line-soft: #edf1f7;
  --accent: #2b6cb0; --accent-d: #1f4e80; --accent-bg: #ebf3fb;
  --ok: #287a52; --ok-bg: #e9f8f0; --ok-line: #bfe8d2;
  --err: #c03434; --err-bg: #fdf0f0; --err-line: #f3cdcd;
  --warn: #9c6612; --warn-bg: #fdf6e7; --warn-line: #f0dfb7;
  --radius: 10px; --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(23, 34, 46, .05), 0 1px 1px rgba(23, 34, 46, .03);
  --shadow-lg: 0 1px 3px rgba(23, 34, 46, .06), 0 8px 24px -12px rgba(23, 34, 46, .18);
  --ring: 0 0 0 3px rgba(43, 108, 176, .25);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55;
  -webkit-font-smoothing: antialiased; }
button, a, input, select, textarea, summary { touch-action: manipulation; }

/* focus : anneau visible au clavier, discret à la souris */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px;
  border-radius: 4px; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- structure ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: .75rem 1.4rem;
  position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; color: var(--accent-d); letter-spacing: -.01em; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d)); }
.topbar nav { display: flex; gap: 1.2rem; align-items: center; }
.topbar nav a { color: var(--ink); text-decoration: none; font-size: .95rem;
  padding: .25rem 0; border-bottom: 2px solid transparent; transition: color .12s; }
.topbar nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.topbar .logout { color: var(--muted); }
.container { max-width: 860px; margin: 2rem auto; padding: 0 1.2rem; }
h1 { font-size: 1.55rem; margin: 0 0 .3rem; letter-spacing: -.015em;
  text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; letter-spacing: -.01em; }
.card { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.4rem 1.5rem; margin: 1.2rem 0;
  box-shadow: var(--shadow); }
.card.warn { border-color: var(--warn-line); background: var(--warn-bg); }

/* ---------- formulaires ---------- */
label { display: block; margin: .7rem 0; font-size: .9rem; color: var(--muted); }
input, textarea, button, select { font: inherit; }
input, textarea, select { width: 100%; margin-top: .25rem; padding: .55rem .75rem;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  background: #fff; transition: border-color .12s, box-shadow .12s; }
input:hover, textarea:hover, select:hover { border-color: #c9d3e0; }
input::placeholder { color: #9aa7b8; }
select { width: auto; background-color: #fff; color: var(--ink); }
input[type="file"] { padding: .45rem .55rem; background: var(--line-soft); }
input[type="file"]::file-selector-button { font: inherit; font-size: .88rem;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--ink); padding: .35rem .8rem; margin-right: .8rem; cursor: pointer; }
input[type="file"]::file-selector-button:hover { border-color: var(--accent);
  color: var(--accent); }

button, .button { display: inline-flex; align-items: center; justify-content: center;
  gap: .45rem; background: var(--accent); color: #fff; border: 0;
  padding: .6rem 1.15rem; border-radius: 8px; cursor: pointer;
  text-decoration: none; font-size: .95rem; font-weight: 500;
  box-shadow: var(--shadow); transition: background .12s, transform .06s; }
button:hover, .button:hover { background: var(--accent-d); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
button.link { background: none; color: var(--accent); padding: 0; box-shadow: none;
  font-weight: 400; }
button.link:hover { text-decoration: underline; background: none; }
button.primary { background: var(--ok); }
button.primary:hover { background: #1f5f40; }
.small-btn { padding: .34rem .9rem; font-size: .85rem; }

.login-card { max-width: 380px; margin: 3.2rem auto; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin: 4.5rem 0 -2rem; font-size: 1.05rem; }
.two-col { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }
.row-form { display: grid; grid-template-columns: 1.5fr 1.5fr 1fr auto; gap: .8rem;
  align-items: end; }
.row-form button { height: 42px; }
.inline { display: inline; }
.actions { display: flex; gap: 1rem; align-items: center; }

/* ---------- tableaux ---------- */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line-soft);
  font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .05em; }
td { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--err); }
.error-box { border-left: 3px solid var(--err); color: var(--err);
  background: var(--err-bg); font-size: .92rem; }
.checklist { margin: .3rem 0 .6rem 1.1rem; padding: 0; }
.checklist li { margin: .15rem 0; }
/* dépôt : barre de progression d'envoi */
.upload-progress { margin: .8rem 0; }
.upload-bar { height: 8px; background: var(--line-soft); border-radius: 6px;
  overflow: hidden; border: 1px solid var(--line); }
.upload-fill { height: 100%; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-d));
  transition: width .25s ease; }
.progress-line { margin-top: .25rem; }
.table-scroll { overflow-x: auto; }
/* dépôt : zone de glisser-déposer */
#upload-form.drop-target { outline: 2px dashed var(--accent); outline-offset: 6px;
  border-radius: 8px; }
/* relecture : mentions [À COMPLÉTER] cliquables vers la correction */
.report-preview a.mark-link { text-decoration: none; }
.report-preview a.mark-link:hover mark { background: #ffe066; }
.success { color: var(--ok); }

/* ---------- badges : pastille + libellé ---------- */
.badge { display: inline-flex; align-items: center; gap: .38rem;
  font-size: .78rem; font-weight: 600; padding: .14rem .6rem;
  border-radius: 20px; background: var(--line-soft); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.off { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.badge.todo { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.run { background: var(--accent-bg); color: var(--accent-d);
  border-color: #cfe0f2; }
.badge.run::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.badge.type { background: #eef2ff; color: #4c51bf; border-color: #dde3fb; }
.badge.type::before { display: none; }

/* tableau de bord : recherche + tri + finitions */
.table-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.table-head h2 { margin: 0; }
.search-box { width: auto; min-width: min(280px, 100%); margin: 0; }
.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap;
  transition: color .12s; }
.data-table th.sortable:hover { color: var(--accent); }
.data-table th.sortable::after { content: "⇅"; opacity: .3; font-size: .9em; margin-left: .35em; }
.data-table th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
.data-table th[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #f7fafc; }
.data-table td { vertical-align: middle; }
.no-results { padding: .8rem 0; }
.row-actions { display: flex; align-items: center; gap: .5rem .9rem; flex-wrap: wrap; }
.row-actions .link { white-space: nowrap; }

/* ---------- relecture guidée ---------- */
.stepper { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 1.2rem 0;
  flex-wrap: wrap; counter-reset: step; }
.stepper li { flex: 1; min-width: 150px; }
.stepper li a { display: block; text-align: center; padding: .6rem .5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600;
  box-shadow: var(--shadow); transition: border-color .12s, color .12s; }
.stepper li a:hover { border-color: var(--accent); color: var(--accent); }
.stepper li.current a { background: var(--accent); color: #fff; border-color: var(--accent); }
.stepper li.done a { border-color: var(--ok-line); color: var(--ok); background: var(--ok-bg); }
.stepper li.done a::after { content: " ✓"; }
.stepper li.current.done a { color: #fff; background: var(--ok); border-color: var(--ok); }

/* grille : liste de postes (une carte par poste) */
.grid-list { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0 1.4rem; }
.grid-item { border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; background: #fbfcfe; }
.grid-item-warn { border-color: var(--warn-line); background: var(--warn-bg); }
.grid-item-main { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; }
.grid-poste { font-weight: 600; color: var(--ink); }
.grid-value-cell { display: flex; align-items: center; }
.grid-val { font-weight: 700; font-size: 1.05rem; color: var(--accent-d);
  background: var(--accent-bg); padding: .18rem .6rem; border-radius: 6px;
  font-variant-numeric: tabular-nums; }
.grid-none { color: var(--muted); font-style: italic; font-size: .9rem; }
.grid-edit { width: auto; min-width: 7ch; max-width: 26ch; font-weight: 700;
  font-size: 1.02rem; text-align: center; padding: .4rem .6rem; margin: 0;
  color: var(--accent-d); font-variant-numeric: tabular-nums; }
.grid-edit.warn-input { border-color: var(--warn); background: #fff8e8; }
.grid-note { margin: .5rem 0 0; font-size: .82rem; }
.grid-note.warn { color: var(--warn); }
.grid-note.ok { color: var(--ok); }
.grid-ctx { margin: .45rem 0 0; font-size: .8rem; color: var(--muted); font-style: italic; }
.step-actions { display: flex; gap: .8rem; margin-top: 1.2rem; align-items: center; }
.point { display: flex; gap: .8rem; align-items: flex-start; padding: .7rem;
  border: 1px solid var(--line); border-radius: var(--radius); margin: .5rem 0;
  transition: background .15s, border-color .15s; }
.point.checked { background: var(--ok-bg); border-color: var(--ok-line); }
.point-check { margin: 0; }
.tick { background: none; border: 1.5px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; padding: 0; font-size: 1rem;
  line-height: 1; flex-shrink: 0; box-shadow: none; }
.point.checked .tick { background: var(--ok); color: #fff; border-color: var(--ok); }
.check-summary { list-style: none; padding: 0; }
.check-summary li { padding: .4rem 0; font-weight: 600; }

/* corrections côte à côte */
.corrections-intro { margin-bottom: .5rem; }
.fix-card { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 1.4rem;
  align-items: start; scroll-margin-top: 1rem; }
.fix-card.done { border-color: var(--ok-line); background: #fbfffc; }
.fix-issue { border-right: 1px solid var(--line); padding-right: 1.2rem; }
.fix-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .6rem;
  border-radius: 20px; background: var(--err-bg); color: var(--err);
  border: 1px solid var(--err-line); margin-bottom: .6rem; }
.fix-card.done .fix-badge { background: var(--ok-bg); color: var(--ok);
  border-color: var(--ok-line); }
.fix-label { font-weight: 600; font-size: .82rem; color: var(--muted);
  margin: .6rem 0 .2rem; text-transform: uppercase; letter-spacing: .02em; }
.fix-issue ul { margin: .2rem 0; padding-left: 1.1rem; }
.fix-issue li { margin-bottom: .35rem; }
.fix-edit { margin: 0; }
/* passage : texte figé + champs éditables en ligne, sans défilement */
.fix-passage { white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, Menlo, monospace; font-size: .86rem; line-height: 1.9;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; padding: .9rem; }
.slot-input { font: inherit; border: none; border-bottom: 2px solid var(--accent);
  padding: 0 .25rem; margin: 0 1px; color: var(--ink); border-radius: 3px 3px 0 0;
  min-width: 3ch; width: auto; }
.slot-marker { background: #fff4d6; border-bottom-color: var(--warn); }
.slot-value { background: #e5efff; }
.slot-input:focus { outline: none; background: #fff; box-shadow: 0 2px 0 var(--accent); }
.fix-text-auto { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .86rem;
  line-height: 1.6; resize: none; overflow: hidden; border: 1px solid var(--line);
  border-radius: 8px; padding: .8rem; }
.fix-buttons { display: flex; gap: 1.2rem; align-items: center; margin-top: .8rem; }
.revert-btn { color: var(--muted); }
.revert-btn:hover { color: var(--err); }
.revert-btn.redo:hover { color: var(--ok); }
/* texte retiré / original de l'IA : barré rouge, pour juger ce qui a été perdu */
.removed-original { display: block; color: var(--err); background: var(--err-bg);
  text-decoration: line-through; text-decoration-thickness: 1px;
  border: 1px solid var(--err-line); border-radius: 6px; padding: .45rem .6rem;
  margin: .25rem 0; font-size: .85rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; }
.removed-why { margin: .3rem 0 .6rem; }
.original-preview { margin-top: .8rem; }
.original-preview summary { cursor: pointer; color: var(--muted); font-size: .82rem; }
.original-preview summary:hover { color: var(--accent); }
@media (max-width: 760px) {
  .fix-card { grid-template-columns: 1fr; }
  .fix-issue { border-right: 0; border-bottom: 1px solid var(--line);
    padding-right: 0; padding-bottom: 1rem; }
}
.review-head { display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: .5rem; }
.review-head-right { display: flex; gap: 1rem; align-items: center; }
.reset-all { color: var(--muted); font-size: .85rem; }
.reset-all:hover { color: var(--err); text-decoration: underline; }
.status-line { display: flex; gap: 1rem; align-items: center; }
.review-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem;
  align-items: start; }
.report-text { width: 100%; min-height: 62vh; font-family: ui-monospace, "SF Mono",
  Menlo, monospace; font-size: .86rem; line-height: 1.55; white-space: pre-wrap;
  resize: vertical; }
/* aperçu du rapport en relecture (style document) */
.report-preview { font-family: "Times New Roman", Georgia, serif; font-size: 1.02rem;
  line-height: 1.5; color: #1a1a1a; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 2rem 2.4rem; max-height: 70vh; overflow-y: auto;
  overscroll-behavior: contain; }
.report-preview .r-title { text-align: center; font-weight: 700; font-size: 1.3rem;
  margin: .6rem 0; }
.report-preview .r-section { font-weight: 700; text-decoration: underline; margin: .4rem 0; }
.report-preview .r-body { text-align: justify; margin: .15rem 0; }
.report-preview .r-gap { height: .7rem; }
.report-preview mark { background: #fff2a8; padding: 0 .15rem; border-radius: 3px; }
.report-preview .ungrounded, .ungrounded { background: var(--err-bg);
  border-bottom: 2px dotted var(--err); border-radius: 2px; padding: 0 .1rem;
  cursor: help; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin: .3rem 0 .7rem;
  color: var(--muted); }
.legend-item { display: inline-flex; align-items: baseline; gap: .4rem; }
.legend-swatch { font-style: normal; }
.edit-toggle { margin: 1rem 0; }
.edit-toggle summary { cursor: pointer; color: var(--accent); font-weight: 600;
  font-size: .9rem; padding: .4rem 0; }
.review-actions { display: flex; gap: .8rem; margin-top: .8rem; }
.review-side { position: sticky; top: 4.2rem; }
.review-side h3 { font-size: .95rem; margin: 1rem 0 .3rem; }
.vigil-count { font-weight: 600; }
.warn-txt { color: var(--warn); }
.ok-txt { color: var(--ok); }
.vigil-list { padding-left: 1.1rem; margin: .4rem 0; }
.vigil-list li { font-size: .82rem; margin-bottom: .5rem; color: var(--ink); }
code { background: #eef2f7; padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }
@media (max-width: 800px) { .review-grid { grid-template-columns: 1fr; }
  .review-side { position: static; } }
@media (max-width: 640px) {
  .row-form, .two-col { grid-template-columns: 1fr; }
  .container { margin: 1.2rem auto; }
  .card { padding: 1.1rem 1.15rem; }
}
