/* AIGENCY Atlas — couleurs du logo AIGENCY (marine #0b2a4a, bleu #207abc, vert #b2d12f) */
:root {
  --primaire: #0b2a4a; --secondaire: #207abc; --accent: #b2d12f; --accent-fonce: #7f9a16;
  --texte: #1f2d3d; --muted: #66768a; --fond: #f4f7fa; --carte: #fff; --ligne: #e1e7ee; --survol: #eaf2fa;
  --ok: #2f7d32; --ok-fond: #eaf6e7; --alerte: #a66300; --alerte-fond: #fff5e1; --erreur: #b3261e; --erreur-fond: #fdecea;
  --rayon: 12px; --ombre: 0 1px 2px rgb(11 42 74 / 6%), 0 4px 16px rgb(11 42 74 / 5%);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--fond); color: var(--texte); font: 15px/1.55 Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--secondaire); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.55rem; margin: 0 0 .3rem; color: var(--primaire); letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; color: var(--primaire); }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.petit { font-size: .85rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--secondaire) 55%, transparent); outline-offset: 2px; }

/* ---------- boutons, champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--primaire); background: var(--primaire);
  color: #fff; border-radius: 9px; padding: .55rem 1rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #143d66; }
.btn.secondaire { background: #fff; color: var(--primaire); border-color: var(--ligne); }
.btn.secondaire:hover { background: var(--survol); }
.btn.vert { background: var(--accent); border-color: var(--accent); color: var(--primaire); }
.btn.danger { background: #fff; color: var(--erreur); border-color: #f1c9c5; }
.btn.petit { padding: .3rem .65rem; font-size: .85rem; }
.btn.plein { width: 100%; padding: .7rem 1rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg { width: 18px; height: 18px; }
.lien-action { background: none; border: 0; color: var(--secondaire); font-weight: 600; cursor: pointer; padding: 0; text-decoration: none; font-size: .9rem; }
.champ { margin-bottom: .9rem; }
.champ label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
input:not([type=checkbox]), select, textarea { width: 100%; border: 1px solid var(--ligne); background: #fff; border-radius: 9px; padding: .55rem .7rem; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--secondaire); outline: none; box-shadow: 0 0 0 3px rgb(32 122 188 / 15%); }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 .9rem; }
.alerte { border-radius: 9px; padding: .65rem .85rem; margin: .6rem 0; background: var(--alerte-fond); color: var(--alerte); border: 1px solid #f3dfb6; overflow-wrap: anywhere; }
.alerte.ok { background: var(--ok-fond); color: var(--ok); border-color: #cfe7c9; }
.alerte.erreur { background: var(--erreur-fond); color: var(--erreur); border-color: #f4c7c3; }
.copie { display: flex; gap: .4rem; margin-top: .4rem; }
.copie input { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }

/* ---------- page de connexion */
.page-auth { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #e3eef8 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #eef6d8 0, transparent 60%), var(--fond); }
.auth { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 1rem; padding: 24px 16px; }
.auth-carte { width: min(420px, 100%); background: var(--carte); border: 1px solid var(--ligne); border-radius: 18px; box-shadow: var(--ombre); padding: 2rem 1.75rem; }
.auth-logo { height: 34px; display: block; }
.auth-produit { margin: .4rem 0 1.4rem; font-weight: 800; font-size: 1.05rem; letter-spacing: .32em; text-transform: uppercase; color: var(--secondaire); }
.auth-pied { color: var(--muted); font-size: .8rem; text-align: center; }
.compte { font-weight: 600; background: var(--survol); border-radius: 9px; padding: .5rem .75rem; overflow-wrap: anywhere; }

/* ---------- mise en page */
.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--ligne); padding: 20px 14px 16px; overflow-y: auto; }
.brand { display: block; text-decoration: none; padding: 0 8px 4px; }
.brand img { height: 26px; display: block; }
.brand .produit { display: block; margin-top: .35rem; font-weight: 800; letter-spacing: .32em; font-size: .78rem; color: var(--secondaire); text-transform: uppercase; }
.espace { margin: 14px 4px 10px; }
.espace .nom { font-weight: 700; color: var(--primaire); padding: .4rem .6rem; background: var(--fond); border-radius: 9px; overflow-wrap: anywhere; }
.espace select { font-weight: 600; }
.espace small { display: block; color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 .25rem .2rem; }
#nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: 9px; color: #42566b; text-decoration: none; font-weight: 500; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: var(--survol); color: var(--primaire); }
.nav-item.actif { background: var(--primaire); color: #fff; }
.nav-item .ext { margin-left: auto; opacity: .55; width: 14px; height: 14px; }
.nav-sep { margin: .9rem .65rem .25rem; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--ligne); display: grid; gap: .5rem; }
.user { display: flex; gap: .6rem; align-items: center; min-width: 0; }
.initiales { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--primaire); font-weight: 800; font-size: .85rem; }
.user .infos { min-width: 0; }
.user .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .role { font-size: .78rem; color: var(--muted); }
.link-muted { color: var(--muted); font-size: .85rem; text-decoration: none; }
.main { padding: 28px clamp(16px, 3vw, 40px) 48px; max-width: 1240px; width: 100%; margin: 0 auto; outline: none; }
.main.plein { max-width: none; padding-bottom: 16px; }
.bottom-nav { display: none; }
.titre-page { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 1.1rem 1.2rem; box-shadow: var(--ombre); min-width: 0; }
.section-titre { display: flex; align-items: center; justify-content: space-between; margin: 1.6rem 0 .7rem; gap: 1rem; }
.section-titre h2 { margin: 0; }

