:root {
  --rouge: #c8102e; --rouge-f: #9b0c23; --encre: #1d2330; --gris: #667085; --trait: #dfe3ea;
  --fond: #f4f5f8; --blanc: #fff; --vl1: #1565c0; --vl1-f: #e6f0fb; --vl2: #b45309; --vl2-f: #fdf1e1;
  --vert: #1b7f4b; --rayon: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--encre); background: var(--fond); }
a { color: inherit; }
h1 { font-size: 1.3rem; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
small { color: var(--gris); font-weight: normal; }

.top { background: var(--rouge); color: #fff; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; padding: .6rem 1rem; }
.brand { text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.brand small { color: #ffd9de; font-size: .8rem; }
.logo { background: #fff; color: var(--rouge); border-radius: 6px; padding: .1rem .4rem; font-size: .9rem; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
nav a, .lien { color: #fff; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; background: none; border: 0; font: inherit; cursor: pointer; }
nav a:hover, .lien:hover, nav a.on { background: rgba(255,255,255,.2); }
.pastille { background: #fff; color: var(--rouge); border-radius: 99px; padding: 0 .45rem; font-size: .8rem; font-weight: 700; }

main { max-width: 1300px; margin: 0 auto; padding: 1rem; }
footer { text-align: center; color: var(--gris); font-size: .8rem; padding: 1.5rem 1rem; }
.carte { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.2rem; }
.etroit { max-width: 420px; margin: 2rem auto; }
.moyen { max-width: 640px; margin: 1rem auto; }
.aide { color: var(--gris); margin-top: 0; }
.vide { color: var(--gris); text-align: center; padding: 2rem 0; }
.entete { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.entete h1 { margin: 0; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .7rem; border: 1px solid; }
.flash.ok { background: #e8f6ee; border-color: #a9dbbf; color: #14532d; }
.flash.err { background: #fdeaea; border-color: #f3b4b4; color: #8a1616; }
.flash.warn { background: #fff6dd; border-color: #f0d68a; color: #7a5200; }

label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .55rem .6rem; border: 1px solid #c5cbd6; border-radius: 7px; font: inherit; font-weight: normal; background: #fff; color: var(--encre); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rouge); outline-offset: 1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0; }
input:disabled, select:disabled { background: #f0f1f4; color: var(--gris); }
.ligne { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.case { font-weight: normal; display: flex; align-items: center; gap: .5rem; }
fieldset.choix { border: 0; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
fieldset.choix legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.radio { display: flex; gap: .6rem; align-items: center; border: 2px solid var(--trait); border-radius: 9px; padding: .7rem; margin: 0; cursor: pointer; font-weight: normal; }
.radio.vl1:has(input:checked) { border-color: var(--vl1); background: var(--vl1-f); }
.radio.vl2:has(input:checked) { border-color: var(--vl2); background: var(--vl2-f); }

.btn { display: inline-block; background: var(--rouge); color: #fff; border: 0; border-radius: 7px; padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--rouge-f); }
.btn.sm { padding: .3rem .65rem; font-size: .85rem; }
.btn.gris { background: #e7e9ee; color: var(--encre); }
.btn.gris:hover { background: #d6d9e0; }
.btn.vert { background: var(--vert); }
.btn.rouge { background: #fff; color: var(--rouge); box-shadow: inset 0 0 0 1px var(--rouge); }
.inline { display: inline; }

.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--trait); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); }
td.motif { max-width: 320px; }
td.actions { white-space: nowrap; text-align: right; }
td input, td select { margin: 0; min-width: 110px; }
tr.refuse td, tr.inactif td { opacity: .55; }
tr.refuse td.actions, tr.inactif td.actions, tr.inactif td input, tr.inactif td select { opacity: 1; }

.badge { display: inline-block; border-radius: 5px; padding: 0 .4rem; font-size: .78rem; font-weight: 700; color: #fff; }
.badge.vl1 { background: var(--vl1); } .badge.vl2 { background: var(--vl2); }
.statut { display: inline-block; border-radius: 99px; padding: .05rem .6rem; font-size: .8rem; font-weight: 600; }
.statut.attente { background: #fff1c9; color: #7a5200; }
.statut.valide { background: #dff3e7; color: #14532d; }
.statut.refuse { background: #eceef2; color: #555; }
.conflit { color: #b42318; font-size: .8rem; font-weight: 600; }

.barre { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.nav-semaine { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.nav-semaine h1 { margin: 0 0 0 .5rem; font-size: 1.15rem; }
.filtres { display: flex; flex-wrap: wrap; gap: .4rem; }
.puce { text-decoration: none; padding: .3rem .8rem; border-radius: 99px; background: #fff; border: 1px solid var(--trait); font-size: .85rem; }
.puce.on { background: var(--encre); color: #fff; border-color: var(--encre); }
.puce.vl1.on { background: var(--vl1); border-color: var(--vl1); }
.puce.vl2.on { background: var(--vl2); border-color: var(--vl2); }

.semaine { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; align-items: start; }
.jour { background: #fff; border: 1px solid var(--trait); border-radius: var(--rayon); padding: .5rem; min-height: 180px; }
.jour.weekend { background: #fafbfc; }
.jour.aujourdhui { border-color: var(--rouge); box-shadow: 0 0 0 1px var(--rouge); }
.jour-titre { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; text-transform: capitalize; padding-bottom: .4rem; margin-bottom: .4rem; border-bottom: 1px solid var(--trait); }
.jour-titre strong { font-size: 1.05rem; }
.plus { text-decoration: none; width: 1.5rem; height: 1.5rem; line-height: 1.4rem; text-align: center; border-radius: 50%; background: #eef0f4; font-weight: 700; color: var(--gris); }
.plus:hover { background: var(--rouge); color: #fff; }
.libre { color: #a3a9b5; font-size: .8rem; text-align: center; margin: 1.5rem 0; }

.resa { display: block; text-decoration: none; border-radius: 7px; padding: .4rem .5rem; margin-bottom: .4rem; font-size: .82rem; border-left: 4px solid; overflow-wrap: anywhere; }
.resa.vl1 { background: var(--vl1-f); border-color: var(--vl1); }
.resa.vl2 { background: var(--vl2-f); border-color: var(--vl2); }
.resa.attente { border-left-style: dashed; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.65) 0 6px, transparent 6px 12px); }
.resa .heure { font-weight: 700; margin-right: .3rem; }
.resa strong, .resa .motif, .resa .etat { display: block; }
.resa .motif { color: #475066; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.resa .etat { font-size: .75rem; color: var(--gris); margin-top: .15rem; }
.resa.valide .etat { color: var(--vert); font-weight: 600; }
.legende { color: var(--gris); font-size: .8rem; }
.resa.demo { display: inline-block; margin: 0 .3rem 0 0; background-color: #eef0f4; border-color: var(--gris); }

.ajout { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 0 .8rem; align-items: end; }
.ajout .btn { margin-bottom: .9rem; }

@media (max-width: 900px) {
  .semaine { grid-template-columns: 1fr; }
  .jour { min-height: 0; }
  .libre { margin: .3rem 0; text-align: left; }
  .ajout, .ligne, fieldset.choix { grid-template-columns: 1fr; }
}

/* --- Mot de passe : afficher / masquer --- */
.mdp { position: relative; display: block; margin-top: .25rem; }
.mdp input { margin-top: 0; padding-right: 5.2rem; }
.oeil { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); border: 0; background: #eef0f4; color: var(--encre); border-radius: 5px; padding: .2rem .5rem; font: inherit; font-size: .78rem; cursor: pointer; }
td .mdp { margin-top: 0; min-width: 170px; }

/* --- Messages WhatsApp / SMS --- */
.btn.wa { background: #128c4b; } .btn.wa:hover { background: #0d6e3a; }
.btn.sms { background: #344054; } .btn.sms:hover { background: #1d2939; }
.sans-tel { font-style: italic; }
.notif { background: #eef6ff; border: 1px solid #b3d1f5; border-radius: 8px; padding: .8rem 1rem; margin-bottom: .7rem; }
.notif .apercu { margin: .3rem 0 .6rem; color: #344054; font-size: .9rem; }
.notif .dest { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .3rem; }
.notif .dest span { min-width: 10rem; font-weight: 600; }
.resa .lieu { display: block; color: #475066; }

/* --- Vues mois et année --- */
.filtres { gap: .4rem 1rem; }
.groupe { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.mois { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; min-width: 760px; }
.mjour { text-align: center; font-size: .78rem; text-transform: uppercase; color: var(--gris); padding: .2rem 0; }
.mcase { background: #fff; border: 1px solid var(--trait); border-radius: 8px; min-height: 104px; padding: .3rem; }
.mcase.weekend { background: #fafbfc; }
.mcase.hors { background: none; border: 0; }
.mcase.aujourdhui { border-color: var(--rouge); box-shadow: 0 0 0 1px var(--rouge); }
.mtete { display: flex; justify-content: space-between; align-items: center; margin-bottom: .2rem; }
.mnum { font-weight: 700; text-decoration: none; padding: 0 .3rem; border-radius: 5px; }
.mnum:hover { background: #eef0f4; }
.mcase .plus { width: 1.25rem; height: 1.25rem; line-height: 1.15rem; font-size: .85rem; }
.chip { display: block; text-decoration: none; font-size: .74rem; line-height: 1.35; border-radius: 4px; padding: 0 .3rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.chip.vl1 { background: var(--vl1-f); border-color: var(--vl1); }
.chip.vl2 { background: var(--vl2-f); border-color: var(--vl2); }
.chip.attente { border-left-style: dashed; opacity: .8; font-style: italic; }
.chip.plusn { border: 0; color: var(--gris); }
.chip.demo { display: inline-block; margin-right: .3rem; }
.annee { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .7rem; }
.amois { background: #fff; border: 1px solid var(--trait); border-radius: var(--rayon); padding: .6rem; }
.atitre { display: block; font-weight: 700; text-decoration: none; margin-bottom: .3rem; }
.atitre:hover { color: var(--rouge); }
.agrille { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .78rem; }
.aj { color: var(--gris); font-size: .68rem; }
.ac { text-decoration: none; border-radius: 4px; padding: .12rem 0; }
.ac:hover { outline: 1px solid var(--encre); }
.ac.auj { outline: 2px solid var(--rouge); font-weight: 700; }
.ac.a1 { background: var(--vl1); color: #fff; }
.ac.a2 { background: var(--vl2); color: #fff; }
.ac.a1.a2 { background: linear-gradient(135deg, var(--vl1) 50%, var(--vl2) 50%); }
.ac.a1.att { background: var(--vl1-f); color: var(--vl1); box-shadow: inset 0 0 0 1px var(--vl1); }
.ac.a2.att { background: var(--vl2-f); color: var(--vl2); box-shadow: inset 0 0 0 1px var(--vl2); }
.ac.a1.a2.att { background: linear-gradient(135deg, var(--vl1-f) 50%, var(--vl2-f) 50%); color: var(--encre); box-shadow: inset 0 0 0 1px var(--gris); }
.ac.demo { display: inline-block; padding: .05rem .5rem; margin-right: .3rem; }
.ajout { grid-template-columns: repeat(5, 1fr) auto; }
@media (max-width: 900px) { .ajout { grid-template-columns: 1fr; } }

/* --- Refus avec motif --- */
details.refus { display: inline-block; text-align: left; vertical-align: top; }
details.refus summary { list-style: none; }
details.refus summary::-webkit-details-marker { display: none; }
details.refus[open] { display: block; margin: .3rem 0; }
details.refus form { background: #f7f8fa; border: 1px solid var(--trait); border-radius: 8px; padding: .6rem; margin-top: .3rem; width: 270px; white-space: normal; margin-left: auto; }
details.refus label { margin-bottom: .5rem; }
