/* Interface commune : app des agences, super admin, pages de connexion */
:root {
  --fond: #f5f7fb; --carte: #ffffff; --texte: #1b2a3a; --doux: #64748b; --bord: #e3e8f0; --bord2: #cfd8e3;
  --p: #3f5f86; --p2: #2f4a6b; --p-clair: #e8eef6; --accent: #f2c14e; --ok: #1f8a4c; --ok-clair: #e5f5ec;
  --err: #c0392b; --err-clair: #fdecea; --att: #b7791f; --att-clair: #fdf6e3; --rayon: 14px;
  --ombre: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --fond: #0f1620; --carte: #17212e; --texte: #e6edf5; --doux: #93a3b8; --bord: #263445; --bord2: #33465c;
    --p: #7aa2d6; --p2: #9dbbe3; --p-clair: #1d2c3e; --ok-clair: #12301f; --err-clair: #3a1916; --att-clair: #352a12; --ombre: 0 1px 2px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--p); }
h1 { font-size: 1.5rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .8rem; }
h3 { font-size: .98rem; margin: 1.2rem 0 .5rem; }
.sous { color: var(--doux); margin: 0 0 1.2rem; font-size: .92rem; }
.petit { font-size: .82rem; color: var(--doux); }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--p-clair); padding: .1em .35em; border-radius: 5px; word-break: break-all; }
pre.code { display: block; padding: .9rem 1rem; white-space: pre-wrap; margin: .4rem 0; border: 1px solid var(--bord); }

/* Mise en page avec menu latéral */
.mise { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.menu { background: var(--carte); border-right: 1px solid var(--bord); padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: .2rem; }
.marque { font-weight: 800; font-size: 1.02rem; padding: .2rem .6rem 1rem; display: flex; align-items: center; gap: .5rem; }
.marque i { width: 30px; height: 30px; border-radius: 9px; background: var(--p); display: grid; place-items: center; font-style: normal; color: #fff; font-size: 16px; }
.menu a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px; color: var(--texte); text-decoration: none; font-weight: 500; font-size: .93rem; }
.menu a:hover { background: var(--p-clair); }
.menu a.actif { background: var(--p); color: #fff; }
.menu a .pastille { margin-left: auto; background: var(--err); color: #fff; font-size: .7rem; border-radius: 999px; padding: 0 .45rem; font-weight: 700; }
.menu .bas { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--bord); font-size: .82rem; color: var(--doux); }
.contenu { padding: 1.8rem 2rem 4rem; max-width: 1180px; width: 100%; min-width: 0; }
.bandeau { padding: .7rem 1rem; border-radius: 12px; margin-bottom: 1.2rem; font-size: .9rem; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.bandeau.info { background: var(--p-clair); }
.bandeau.att { background: var(--att-clair); color: var(--att); }
.bandeau.err { background: var(--err-clair); color: var(--err); }
.bandeau.ok { background: var(--ok-clair); color: var(--ok); }
.bandeau .btn { margin-left: auto; }
@media (max-width: 860px) {
  .mise { grid-template-columns: 1fr; }
  .menu { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: .5rem; gap: .3rem; border-right: 0; border-bottom: 1px solid var(--bord); }
  .menu a { white-space: nowrap; padding: .45rem .7rem; }
  .marque, .menu .bas { display: none; }
  .contenu { padding: 1.1rem 1rem 3rem; }
}

/* Cartes, grilles */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.2rem 1.3rem; box-shadow: var(--ombre); margin-bottom: 1.1rem; min-width: 0; }
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.1rem; }
.grille2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; box-shadow: var(--ombre); min-width: 0; }
.kpi b { display: block; font-size: 1.6rem; letter-spacing: -.02em; }
.kpi span { color: var(--doux); font-size: .84rem; }
.jauge { height: 9px; background: var(--p-clair); border-radius: 99px; overflow: hidden; margin: .5rem 0 .2rem; }
.jauge i { display: block; height: 100%; background: var(--p); border-radius: 99px; }
.jauge.att i { background: var(--att); } .jauge.err i { background: var(--err); }

