:root {
  --bg: #fafaf7;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e5e3dc;
  --line-strong: #b8b5a8;
  --conf: #1f7a3e;
  --conf-soft: #d4e9d9;
  --rej: #b8342c;
  --rej-soft: #f3d6d3;
  --doute: #c9821a;
  --doute-soft: #fae7c8;
  --notfound: #5a5a5a;
  --notfound-soft: #e8e6df;
  --accent: #8b6914;
  --hover: #f5f3ec;
  --validated: #1e5db0;
  --validated-soft: #d6e4f5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); }
/* D17/18a — lien source officielle : couleur lisible (contraste fort) + souligné. */
a { color: #1556b0; text-decoration: underline; }
a:hover { color: #0d3c80; }
/* Lien dans un en-tête de panneau (fond sombre/bleu) → couleur CLAIRE, sinon bleu-sur-bleu invisible. */
.pane-head a { font-weight: 600; color: #cfe0ff; text-decoration: underline; }
.pane-head a:hover { color: #ffffff; }
body {
  font-family: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.55;
}
.ui { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }

/* ---------- Header ---------- */

header {
  border-bottom: 2px solid var(--line-strong);
  padding: 22px 40px 18px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
header h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
header .sub { color: var(--muted); font-size: 13px; font-style: italic; margin-top: 2px; }

.validator-info {
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
}
.validator-info strong { color: var(--ink); }
.validator-info .progress {
  margin-top: 4px;
  background: var(--hover);
  border-radius: 12px;
  height: 8px;
  width: 200px;
  overflow: hidden;
}
.validator-info .progress > div {
  height: 100%;
  background: var(--validated);
  transition: width 0.3s;
}
.validator-info button {
  background: none; border: 1px solid var(--line-strong);
  padding: 3px 8px; border-radius: 2px; font-size: 11px;
  cursor: pointer; margin-left: 6px;
  font-family: inherit;
}

main { padding: 22px 40px 80px; max-width: 1500px; }

/* ---------- Filters bar ---------- */

/* D25a — refonte : carte à 2 zones (en-tête + grille). En-tête = titre · pill filtres actifs ·
   réinitialiser · rafraîchir · compte. Grille = champs label-au-dessus, alignés, repère visuel
   sur les champs actifs. */
.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 14px;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.filters-head {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--hover);
  border-radius: 6px 6px 0 0;
}
.filters-title { font-weight: 600; color: var(--ink); letter-spacing: 0.02em; }
/* D25a — zone filtres actifs = puces retirables (chacune avec ✕), plus un simple compteur. */
.filters-active { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--validated-soft); color: var(--validated);
  border: 1px solid #bcd3f0; border-radius: 12px;
  padding: 2px 4px 2px 9px; font-size: 11px; line-height: 1.4;
}
.filter-chip .chip-label { opacity: 0.75; }
.filter-chip .chip-label::after { content: " :"; }
.filter-chip .chip-val { font-weight: 600; }
.chip-x {
  border: none; background: rgba(30, 93, 176, 0.16); color: var(--validated);
  width: 15px; height: 15px; padding: 0; border-radius: 50%; cursor: pointer;
  font-size: 9px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.chip-x:hover { background: var(--rej); color: white; }
.filters-spacer { flex: 1 1 auto; }
.filters-reset {
  background: none; border: 1px solid var(--line-strong); color: var(--muted);
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font: inherit; font-size: 12px;
}
.filters-reset:hover:not(:disabled) { background: var(--rej-soft); border-color: var(--rej); color: var(--rej); }
.filters-reset:disabled { opacity: 0.4; cursor: default; }
.filters .refresh {
  background: var(--validated); color: white; border: none;
  padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.filters .refresh:hover { background: #164a8a; }
.filters .count { color: var(--muted); font-style: italic; font-size: 12px; white-space: nowrap; }

.filters-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 12px 14px; }
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600;
}
.filter-field select, .filter-field input {
  font: inherit; font-size: 13px; padding: 5px 8px; color: var(--ink);
  border: 1px solid var(--line-strong); background: white; border-radius: 4px; min-width: 132px;
}
.filter-field select:focus, .filter-field input:focus {
  outline: none; border-color: var(--validated); box-shadow: 0 0 0 2px var(--validated-soft);
}
/* champ actif (valeur ≠ « tous ») : liseré accent → repérage immédiat de ce qui filtre. */
.filter-field select.active, .filter-field input.active {
  border-color: var(--validated); background: var(--validated-soft); font-weight: 600;
}
.filter-field--search input { min-width: 210px; }

/* ---------- Data table ---------- */

.table-scroll {
  max-height: 75vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-top: none;
}

table.data {
  border-collapse: collapse;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 12px;
  background: var(--panel);
  width: 100%;
}
table.data thead {
  background: #2a2a2a; color: #fafaf7;
  position: sticky; top: 0; z-index: 2;
}
table.data th {
  padding: 8px 10px; text-align: left;
  font-weight: 500;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid #4a4a4a;
  white-space: nowrap;
  font-size: 11.5px;
  line-height: 1.3;
}
table.data th:hover { background: #404040; }
table.data th.sortable::after { content: " ⇅"; opacity: 0.4; font-size: 10px; }
table.data th.sort-asc::after { content: " ↑"; opacity: 1; }
table.data th.sort-desc::after { content: " ↓"; opacity: 1; }
table.data td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.data td.num {
  font-family: "SF Mono", Menlo, monospace;
  text-align: right;
}
table.data td.num.bold { font-weight: 600; }

/* Column-specific widths */
table.data th.col-pourvoi,
table.data td.col-pourvoi {
  max-width: 90px;
  width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data th.col-status,
table.data td.col-status {
  width: 40px;
  text-align: center;
}
table.data tr.row-approuve td { background: #fafff9; }
table.data tr.row-doute td { background: #fffaf0; }
table.data tr.row-rejete td { background: #fff5f3; }
table.data tr.row-notfound td { background: #f7f6f1; color: var(--muted); font-style: italic; }
table.data tbody tr:hover td { background: var(--hover) !important; cursor: pointer; }

.validation-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.vdot-approuve { background: var(--conf); }
.vdot-doute { background: var(--doute); }
.vdot-rejete { background: var(--rej); }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.approuve { background: var(--conf-soft); color: var(--conf); }
.badge.doute { background: var(--doute-soft); color: var(--doute); }
.badge.rejete { background: var(--rej-soft); color: var(--rej); }
.badge.notfound { background: var(--notfound-soft); color: var(--notfound); }
.badge.conf { background: var(--conf-soft); color: var(--conf); }
.badge.rej { background: var(--rej-soft); color: var(--rej); }
.badge.neutral { background: #e8e6df; color: var(--muted); }
.badge.mine { background: var(--validated-soft); color: var(--validated); }
/* D15a — skip Sonnet + type fiable v3 */
.badge.skip { background: #d9e9ff; color: #1b4f9c; }
.badge.horsv4 { background: #ededed; color: #777; font-style: italic; }
.badge.type-mono { background: #e3f0e3; color: #2c6e3f; }
.badge.type-multi { background: #fdebd2; color: #9c5b1b; }
.badge.type-indet { background: #ececec; color: #666; }
/* D18b — « Texte jugé » : ⚠ résumé/extrait = WARNING ambre qui doit sauter aux yeux
   dans une liste de verts ; « officiel » discret. */
.badge.prov-warn { background: #ffe08a; color: #7a4b00; font-weight: 700; border: 1px solid #d99a16; }
.badge.prov-officiel { background: #eef0ec; color: #7a8077; }
/* D18b — « commentaire vide → à re-sourcer » : ton info teal, DISTINCT de l'ambre résumé
   (action humaine, pas fragilité de source). */
.badge.resource { background: #dceef0; color: #2a6b73; font-weight: 600; }
/* D19b — source inexploitable (arrêt non jugeable) : rouge sobre, distinct du 📄 re-sourcer. */
.badge.inexploitable { background: #fbe0de; color: #8a1c12; font-weight: 700; border: 1px solid #d98e86; }
/* D19b — source vide (arrêt résolu, texte 0 octet) : ambre, récupérable par re-fetch. */
.badge.source-vide { background: #fcefd6; color: #8a5a12; font-weight: 600; border: 1px solid #d9b46a; }
.conf-tag { font-size: 0.72em; color: var(--muted); margin-left: 3px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--panel);
  width: 100%; max-width: 1400px;
  max-height: 95vh;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  font-family: -apple-system, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.modal-header h3 {
  font-size: 17px; font-weight: 500;
  font-family: "Iowan Old Style", Georgia, serif;
  line-height: 1.4;
}
.modal-header .close {
  background: none; border: 1px solid var(--line-strong);
  padding: 5px 12px; cursor: pointer; font-size: 12px;
  border-radius: 2px;
}
.modal-body { padding: 10px 24px 12px; overflow-y: auto; flex: 1 1 auto; min-height: 200px; }

.context-details {
  background: white;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.context-details > summary {
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  list-style: none;
}
.context-details > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.context-details[open] > summary::before {
  transform: rotate(90deg);
}
.context-details > summary:hover { background: var(--hover); }
.modal-context {
  padding: 4px 12px 10px;
  margin-top: 0;
  border-top: 1px solid var(--line);
}
.modal-context > *:last-child { margin-bottom: 0; }

.meta-block {
  background: var(--bg);
  padding: 12px 14px;
  border-radius: 3px;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--muted);
}
.modal-context .meta-block {
  background: transparent;
  padding: 0;
  margin-bottom: 6px;
}
.meta-block strong { color: var(--ink); }

.scores-block {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.scores-block .s {
  background: var(--bg);
  padding: 4px 6px;
  border-radius: 2px;
  font-size: 11px;
  text-align: center;
}
.scores-block .s .lbl {
  color: var(--muted); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.scores-block .s .val {
  font-size: 16px; font-family: "SF Mono", Menlo, monospace;
  margin-top: 1px;
}

.vertex-reason,
.sonnet-reason {
  background: #fffcf0;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.5;
  font-family: "Iowan Old Style", Georgia, serif;
}
.sonnet-reason {
  background: #f5f8fc;
  border-left-color: var(--validated);
  margin-top: 6px;
}
.sonnet-reason .lbl {
  color: var(--validated);
}
.vertex-reason .lbl {
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 4px;
}

.texts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 0;
}
.text-pane {
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.text-pane .pane-head {
  background: #2a2a2a; color: #fafaf7;
  padding: 8px 12px;
  font-size: 12px; font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.text-pane .pane-head .copy-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fafaf7;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.text-pane .pane-head .copy-btn:hover { background: rgba(255, 255, 255, 0.2); }
.text-pane .pane-head .copy-btn.copied {
  background: var(--conf);
  border-color: var(--conf);
  color: white;
}
.text-pane .pane-body {
  background: white;
  padding: 14px 16px;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 13.5px;
  line-height: 1.6;
  /* D17/18a — hauteur bornée + scroll interne : sinon un commentaire long (15k car.)
     pousse la zone « dépôt document + jugement Sonnet » hors écran. Les panneaux
     défilent indépendamment, la zone de dépôt reste atteignable sous la grille. */
  max-height: 42vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.text-pane .pane-body.empty {
  color: var(--muted); font-style: italic;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 12px;
}

/* ---------- Validation zone ---------- */

.validation-zone {
  border-top: 1px solid var(--line);
  padding: 12px 24px 14px;
  background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
  max-height: 60vh;
  overflow-y: auto;
}
.validation-zone h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.vote-buttons {
  display: flex; gap: 10px;
}
.vote-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid;
  background: white;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.vote-btn.approuve { border-color: var(--conf); color: var(--conf); }
.vote-btn.approuve:hover, .vote-btn.approuve.selected { background: var(--conf); color: white; }
.vote-btn.doute { border-color: var(--doute); color: var(--doute); }
.vote-btn.doute:hover, .vote-btn.doute.selected { background: var(--doute); color: white; }
.vote-btn.rejete { border-color: var(--rej); color: var(--rej); }
.vote-btn.rejete:hover, .vote-btn.rejete.selected { background: var(--rej); color: white; }

.vote-comment {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: inherit;
  font-size: 13px;
  min-height: 44px;
  resize: vertical;
}

.existing-validations {
  background: white;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
  font-size: 12px;
}
.existing-validations .ev-row {
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.existing-validations .ev-row:last-child { border-bottom: none; }
.existing-validations .ev-empty { color: var(--muted); font-style: italic; }

.save-status {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  min-height: 0;
}
.save-status:empty { display: none; }
.save-status.saving { color: var(--accent); }
.save-status.saved { color: var(--conf); }
.save-status.error { color: var(--rej); font-weight: 600; }

/* ---------- Welcome modal ---------- */

.welcome-modal {
  background: var(--panel);
  padding: 36px 40px;
  border-radius: 4px;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.welcome-modal h2 {
  font-size: 22px;
  margin-bottom: 8px;
  font-family: "Iowan Old Style", Georgia, serif;
  font-weight: 500;
}
.welcome-modal p {
  color: var(--muted);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.welcome-modal input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 14px;
}
.welcome-modal button {
  width: 100%;
  padding: 12px;
  background: var(--validated);
  color: white;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.welcome-modal button.secondary-btn {
  background: white;
  color: var(--validated);
  border: 1px solid var(--line-strong);
  margin-top: 8px;
}
.welcome-modal button.secondary-btn:hover {
  background: var(--hover);
}
.welcome-modal form {
  display: flex;
  flex-direction: column;
}
.welcome-modal .login-error {
  color: var(--rej);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}
.welcome-modal .login-info {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  min-height: 16px;
  font-style: italic;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-family: -apple-system, system-ui, sans-serif;
}
.loading.error { color: var(--rej); }

/* A2c — Observer column (read-only) + Δ Obs↔Sonnet derived signal */
.cell-observer {
  opacity: 0.7;
  font-style: italic;
  background: rgba(120, 120, 120, 0.06);
}
.validation-dot.observer-dot {
  border: 1px solid rgba(80, 80, 80, 0.5);
  opacity: 0.8;
}
.col-divergence {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.div-flag {
  color: #c0392b;
  font-weight: 600;
}
.div-ok {
  color: #27ae60;
  opacity: 0.6;
}
/* D17/18a — état nuancé « à examiner » (Doute Observer/Sonnet) : orange, distinct du désaccord rouge. */
.div-examiner {
  color: var(--doute);
  font-weight: 600;
}
/* D19b — « hors Δ (source) » : gris sobre, ce n'est pas un désaccord mais un défaut de source. */
.div-inexploitable {
  color: #8a1c12;
  font-style: italic;
  opacity: 0.85;
}
.observer-block {
  padding: 0.6em 0.8em;
  margin: 0.6em 0;
  background: rgba(120, 120, 120, 0.08);
  border-left: 3px solid #888;
  font-size: 0.95em;
}
.observer-block.observer-absent {
  opacity: 0.6;
  font-style: italic;
}

/* D17/18a Part B — zone dépôt document + jugement Sonnet (modal). */
.deposit-block { margin-top: 16px; padding: 14px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: #fbfaf6; }
.deposit-head { font-weight: 700; margin-bottom: 6px; }
.deposit-hint { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.deposit-controls { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; font-size: 14px; }
.deposit-controls select, .deposit-file input { font-size: 13px; }
#depositText { width: 100%; min-height: 120px; font-family: inherit; font-size: 13px;
  padding: 8px; border: 1px solid var(--line-strong); border-radius: 4px; resize: vertical; }
.deposit-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
#depositJudgeBtn { background: #1556b0; color: #fff; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 4px; font-size: 14px; }
#depositJudgeBtn:hover { background: #0d3c80; }
.deposit-status { font-size: 13px; color: var(--ink); }
.deposit-cap { margin-top: 10px; font-size: 12px; color: var(--doute); background: #fdf6e9;
  padding: 6px 8px; border-radius: 4px; }

/* D17/18a Part B — panneau droit transformé en zone de dépôt quand l'arrêt est indisponible. */
.text-pane.deposit-pane .pane-head { background: #1556b0; }
.deposit-pane-body {
  white-space: normal !important;
  font-family: -apple-system, system-ui, sans-serif !important;
  font-size: 13px !important;
  max-height: none !important;
  background: #fbfaf6 !important;
}
.deposit-pane-body .deposit-hint { margin-bottom: 8px; }
.deposit-pane-body #depositText { min-height: 160px; }

/* D17/18a — bandeau verdict Sonnet visible en haut du modal. */
.sonnet-banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 5px;
  border-left: 4px solid var(--muted); background: #f7f6f1; font-size: 13px; }
.sonnet-banner.sb-approuve { border-left-color: var(--conf); background: #f2f9f4; }
.sonnet-banner.sb-doute { border-left-color: var(--doute); background: #fdf6e9; }
.sonnet-banner.sb-rejete { border-left-color: var(--rej); background: #fbf0ef; }
.sonnet-banner .sb-head { margin-bottom: 4px; }
.sonnet-banner .sb-raison { color: var(--ink); line-height: 1.5; }

/* D17/18a — provenance + verdict précédent dans le bandeau Sonnet. */
.sonnet-banner .sb-prov { font-weight: 600; color: var(--accent); }
.sonnet-banner .sb-prev { margin-top: 6px; font-size: 12px; color: var(--muted);
  border-top: 1px dashed var(--line-strong); padding-top: 5px; }

/* D21a — version B (juriste aveugle) : masquer le titre orphelin « Validations existantes »
   (son contenu est déjà vidé par render.js en B). Hook .view-juriste posé sur <body>. */
body.view-juriste #existingValidationsTitle { display: none; }
