:root {
  --marine: #0b2545; --marine2: #13315c; --teal: #138a80; --teal-c: #e3f4f2;
  --fond: #f3f5f8; --carte: #fff; --texte: #1b2433; --muted: #6a7587; --bord: #dde2ea;
  --rouge: #c0392b; --orange: #d9822b; --jaune: #fff6d6; --vert: #2e8b57; --bleu: #2563a8; --violet: #6b4fbb; --cyan: #138a9c;
  --r: 10px; --ombre: 0 1px 2px rgba(11, 37, 69, .06), 0 2px 8px rgba(11, 37, 69, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--texte);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
a { color: var(--bleu); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; } h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; color: var(--marine2); }
h3 { font-size: 1rem; margin: 0 0 .8rem; color: var(--marine); } h4 { font-size: .85rem; margin: .9rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); } .petit { font-size: .85rem; } .droite { text-align: right; margin-left: auto; }
[hidden] { display: none !important; }

/* Navigation */
#nav { position: sticky; top: 0; z-index: 20; background: var(--marine); color: #fff; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; height: 54px; }
#nav .marque { color: #fff; font-weight: 700; white-space: nowrap; }
#nav nav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; }
#nav nav a { color: #c9d6ea; padding: .5rem .8rem; border-radius: 8px; white-space: nowrap; position: relative; display: flex; gap: .4rem; align-items: center; }
#nav nav a:hover { background: var(--marine2); color: #fff; }
#nav nav a.actif { background: var(--marine2); color: #fff; box-shadow: inset 0 -3px 0 var(--teal); }
#nav .ico { opacity: .8; }
.pastille { background: var(--orange); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; }
#nav .moi { display: flex; align-items: center; gap: .6rem; font-size: .85rem; white-space: nowrap; }
#nav .btn-ico { color: #fff; }
.sync { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; }
.sync.off { background: var(--rouge); } .sync.att { background: var(--orange); }
main { max-width: 1400px; margin: 0 auto; padding: 1.2rem 1rem 5rem; }

