:root {
  --marque: #2f6fed;
  --marque-fonce: color-mix(in srgb, var(--marque) 80%, black);
  --marque-pale: color-mix(in srgb, var(--marque) 10%, white);
  --fond: #f5f6f8;
  --surface: #ffffff;
  --bord: #e3e6eb;
  --bord-fort: #cfd4dc;
  --texte: #1b1f27;
  --texte-2: #5b6472;
  --texte-3: #8a93a1;
  --ok: #138a52;      --ok-pale: #e6f5ed;
  --alerte: #b26a00;  --alerte-pale: #fff3dc;
  --danger: #c4314b;  --danger-pale: #fdeaed;
  --info: #3a5ccc;    --info-pale: #e9eefc;
  --neutre-pale: #eef0f3;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--texte);
  background: var(--fond);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--marque); }
[hidden] { display: none !important; }
.sous { color: var(--texte-2); }
.aide { color: var(--texte-3); font-size: .85rem; margin-top: .35rem; }
.erreur { color: var(--danger); min-height: 1.2em; margin-top: .5rem; }
.ico { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* Boutons et champs */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
  padding: .5rem .85rem; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--neutre-pale); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primaire { background: var(--marque); border-color: var(--marque); color: #fff; }
.btn.primaire:hover { background: var(--marque-fonce); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.discret { border-color: transparent; background: transparent; color: var(--texte-2); }
.btn.discret:hover { background: var(--neutre-pale); }
.btn.petit { padding: .3rem .6rem; font-size: .85rem; }
.btn.large { padding: .7rem 1.1rem; width: 100%; }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--surface);
  border: 1px solid var(--bord-fort); border-radius: 8px; padding: .5rem .65rem; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--marque); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--texte-2); margin: .75rem 0 .3rem; }
