/* CRM Brasserie de Senlis — feuille de style unique */

:root {
  --fond: #f6f3ee;
  --surface: #fffefc;
  --surface-2: #faf7f2;
  --bordure: #e6e0d5;
  --bordure-forte: #d5cbba;

  --encre: #1f1a15;
  --encre-2: #574e44;
  --encre-3: #8a8074;

  --ambre: #a8590c;
  --ambre-fort: #7d4108;
  --ambre-pale: #fdf1e0;
  --orge: #d9a441;

  --vert: #4a7a35;
  --vert-pale: #eef5e8;
  --rouge: #a8322a;
  --rouge-pale: #fceeed;
  --bleu: #2f5d8c;
  --bleu-pale: #eaf1f8;

  --rayon: 10px;
  --ombre: 0 1px 2px rgba(31, 26, 21, .05), 0 6px 16px -8px rgba(31, 26, 21, .12);
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--police);
  font-size: 14px;
  line-height: 1.5;
  color: var(--encre);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ambre); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-3); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------- Structure ------------------------------- */

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.laterale {
  background: #221c16;
  color: #e8e0d4;
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.marque { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.marque .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(160deg, var(--orge), var(--ambre));
  display: grid; place-items: center; font-size: 18px;
}
.marque strong { display: block; font-size: 13.5px; line-height: 1.25; }
.marque span { font-size: 11px; color: #a89b88; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 8px;
  color: #cabfae; font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: #2e261e; color: #f2ebe0; text-decoration: none; }
.nav a.actif { background: var(--ambre); color: #fff; }
.nav a .puce {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.14); padding: 1px 7px; border-radius: 20px;
}
.nav a.actif .puce { background: rgba(0,0,0,.22); }
.laterale footer { margin-top: auto; font-size: 11px; color: #8a7d6c; padding: 0 6px; line-height: 1.6; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; background: rgba(246,243,238,.9);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--bordure);
}
.barre .titre { flex: 1; min-width: 0; }
.barre .titre p { margin: 2px 0 0; font-size: 12.5px; color: var(--encre-3); }
.contenu { padding: 22px 26px 60px; }

/* -------------------------------- Éléments -------------------------------- */

.carte {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); box-shadow: var(--ombre);
}
.carte > header {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--bordure);
}
.carte > header h2 { flex: 1; }
.carte .corps { padding: 16px; }

.grille { display: grid; gap: 14px; }
.grille.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }

.kpi-carte { padding: 15px 16px; }
.kpi-carte .etiquette { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-3); }
.kpi-carte .valeur { font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-carte .detail { font-size: 12.5px; color: var(--encre-2); margin-top: 3px; }

.jauge { height: 5px; border-radius: 3px; background: var(--bordure); overflow: hidden; margin-top: 10px; }
.jauge i { display: block; height: 100%; background: var(--ambre); border-radius: 3px; }
.jauge.ok i { background: var(--vert); }
.jauge.alerte i { background: var(--rouge); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--bordure-forte); background: var(--surface);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primaire { background: var(--ambre); border-color: var(--ambre); color: #fff; }
.btn.primaire:hover { background: var(--ambre-fort); }
.btn.discret { border-color: transparent; background: transparent; color: var(--encre-2); }
.btn.discret:hover { background: var(--surface-2); }
.btn.danger { color: var(--rouge); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.champ { display: flex; flex-direction: column; gap: 5px; }
.champ > label { font-size: 12px; color: var(--encre-2); font-weight: 500; }
input[type=text], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--bordure-forte);
  border-radius: 8px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orge); outline-offset: -1px; border-color: var(--orge); }
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%238a8074'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 26px; }

