/* 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; } }