/* ---------- accueil */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; background: linear-gradient(120deg, var(--primaire), #123c66 60%, #1b5b8f);
  color: #fff; border-radius: 18px; padding: 1.6rem 1.8rem; }
.hero h1 { color: #fff; font-size: 1.7rem; }
.hero .sous { margin: 0; opacity: .9; }
.hero .slogan { margin: .4rem 0 0; color: var(--accent); font-weight: 600; font-size: .9rem; }
.hero img { width: 84px; height: 84px; flex: none; filter: drop-shadow(0 6px 18px rgb(0 0 0 / 25%)); }
.ask { display: flex; gap: .5rem; margin: 1rem 0; background: #fff; border: 1px solid var(--ligne); border-radius: 14px; padding: .4rem; box-shadow: var(--ombre); }
.ask input { border: 0; box-shadow: none !important; font-size: 1rem; }
.envoyer { flex: none; width: 44px; height: 44px; border-radius: 11px; border: 0; background: var(--accent); color: var(--primaire); display: grid; place-items: center; cursor: pointer; }
.envoyer svg { width: 20px; height: 20px; }
.univers { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem; }
.tuile { display: flex; gap: .7rem; align-items: center; text-align: left; background: #fff; border: 1px solid var(--ligne); border-left: 4px solid var(--trait, var(--secondaire));
  border-radius: 12px; padding: .8rem .9rem; cursor: pointer; font-weight: 600; color: var(--primaire); }
.tuile:hover { background: var(--survol); }
.tuile .ico svg { width: 26px; height: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1px solid var(--ligne); background: #fff; border-radius: 999px; padding: .38rem .8rem; cursor: pointer; font-size: .88rem; color: #31465c; text-align: left; }
.chip:hover { border-color: var(--secondaire); color: var(--secondaire); }
.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; }
.widget { display: flex; flex-direction: column; gap: .5rem; }
.widget .entete { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--primaire); }
.pastille { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--survol); color: var(--secondaire); }
.pastille svg { width: 18px; height: 18px; }
.widget.rouge .pastille { background: var(--erreur-fond); color: var(--erreur); }
.chiffre { font-size: 2rem; font-weight: 800; color: var(--primaire); line-height: 1.1; }
.widget ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; }
.widget li { display: flex; justify-content: space-between; gap: .6rem; }
.widget li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget .lien-action { margin-top: auto; }
.mini-etapes { display: flex; gap: .3rem; flex-wrap: wrap; }
.mini-etapes span { background: var(--fond); border-radius: 7px; padding: .15rem .45rem; font-size: .8rem; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: .25rem; border-radius: 999px; padding: .1rem .55rem; font-size: .76rem; font-weight: 700; white-space: nowrap; background: var(--fond); color: #42566b; border: 1px solid var(--ligne); }
.badge.open { background: #e6f1fb; color: #155d92; border-color: #cfe3f5; }
.badge.pending { background: var(--alerte-fond); color: var(--alerte); border-color: #f3dfb6; }
.badge.resolved { background: var(--ok-fond); color: var(--ok); border-color: #cfe7c9; }
.badge.urgent { background: var(--erreur); color: #fff; border-color: var(--erreur); }
.badge.high { background: var(--erreur-fond); color: var(--erreur); border-color: #f4c7c3; }
.badge.medium { background: var(--alerte-fond); color: var(--alerte); border-color: #f3dfb6; }
.badge.sla-ko { background: var(--erreur); color: #fff; border-color: var(--erreur); }
.badge.sla-proche { background: #ffb224; color: #3d2600; border-color: #ffb224; }
.badge.role-admin { background: var(--primaire); color: #fff; border-color: var(--primaire); }
.badge.role-agent { background: #e6f1fb; color: #155d92; }
.badge.role-commercial { background: #f1f8dc; color: #4f6110; border-color: #dcebaa; }
.badge.invite { background: var(--alerte-fond); color: var(--alerte); }
.badge.off { background: #eee; color: #777; }

/* ---------- listes (tickets, utilisateurs) */
.filtres { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.segment { display: inline-flex; border: 1px solid var(--ligne); border-radius: 10px; overflow: hidden; background: #fff; }
.segment button { border: 0; background: none; padding: .42rem .8rem; cursor: pointer; font-weight: 600; color: #42566b; font-size: .88rem; }
.segment button.actif { background: var(--primaire); color: #fff; }
.segment button + button { border-left: 1px solid var(--ligne); }
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: 1px solid var(--ligne); }
.ligne-ticket { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .75rem .3rem; text-decoration: none; color: inherit; border-radius: 8px; }
.ligne-ticket:hover { background: var(--survol); }
.ligne-ticket .haut { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; min-width: 0; }
.ligne-ticket .client { font-weight: 700; color: var(--primaire); }
.ligne-ticket .apercu { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-ticket .droite { display: flex; gap: .35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.non-lus { background: var(--secondaire); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 0 .45rem; }
.vide-liste { padding: 2rem 1rem; text-align: center; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--ligne); }
td { padding: .6rem .5rem; border-bottom: 1px solid var(--ligne); vertical-align: middle; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
td select { width: auto; padding: .3rem .5rem; }

/* ---------- détail ticket */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.fil-ticket { display: flex; flex-direction: column; gap: .6rem; max-height: calc(100vh - 330px); min-height: 240px; overflow-y: auto; padding: .4rem .2rem; }
.bulle { max-width: 82%; border-radius: 14px; padding: .55rem .8rem; background: var(--fond); white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle .md { white-space: normal; } .bulle .md p { margin: .25rem 0; } .bulle .md ul, .bulle .md ol { margin: .25rem 0; padding-left: 1.2rem; }
.bulle .md h4 { margin: .4rem 0 .2rem; }
.bulle .auteur { font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; white-space: normal; }
.bulle.user { align-self: flex-start; background: #fff; border: 1px solid var(--ligne); }
.bulle.assistant { align-self: flex-end; background: #e6f1fb; }
.bulle.prive { align-self: flex-end; background: #fff8dc; border: 1px dashed #e8c96a; }
.bulle.system { align-self: center; background: none; color: var(--muted); font-size: .82rem; text-align: center; max-width: 100%; }
.reponse { margin-top: .8rem; border-top: 1px solid var(--ligne); padding-top: .8rem; }
.reponse textarea { min-height: 90px; resize: vertical; }
.reponse.prive textarea { background: #fffbea; border-color: #e8c96a; }
.reponse .barre { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.infos-ticket dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .8rem; margin: 0; font-size: .9rem; }
.infos-ticket dt { color: var(--muted); }
.infos-ticket dd { margin: 0; overflow-wrap: anywhere; }
.infos-ticket .actions { display: grid; gap: .45rem; margin-top: 1rem; }

/* ---------- CRM : vue par étapes */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.colonne { background: #eef2f6; border-radius: 12px; padding: .6rem; display: flex; flex-direction: column; gap: .5rem; min-height: 120px; }
.colonne .entete { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--primaire); padding: .1rem .2rem; }
.carte-lead { background: #fff; border: 1px solid var(--ligne); border-radius: 10px; padding: .6rem .7rem; text-decoration: none; color: inherit; display: grid; gap: .15rem; }
.carte-lead:hover { border-color: var(--secondaire); }
.carte-lead .titre { font-weight: 600; color: var(--primaire); font-size: .92rem; }
.carte-lead .meta { font-size: .8rem; color: var(--muted); }
.activites { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.activites li { border-left: 3px solid var(--accent); padding: .2rem .7rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.activites .meta { font-size: .8rem; color: var(--muted); white-space: normal; }

/* ---------- assistant */
.chat { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 1rem; height: calc(100vh - 44px); }
.chat-liste { background: #fff; border: 1px solid var(--ligne); border-radius: var(--rayon); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.chat-liste .haut { padding: .7rem; border-bottom: 1px solid var(--ligne); }
.chat-liste .haut .btn { width: 100%; }
.chat-liste ul { list-style: none; margin: 0; padding: .3rem; overflow-y: auto; }
.chat-liste a { display: grid; gap: .1rem; padding: .55rem .6rem; border-radius: 9px; text-decoration: none; color: inherit; }
.chat-liste a:hover { background: var(--survol); }
.chat-liste a.actif { background: var(--survol); box-shadow: inset 3px 0 0 var(--secondaire); }
.chat-liste .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-liste .d { font-size: .78rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.fil { background: #fff; border: 1px solid var(--ligne); border-radius: var(--rayon); display: flex; flex-direction: column; min-height: 0; }
.fil-haut { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--ligne); }
.fil-haut .retour { display: none; }
.avatar { width: 38px; height: 38px; flex: none; }
.messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.msg { max-width: min(760px, 88%); border-radius: 14px; padding: .65rem .9rem; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--primaire); color: #fff; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--fond); }
.msg.assistant p { margin: .3rem 0; } .msg.assistant ul, .msg.assistant ol { margin: .3rem 0; padding-left: 1.2rem; } .msg.assistant h4 { margin: .5rem 0 .2rem; color: var(--primaire); }
.msg .auteur { font-size: .76rem; font-weight: 700; color: var(--secondaire); margin-bottom: .1rem; }
.msg.system { align-self: center; color: var(--muted); font-size: .85rem; }
.msg.ecrit { display: flex; gap: 4px; padding: .8rem; }
.msg.ecrit i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite; }
.msg.ecrit i:nth-child(2) { animation-delay: .2s; } .msg.ecrit i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.saisie { border-top: 1px solid var(--ligne); padding: .7rem 1rem .5rem; }
.saisie form { display: flex; gap: .5rem; align-items: flex-end; }
.saisie textarea { resize: none; max-height: 180px; }
.saisie .note { font-size: .74rem; color: var(--muted); margin: .4rem 0 0; }
.univers-actif { font-size: .8rem; color: var(--secondaire); font-weight: 600; margin-bottom: .3rem; }
.vide { margin: auto; text-align: center; max-width: 560px; display: grid; gap: .6rem; justify-items: center; }
.vide .avatar { width: 64px; height: 64px; }

/* ---------- bibliothèque */
.resultats { display: grid; gap: .8rem; }
.resultat .source { font-size: .8rem; color: var(--secondaire); font-weight: 700; }
.resultat p { margin: .3rem 0 .6rem; color: #3b4d60; }

/* ---------- responsive (16 px de marge, pas de défilement horizontal de la page) */
@media (max-width: 1000px) { .detail { grid-template-columns: 1fr; } .fil-ticket { max-height: 60vh; } }
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar { display: none; }
  .main { padding: 16px 16px 90px; }
  .main.plein { padding-bottom: 76px; }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; background: #fff; border-top: 1px solid var(--ligne); z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: .45rem 0; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.actif { color: var(--primaire); }
  .hero { padding: 1.2rem; } .hero img { display: none; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 92px); }
  .chat.avec-fil .chat-liste { display: none; }
  .chat:not(.avec-fil) .fil { display: none; }
  .fil-haut .retour { display: inline-flex; }
  .cache-mobile { display: none; }
  .ligne-ticket { grid-template-columns: 1fr; }
  .ligne-ticket .droite { justify-content: flex-start; }
  .entete-mobile { display: flex !important; }
}
.entete-mobile { display: none; align-items: center; justify-content: space-between; gap: .6rem; padding: 14px 16px 0; background: var(--fond); }
.entete-mobile img { height: 22px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- mode intégré : application complète (Chatwoot, Krayin) dans Atlas, menu replié en barre d'icônes */
.layout > .main, .layout > .integre { grid-column: 2; grid-row: 1; }
.integre { position: sticky; top: 0; height: 100vh; background: #fff; }
.cadre-app { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.cadre-app[hidden] { display: none; }
button.nav-item { background: none; border: 0; width: 100%; font: inherit; cursor: pointer; text-align: left; }
.brand-icone { display: none; width: 30px; height: 30px; margin: 0 auto; }
.bascule-rail { display: none; place-items: center; align-self: flex-end; width: 32px; height: 32px; margin-top: 8px; border: 1px solid var(--ligne); border-radius: 8px; background: #fff; color: #42566b; cursor: pointer; }
.bascule-rail:hover { background: var(--survol); color: var(--primaire); }
.bascule-rail svg { width: 17px; height: 17px; }
.integre-actions { display: none; }
body.mode-integre .bascule-rail { display: grid; }
body.mode-integre .integre-actions { display: grid; gap: 2px; margin-top: auto; padding-top: .6rem; }
body.mode-integre .sidebar-foot { margin-top: .6rem; }
body.rail .layout { grid-template-columns: 64px minmax(0, 1fr); }
body.rail .sidebar { padding: 14px 8px 12px; overflow-x: hidden; }
body.rail .brand { padding: 0; }
body.rail .brand .logo, body.rail .brand .produit, body.rail .espace, body.rail .lib, body.rail .nav-item .ext,
body.rail .user .infos, body.rail .sidebar-foot .link-muted { display: none; }
body.rail .brand-icone { display: block; }
body.rail .bascule-rail { align-self: center; }
body.rail .nav-item { justify-content: center; padding: .6rem 0; }
body.rail .nav-sep { height: 1px; margin: .5rem .35rem; padding: 0; font-size: 0; background: var(--ligne); }
body.rail .user { justify-content: center; }

/* Résultats (rapport de valeur) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .9rem; margin-bottom: .9rem; }
.kpi .kpi-titre { font-weight: 600; color: var(--muted); font-size: .88rem; }
.kpi .chiffre { font-size: 1.9rem; font-weight: 800; color: var(--primaire); line-height: 1.2; margin: .2rem 0; }
.kpis.secondaires .chiffre { font-size: 1.4rem; }
.evol { display: inline-block; margin-top: .4rem; font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--fond); color: var(--muted); }
.evol.hausse { background: var(--ok-fond); color: var(--ok); }
.evol.baisse { background: var(--alerte-fond); color: var(--alerte); }
.grille-resultats { display: grid; grid-template-columns: 2fr 1fr; gap: .9rem; margin-bottom: .9rem; }
.histo { display: flex; align-items: stretch; gap: .6rem; height: 190px; padding-top: .4rem; }
.histo .histo-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem; min-width: 0; }
.histo .valeur { font-size: .8rem; font-weight: 700; color: var(--primaire); }
.histo .piste { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; }
.histo .barre { width: 100%; background: color-mix(in srgb, var(--secondaire) 28%, #fff); border-radius: 6px 6px 0 0; display: flex; align-items: flex-end; overflow: hidden; min-height: 2px; }
.histo .part-ia { width: 100%; background: var(--secondaire); }
.histo .mois { font-size: .78rem; color: var(--muted); text-transform: capitalize; }
.legende { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.pastille-ia, .pastille-total { width: 11px; height: 11px; border-radius: 3px; background: var(--secondaire); display: inline-block; }
.pastille-total { background: color-mix(in srgb, var(--secondaire) 28%, #fff); margin-left: .6rem; }
.canaux { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.canaux li { display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: center; gap: .6rem; }
.jauge { height: 8px; background: var(--fond); border-radius: 99px; overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--accent-fonce); }
.pistes { margin: .3rem 0 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
.resultats > .carte { margin-bottom: .9rem; }
@media (max-width: 860px) { .grille-resultats { grid-template-columns: 1fr; } .histo { height: 150px; gap: .35rem; } }

/* Essai guidé : carte « Bien démarrer » */
.demarrage { margin-bottom: 1.2rem; border-left: 4px solid var(--accent); }
.demarrage-entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.demarrage-entete h2 { margin-bottom: .15rem; }
.essai-reste { text-align: right; display: grid; }
.essai-reste strong { font-size: 1.25rem; color: var(--primaire); }
.progression { height: 8px; background: var(--fond); border-radius: 99px; overflow: hidden; margin: .7rem 0 .9rem; }
.progression span { display: block; height: 100%; background: var(--accent-fonce); transition: width .4s; }
.etapes-demarrage { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.etapes-demarrage li { display: grid; grid-template-columns: 26px 1fr auto; align-items: start; gap: .6rem; padding: .55rem .6rem; border: 1px solid var(--ligne); border-radius: 10px; }
.etapes-demarrage li.fait { background: var(--ok-fond); border-color: transparent; }
.etapes-demarrage li.fait .etape-titre { color: var(--ok); }
.etapes-demarrage .coche { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ligne); display: grid; place-items: center; font-size: .8rem; font-weight: 800; margin-top: .1rem; }
.etapes-demarrage li.fait .coche { background: var(--ok); border-color: var(--ok); color: #fff; }
.etape-titre { font-weight: 600; color: var(--primaire); }
.code-widget { width: 100%; font: .78rem/1.4 ui-monospace, Consolas, monospace; margin: .4rem 0; resize: vertical; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 860px) { .essai-reste { text-align: left; } .etapes-demarrage li { grid-template-columns: 26px 1fr; } .etapes-demarrage li > .btn { grid-column: 2; justify-self: start; } }

/* Éditeur de la fiche de l'assistant (Atlas et console) */
.fe-form { display: grid; gap: 1rem; }
.fe-section { border: 1px solid var(--ligne, #e1e7ee); border-radius: 10px; padding: .8rem 1rem 1rem; margin: 0; display: grid; gap: .8rem; min-width: 0; }
.fe-section legend { font-weight: 700; color: var(--primaire, #0b2a4a); padding: 0 .4rem; }
.fe-champ { display: grid; gap: .3rem; }
.fe-champ > label { font-weight: 600; }
.fe-champ textarea, .fe-champ input, .fe-horaires input { width: 100%; }
.fe-aide { color: var(--muted, #66768a); font-size: .85rem; font-weight: 400; }
.fe-autre { border-top: 1px dashed var(--ligne, #e1e7ee); padding-top: .6rem; }
.fe-titre-autre { font-weight: 600; }
.fe-lien { background: none; border: 0; padding: 0; color: var(--secondaire, #207abc); cursor: pointer; font-size: .85rem; justify-self: start; }
.fe-horaires { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem .9rem; }
.fe-jour { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: .5rem; }
.fe-ligne { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: center; }
.fe-actions { position: sticky; bottom: 0; background: var(--carte, #fff); padding: .6rem 0; display: grid; gap: .5rem; border-top: 1px solid var(--ligne, #e1e7ee); }
.fe-message { padding: .6rem .8rem; border-radius: 8px; background: var(--fond, #f4f7fa); margin-bottom: .6rem; }
.fe-message.ok { background: var(--ok-fond, #eaf6e7); color: var(--ok, #2f7d32); }
.fe-message.erreur { background: var(--erreur-fond, #fdecea); color: var(--erreur, #b3261e); }
.fe-historique { margin-top: 1.2rem; }
.fe-historique ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.fe-historique li { border: 1px solid var(--ligne, #e1e7ee); border-radius: 8px; padding: .5rem .7rem; display: grid; gap: .2rem; }

/* Documents de l'assistant */
.fd-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fd-depot { display: grid; gap: .3rem; place-items: center; text-align: center; padding: 1.4rem 1rem; border: 2px dashed var(--ligne, #e1e7ee); border-radius: 12px; cursor: pointer; margin: .6rem 0; }
.fd-depot:hover, .fd-depot.survol, .fd-input:focus-visible + .fd-depot { border-color: var(--secondaire, #207abc); background: var(--survol, #eaf2fa); }
.fd-journal { display: grid; gap: .3rem; margin-bottom: .6rem; }
.fd-journal .fe-message { margin: 0; }
.fd-liste { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.fd-liste li { display: grid; grid-template-columns: 1fr auto auto; gap: .4rem 1rem; align-items: center; border: 1px solid var(--ligne, #e1e7ee); border-radius: 10px; padding: .6rem .8rem; }
.fd-nom strong { overflow-wrap: anywhere; }
.fd-badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .55rem; border-radius: 99px; background: var(--fond, #f4f7fa); }
.fd-badge.ok { background: var(--ok-fond, #eaf6e7); color: var(--ok, #2f7d32); }
.fd-badge.attente { background: var(--survol, #eaf2fa); color: var(--secondaire, #207abc); }
.fd-badge.alerte { background: var(--alerte-fond, #fff5e1); color: var(--alerte, #a66300); }
.fd-badge.erreur { background: var(--erreur-fond, #fdecea); color: var(--erreur, #b3261e); }
.fd-actions { display: flex; gap: .8rem; }
.atelier-onglets { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.atelier-onglets a { padding: .4rem .9rem; border-radius: 99px; border: 1px solid var(--ligne, #e1e7ee); text-decoration: none; color: var(--texte, #1f2d3d); font-weight: 600; font-size: .9rem; }
.atelier-onglets a.actif { background: var(--primaire, #0b2a4a); border-color: var(--primaire, #0b2a4a); color: #fff; }
@media (max-width: 700px) { .fd-liste li { grid-template-columns: 1fr; } }

/* Site web de l'assistant */
.fs-form { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
.fs-url { flex: 1 1 18rem; min-width: 0; }
.fs-import { display: grid; gap: .3rem; border: 1px solid var(--ligne, #e1e7ee); border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0; }
.fs-import strong { overflow-wrap: anywhere; }
.fs-proposition { border-top: 1px solid var(--ligne, #e1e7ee); margin-top: .8rem; padding-top: .6rem; }
.fs-champ { border: 1px solid var(--ligne, #e1e7ee); border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0; }
.fs-titre { font-weight: 600; display: flex; gap: .4rem; align-items: center; cursor: pointer; }
.fs-comparaison { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .4rem; }
.fs-valeur { white-space: pre-line; margin: .2rem 0; overflow-wrap: anywhere; }
.fs-valeur.ancien { color: var(--muet, #5b6b7d); }
.fs-pages ul { margin: .4rem 0 0; padding-left: 1.2rem; display: grid; gap: .2rem; }
.fs-pages a { overflow-wrap: anywhere; }
@media (max-width: 700px) { .fs-comparaison { grid-template-columns: 1fr; } }

/* Mobile : barre d'enregistrement de la fiche au-dessus de la navigation du bas */
@media (max-width: 860px) { .fe-actions { bottom: calc(58px + env(safe-area-inset-bottom)); } }

/* Marque HADIA (by aiagency.ma) — logo complet dans le menu et à la connexion, symbole en mode replié */
.brand img.logo { height: 84px; width: auto; }
.brand .produit { margin-top: .15rem; letter-spacing: .02em; text-transform: none; font-weight: 600; font-size: .72rem; color: var(--muted, #5b6b7d); }
.auth-logo { height: 96px; width: auto; margin: 0 auto; }
.auth-produit { margin: .2rem 0 1.2rem; letter-spacing: .02em; text-transform: none; font-weight: 600; font-size: .8rem; color: var(--muted, #5b6b7d); text-align: center; }
.entete-mobile img { height: 42px; width: auto; }
.brand-icone { object-fit: contain; }
.brand img.brand-icone { display: none; height: 30px; }
body.rail .brand img.brand-icone { display: block; }
body.rail .brand img.logo { display: none; }
