:root {
  --paper: #F1F4F1;
  --paper-alt: #E6EEE7;
  --ink: #17231C;
  --navy: #123524;
  --navy-dark: #0B2418;
  --teal: #16A34A;
  --teal-dark: #0F7C38;
  --gold: #22C55E;
  --gold-light: #86EFAC;
  --amber: #B4780F;
  --green: #15803D;
  --red: #A32C29;
  --line: #D6DED8;
  --muted: #5A6B60;
  --radius: 6px;
  --shadow: 0 2px 14px rgba(18, 53, 36, 0.08);
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h2 { color: var(--navy); margin-top: 0; }

a { color: var(--teal-dark); }

/* ---------------------------------------------------------------------- */
/* En-tête / navigation                                                   */
/* ---------------------------------------------------------------------- */
.site-header {
  background: var(--navy);
  color: #EAF1EE;
  padding: 16px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 3px solid var(--gold);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-seal {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-light);
  background: var(--navy-dark);
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: #fff; }
.brand-name .brand-accent { color: var(--gold-light); }
.brand-tagline {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #A9C0BA;
}

.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-nav a {
  color: #CBDAD4;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: #fff; border-bottom-color: var(--gold-light); }
.site-nav .user-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #8FA69F;
  margin-right: 4px;
}

/* ---------------------------------------------------------------------- */
/* Structure générale                                                     */
/* ---------------------------------------------------------------------- */
.container { max-width: 920px; margin: 0 auto; padding: 0 20px; }

.hero {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #EAF1EE;
  padding: 46px 20px 58px;
  text-align: center;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 10px;
}
.hero h1 {
  color: #fff;
  font-size: 2rem;
  margin: 0 0 10px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.hero p {
  color: #C3D3CD;
  max-width: 520px;
  margin: 0 auto;
  font-size: 0.98rem;
  line-height: 1.5;
}

.page-body { margin-top: -32px; padding-bottom: 50px; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 30px 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------------- */
/* Sections numérotées du dossier (formulaire public)                     */
/* ---------------------------------------------------------------------- */
.dossier-section { margin-bottom: 30px; }
.dossier-section:last-of-type { margin-bottom: 0; }

.dossier-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.dossier-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.dossier-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--navy);
  font-weight: 600;
}

label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.87rem;
  color: var(--navy);
}

input[type=text], input[type=email], input[type=tel], select, textarea, input[type=file] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.94rem;
  background: #fff;
  font-family: var(--font-body);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}