/* Formulaires */
.champ { margin-bottom: .9rem; min-width: 0; }
.champ label { display: block; font-weight: 600; font-size: .87rem; margin-bottom: .3rem; }
.champ .aide { font-size: .8rem; color: var(--doux); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--texte); background: var(--carte); border: 1.5px solid var(--bord2); border-radius: 10px; padding: .6rem .75rem; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px rgba(63,95,134,.15); }
input[type=color] { width: 54px; height: 40px; border: 1.5px solid var(--bord2); border-radius: 10px; background: var(--carte); padding: 3px; }
.ligne { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.case { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; margin: .4rem 0; font-size: .92rem; }
.case input { margin-top: .25rem; width: 1.05rem; height: 1.05rem; accent-color: var(--p); flex-shrink: 0; }
.interrupteur { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--bord); }
.interrupteur:last-child { border-bottom: 0; }
.interrupteur b { display: block; font-size: .93rem; }
.interrupteur span { font-size: .82rem; color: var(--doux); }
.interrupteur input { width: 42px; height: 24px; accent-color: var(--p); flex-shrink: 0; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .9rem; border-radius: 10px; padding: .58rem 1rem; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-p { background: var(--p); color: #fff; } .btn-p:hover { background: var(--p2); }
.btn-g { background: var(--carte); border-color: var(--bord2); color: var(--texte); } .btn-g:hover { border-color: var(--p); }
.btn-d { background: var(--err); color: #fff; }
.btn-l { background: none; color: var(--p); padding: .3rem .4rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-mini { padding: .32rem .65rem; font-size: .8rem; border-radius: 8px; }
.barre { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }

/* Tableaux */
.tableau-conteneur { overflow-x: auto; border: 1px solid var(--bord); border-radius: 12px; background: var(--carte); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); font-weight: 700; padding: .65rem .8rem; border-bottom: 1px solid var(--bord); background: var(--fond); white-space: nowrap; }
td { padding: .65rem .8rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.cliquable { cursor: pointer; } tr.cliquable:hover td { background: var(--p-clair); }

/* Badges */
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; background: var(--p-clair); color: var(--p); white-space: nowrap; }
.badge.ok { background: var(--ok-clair); color: var(--ok); } .badge.err { background: var(--err-clair); color: var(--err); } .badge.att { background: var(--att-clair); color: var(--att); }

/* Divers */
.msg { display: none; padding: .6rem .85rem; border-radius: 10px; font-size: .88rem; margin-top: .7rem; }
.msg.ok { display: block; background: var(--ok-clair); color: var(--ok); } .msg.err { display: block; background: var(--err-clair); color: var(--err); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2a3a; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; font-size: .9rem; z-index: 1000; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast.err { background: var(--err); }
.vide { text-align: center; color: var(--doux); padding: 2rem 1rem; }
.etapes { list-style: none; padding: 0; margin: 0; }
.etapes li { display: flex; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--bord); }
.etapes li:last-child { border-bottom: 0; }
.etapes .rond { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bord2); flex-shrink: 0; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.etapes li.fait .rond { background: var(--ok); border-color: var(--ok); color: #fff; }
.etapes li .btn { margin-left: auto; }
.onglets { display: flex; gap: .3rem; border-bottom: 1px solid var(--bord); margin-bottom: 1.1rem; overflow-x: auto; }
.onglets button { font: inherit; font-weight: 600; font-size: .9rem; background: none; border: 0; border-bottom: 2.5px solid transparent; padding: .6rem .8rem; color: var(--doux); cursor: pointer; white-space: nowrap; }
.onglets button.actif { color: var(--p); border-bottom-color: var(--p); }
.modale-fond { position: fixed; inset: 0; background: rgba(10,18,28,.5); z-index: 900; display: grid; place-items: center; padding: 16px; }
.modale { background: var(--carte); border-radius: 16px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modale h2 { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.liste-cons { display: flex; flex-direction: column; gap: .6rem; }
.cons { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: .8rem; align-items: center; border: 1px solid var(--bord); border-radius: 12px; padding: .7rem; background: var(--carte); }
.cons .ph { width: 56px; height: 56px; border-radius: 50%; background: var(--p-clair); display: grid; place-items: center; font-weight: 700; color: var(--p); overflow: hidden; }
.cons .ph img { width: 100%; height: 100%; object-fit: cover; }
.puces { display: flex; flex-wrap: wrap; gap: .45rem; }
.puces label { display: inline-flex; align-items: center; gap: .4rem; border: 1.5px solid var(--bord2); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; font-size: .88rem; background: var(--carte); }
.puces label:has(input:checked) { border-color: var(--p); background: var(--p-clair); }
.puces input { accent-color: var(--p); }
.apercu-cadre { width: 100%; height: 640px; border: 1px solid var(--bord); border-radius: 18px; background: #fff; }
.graph { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: .5rem; }
.graph div { flex: 1; background: var(--p); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.graph div i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--ok); border-radius: 4px 4px 0 0; }
.forfaits { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.forfait { border: 1.5px solid var(--bord); border-radius: 16px; padding: 1.2rem; background: var(--carte); display: flex; flex-direction: column; }
.forfait.vedette { border-color: var(--p); box-shadow: 0 0 0 3px rgba(63,95,134,.12); }
.forfait .prix { font-size: 1.9rem; font-weight: 800; margin: .3rem 0; }
.forfait .prix small { font-size: .9rem; color: var(--doux); font-weight: 500; }
.forfait ul { padding-left: 1.1rem; margin: .6rem 0 1rem; font-size: .88rem; flex: 1; }
.forfait.actuel { border-color: var(--ok); }

/* Pages de connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background: linear-gradient(160deg, var(--p-clair), var(--fond) 60%); }
.auth .boite { width: 100%; max-width: 440px; background: var(--carte); border: 1px solid var(--bord); border-radius: 20px; padding: 2rem 1.8rem; box-shadow: 0 20px 50px rgba(16,24,40,.1); }
.auth .marque { padding: 0 0 1.2rem; justify-content: center; }
.auth h1 { text-align: center; font-size: 1.35rem; }
.auth .sous { text-align: center; }
.auth .btn-p { width: 100%; padding: .75rem; font-size: .98rem; }
.auth .liens { text-align: center; margin-top: 1.1rem; font-size: .88rem; display: flex; flex-direction: column; gap: .35rem; }
.cache { display: none !important; }
