:root {
  --ink:        #0f1e2e;   /* bleu ardoise très foncé (texte) */
  --ink-soft:   #43566a;   /* texte secondaire */
  --paper:      #f5f7f9;   /* fond général */
  --card:       #ffffff;   /* surfaces */
  --line:       #d7dee6;   /* filets */
  --brand:      #1b4a73;   /* bleu institutionnel */
  --brand-ink:  #12304b;
  --accent:     #0b7a5b;   /* vert validation */
  --accent-bg:  #e6f4ee;
  --danger:     #b3261e;   /* rouge alerte */
  --danger-bg:  #fbe9e7;
  --warn:       #8a5a00;   /* orange avertissement */
  --warn-bg:    #fdf1dd;
  --radius:     10px;
  --shadow:     0 1px 2px rgba(15,30,46,.06), 0 8px 24px rgba(15,30,46,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Marque ---------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px;
  background:
    linear-gradient(135deg, var(--brand) 0 50%, transparent 0),
    linear-gradient(315deg, var(--brand) 0 50%, transparent 0),
    var(--card);
  box-shadow: inset 0 0 0 2px var(--brand);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px;
  background:
    repeating-linear-gradient(0deg, var(--brand) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(90deg, var(--brand) 0 2px, transparent 2px 4px);
  opacity: .5;
}
.brand-text {
  font-weight: 800; letter-spacing: .14em; font-size: .82rem; color: var(--brand-ink);
}

/* ---------- Barre supérieure ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.link-quiet {
  color: var(--ink-soft); text-decoration: none; font-size: .9rem;
  border-bottom: 1px solid transparent; padding-bottom: 1px;
}
.link-quiet:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Layout page ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.page-title {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -.01em; margin: 0 0 .5rem;
}
.page-lead { color: var(--ink-soft); margin: 0 0 2rem; max-width: 60ch; }

/* ---------- Zone de dépôt ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--card); padding: 3rem 1.5rem; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s, transform .05s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--brand); }
.dropzone.dragover { border-color: var(--brand); background: #eef4f9; }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.dz-icon { width: 40px; height: 40px; color: var(--brand); margin-bottom: .3rem; }
.dz-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.dz-or { color: var(--ink-soft); margin: .1rem 0; font-size: .9rem; }
.dz-hint { color: var(--ink-soft); font-size: .82rem; margin: .6rem 0 0; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit; font-weight: 650; border-radius: 8px; padding: .62rem 1.15rem;
  cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); background: #eef4f9; }

/* ---------- Traitement ---------- */
.panel {
  margin-top: 1.5rem; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.5rem; display: flex; align-items: center; gap: 1rem;
}
.processing-text { margin: 0; color: var(--ink-soft); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Résultats ---------- */
.result-head {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem;
  border-radius: var(--radius); font-weight: 700; margin: 1.5rem 0 1rem;
}
.result-head .badge-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.rh-valid   { background: var(--accent-bg); color: var(--accent); }
.rh-valid   .badge-dot { background: var(--accent); }
.rh-invalid { background: var(--danger-bg); color: var(--danger); }
.rh-invalid .badge-dot { background: var(--danger); }
.rh-warn    { background: var(--warn-bg);   color: var(--warn); }
.rh-warn    .badge-dot { background: var(--warn); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1.25rem;
}
.card-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); padding: .9rem 1.25rem; border-bottom: 1px solid var(--line);
  margin: 0; font-weight: 700;
}
.kv { display: grid; grid-template-columns: minmax(140px, 34%) 1fr; }
.kv > div { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); }
.kv > div:nth-last-child(-n+2) { border-bottom: none; }
.kv .k { color: var(--ink-soft); font-size: .9rem; }
.kv .v { font-weight: 600; word-break: break-word; }
.kv .di-tag {
  display: inline-block; font-size: .72rem; font-weight: 700; color: var(--brand);
  background: #eef4f9; border-radius: 4px; padding: .05rem .35rem; margin-right: .4rem;
}

.cert-note { color: var(--ink-soft); font-size: .85rem; padding: .8rem 1.25rem; }

/* ---------- Alertes ---------- */
.alert { border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; font-size: .95rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); }

.restart-row { margin-top: 1.5rem; }

/* Barre d'action au-dessus du résultat */
.result-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 1.75rem 0 0;
  padding-top: 1.25rem; border-top: 1px solid var(--line);
  /* Cible du défilement après analyse : on laisse respirer au-dessus pour que
     le nom du fichier et le bouton « Effacer » ne collent pas au bord haut. */
  scroll-margin-top: 1.5rem;
}
.result-filename {
  font-size: .9rem; color: var(--ink-soft); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-small { padding: .4rem .8rem; font-size: .85rem; }

.hidden { display: none !important; }

/* ---------- Connexion ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e7eef4, transparent),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}
.login-card .brand { margin-bottom: 1.5rem; }
.login-title { font-size: 1.3rem; margin: 0 0 .35rem; }
.login-sub { color: var(--ink-soft); font-size: .92rem; margin: 0 0 1.25rem; }
.login-form { display: flex; flex-direction: column; gap: .5rem; }
.field-label { font-size: .82rem; font-weight: 650; color: var(--ink-soft); }
.field-input {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fbfcfd; margin-bottom: .5rem;
}
.field-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.login-form .btn { margin-top: .25rem; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { transition: none !important; }
}

@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr; }
  .kv > div { border-bottom: 1px solid var(--line); }
  .kv .k { padding-bottom: 0; }
}
