/* ═══════════════════════════════════════════════════════════════════════════
   Vizyo Verify — back-office de validation.
   Thème clair, dense, desktop d'abord, contraste AA.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #d8dde4;
  --border-strong: #b5bdc9;
  --text: #18212e;
  --muted: #5a6472;

  --primary: #1d4ed8;
  --primary-hover: #1a44be;
  --success: #15803d;
  --success-hover: #136f35;
  --danger: #b91c1c;
  --danger-hover: #a31717;

  --neutral-soft: #e5e8ee;
  --neutral-text: #374151;
  --info-soft: #dbeafe;
  --info-text: #1e3a8a;
  --warn-soft: #fef3c7;
  --warn-text: #78350f;
  --warn-border: #ecd390;
  --success-soft: #dcfce7;
  --success-text: #14532d;
  --danger-soft: #fee2e2;
  --danger-text: #7f1d1d;
  --dark-soft: #374151;

  --radius: 12px;
  --radius-s: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, 0.12);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, 0.22);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.app { height: 100vh; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.noscript { padding: 24px; text-align: center; }

h1 { font-size: 18px; margin: 0; }
h2 { font-size: 14px; margin: 0; }
p { margin: 0 0 4px; }

.muted { color: var(--muted); }
.text-danger { color: var(--danger); font-weight: 600; }
.spacer { flex: 1; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Barre supérieure ─────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 46px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1); flex-shrink: 0;
}

.brand { font-size: 15px; font-weight: 800; letter-spacing: -0.2px; }
.brand-accent { color: var(--primary); }
.brand-lg { font-size: 24px; text-align: center; margin-bottom: 2px; }

.topnav { display: flex; gap: 2px; }

.nav-link {
  border: 0; background: none; cursor: pointer;
  padding: 6px 12px; border-radius: var(--radius-s);
  font: inherit; font-weight: 600; color: var(--muted);
}
.nav-link:hover { background: var(--neutral-soft); color: var(--text); }
.nav-link.active { background: var(--info-soft); color: var(--info-text); }

.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }

/* ── Pages liste ──────────────────────────────────────────────────────────── */

.page { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.counter { font-size: 13px; padding: 4px 12px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden;
}

/* ── Tableaux ─────────────────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 700;
  padding: 8px 12px; border-bottom: 1px solid var(--border-strong);
  background: #fafbfc; white-space: nowrap;
}

.table td {
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }

.row-click { cursor: pointer; }
.row-click:hover, .row-click:focus-visible { background: #f0f4fb; outline: none; }
.row-locked td { color: var(--muted); }

.cell-ref { font-weight: 700; white-space: nowrap; }
.cell-age { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-sub { font-size: 12px; }
/* Filtres du suivi des liens */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); }
.chip-active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.form-details { margin: 8px 0 4px; }
.form-details summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; }

.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .btn + .btn { margin-left: 6px; }
.cell-note { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note-chip { color: var(--warn-text); background: var(--warn-soft); border-radius: 6px; padding: 2px 6px; }

.doc-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-info    { background: var(--info-soft);    color: var(--info-text); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge-dark    { background: var(--dark-soft);    color: #f9fafb; }

/* ── Boutons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: var(--neutral-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-ghost { background: none; border-color: var(--danger); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }

kbd {
  font: 11px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: rgba(0, 0, 0, 0.14); border-radius: 4px; padding: 2px 5px;
}
.btn-primary kbd, .btn-success kbd, .btn-danger kbd { background: rgba(255, 255, 255, 0.25); }

/* ── Formulaires ──────────────────────────────────────────────────────────── */

.input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  font: inherit; color: var(--text); background: var(--surface);
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.input:disabled { background: var(--neutral-soft); color: var(--muted); }
.input-narrow { width: 110px; }

textarea.input { resize: vertical; }

.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 4px; }
.form-field { margin-bottom: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--danger); font-weight: 600; min-height: 18px; margin: 6px 0; }

.radio-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.radio-inline { display: flex; gap: 18px; margin-bottom: 10px; }
.radio-line, .check-line {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
}
.radio-line:hover, .check-line:hover { background: var(--neutral-soft); }
.radio-locked { color: var(--danger-text); }
.check-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }

.locked-note {
  margin-top: 6px; padding: 6px 10px; border-radius: var(--radius-s);
  background: var(--danger-soft); color: var(--danger-text); font-weight: 600;
}
.info-line { margin-top: 4px; }
.confirm-text { padding: 4px 0; }

.link-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.link-input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ── Connexion (V0) ───────────────────────────────────────────────────────── */

.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }

.login-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  padding: 32px 28px;
}
.login-sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* ── États vides / erreurs ────────────────────────────────────────────────── */

.empty-state { padding: 48px 24px; text-align: center; }
.empty-emoji { font-size: 28px; margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.empty-state .btn { margin-top: 10px; }

/* ── Dossier (V2) ─────────────────────────────────────────────────────────── */

.dossier { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.dossier-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap;
}
.dossier-bar .ref { font-size: 15px; }
.doc-label { font-weight: 600; }

.banner {
  padding: 8px 16px; font-weight: 600; flex-shrink: 0;
}
.banner-warn { background: var(--warn-soft); color: var(--warn-text); border-bottom: 1px solid var(--warn-border); }

.dossier-cols {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 40fr 35fr 25fr;
  gap: 1px; background: var(--border);
}

.col-scroll { background: var(--surface); overflow-y: auto; padding: 12px 14px; min-width: 0; }

.col-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 10px;
}