input[type="checkbox"] { width: auto; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.carte-connexion { background: var(--surface); padding: 2rem; border-radius: 16px; box-shadow: var(--ombre); width: min(380px, 100%); border: 1px solid var(--bord); }
.carte-connexion h1 { margin-top: .75rem; }
.carte-connexion .btn { margin-top: 1rem; }
.logo-grand svg, .logo svg { display: block; }
.logo-grand svg { width: 48px; height: 48px; }
.logo-grand rect, .logo rect { fill: var(--marque); }
.logo-grand path, .logo path { stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }

/* En-tête */
.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface); border-bottom: 1px solid var(--bord); padding: .6rem 1.25rem; position: sticky; top: 0; z-index: 5;
}
.marque { display: flex; align-items: center; gap: .6rem; font-weight: 700; min-width: 0; }
.logo svg { width: 28px; height: 28px; }
.fil { font-weight: 500; color: var(--texte-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fil a { color: var(--texte-2); text-decoration: none; }
.fil a:hover { text-decoration: underline; }
.entete-droite { display: flex; align-items: center; gap: .6rem; }
.profil { color: var(--texte-2); font-size: .85rem; }
.etat-services { display: flex; gap: .35rem; }
.onglets { display: flex; gap: .25rem; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--bord); overflow-x: auto; }
.onglets button {
  border: 0; background: none; font: inherit; color: var(--texte-2); padding: .75rem .8rem; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.onglets button[aria-current="page"] { color: var(--marque); border-bottom-color: var(--marque); }
.onglets .compteur { background: var(--danger); color: #fff; border-radius: 99px; font-size: .72rem; padding: .05rem .4rem; margin-left: .3rem; }
.contenu { padding: 1.25rem; max-width: 1280px; margin: 0 auto; }

/* Cartes et grilles */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.1rem; box-shadow: var(--ombre); }
.carte + .carte { margin-top: 1rem; }
.grille { display: grid; gap: 1rem; }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .9rem 1rem; }
.kpi .valeur { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .libelle { color: var(--texte-2); font-size: .85rem; }
.kpi.alerte .valeur { color: var(--danger); }
.barre-outils { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.barre-outils .groupe { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.puces button { border: 1px solid var(--bord-fort); background: var(--surface); border-radius: 99px; padding: .3rem .75rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--texte-2); }
.puces button[aria-pressed="true"] { background: var(--marque-pale); color: var(--marque-fonce); border-color: var(--marque); font-weight: 600; }

/* Tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-wrap table { min-width: 640px; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-3); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: #fafbfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td input, td select { padding: .35rem .5rem; }
.vide { color: var(--texte-3); text-align: center; padding: 2rem; }

/* Badges */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--neutre-pale); color: var(--texte-2); white-space: nowrap; }
.badge.ok { background: var(--ok-pale); color: var(--ok); }
.badge.alerte { background: var(--alerte-pale); color: var(--alerte); }
.badge.danger { background: var(--danger-pale); color: var(--danger); }
.badge.info { background: var(--info-pale); color: var(--info); }
.badge + .badge { margin-left: .25rem; }

/* Agenda */
.agenda { display: grid; border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); overflow: auto; }
.agenda .entete-col { position: sticky; top: 0; background: #fafbfc; border-bottom: 1px solid var(--bord); padding: .5rem; font-weight: 600; text-align: center; z-index: 2; }
.agenda .heures { position: relative; border-right: 1px solid var(--bord); }
.agenda .heure { position: absolute; right: .4rem; font-size: .75rem; color: var(--texte-3); transform: translateY(-50%); }
.agenda .colonne { position: relative; border-right: 1px solid var(--bord); min-width: 150px; }
.agenda .colonne:last-child { border-right: 0; }
.agenda .ligne-h { position: absolute; left: 0; right: 0; border-top: 1px solid #f0f2f5; }
.agenda .ferme { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(45deg, #f6f7f9, #f6f7f9 6px, #eef0f3 6px, #eef0f3 12px); }
.agenda .bloc {
  position: absolute; left: 4px; right: 4px; border-radius: 6px; padding: .25rem .4rem; font-size: .78rem; overflow: hidden; cursor: pointer;
  background: var(--marque-pale); border-left: 3px solid var(--marque); color: var(--texte);
}
.agenda .bloc.a_valider { background: var(--alerte-pale); border-left-color: var(--alerte); }
.agenda .bloc.verrou { background: var(--neutre-pale); border-left-color: var(--texte-3); border-style: dashed; }
.agenda .bloc strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda .maintenant { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 1; }

/* Formulaires en grille */
.champs { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.jours { display: flex; gap: .5rem; flex-wrap: wrap; }
.jours label { display: inline-flex; align-items: center; gap: .25rem; margin: 0; font-weight: 500; }
.creneaux-liste { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.creneaux-liste button { border: 1px solid var(--bord-fort); background: var(--surface); border-radius: 8px; padding: .35rem .6rem; cursor: pointer; font: inherit; font-size: .85rem; }
.creneaux-liste button[aria-pressed="true"] { background: var(--marque); color: #fff; border-color: var(--marque); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.code-acces { font-family: ui-monospace, Menlo, monospace; font-size: 1.2rem; background: var(--neutre-pale); padding: .5rem .75rem; border-radius: 8px; display: inline-block; letter-spacing: .05em; }

/* Tiroir */
.tiroir { position: fixed; inset: 0; z-index: 20; }
.tiroir-fond { position: absolute; inset: 0; background: rgba(16, 24, 40, .35); }
.tiroir-panneau { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); padding: 1.5rem; overflow-y: auto; box-shadow: -8px 0 24px rgba(16, 24, 40, .15); }
.fermer { position: absolute; top: .75rem; right: .75rem; }
.bloc-info { background: #fafbfc; border: 1px solid var(--bord); border-radius: 8px; padding: .75rem; margin: .5rem 0 1rem; }
.transcription { white-space: pre-wrap; font-size: .88rem; line-height: 1.5; max-height: 320px; overflow-y: auto; }
.journal { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.journal li { padding: .35rem 0; border-bottom: 1px dashed var(--bord); }
.journal time { color: var(--texte-3); margin-right: .5rem; font-variant-numeric: tabular-nums; }

/* Modale d'appel */
.modale { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modale-carte { position: relative; background: var(--surface); border-radius: 16px; padding: 1.5rem; width: min(560px, 100%); max-height: 92vh; overflow-y: auto; }
.appel-etat { display: flex; align-items: center; gap: .5rem; margin: 1rem 0 .5rem; font-weight: 600; }
.voyant { width: 12px; height: 12px; border-radius: 50%; background: var(--texte-3); }
.voyant.actif { background: var(--ok); box-shadow: 0 0 0 0 rgba(19, 138, 82, .5); animation: pulse 1.4s infinite; }
.voyant.parle { background: var(--marque); }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(19, 138, 82, 0); } 100% { box-shadow: 0 0 0 0 rgba(19, 138, 82, 0); } }
.transcription-live { min-height: 120px; max-height: 300px; overflow-y: auto; background: #fafbfc; border: 1px solid var(--bord); border-radius: 8px; padding: .75rem; font-size: .9rem; }
.transcription-live p { margin: 0 0 .5rem; }
.transcription-live .agent { color: var(--marque-fonce); }

.toast { visibility: hidden; opacity: 0; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--texte); color: #fff; padding: .7rem 1rem; border-radius: 8px; transition: transform .25s, opacity .25s, visibility .25s; z-index: 40; max-width: calc(100% - 32px); }
.toast.visible { transform: translateX(-50%) translateY(0); visibility: visible; opacity: 1; }
.toast.erreur { background: var(--danger); }

@media (max-width: 720px) {
  .entete { flex-wrap: wrap; padding: .6rem 16px; }
  .profil, .etat-services { display: none; }
  .contenu { padding: 16px; }
  .onglets { padding: 0 8px; }
  th, td { padding: .5rem; }
}
