@font-face { font-family: 'JUST Sans'; src: url('fonts/JUSTSans-Regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JUST Sans'; src: url('fonts/JUSTSans-Medium.woff') format('woff'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'JUST Sans'; src: url('fonts/JUSTSans-SemiBold.woff') format('woff'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'JUST Sans'; src: url('fonts/JUSTSans-Bold.woff') format('woff'); font-weight: 700; font-display: swap; }

:root {
  --header: #1f3238;
  --teal: #2b8a8a;
  --teal-dark: #217070;
  --teal-pale: #e8f4f4;
  --bg: #eef1f2;
  --panel: #fff;
  --ink: #1d2327;
  --muted: #62707a;
  --line: #dfe4e6;
  --ok: #1e8a4c;
  --warn: #c07b00;
  --err: #b5121b;
  --radius: 8px;
  --shadow: 0 4px 18px rgba(15, 30, 35, .12);
  font-family: 'JUST Sans', "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }
.espace { flex: 1; }
.erreur { color: var(--err); background: #fdecee; border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- Boutons ---------- */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn.primaire { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.btn.primaire:hover { background: var(--teal-dark); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.fantome { background: transparent; }
.btn.petit { padding: 4px 10px; font-size: 12.5px; }
.btn.large { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Connexion ---------- */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--header) 0%, #1d5d61 55%, var(--teal) 100%); }
.connexion-carte { width: min(420px, 100%); background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.connexion-marque { background: var(--header); color: #fff; text-align: center; padding: 24px 20px 16px; border-bottom: 4px solid #2fc3c3; }
.connexion-marque img { height: 64px; }
.connexion-marque p { margin: 10px 0 0; font-size: 12.5px; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.connexion-corps { padding: 22px 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.connexion-corps h1 { margin: 0; font-size: 20px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
input[type=text], input:not([type]), input[type=password], input[type=url], select {
  border: 1px solid #c9d1d4; border-radius: 6px; padding: 9px 10px; font-size: 14px; font-weight: 400; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.retour { color: var(--muted); font-size: 13px; text-align: center; text-decoration: none; }
.retour:hover { color: var(--teal-dark); }

/* ---------- Structure ---------- */
.app { min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr; }
.barre { display: flex; align-items: center; gap: 12px; background: var(--header); color: #fff; padding: 8px 18px; }
.barre-logo { height: 40px; }
.barre-titre { font-weight: 600; font-size: 16px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.3); }
.barre .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.barre .btn:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.moi { font-size: 13px; opacity: .9; }
.moi .badge { margin-left: 6px; }
.menu { display: flex; gap: 4px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 18px; }
.menu a { padding: 12px 14px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 3px solid transparent; }
.menu a:hover { color: var(--ink); }
.menu a.actif { color: var(--teal-dark); border-bottom-color: var(--teal); }
.contenu { padding: 22px 18px 120px; max-width: 1200px; width: 100%; margin: 0 auto; }
.entete { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.entete h1 { margin: 0; font-size: 22px; }
.entete .sous { color: var(--muted); }

/* ---------- Cartes / tableaux ---------- */
.carte { background: var(--panel); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.07); margin-bottom: 16px; }
.carte > h2 { margin: 0; padding: 14px 18px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.carte-corps { padding: 16px 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f7f9f9; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
td .nom { font-weight: 600; }
td small { color: var(--muted); display: block; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fdf2dc; color: var(--warn); }
.badge.err { background: #fdecee; color: var(--err); }
.badge.neutre { background: #edf0f1; color: var(--muted); }
.badge.role { background: rgba(255,255,255,.18); color: #fff; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Fichiers sources ---------- */
.fichiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.depot { border: 2px dashed #c9d1d4; border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, background .15s; }
.depot.survol { border-color: var(--teal); background: var(--teal-pale); }
.depot h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.depot .actuel { font-size: 12.5px; color: var(--muted); min-height: 34px; }
.depot .actuel strong { color: var(--ink); font-weight: 600; word-break: break-all; }
.depot .aide { font-size: 12px; color: var(--muted); }
.depot progress { width: 100%; height: 6px; }
.depot input[type=file] { display: none; }

/* ---------- Formulaires ---------- */
.grille-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.case { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.case input { width: 16px; height: 16px; accent-color: var(--teal); }
.cases-municipalites { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

pre.rapport { margin: 0; padding: 14px 18px; background: #f7f9f9; font-size: 12.5px; max-height: 320px; overflow: auto; white-space: pre-wrap; }

/* ---------- Console de génération ---------- */
.travail { position: fixed; right: 16px; bottom: 16px; width: min(640px, calc(100vw - 32px)); background: #172529; color: #d7e4e6;
  border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.35); z-index: 50; overflow: hidden; }
.travail-tete { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #0f1a1d; font-weight: 600; }
.travail-tete .btn { color: #d7e4e6; border-color: rgba(255,255,255,.2); }
.travail pre { margin: 0; padding: 10px 14px; max-height: 300px; overflow: auto; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.travail.reduit pre { display: none; }
.travail .pastille { width: 9px; height: 9px; border-radius: 50%; background: #f3a712; display: inline-block; animation: pulse 1s infinite; }
.travail .pastille.ok { background: #3ccf7a; animation: none; }
.travail .pastille.err { background: #ff5c5c; animation: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Dialogue / toast ---------- */
.dialogue { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.dialogue::backdrop { background: rgba(20,35,40,.5); backdrop-filter: blur(2px); }
.dialogue form { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.dialogue h2 { margin: 0; font-size: 18px; }
.dialogue-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--header); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 100; max-width: 90vw; }
.toast.err { background: var(--err); }
.toast.warn { background: var(--warn); }

@media (max-width: 720px) {
  .barre-titre, .moi { display: none; }
  .menu { overflow-x: auto; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

/* ---------- Tuiles ---------- */
.tuiles-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0 10px; }
.tuiles-stats div { background: #f4f8f8; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.tuiles-stats strong { font-size: 18px; color: var(--teal-dark); }
.tuiles-stats span { font-size: 12px; color: var(--muted); }
table.zooms { font-size: 12px; margin-top: 6px; }
table.zooms th, table.zooms td { padding: 5px 8px; text-align: right; white-space: nowrap; }
table.zooms th:first-child, table.zooms td:first-child { text-align: left; color: var(--muted); }
tr.resultat td { background: #f7f9f9; font-size: 12.5px; }
code { background: #eef1f2; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

textarea { border: 1px solid #c9d1d4; border-radius: 6px; padding: 9px 10px; font: inherit; font-size: 14px; font-weight: 400; resize: vertical; }
textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

/* Console en ligne (serveur sans QGIS) : génération et dépôt de fichiers se font sur le poste */
.bandeau-en-ligne { background: #fff7e6; border-bottom: 1px solid #f0d9a8; color: #5c4210; padding: 10px 18px; font-size: 13px; line-height: 1.5; }
.bandeau-en-ligne code { background: #fff; padding: 1px 5px; border-radius: 3px; }
body.en-ligne #btn-gen, body.en-ligne #btn-gen-tous, body.en-ligne #btn-code, body.en-ligne #btn-code-tous,
body.en-ligne #t-generer, body.en-ligne #t-forcer, body.en-ligne .depot input[type=file],
body.en-ligne section.carte:has(.fichiers) { display: none !important; }
