/* Interface de la plateforme de cartes bénéficiaires.
   Sobre et dense : l'écran de travail d'un poste de base, pas une vitrine. */

:root {
  --bleu: #1f3864;
  --bleu-clair: #2f5597;
  --accent: #c44536;
  --ok: #2e7d32;
  --alerte: #b26a00;
  --fond: #f4f5f7;
  --carte: #ffffff;
  --bord: #d9dce1;
  --texte: #1c2430;
  --gris: #6b7280;
  --rayon: 7px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 14px;
  color: var(--texte);
  background: var(--fond);
}

/* ---------- Ossature ---------- */
#app { display: flex; flex-direction: column; height: 100%; }

header {
  display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap;
  padding: 10px 18px;
  background: linear-gradient(100deg, var(--bleu) 0%, var(--bleu-clair) 100%);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  flex: 0 0 auto;
}
header .marque { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
header .logo { width: 34px; height: 34px; flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
header h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; line-height: 1.2; }
header .sous-titre { font-size: 11.5px; opacity: .75; }
header .groupe-campagne {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 4px 4px 4px 10px;
}
header .groupe-campagne label { font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; opacity: .85; font-weight: 600; }
header .groupe-campagne select { min-width: 170px; border: 0; border-radius: 5px;
  padding: 5px 8px; font-weight: 600; color: var(--bleu); }
header .groupe-campagne button.action { background: var(--accent); white-space: nowrap; }
header .groupe-campagne button.action:hover { background: #a83a2d; }
header .grandir { flex: 1; }
header select, header button { font-size: 13px; }
header .etiquette { font-size: 12px; opacity: .85; }
header .pastille { box-shadow: 0 0 0 1px rgba(255,255,255,.35); }

#corps { display: flex; flex: 1; min-height: 0; }

nav {
  width: 208px; flex: 0 0 208px;
  background: #fff; border-right: 1px solid var(--bord);
  padding: 10px 0; overflow-y: auto;
}
nav button {
  display: block; width: 100%; text-align: left;
  padding: 11px 16px; border: 0; background: none;
  font-size: 14px; color: var(--texte); cursor: pointer;
  border-left: 3px solid transparent;
}
nav button:hover { background: #eef1f6; }
nav button.actif {
  background: #e8edf6; border-left-color: var(--bleu-clair);
  font-weight: 600; color: var(--bleu);
}
nav button .num {
  display: inline-block; width: 20px; color: var(--gris); font-weight: 400;
}
nav button.actif .num { color: var(--bleu-clair); }

main { flex: 1; overflow-y: auto; padding: 18px 22px 40px; min-width: 0; }
section.onglet { display: none; max-width: 1180px; }
section.onglet.actif { display: block; }

h2 { font-size: 18px; margin: 0 0 4px; color: var(--bleu); }
h2 + .chapeau { margin: 0 0 18px; color: var(--gris); max-width: 760px; line-height: 1.5; }
h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase;
     letter-spacing: .4px; color: var(--gris); }

/* ---------- Blocs ---------- */
.bloc {
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 16px 18px; margin-bottom: 16px;
}
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grille3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 1000px) { .grille2, .grille3 { grid-template-columns: 1fr; } }

/* ---------- Formulaires ---------- */
label.champ { display: block; margin-bottom: 12px; }
label.champ > span {
  display: block; font-size: 12px; color: var(--gris);
  margin-bottom: 4px; font-weight: 600;
}
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--bord); border-radius: 5px;
  font: inherit; background: #fff; color: var(--texte);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--bleu-clair); outline-offset: -1px; border-color: var(--bleu-clair);
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.aide { font-size: 12px; color: var(--gris); margin-top: 4px; line-height: 1.45; }