/* Blocs */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--r); padding: 1rem 1.1rem; box-shadow: var(--ombre); margin-bottom: 1rem; }
.entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; justify-content: flex-end; margin-top: .8rem; }
.entete .actions { margin-top: 0; } .entete .actions select { width: auto; } .actions.gauche { justify-content: flex-start; }
.retour { font-size: .85rem; display: inline-block; margin-bottom: .3rem; }
.grille2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.grille2.serre { gap: .5rem 1.5rem; }
.deux-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; align-items: start; }
.deux-col.larg { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.vide, .chargement { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.chargement.plein { padding-top: 40vh; }
.compte { background: var(--fond); color: var(--muted); border-radius: 99px; padding: 0 .5rem; font-size: .8rem; font-weight: 600; }

/* Boutons */
.btn { font: inherit; border: 1px solid var(--bord); background: #fff; color: var(--texte); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; justify-content: center; }
.btn:hover { border-color: #b8c2d1; background: #fafbfd; }
.btn.primaire { background: var(--teal); border-color: var(--teal); color: #fff; } .btn.primaire:hover { background: #0f766d; }
.btn.danger { color: var(--rouge); border-color: #e9b7b1; } .btn.danger:hover { background: #fdf1ef; }
.btn.petit { padding: .25rem .6rem; font-size: .85rem; }
.btn.large { width: 100%; padding: .85rem; font-size: 1.05rem; margin: .5rem 0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ico { background: none; border: 0; cursor: pointer; font-size: 1rem; padding: .3rem .5rem; color: var(--muted); border-radius: 6px; }
.btn-ico:hover { background: rgba(0, 0, 0, .06); }
.lien { background: none; border: 0; color: var(--bleu); cursor: pointer; font: inherit; margin-top: .5rem; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); margin-bottom: .6rem; }
label.inline { flex-direction: row; align-items: center; margin: 0; }
input, select, textarea { font: inherit; font-size: .95rem; color: var(--texte); padding: .5rem .6rem; border: 1px solid var(--bord); border-radius: 7px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fd3cc; border-color: var(--teal); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; padding: .6rem .8rem; margin: 0 0 .8rem; } fieldset[disabled] { border: 0; padding: 0; }
legend { font-size: .82rem; color: var(--muted); padding: 0 .3rem; }
.grille-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 .9rem; }
.cases { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .4rem; }
label.case { flex-direction: row; align-items: center; gap: .4rem; color: var(--texte); font-size: .88rem; margin: 0; }
label.case input { width: auto; }
.a-verifier input, .a-verifier select, fieldset.a-verifier { background: var(--jaune); border-color: #e7c65c; }
.a-verifier { color: #8a6400; }
.avec-btn { display: flex; gap: .4rem; } small { font-size: .75rem; }
.filtres { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .7rem; }
.filtres input[name=q] { flex: 1 1 220px; width: auto; } .filtres select, .filtres input[type=date] { width: auto; }
.recherche { max-width: 320px; margin-bottom: .8rem; }
.ligne-upload { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; } .ligne-upload select { width: auto; } .ligne-upload input { flex: 1; width: auto; }

/* Tableaux */
.defile { overflow-x: auto; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--r); }
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th { text-align: left; font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; padding: .6rem .7rem; border-bottom: 1px solid var(--bord); background: #fafbfc; white-space: nowrap; }
.tableau td { padding: .55rem .7rem; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.tableau tr[data-href], .tableau tr.cliquable { cursor: pointer; } .tableau tbody tr:hover { background: #f6f9fc; }
.tableau.compact td { padding: .4rem .5rem; } .carte .tableau { font-size: .87rem; }
tr.inactif { opacity: .5; } tr.bloque { opacity: .5; }

/* Badges et pastilles */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; background: #eef1f5; color: #4a5568; }
.badge.bleu { background: #e3edf9; color: var(--bleu); } .badge.violet { background: #eee9fb; color: var(--violet); }
.badge.cyan { background: #e0f3f5; color: var(--cyan); } .badge.orange { background: #fcefe0; color: #b0611a; }
.badge.vert { background: #e3f3ea; color: var(--vert); } .badge.vertf { background: var(--vert); color: #fff; }
.badge.rouge { background: #fbe7e4; color: var(--rouge); }
.chip { display: inline-block; min-width: 2.1em; text-align: center; font-size: .72rem; font-weight: 700; padding: .1rem .35rem; border-radius: 5px; background: #e5e9ef; color: #4a5568; }
.chip.vert { background: #2e8b57; color: #fff; } .chip.cyan { background: #138a9c; color: #fff; } .chip.violet { background: #6b4fbb; color: #fff; }
.chip.bleu { background: #2563a8; color: #fff; } .chip.orange { background: #f4d7b4; color: #8a4b10; } .chip.rouge { background: #f3c4bd; color: #8e2418; }
.tag { display: inline-block; font-size: .78rem; background: #eef1f5; padding: .15rem .5rem; border-radius: 6px; margin: .1rem .2rem .1rem 0; color: var(--texte); }
.tag.alerte { background: var(--jaune); color: #8a6400; } .tag.lien { background: #e3edf9; color: var(--bleu); }
.acces { font-size: .8rem; } .acces.a_demander { color: var(--rouge); font-weight: 600; } .acces.demande { color: var(--orange); } .acces.obtenu { color: var(--vert); }
.bandeau { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; }
.bandeau.orange { background: #fdf3e7; border-color: #f1cfa4; } .bandeau.jaune { background: var(--jaune); border-color: #eedc94; }
.bandeau.bleu { background: #eaf2fb; border-color: #c4d8f0; } .bandeau.vert { background: #e8f5ee; border-color: #b9dfc8; }
.similaire { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }

/* Tableau de bord */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--r); padding: .9rem 1rem; display: flex; flex-direction: column; color: var(--texte); box-shadow: var(--ombre); }
.kpi b { font-size: 1.8rem; color: var(--marine); } .kpi span { font-size: .82rem; color: var(--muted); }
.kpi.alerte { border-left: 4px solid var(--orange); } .kpi.alerte b { color: #b0611a; }
.bord-alerte { border-left: 4px solid var(--orange); }
.barre { display: grid; grid-template-columns: 170px 1fr 40px; gap: .6rem; align-items: center; margin: .35rem 0; font-size: .88rem; }
.barre i { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--teal) var(--p), #edf0f4 var(--p)); }
.barre b { text-align: right; }

/* Nominations */
.onglets { display: flex; gap: .3rem; border-bottom: 1px solid var(--bord); margin-bottom: 1rem; flex-wrap: wrap; }
.onglets > * { background: none; border: 0; font: inherit; padding: .55rem .9rem; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.onglets .actif { color: var(--marine); border-bottom-color: var(--teal); font-weight: 600; }
.liste-nomin { display: flex; flex-direction: column; gap: .5rem; }
.nomin { display: block; color: var(--texte); margin: 0; padding: .75rem 1rem; }
.nomin:hover { border-color: #b8c2d1; } .nomin .l1 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.nomin .l2 { font-size: .85rem; margin: .2rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.corps-mail { white-space: pre-wrap; font: .87rem/1.45 ui-monospace, Menlo, Consolas, monospace; background: #f8f9fb; border-radius: 6px; padding: .8rem; margin: 0; }
.pieces { margin: .4rem 0 .8rem; }

/* Fiche */
.intervenants { list-style: none; padding: 0; margin: 0 0 .5rem; }
.intervenants li { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid #eef1f5; }
.journal { list-style: none; padding: 0; margin: 0; max-height: 380px; overflow: auto; font-size: .87rem; }
.journal li { padding: .4rem 0; border-bottom: 1px solid #eef1f5; } .journal small { color: var(--muted); }
.frise, .check { list-style: none; padding: 0; margin: 0; font-size: .88rem; } .frise li, .check li { padding: .2rem 0; }
.check li.fait { color: var(--vert); }
.consignes { background: #f8fafc; border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; } .consignes p { margin: .3rem 0; }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.galerie a { display: flex; flex-direction: column; font-size: .72rem; color: var(--muted); }
.galerie img, .galerie .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #e8ecf1; display: grid; place-items: center; }

/* Planning */
.planning { border-collapse: collapse; width: 100%; min-width: 900px; font-size: .82rem; table-layout: fixed; }
.planning th, .planning td { border: 1px solid #e4e8ee; padding: .35rem; vertical-align: top; }
.planning thead th { background: #fafbfc; position: sticky; top: 0; }
.planning th.auj { background: var(--teal-c); color: var(--teal); }
.planning tbody th { text-align: left; white-space: nowrap; background: #fafbfc; font-weight: 600; width: 150px; }
.planning td.we { background: #fbfbfd; } .planning td.editable { cursor: pointer; } .planning td.editable:hover { background: #f1f7f6; }
.planning td { height: 54px; overflow: hidden; } .planning thead th:first-child { width: 150px; }
.non-affectees th { color: var(--orange) !important; } .non-affectees td { background: #fffaf3; }
.role-jour { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; } .role-jour small { color: var(--muted); font-size: .7rem; }
.remarque { font-size: .7rem; font-weight: 600; color: #8a4b10; margin-top: .15rem; }
.mini-mission { display: block; margin-top: .25rem; padding: .2rem .35rem; border-radius: 5px; background: #e3edf9; color: var(--marine); font-size: .74rem; line-height: 1.25; border-left: 3px solid var(--bleu); }
.mini-mission small { display: block; color: var(--muted); }
.mini-mission.prete, .mini-mission.a_replanifier { background: #fcefe0; border-left-color: var(--orange); }
.mini-mission.en_cours { border-left-color: var(--violet); } .mini-mission.terminee_terrain, .mini-mission.rapport_relecture, .mini-mission.rapport_envoye { background: #e3f3ea; border-left-color: var(--vert); }
.outils { margin: 0 0 .8rem; }

/* Fenêtres */
.modal-fond { position: fixed; inset: 0; background: rgba(11, 37, 69, .45); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; width: min(520px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.large { width: min(860px, 100%); }
.modal-tete { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--bord); }
.modal-tete h3 { margin: 0; } .modal-corps { padding: 1rem 1.1rem; overflow: auto; }
#toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--marine); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--ombre); max-width: 360px; animation: entree .2s; }
.toast.err { background: var(--rouge); }
@keyframes entree { from { transform: translateY(10px); opacity: 0; } }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--marine) 0%, var(--marine2) 60%, var(--teal) 140%); }
.connexion .carte { width: min(380px, 100%); padding: 2rem; text-align: center; }
.connexion .carte label { text-align: left; } .connexion .logo { font-size: 2.4rem; }

/* Terrain (mobile) */
.terrain { max-width: 640px; margin: 0 auto; }
.mission-terrain { display: block; color: var(--texte); padding: .8rem 1rem; margin-bottom: .6rem; border-left: 4px solid var(--bleu); }
.mission-terrain.en_cours { border-left-color: var(--violet); } .mission-terrain.terminee_terrain, .mission-terrain.rapport_relecture, .mission-terrain.rapport_envoye { border-left-color: var(--vert); opacity: .8; }
.mission-terrain .l1 { display: flex; justify-content: space-between; gap: .5rem; font-size: 1.05rem; }
.mission-terrain .l2 { margin: .25rem 0; } .mission-terrain .l3 { font-size: .85rem; }
.mission-terrain .nouveau { margin-top: .4rem; font-size: .8rem; font-weight: 700; color: var(--orange); }
.mon-planning { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin: .5rem 0; }
.mon-planning > div { background: #fff; border: 1px solid var(--bord); border-radius: 8px; padding: .35rem .5rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; min-width: 70px; font-size: .75rem; }
.fiche .tete { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.infos { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1rem; }
.infos div { display: flex; flex-direction: column; } .infos span { font-size: .72rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.infos small { color: var(--muted); }
.pointage { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.pointage .btn { flex-direction: column; padding: .8rem .5rem; min-height: 64px; }
.pointage .btn.fait { background: var(--teal-c); border-color: #9fd8d1; color: var(--teal); }
.pointage .btn b { font-size: 1.05rem; }
.check-terrain { list-style: none; padding: 0; margin: 0; }
.check-terrain li label { flex-direction: row; align-items: center; gap: .7rem; font-size: 1rem; color: var(--texte); padding: .55rem 0; border-bottom: 1px solid #eef1f5; margin: 0; }
.check-terrain input { width: 24px; height: 24px; flex-shrink: 0; }
.ligne-photo { display: flex; gap: .5rem; margin-bottom: .7rem; } .ligne-photo select { flex: 1; }
.form-frais { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; } .form-frais input[name=commentaire] { grid-column: 1 / -1; }
.frais { padding-left: 1.1rem; margin: 0 0 .6rem; } .frais small { display: block; }

@media (max-width: 900px) {
  .deux-col, .deux-col.larg { grid-template-columns: 1fr; }
  .mail { position: static; max-height: 45vh; }
}
@media (max-width: 760px) {
  #nav { height: 50px; }
  #nav nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--marine); justify-content: space-around; padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); gap: 0; z-index: 30; }
  #nav nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: .1rem; font-size: .64rem; padding: .35rem .15rem; text-align: center; }
  #nav nav a .lib { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #nav nav a[data-route="#/parametrage"] { display: none; }
  #nav nav a .ico { font-size: 1.15rem; opacity: 1; }
  #nav nav a.actif { box-shadow: none; }
  #nav .pastille { position: absolute; top: 0; right: 0; }
  #nav .moi .nom { display: none; }
  main { padding: .9rem .75rem 6rem; }
  .barre { grid-template-columns: 110px 1fr 30px; }
  #toasts { left: 1rem; bottom: 5rem; }
}
.photo-locale { position: relative; }
.suppr-photo { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(11, 37, 69, .75); color: #fff; font-size: .8rem; cursor: pointer; }
.modifie input, .modifie select { background: #fdf0e2; border-color: #e9a65c; font-weight: 600; }
.modifie { color: #b0611a; }
fieldset.affectation select { font-weight: 600; }
.geo { margin-top: .4rem; padding: .5rem .6rem; border-radius: 7px; background: #f1f7f6; color: var(--texte); font-size: .84rem; line-height: 1.4; }
.geo .actions { margin-top: .4rem; } .geo small { display: block; margin-top: .3rem; font-size: .7rem; }
.zone-depot { border: 2px dashed #9fd8d1; border-radius: 10px; background: #f4fbfa; padding: 1.3rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center; cursor: pointer; margin-bottom: 1rem; color: var(--marine); }
.zone-depot:hover, .zone-depot:focus, .zone-depot.survol { border-color: var(--teal); background: var(--teal-c); outline: none; }
.zone-depot b { font-size: 1.05rem; }
.survol-depot { outline: 3px dashed var(--teal); outline-offset: -6px; border-radius: 12px; }
.liste-depot { list-style: none; padding: 0; margin: 0 0 .5rem; max-height: 320px; overflow: auto; }
.liste-depot li { display: flex; justify-content: space-between; align-items: center; padding: .45rem 0; border-bottom: 1px solid #eef1f5; }
