:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --primary-ink: #ffffff;
  --accent: #ea580c;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --info-bg: #e0f2fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
input, button, select { font: inherit; color: inherit; }
kbd { font: 11px ui-monospace, monospace; opacity: .7; margin-left: .4rem; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--danger); font-weight: 600; }
.stack { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
input[type=email], input[type=password], input[type=search], input:not([type]), input[type=text] {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-weight: 400; font-size: 1rem;
}
input:focus { outline: 2px solid #93c5fd; outline-offset: 0; border-color: #60a5fa; }

/* ---- Bandeaux ---- */
.staging-banner { background: #7c3aed; color: #fff; text-align: center; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px; }
.flash { margin: .75rem auto 0; max-width: 1100px; width: calc(100% - 32px); padding: .7rem 1rem; border-radius: 10px; font-weight: 600; background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* ---- Boutons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: #1e293b; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-big { padding: .8rem 1.3rem; font-size: 1.05rem; }
.link-btn { background: none; border: 0; padding: 0; color: #2563eb; cursor: pointer; text-decoration: underline; font-size: .9rem; }
.link-btn.danger { color: var(--danger); }
.icon-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .35rem .6rem; font-size: 1.1rem; cursor: pointer; text-decoration: none; min-width: 52px; }
.icon-btn span { font-size: .65rem; color: var(--muted); }
form.inline { display: inline; }

/* ---- En-tête ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 16px; max-width: 1100px; margin: 0 auto; }
.brand { text-decoration: none; display: grid; }
.brand strong { font-size: 1.5rem; letter-spacing: -.02em; }
.eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topnav { display: flex; gap: .5rem; }
.topnav form { margin: 0; }
.topbar-review { max-width: none; background: #fff; border-bottom: 1px solid var(--line); padding: .6rem 16px; justify-content: flex-start; }
.back { text-decoration: none; font-weight: 600; padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--line); }
.review-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 120px; }
.wrap.narrow { max-width: 720px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }

/* ---- Connexion ---- */
.auth { min-height: 90vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; }

/* ---- Accueil ---- */
.actions-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.hero-btn { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); text-decoration: none; min-height: 84px; }
.hero-btn small { display: block; color: var(--muted); font-size: .8rem; }
.hero-primary { background: var(--primary); color: #fff; }
.hero-primary small { color: #cbd5e1; }
.hero-accent { outline: 2px solid var(--accent); }
.hero-icon { font-size: 1.6rem; }

.list-card { padding: 0; overflow: hidden; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; }
.tab { padding: .4rem .8rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .9rem; border: 1px solid var(--line); background: #fff; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab .count { opacity: .7; font-weight: 500; }
.search { flex: 1 1 220px; max-width: 320px; }
.select-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 1.2rem; border-bottom: 1px solid var(--line); background: #f8fafc; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

.fiche-list { list-style: none; margin: 0; padding: 0; }
.fiche-row { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); }
.fiche-row:hover { background: #f8fafc; }
.fiche-link { flex: 1; min-width: 0; display: grid; gap: .1rem; text-decoration: none; }
.fiche-name { font-weight: 700; }
.fiche-meta { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fiche-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .15rem; }
.tag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: #f1f5f9; color: #334155; font-weight: 600; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-info { background: var(--info-bg); color: #0369a1; }
.status { font-size: .75rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.status-a_traiter { background: var(--warn-bg); color: var(--warn); }
.status-traitee { background: var(--ok-bg); color: var(--ok); }
.status-archivee { background: #e2e8f0; color: #475569; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 1rem; font-size: .9rem; }

.bulk-bar { display: none; position: sticky; bottom: 76px; margin: .8rem; padding: .7rem 1rem; background: #1e293b; color: #fff; border-radius: var(--radius); align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; z-index: 5; }
.bulk-bar.show { display: flex; }
.bulk-bar .btn { min-height: 38px; padding: .4rem .8rem; color: var(--ink); }
.bulk-bar .btn-danger { color: var(--danger); }
.bulk-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.export-bar { position: sticky; bottom: 0; padding: .8rem; background: linear-gradient(transparent, var(--card) 30%); z-index: 4; }

/* ---- Révision ---- */
.review { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); height: calc(100vh - 58px); }
.viewer-panel { display: flex; flex-direction: column; background: #1e293b; min-height: 0; }
.viewer { flex: 1; overflow: hidden; position: relative; cursor: grab; touch-action: none; min-height: 0; }
.viewer.dragging { cursor: grabbing; }
.viewer img { position: absolute; left: 50%; top: 50%; transform-origin: center center; user-select: none; max-width: none; }
.viewer-tools { display: flex; justify-content: center; gap: .4rem; padding: .5rem; background: #0f172a; }
.viewer-tools button, .viewer-tools a { background: #334155; color: #fff; border: 0; border-radius: 8px; min-width: 44px; height: 40px; padding: 0 .7rem; cursor: pointer; font-size: 1.05rem; text-decoration: none; display: inline-grid; place-items: center; }
.form-panel { overflow-y: auto; padding: 1rem 1.2rem 2rem; background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; }
.field { margin-bottom: .7rem; }
.field-top { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.field-top label, .field-top legend { font-weight: 700; font-size: .85rem; padding: 0; }
.field input { font-size: 1.05rem; }
.field-warn { display: block; color: var(--warn); font-size: .8rem; font-weight: 600; margin-top: .2rem; }
.doubt { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.doubt input { width: 14px; height: 14px; }
.doubt.on { color: var(--warn); }
.doubt.on ~ input, .field:has(.doubt.on) input { background: #fffbeb; border-color: #fbbf24; }
fieldset.sources { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem .2rem; margin: 0 0 .8rem; }
.chip-group { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .5rem; }
.chip-group-label { font-size: .75rem; font-weight: 700; color: var(--muted); width: 100%; }
.chip { display: inline-flex; cursor: pointer; font-weight: 500; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; background: #fff; user-select: none; }
.chip input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip input:focus-visible + span { outline: 2px solid #60a5fa; outline-offset: 1px; }
.chip-wide span { border-radius: 10px; font-size: .85rem; }
.consent { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.notice { padding: .6rem .8rem; border-radius: 10px; margin-bottom: .8rem; font-size: .9rem; }
.notice-warn { background: var(--warn-bg); color: #78350f; }
.review-actions { display: flex; flex-wrap: wrap; gap: .5rem; position: sticky; bottom: 0; background: #fff; padding: .7rem 0; border-top: 1px solid var(--line); }
.review-foot { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1rem; }

/* ---- Capture ---- */
.scan { padding-top: 1rem; display: grid; gap: 1rem; max-width: 560px; }
.capture-btn, .dropzone { display: grid; place-items: center; gap: .5rem; padding: 2.2rem 1rem; border-radius: 18px; background: var(--primary); color: #fff; cursor: pointer; text-align: center; font-size: 1.25rem; font-weight: 700; min-height: 42vh; }
.dropzone { background: #fff; color: var(--ink); border: 2px dashed #cbd5e1; min-height: 30vh; font-size: 1.05rem; }
.dropzone.over { border-color: var(--accent); background: #fff7ed; }
.capture-icon { font-size: 3rem; }
.progress { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.upload-errors { color: var(--danger); font-size: .85rem; padding-left: 1.2rem; }
.scan-after { display: grid; gap: .6rem; }

/* ---- Accès ---- */
.add-access { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.add-access input[type=email] { flex: 1 1 220px; }
.access-list { list-style: none; padding: 0; margin: 0; }
.access-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--line); }

/* ---- Téléphone ---- */
@media (max-width: 860px) {
  .review { grid-template-columns: 1fr; height: auto; }
  .viewer { height: 52vh; flex: none; }
  .form-panel { overflow: visible; }
}
@media (max-width: 560px) {
  .brand strong { font-size: 1.2rem; }
  .grid2 { grid-template-columns: 1fr; }
  .fiche-row { padding: .7rem .8rem; }
  .status { display: none; }
  .bulk-bar { bottom: 70px; }
}