/* Blocs de la colonne données / contexte */

.block {
  border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 10px 12px; margin-bottom: 10px; background: var(--surface);
}
.block-title { font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.block-warn { background: var(--warn-soft); border-color: var(--warn-border); }
.block-warn .block-title { color: var(--warn-text); }
.block-danger { background: var(--danger-soft); border-color: #f3b6b6; }
.block-danger .block-title { color: var(--danger-text); }

.field-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 3px 0; border-bottom: 1px dashed rgba(0, 0, 0, 0.07);
}
.field-row:last-child { border-bottom: 0; }
.field-lbl { color: var(--muted); font-weight: 600; flex-shrink: 0; }
.field-val { text-align: right; word-break: break-word; display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.divergence { margin-bottom: 8px; }
.divergence:last-child { margin-bottom: 0; }
.divergence-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.divergence-cell {
  background: var(--surface); border: 1px solid #f3b6b6; border-radius: 6px;
  padding: 5px 8px; display: flex; flex-direction: column; gap: 2px; word-break: break-word;
}
.src-tag { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: var(--danger-text); }

.prolongation {
  margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-s);
  background: var(--info-soft); color: var(--info-text); font-weight: 600;
}

.check-ok { color: var(--success-text); padding: 2px 0; }
.check-ko { color: var(--danger-text); font-weight: 700; padding: 2px 0; }

.extraction-line { margin-top: 4px; font-size: 12px; }

.person-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }

.decision-item { border-bottom: 1px dashed rgba(0, 0, 0, 0.07); padding: 6px 0; }
.decision-item:last-child { border-bottom: 0; }

.audit-list { max-height: 180px; overflow-y: auto; }
.audit-line { font-size: 12px; color: var(--muted); padding: 2px 0; }

/* Visionneuse */

.viewer { background: var(--surface); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }

.viewer-tabs {
  display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto;
  border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface);
}

.tab {
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  padding: 4px 12px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  color: var(--muted);
}
.tab:hover { background: var(--neutral-soft); color: var(--text); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.viewer-stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: #141a22; cursor: grab; touch-action: none;
}
.viewer-stage.dragging { cursor: grabbing; }

.viewer-img {
  position: absolute; left: 50%; top: 50%;
  max-width: 96%; max-height: 96%;
  transform: translate(-50%, -50%);
  user-select: none; -webkit-user-drag: none;
  will-change: transform;
}

.viewer-controls {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface);
}
.zoom-label { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }

.viewer.full {
  position: fixed; inset: 0; z-index: 70;
  border-radius: 0; box-shadow: var(--shadow-3);
}

/* Barre de décision */

.decision-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -2px 8px rgba(16, 24, 40, 0.07);
  flex-shrink: 0;
}

.decision-readonly { background: var(--neutral-soft); }
.readonly-banner { font-weight: 700; color: var(--neutral-text); }

/* ── Modales ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 20, 28, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}

.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-3);
  width: 480px; max-width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-wide { width: 620px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; }

.modal-body { padding: 14px 18px; overflow-y: auto; }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}

.icon-x {
  border: 0; background: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--muted);
  padding: 4px 8px; border-radius: 6px;
}
.icon-x:hover { background: var(--neutral-soft); color: var(--text); }

/* ── Toasts ───────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed; right: 16px; bottom: 78px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; max-width: 420px;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-s); box-shadow: var(--shadow-2);
  padding: 10px 12px;
}
.toast-info { border-left-color: var(--primary); }
.toast-danger { border-left-color: var(--danger); }
.toast-msg { font-weight: 600; }

/* ── Écrans étroits (secours — le produit est desktop d'abord) ────────────── */

@media (max-width: 1000px) {
  .dossier-cols { grid-template-columns: 1fr; overflow-y: auto; display: flex; flex-direction: column; }
  .viewer { min-height: 320px; }
  .col-scroll { overflow-y: visible; }
}

/* Comparaison visage ↔ portrait du document (docs/04 V2) */
.viewer-stage.is-compare { overflow: auto; cursor: default; }
.compare-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  width: 100%;
  align-items: start;
}
.compare-side { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.compare-side img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: contain;
  max-height: 46vh;
}
.compare-side figcaption {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.face-observations { margin: 6px 0; line-height: 1.45; }
/* Anomalies de capture, en tête de dossier */
.capture-warnings { margin: 4px 0 0; padding-left: 20px; }
.capture-warnings li { margin: 2px 0; line-height: 1.45; }
.advisory-note {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--warn-text);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: 12px;
  line-height: 1.45;
}

/* Séquence de capture du visage */
.seq-video {
  display: block;
  width: 100%;
  max-height: 52vh;
  background: #000;
  border-radius: 8px;
}
.live-line { margin: 8px 0 2px; }