textarea { resize: vertical; min-height: 90px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 220px; }

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 5px;
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--teal);
  color: #fff;
  margin-top: 20px;
  font-family: var(--font-body);
}
button:hover, .btn:hover { background: var(--teal-dark); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { background: #5C6B65; }
.btn-secondary:hover { background: #47534E; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #7E2321; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #155C35; }
.btn-small { padding: 6px 12px; font-size: 0.8rem; margin-top: 0; }

.alert {
  padding: 14px 16px;
  border-radius: 5px;
  margin-top: 18px;
  font-size: 0.92rem;
}
.alert-success { background: #E4F2E9; color: var(--green); border: 1px solid #BEE0CA; }
.alert-error { background: #FBE9E8; color: var(--red); border: 1px solid #F0C4C1; }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.badge-en_attente { background: #FBEDD6; color: var(--amber); }
.badge-validee { background: #DDEEE2; color: var(--green); }
.badge-rejetee { background: #F6DBDA; color: var(--red); }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 30px 10px;
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------- */
/* Élément signature : carte "ticket" (numéro de suivi / certificat)      */
/* ---------------------------------------------------------------------- */
.ticket {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px dashed var(--gold);
  border-radius: 5px;
  padding: 26px 26px 22px;
  margin-top: 20px;
  animation: ticket-in 0.35s ease-out;
}
@keyframes ticket-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ticket-seal {
  position: absolute;
  top: -14px; right: 22px;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid var(--gold-light);
  color: var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  transform: rotate(-8deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.ticket-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.ticket-number {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.02em;
  word-break: break-all;
}
.ticket-body { margin-top: 12px; font-size: 0.9rem; color: var(--ink); }
.ticket-body p { margin: 4px 0; }
.ticket-body strong { color: var(--navy); }

/* ---------------------------------------------------------------------- */
/* Zone de dépôt de fichiers (drag & drop)                                */
/* ---------------------------------------------------------------------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--paper-alt);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--teal); }
.dropzone.dragover { border-color: var(--gold); background: #FBF3E1; }
.dropzone-icon-svg { color: var(--teal); margin-bottom: 6px; }
.dropzone-text { margin: 4px 0 2px; font-size: 0.95rem; color: var(--ink); }
.dropzone-text strong { color: var(--navy); }
.dropzone-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.file-item-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-item-badge {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.badge-pdf { background: var(--red); }
.badge-img { background: #1C5F8A; }
.badge-doc { background: var(--teal); }
.badge-autre { background: #6c757d; }
.file-item-text { min-width: 0; }
.file-item-name { font-size: 0.87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.file-item-size { font-size: 0.77rem; color: var(--muted); }
.file-item-remove { background: none; border: none; color: var(--red); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 4px 8px; margin-top: 0; flex-shrink: 0; }
.file-item-remove:hover { color: #7E2321; background: none; }
.file-count { font-size: 0.83rem; color: var(--muted); margin-top: 10px; font-family: var(--font-mono); }

/* ---------------------------------------------------------------------- */
/* Espace de validation (back-office)                                     */
/* ---------------------------------------------------------------------- */
.admin-wrap { max-width: 1120px; margin: 30px auto; padding: 0 20px; }
.login-wrap { max-width: 400px; margin: 70px auto; padding: 0 20px; }

.login-card-header { text-align: center; margin-bottom: 22px; }
.login-card-header .brand-seal { margin: 0 auto 14px; width: 52px; height: 52px; font-size: 1.15rem; }
.login-card-header h2 { margin-bottom: 2px; }
.login-card-header p { color: var(--muted); font-size: 0.85rem; margin: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat-card .value { font-family: var(--font-mono); font-size: 2rem; font-weight: 600; color: var(--navy); }
.stat-card .label { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

table { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.87rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--paper-alt); color: var(--navy); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover { background: #F8FAF9; }
td:first-child, th:first-child { font-family: var(--font-mono); }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; }

.pagination { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(11, 36, 24, 0.55);
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  border-top: 4px solid var(--gold);
  padding: 26px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box h3 { margin-top: 0; font-family: var(--font-mono); color: var(--navy); font-size: 1.1rem; }
.doc-list { list-style: none; padding: 0; }
.doc-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 0.88rem; }
.doc-list a { color: var(--teal-dark); cursor: pointer; }

/* ---- Bandeau d'en-tête des pages de l'espace de validation ---- */
.page-header {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #EAF1EE;
  padding: 26px 30px 36px;
}
.page-header-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 6px;
}
.page-header h2 { color: #fff; margin: 0 0 4px; font-size: 1.5rem; }
.page-header p { color: #C3D3CD; margin: 0; font-size: 0.88rem; max-width: 560px; }

.admin-wrap { margin-top: -20px; }

/* ---- Fiche de demande en grille de champs (détail) ---- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin: 14px 0 18px;
}
.field-grid .field-full { grid-column: 1 / -1; }
.field-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}
.field-value { font-size: 0.92rem; color: var(--ink); }
.field-value.empty { color: var(--muted); font-style: italic; }

/* ---- Encart certificat de validation (mini-tampon) ---- */
.cert-box {
  border: 1px dashed var(--gold);
  border-radius: 5px;
  padding: 10px 14px;
  background: #FBF6EA;
  margin-top: 8px;
  font-size: 0.85rem;
}
.cert-box a { color: var(--teal-dark); cursor: pointer; font-weight: 600; }
.cert-box .cert-meta { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* ---- Badges de rôle utilisateur ---- */
.badge-admin { background: var(--navy); color: var(--gold-light); }
.badge-validateur { background: #DDEEE2; color: var(--teal-dark); }

/* ---- Badges de type d'action (journal d'audit) ---- */
.badge-connexion { background: #E3ECEF; color: #2C5F73; }
.badge-validation { background: #DDEEE2; color: var(--green); }
.badge-rejet { background: #F6DBDA; color: var(--red); }
.badge-creation_utilisateur { background: #FBEDD6; color: var(--amber); }
.badge-suppression_utilisateur { background: #F0E3EC; color: #7A3B63; }

/* ---- Logo personnalisé dans le sceau de marque ---- */
.brand-seal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.logo-preview {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--paper-alt);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--navy);
  flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.badge-modification_parametres { background: #E3ECEF; color: #2C5F73; }

/* ---- Badge action "resoumission" (journal d'audit) ---- */
.badge-resoumission { background: #FBEDD6; color: var(--amber); }

/* ---- Badge action "consultation_document" (journal d'audit) ---- */
.badge-consultation_document { background: #E6EEE7; color: var(--teal-dark); }

/* ---- Badge action "suppression_demande" (journal d'audit) ---- */
.badge-suppression_demande { background: #F6DBDA; color: var(--red); }

/* ---- Badges actions "archivage" / "desarchivage" (journal d'audit) ---- */
.badge-archivage { background: #E6EEE7; color: var(--muted); }
.badge-desarchivage { background: #DDEEE2; color: var(--teal-dark); }

/* ---- Badges actions de messagerie (journal d'audit) ---- */
.badge-message_demandeur { background: #FBEDD6; color: var(--amber); }
.badge-reponse_message { background: #DDEEE2; color: var(--teal-dark); }

/* ---- Badge action "nouvelle_demande" (journal d'audit) ---- */
.badge-nouvelle_demande { background: #E6EEE7; color: var(--teal-dark); }

/* ---- Bannieres de verdict (espace douane) ---- */
.verdict { padding: 26px; border-radius: 8px; text-align: center; }
.verdict-icone { font-size: 2.4rem; margin-bottom: 6px; line-height: 1; }
.verdict-titre { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; }
.verdict-ok { background: #DDEEE2; color: var(--green); border: 2px solid var(--green); }
.verdict-attente { background: #FBEDD6; color: var(--amber); border: 2px solid var(--amber); }
.verdict-rejet { background: #F6DBDA; color: var(--red); border: 2px solid var(--red); }

/* ---- Badge action "verification_douane" (journal d'audit) ---- */
.badge-verification_douane { background: #E3ECEF; color: #2C5F73; }

/* ---- Badges actions de mot de passe (journal d'audit) ---- */
.badge-reinitialisation_mot_de_passe { background: #FBEDD6; color: var(--amber); }
.badge-changement_mot_de_passe { background: #DDEEE2; color: var(--teal-dark); }

/* ---- Badge action "telechargement_document" (journal d'audit) ---- */
.badge-telechargement_document { background: #FBEDD6; color: var(--amber); }