.recherche { position: relative; width: 300px; }
.recherche input { padding-left: 32px; }
.recherche::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--encre-3); font-size: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--bordure); color: var(--encre-2);
  white-space: nowrap;
}
.badge.vert { background: var(--vert-pale); border-color: #cfe0c2; color: var(--vert); }
.badge.rouge { background: var(--rouge-pale); border-color: #f0d0cd; color: var(--rouge); }
.badge.ambre { background: var(--ambre-pale); border-color: #f2ddbe; color: var(--ambre-fort); }
.badge.bleu { background: var(--bleu-pale); border-color: #cfdff0; color: var(--bleu); }
.badge.a { background: #2b241c; border-color: #2b241c; color: #f5c877; }

/* --------------------------------- Tables --------------------------------- */

.tableau-conteneur { overflow-x: auto; }
.tableau-conteneur.large > table { min-width: 1180px; }
.tableau-conteneur.large th:first-child,
.tableau-conteneur.large td:first-child { min-width: 240px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--encre-3); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--bordure); background: var(--surface-2);
  position: sticky; top: 0; white-space: nowrap;
}
thead th.triable { cursor: pointer; user-select: none; }
thead th.triable:hover { color: var(--encre); }
thead th .fleche { color: var(--ambre); }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.cliquable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.principale { font-weight: 600; }
.secondaire { font-size: 12px; color: var(--encre-3); }
.negatif { color: var(--rouge); }
.positif { color: var(--vert); }

.vide { padding: 44px 16px; text-align: center; color: var(--encre-3); }

/* --------------------------------- Filtres -------------------------------- */

.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--bordure); }
.filtres select, .filtres input[type=search] { width: auto; min-width: 130px; }
.pagination { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: 13px; color: var(--encre-2); }
.pagination .espace { flex: 1; }

/* ---------------------------------- Fiche --------------------------------- */

.fiche { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.fiche-entete { display: flex; gap: 14px; align-items: flex-start; padding: 16px; }
.fiche-entete .avatar {
  width: 46px; height: 46px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--ambre-pale); color: var(--ambre-fort); font-weight: 700; font-size: 17px;
}
.paires { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.paire .cle { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--encre-3); }
.paire .val { margin-top: 2px; white-space: pre-line; word-break: break-word; }
.paire .val:empty::after { content: "—"; color: var(--bordure-forte); }

/* Case a cocher seule, dans un cadre de la meme hauteur que les champs texte
   pour que la grille du formulaire reste alignee. */
/* Ce label n'est pas un intitule de champ mais l'enveloppe cliquable de la case :
   selecteur plus specifique que « .champ > label » pour ne pas heriter de sa taille. */
.champ > label.bascule {
  display: flex; align-items: center; cursor: pointer;
  padding: 7px 10px; border: 1px solid var(--bordure-forte); border-radius: 8px; background: var(--surface);
  font-size: 14px;
}
/* Cale invisible d'une ligne de texte : le cadre garde la hauteur d'un champ texte. */
.bascule::before { content: ""; display: block; width: 0; height: 1.5em; }
.bascule:hover { background: var(--surface-2); }
.bascule input { width: 18px; height: 18px; margin: 0; accent-color: var(--ambre); cursor: pointer; }

.formulaire { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.formulaire .pleine { grid-column: 1 / -1; }

.fil { list-style: none; margin: 0; padding: 0; }
.fil li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--bordure); }
.fil li:last-child { border-left-color: transparent; padding-bottom: 0; }
.fil li::before {
  content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--ambre);
}
.fil .entete-item { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fil .date { font-size: 12px; color: var(--encre-3); font-variant-numeric: tabular-nums; }
.fil .texte { margin-top: 3px; white-space: pre-line; color: var(--encre-2); }
.fil .actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.fil li:hover .actions, .fil li:focus-within .actions { opacity: 1; }
.fil .actions .btn { padding: 3px 8px; font-size: 12.5px; }
.fil form { padding-bottom: 4px; }

/* --------------------------------- Import --------------------------------- */

.depot {
  border: 2px dashed var(--bordure-forte); border-radius: var(--rayon);
  padding: 40px 20px; text-align: center; background: var(--surface-2); cursor: pointer;
}
.depot.survol { border-color: var(--ambre); background: var(--ambre-pale); }
.depot .icone { font-size: 30px; }
.depot p { margin: 8px 0 0; color: var(--encre-2); }

/* -------------------------------- Divers ---------------------------------- */

.message { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }
.message.erreur { background: var(--rouge-pale); border: 1px solid #f0d0cd; color: var(--rouge); }
.message.succes { background: var(--vert-pale); border: 1px solid #cfe0c2; color: var(--vert); }
.message.info { background: var(--bleu-pale); border: 1px solid #cfdff0; color: var(--bleu); }

.notif {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #221c16; color: #fff; padding: 10px 18px; border-radius: 22px;
  box-shadow: 0 8px 26px rgba(0,0,0,.25); z-index: 100; font-size: 13.5px;
}

.pile { display: flex; flex-direction: column; gap: 14px; }
.rang { display: flex; align-items: center; gap: 10px; }
.rang.fin { justify-content: flex-end; }

@media (max-width: 1080px) {
  .fiche { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .laterale { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; }
  .laterale footer, .marque span { display: none; }
  .nav { flex-direction: row; }
  .recherche { width: 180px; }
}

/* ---- Utilisateur connecte, au pied de la barre laterale ---- */
.utilisateur { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--bordure, #e3ddd3); }
.utilisateur .qui { display: flex; align-items: center; gap: 9px; }
.utilisateur img,
.utilisateur .pastille {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ambre, #c98a2e); color: #fff; font: 600 13px/1 system-ui, sans-serif;
}
.utilisateur img { object-fit: cover; }
/* min-width:0 : sans lui, une adresse longue elargit la barre laterale au lieu d'etre tronquee. */
.utilisateur .identite { min-width: 0; display: flex; flex-direction: column; }
.utilisateur .identite strong { font-size: 12.5px; }
.utilisateur .identite span  { font-size: 11px; color: #8a7d6c; }
.utilisateur .identite strong,
.utilisateur .identite span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deconnexion {
  display: block; margin-top: 9px; font-size: 11.5px; color: #8a7d6c;
  text-decoration: none; padding: 5px 0;
}
.deconnexion:hover { color: var(--texte, #2c2620); text-decoration: underline; }
.sans-connexion {
  font-size: 11px; line-height: 1.5; color: #8a2028;
  background: #fdf3f3; border-radius: 6px; padding: 8px 10px;
}

/* Doit rester APRES les styles de base du bloc utilisateur : a specificite egale,
   c'est la derniere regle du fichier qui gagne. Placee plus haut, elle ne s'appliquerait
   jamais, la barre laterale garderait sa hauteur et mangerait l'ecran d'un telephone. */
@media (max-width: 800px) {
  .utilisateur {
    margin: 0 0 0 auto; padding: 0 0 0 12px;
    border-top: 0; border-left: 1px solid var(--bordure, #e3ddd3);
    display: flex; align-items: center; gap: 10px; flex: none;
  }
  .utilisateur .identite { display: none; }
  .deconnexion { margin-top: 0; white-space: nowrap; }
}

/* ---- Onglets par réseau, écran « À relancer » ---- */
.onglets {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--bordure);
}
.onglets a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--encre-2);
  text-decoration: none; white-space: nowrap;
  border: 1px solid transparent;
}
.onglets a:hover { background: var(--surface-2); text-decoration: none; border-color: var(--bordure); }
.onglets a.actif { background: var(--ambre); border-color: var(--ambre); color: #fff; }
.onglets .compte {
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  padding: 1px 7px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--bordure); color: var(--encre-3);
}
/* Sur l'onglet actif, la pastille doit rester lisible sur fond ambre. */
.onglets a.actif .compte { background: rgba(0,0,0,.22); border-color: transparent; color: #fff; }

@media (max-width: 800px) {
  /* Les onglets défilent horizontalement plutôt que de casser la mise en page. */
  .onglets { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
