:root {
  --teal: #0f766e;
  --teal-d: #0b544e;
  --teal-l: #e6f4f1;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.05);
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: var(--teal); }
.hidden { display: none !important; }

/* --- Layout --- */
header.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 60px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.brand small { color: var(--muted); font-weight: 500; }
nav.tabs { display: flex; gap: 4px; margin-left: 8px; }
nav.tabs button {
  background: none; border: 0; padding: 8px 14px; border-radius: 9px;
  color: var(--muted); font-weight: 600;
}
nav.tabs button.active { background: var(--teal-l); color: var(--teal-d); }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); font-size: 13px; }
main { max-width: 1040px; margin: 0 auto; padding: 28px 24px 80px; }

/* --- Buttons --- */
.btn {
  background: var(--teal); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; transition: background .15s;
}
.btn:hover { background: var(--teal-d); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

/* --- Cards --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head { display: flex; align-items: center; margin-bottom: 20px; gap: 14px; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.page-head .spacer { flex: 1; }

/* --- Dossiers grid --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.dossier-card { padding: 18px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.dossier-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.09); }
.dossier-card h3 { margin: 0 0 6px; font-size: 16px; }
.dossier-card .meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* --- Badges / pastilles --- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; }
.badge .pip { width: 8px; height: 8px; border-radius: 50%; }
.b-repondre { background: #dcfce7; color: #166534; }
.b-ne_pas_repondre { background: #fee2e2; color: #991b1b; }
.b-a_arbitrer { background: #fef3c7; color: #92400e; }
.b-nouveau, .b-a_analyser, .b-en_analyse { background: #eef2ff; color: #3730a3; }
.b-analyse { background: var(--teal-l); color: var(--teal-d); }
.b-erreur { background: #fee2e2; color: #991b1b; }

.pastille { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.pastille .pip { width: 10px; height: 10px; border-radius: 50%; }
.v-oui .pip { background: var(--green); } .v-oui { color: var(--green); }
.v-non .pip { background: var(--red); } .v-non { color: var(--red); }
.v-incertain .pip { background: var(--amber); } .v-incertain { color: var(--amber); }

/* --- Synthèse banner --- */
.synthese { padding: 22px 24px; border-radius: var(--radius); margin-bottom: 22px; display: flex; align-items: center; gap: 20px; }
.synthese.repondre { background: linear-gradient(120deg, #ecfdf5, #d1fae5); border: 1px solid #a7f3d0; }
.synthese.ne_pas_repondre { background: linear-gradient(120deg, #fef2f2, #fee2e2); border: 1px solid #fecaca; }
.synthese.a_arbitrer { background: linear-gradient(120deg, #fffbeb, #fef3c7); border: 1px solid #fde68a; }
.synthese .verdict { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.synthese .score { font-size: 13px; color: var(--muted); }
.gauge { margin-left: auto; text-align: right; }
.gauge .num { font-size: 30px; font-weight: 800; }
.gauge .lbl { font-size: 12px; color: var(--muted); }

/* --- Table analyses --- */
table.results { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.results th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
table.results td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.results tr:last-child td { border-bottom: 0; }
.crit-name { font-weight: 600; }
.crit-tags { margin-top: 4px; }
.tag { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px; margin-right: 5px; }
.tag.elim { color: var(--red); border-color: #fecaca; background: #fef2f2; }
.tag.ocr { color: var(--teal-d); border-color: #b9e2db; background: var(--teal-l); font-weight: 600; }
.ocr-note { margin: 12px 0 0; font-size: 13px; color: var(--teal-d); }
.justif { color: var(--ink); }
.source { margin-top: 6px; font-size: 13px; color: var(--muted); }
.source .pageref { color: var(--teal-d); font-weight: 700; }
.source blockquote { margin: 4px 0 0; padding-left: 10px; border-left: 3px solid var(--teal-l);
  font-style: italic; color: var(--muted); }

/* --- Dropzone --- */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center;
  color: var(--muted); transition: .15s; background: var(--card); }
.dropzone.drag { border-color: var(--teal); background: var(--teal-l); color: var(--teal-d); }
.filelist { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.filerow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); }
.filerow .fn { flex: 1; font-size: 14px; }
.filerow select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }

/* --- Forms --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* --- Login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 50% -10%, var(--teal-l), var(--bg)); }
.login-card { width: 360px; padding: 32px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* --- Criteres admin --- */
.crit-table { width: 100%; border-collapse: collapse; }
.crit-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 10px 12px; text-transform: uppercase; }
.crit-table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.switch { display: inline-block; width: 40px; height: 22px; position: relative; }
.switch input { display: none; }
.switch .sl { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .15s; }
.switch .sl::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .sl { background: var(--teal); }
.switch input:checked + .sl::before { transform: translateX(18px); }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--teal-l);
  border-top-color: var(--teal); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* --- Modal --- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: grid; place-items: center; z-index: 50; }
.modal { width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto; padding: 26px; }
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@media print {
  header.topbar, .btn, nav.tabs { display: none !important; }
  main { max-width: none; }
}