button.action {
  padding: 8px 16px; border: 0; border-radius: 5px;
  background: var(--bleu-clair); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer;
}
button.action:hover { background: var(--bleu); }
button.action:disabled { background: #a9b2c1; cursor: not-allowed; }
button.secondaire { background: #fff; color: var(--bleu); border: 1px solid var(--bord); }
button.secondaire:hover { background: #eef1f6; }
button.danger { background: #fff; color: var(--accent); border: 1px solid #e6c4c0; }
button.danger:hover { background: #fdf0ee; }
button.petit { padding: 4px 9px; font-size: 12px; font-weight: 500; }
.rangee { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Pastilles d'état ---------- */
.pastille {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 11px; font-size: 12px; font-weight: 600;
}
.pastille.ok { background: #e3f2e5; color: var(--ok); }
.pastille.non { background: #fdeceb; color: var(--accent); }
.pastille.attente { background: #fdf3e2; color: var(--alerte); }
.pastille.neutre { background: #eceef2; color: var(--gris); }

.avis { padding: 10px 13px; border-radius: 6px; margin-bottom: 12px; line-height: 1.5; }
.avis.alerte { background: #fdf3e2; border-left: 3px solid var(--alerte); }
.avis.erreur { background: #fdeceb; border-left: 3px solid var(--accent); }
.avis.info { background: #eaf0fa; border-left: 3px solid var(--bleu-clair); }
.avis.bon { background: #e9f5ea; border-left: 3px solid var(--ok); }

/* ---------- Calibrage ---------- */
#calibrage-zone { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(330px,1fr); gap: 16px; }
@media (max-width: 1100px) { #calibrage-zone { grid-template-columns: 1fr; } }

#plan {
  position: relative; background: #e9ebef repeating-conic-gradient(#dfe2e7 0% 25%, #e9ebef 0% 50%) 0 0/16px 16px;
  border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden;
  user-select: none; touch-action: none;
}
#plan img { display: block; width: 100%; height: auto; pointer-events: none; }
.zone {
  position: absolute; border: 1.5px solid rgba(47,85,151,.95);
  background: rgba(47,85,151,.10); cursor: move;
}
.zone .nom {
  position: absolute; top: -18px; left: -1px; font-size: 10px; line-height: 16px;
  padding: 0 5px; background: var(--bleu-clair); color: #fff;
  border-radius: 3px 3px 0 0; white-space: nowrap; pointer-events: none;
}
.zone.choisie { border-color: var(--accent); background: rgba(196,69,54,.14); z-index: 5; }
.zone.choisie .nom { background: var(--accent); }
.zone .poignee {
  position: absolute; right: -5px; bottom: -5px; width: 11px; height: 11px;
  background: #fff; border: 1.5px solid var(--accent); border-radius: 2px;
  cursor: nwse-resize;
}
.zone.photo { border-style: dashed; }
.zone.qrcode { border-style: dashed; }

#liste-champs { max-height: 230px; overflow-y: auto; border: 1px solid var(--bord); border-radius: 5px; }
#liste-champs .item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-bottom: 1px solid #eef0f3; cursor: pointer; font-size: 13px;
}
#liste-champs .item:last-child { border-bottom: 0; }
#liste-champs .item:hover { background: #f5f7fa; }
#liste-champs .item.choisi { background: #e8edf6; font-weight: 600; }
#liste-champs .item .type { font-size: 11px; color: var(--gris); margin-left: auto; }

#apercu-reel { width: 100%; border: 1px solid var(--bord); border-radius: 5px; background: #fff; }

/* ---------- Journal ---------- */
#journal, .journal {
  background: #11161f; color: #d6dbe3; border-radius: 6px;
  padding: 10px 13px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; line-height: 1.6; height: 320px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.journal .WARNING { color: #ffc46b; }
.journal .ERROR { color: #ff8b7e; }
.journal .INFO { color: #d6dbe3; }

.barre { height: 8px; background: #e2e5ea; border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.barre > div { height: 100%; background: var(--bleu-clair); width: 0; transition: width .25s; }

table.recap { width: 100%; border-collapse: collapse; font-size: 13px; }
table.recap th, table.recap td {
  text-align: left; padding: 6px 9px; border-bottom: 1px solid #eef0f3;
}
table.recap th { color: var(--gris); font-weight: 600; width: 46%; }

.puce { font-size: 12px; color: var(--gris); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.cache { display: none !important; }

/* ---------- Navigateur de dossiers ---------- */
.liste-dossiers { max-height: 230px; overflow-y: auto; border: 1px solid var(--bord); border-radius: 5px; }
.liste-dossiers .item { padding: 7px 10px; border-bottom: 1px solid #eef0f3; cursor: pointer; }
.liste-dossiers .item:last-child { border-bottom: 0; }
.liste-dossiers .item:hover { background: #f5f7fa; }

/* ---------- Taille de police au calibrage ---------- */
.bloc-police {
  background: #f3f6fb; border: 1px solid #c9d5ea; border-radius: 5px;
  padding: 10px 12px; margin-bottom: 12px;
}
.bloc-police > label { display: block; font-weight: 600; color: var(--bleu); margin-bottom: 6px; }
.bloc-police input[type=number] { width: 80px; font-size: 16px; font-weight: 600; text-align: center; }
.bloc-police .aide { margin-top: 8px; }
#liste-champs .item .taille {
  font-size: 11px; font-weight: 600; color: var(--bleu-clair);
  background: #e8edf6; border-radius: 3px; padding: 1px 5px; margin-left: 6px;
}

/* ---------- Fenêtre de lancement ---------- */
dialog#dlg-lancer {
  border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 20px 22px; width: min(560px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog#dlg-lancer::backdrop { background: rgba(20,30,50,.45); }
.choix-mode { display: grid; gap: 8px; }
.choix-mode label {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px;
  border: 1px solid var(--bord); border-radius: 5px; padding: 9px 12px; cursor: pointer;
}
.choix-mode label:has(input:checked) { border-color: var(--bleu-clair); background: #eef3fb; }
.choix-mode input { grid-row: span 2; align-self: center; }
.choix-mode span { color: var(--gris); font-size: 13px; }

/* ---------- Pages de compte (connexion, demande, mot de passe) ---------- */
body.page-compte { display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; min-height: 100%; height: auto; }
.carte-compte { width: 100%; max-width: 440px; background: var(--carte);
  border: 1px solid var(--bord); border-radius: var(--rayon); padding: 26px 26px 20px; }
.carte-compte h1 { font-size: 20px; color: var(--bleu); margin: 0 0 6px; }
.carte-compte .chapeau { color: var(--gris); margin: 0 0 18px; line-height: 1.5; }
.carte-compte input, .carte-compte textarea { width: 100%; }
.carte-compte a { color: var(--bleu-clair); }

/* ---------- Administration ---------- */
a.lien-bouton { display: inline-block; text-decoration: none; border-radius: 5px;
  padding: 4px 9px; font-size: 12px; font-weight: 500;
  background: #fff; color: var(--bleu); border: 1px solid var(--bord); }
a.lien-bouton:hover { background: #eef1f6; }
table.tableau-admin th { width: auto; white-space: nowrap; }
table.tableau-admin td { vertical-align: top; }
table.tableau-admin td.rangee { display: table-cell; }
table.tableau-admin td.rangee button { margin: 0 4px 4px 0; }
.demande h3 { margin-bottom: 8px; }
nav .pastille { margin-left: 6px; }

/* ---------- Bandeau du compte dans la plateforme ---------- */
#bandeau-compte { display: flex; align-items: center; gap: 8px; font-size: 13px; }
body:not(.en-ligne) #bandeau-compte { display: none; }
#bandeau-compte #nom-compte { font-weight: 600; }
#bandeau-compte a.lien-bouton, #bandeau-compte button.secondaire {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); }
#bandeau-compte a.lien-bouton:hover, #bandeau-compte button.secondaire:hover {
  background: rgba(255,255,255,.24); }
.en-ligne-seulement { display: none; }
body.en-ligne .en-ligne-seulement { display: revert; }
body.en-ligne .local-seulement { display: none !important; }

/* Chemin choisi avec « Parcourir… » : affiché, pas tapé. */
input.chemin[readonly] { background: #f3f5f8; color: var(--texte); cursor: pointer; }

/* ---------- Ordre des champs du QR ---------- */
#liste-qr .item-qr { display: flex; gap: 6px; align-items: center; padding: 5px 8px;
  border-bottom: 1px solid #eef0f3; }
#liste-qr .item-qr.coche { background: #f7f9fc; cursor: grab; }
#liste-qr .item-qr.deplace { opacity: .45; }
#liste-qr .item-qr.survol { box-shadow: inset 0 2px 0 var(--bleu-clair); }
#liste-qr .rang-qr { width: 20px; text-align: right; font-size: 11px; font-weight: 600;
  color: var(--bleu-clair); }
#liste-qr button.petit { padding: 1px 6px; font-size: 10px; line-height: 1.4; }

/* ---------- Page d'accueil (connexion) ---------- */
body.page-accueil { min-height: 100%; height: auto; display: flex; align-items: center;
  justify-content: center; padding: 40px 16px; background: var(--fond); }
.accueil { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  width: 100%; max-width: 980px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(31,56,100,.16); background: var(--carte); }
.accueil .presentation {
  background: linear-gradient(150deg, var(--bleu) 0%, var(--bleu-clair) 100%);
  color: #fff; padding: 34px 34px 26px; border-right: 4px solid var(--accent);
  display: flex; flex-direction: column; }
.accueil .marque { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.accueil .logo { width: 44px; height: 44px; flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.accueil h1 { font-size: 22px; margin: 0; line-height: 1.2; }
.accueil .sous-titre { font-size: 12.5px; opacity: .8; }
.accueil .intro { font-size: 15px; line-height: 1.55; margin: 0 0 16px; }
.accueil .atouts { list-style: none; padding: 0; margin: 0 0 22px; }
.accueil .atouts li { position: relative; padding: 0 0 11px 26px; font-size: 13.5px;
  line-height: 1.5; opacity: .95; }
.accueil .atouts li::before { content: "✓"; position: absolute; left: 0; top: 0;
  width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.18);
  font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.accueil .auteur { margin: auto 0 0; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.22); font-size: 12.5px; opacity: .85; }
.accueil .carte-compte { border: 0; border-radius: 0; max-width: none;
  padding: 34px 30px 24px; align-self: center; }
.accueil .carte-compte h2 { font-size: 20px; color: var(--bleu); margin: 0 0 6px; }
@media (max-width: 760px) {
  body.page-accueil { padding: 0; align-items: stretch; }
  .accueil { grid-template-columns: 1fr; border-radius: 0; box-shadow: none; }
  .accueil .presentation { border-right: 0; border-bottom: 4px solid var(--accent);
    padding: 26px 20px 20px; }
  /* Sur téléphone, le formulaire d'abord : la présentation suit. */
  .accueil .carte-compte { padding: 26px 20px; order: -1; }
}

/* ---------- Jauge de génération ---------- */
.jauge { margin: 14px 0 6px; padding: 14px 16px 12px; border: 1px solid var(--bord);
  border-radius: 8px; background: #f7f9fc; }
.jauge-haut { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.jauge-pct { font-size: 30px; font-weight: 700; color: var(--bleu); line-height: 1;
  font-variant-numeric: tabular-nums; min-width: 82px; }
.jauge-texte { color: var(--gris); font-size: 13px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.barre.grande { height: 14px; border-radius: 7px; margin: 10px 0 8px; }
.barre.grande > div { background: linear-gradient(90deg, var(--bleu-clair), #4f7bd0);
  transition: width .6s ease; }
.jauge-chiffres { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12.5px;
  color: var(--texte); font-variant-numeric: tabular-nums; }
.jauge-chiffres span:empty { display: none; }
#jauge-alertes { color: var(--alerte); font-weight: 600; }
.jauge.finie { background: #eef7ef; border-color: #b9dcbc; }
.jauge.finie .jauge-pct { color: var(--ok); }
.jauge.finie .barre.grande > div { background: var(--ok); }
.jauge.echec { background: #fdf0ee; border-color: #e6c4c0; }
.jauge.echec .jauge-pct { color: var(--accent); }
.details-journal { margin: 6px 0 4px; }
.details-journal summary { cursor: pointer; font-size: 12px; color: var(--gris); padding: 4px 0; }
#details-journal #journal { height: 200px; margin-top: 6px; }
a.action-lien { display: inline-block; padding: 8px 14px; border-radius: 5px;
  background: var(--bleu-clair); color: #fff; font-weight: 600; text-decoration: none; }
a.action-lien:hover { background: var(--bleu); }
.accueil .auteur p { margin: 0 0 6px; }
.accueil .contact-titre { font-size: 12px; opacity: .85; }
.accueil .contacts { list-style: none; padding: 0; margin: 4px 0 0; display: flex;
  flex-wrap: wrap; gap: 8px; }
.accueil .contacts a { display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 16px; background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25); color: #fff; text-decoration: none;
  font-size: 12.5px; }
.accueil .contacts a:hover { background: rgba(255,255,255,.26); }
.accueil .contacts svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* ---------- Taille de la carte et planche A4 ---------- */
.format-carte { gap: 10px; align-items: end; }
.apercu-echelle { margin: 2px 0 8px; }
.apercu-echelle svg { display: block; width: 100%; max-width: 320px; height: auto;
  overflow: visible; }
.apercu-echelle .silhouette-cb { fill: none; stroke: var(--accent); stroke-width: .5;
  stroke-dasharray: 2 1.4; }
.carte-vide { fill: #dfe6f2; }
.carte-bord { fill: none; stroke: #8796b0; stroke-width: .35; }
.carte-bord.deborde { stroke: var(--accent); stroke-width: .9; }
.cote { stroke: var(--gris); stroke-width: .3; }
.cote-txt { font-size: 4.2px; fill: var(--texte); text-anchor: middle;
  font-family: "Segoe UI", Roboto, sans-serif; }
.legende-echelle, .legende-a4 { font-size: 12px; color: var(--gris); line-height: 1.5; }
.apercu-a4 { display: flex; gap: 14px; align-items: flex-start; margin: 6px 0 8px; }
.apercu-a4 svg { flex: 0 0 auto; width: 150px; height: auto;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.18)); }
.apercu-a4 .page-a4 { fill: #fff; stroke: #cfd5df; stroke-width: .6; }
.apercu-a4 .trait-coupe { stroke: #9aa3b2; stroke-width: .35; stroke-dasharray: 1.35 1; }
.apercu-a4 .legende-a4 { padding-top: 4px; }
.alerte-a4 { color: var(--accent); }
.dlg-planche-corps { display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px; align-items: start; }
.dlg-planche-corps .apercu-a4 { flex-direction: column; margin: 0; }
.dlg-planche-corps .apercu-a4 svg { width: 130px; }
.dlg-planche-corps .legende-a4 { max-width: 150px; }
.vraie-planche { margin: 6px 0 12px; text-align: center; }
.vraie-planche img { max-width: 100%; max-height: 520px; border: 1px solid var(--bord);
  box-shadow: 0 2px 8px rgba(0,0,0,.15); background: #fff; }
.vraie-planche.perime img { opacity: .4; }
@media (max-width: 640px) {
  .dlg-planche-corps { grid-template-columns: 1fr; }
  .dlg-planche-corps .legende-a4 { max-width: none; }
}
/* Contacts : icônes seules, rondes. */
.accueil .contacts { gap: 10px; }
.accueil .contacts a { width: 38px; height: 38px; padding: 0; border-radius: 50%;
  justify-content: center; }
.accueil .contacts svg { width: 18px; height: 18px; }
