/* Cembè Essentiel - habillage
   Couleurs franches et coordonnées : bleu roi + corail. */
:root {
  /* Charte Cembè : mauve #6C19FF, noir, gris mauve clair #F4F2FA */
  --bleu: #6C19FF;          /* couleur principale (mauve Cembè) */
  --bleu-fonce: #4A0FB8;
  --bleu-doux: #ECE3FF;
  --corail: #16131F;        /* boutons d'action (noir Cembè) */
  --corail-fonce: #16131F;
  --corail-doux: #FFF0DB;   /* fond "reste à recevoir" */
  --vert: #0E9F6E;
  --vert-doux: #DDF5EC;
  --ambre: #D97706;
  --ambre-doux: #FDF0DC;
  --rouge: #D12F2F;
  --rouge-doux: #FBE3E3;
  --texte: #16131F;
  --texte-2: #575270;
  --fond: #F4F2FA;
  --carte: #FFFFFF;
  --trait: #DCD6EC;
  --rayon: 14px;
  --ombre: 0 2px 10px rgba(22, 19, 31, .08);
  --police: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--police);
  font-size: 16px;
  color: var(--texte);
  background: var(--fond);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--bleu); }

/* ---------- Structure ---------- */
.entete {
  position: sticky; top: 0; z-index: 20;
  background: var(--bleu);
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(108, 25, 255, .35);
}
.entete .logo-app { width: 34px; height: 34px; border-radius: 9px; display: block; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.entete h1 { font-size: 18px; margin: 0; font-weight: 700; flex: 1; }
.entete .retour {
  background: rgba(255,255,255,.15); border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; font-size: 20px; cursor: pointer;
}

.mise-en-page { display: flex; min-height: calc(100vh - 58px); }
.menu-lateral { display: none; }
main {
  flex: 1;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.nav-bas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--carte);
  border-top: 1px solid var(--trait);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-bas a, .menu-lateral a {
  text-decoration: none; color: var(--texte-2);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 10px; min-width: 60px;
}
.nav-bas a .ico, .menu-lateral a .ico { font-size: 20px; line-height: 1; }
.nav-bas a.actif, .menu-lateral a.actif { color: var(--bleu); background: var(--bleu-doux); }

@media (min-width: 900px) {
  .nav-bas { display: none; }
  .menu-lateral {
    display: flex; flex-direction: column; gap: 4px;
    width: 220px; padding: 16px 12px;
    background: var(--carte); border-right: 1px solid var(--trait);
    position: sticky; top: 58px; height: calc(100vh - 58px);
  }
  .menu-lateral a { flex-direction: row; font-size: 15px; padding: 10px 12px; gap: 10px; }
  main { padding-bottom: 32px; }
}

/* ---------- Éléments ---------- */
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.sous-titre { color: var(--texte-2); font-size: 14px; margin: -6px 0 14px; }

.carte {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px;
  margin-bottom: 14px;
}
.carte.bleue { background: var(--bleu); color: #fff; }
.carte.corail { background: var(--corail); color: #fff; }

.grille-chiffres { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 600px) { .grille-chiffres { grid-template-columns: repeat(4, 1fr); } }
.chiffre {
  border-radius: 12px; padding: 12px;
  background: var(--bleu-doux);
}
.carte.bleue .chiffre { color: var(--texte); }
.chiffre .lib { font-size: 13px; color: var(--texte-2); font-weight: 600; }
.chiffre .val { font-size: 19px; font-weight: 800; margin-top: 4px; word-break: break-word; color: var(--bleu-fonce); }
.chiffre.bleu  { background: var(--bleu); color: #fff; }
.chiffre.bleu .lib { color: #E6DAFF; }
.chiffre.vert  { background: var(--vert-doux); }
.chiffre.vert .val { color: #086B4A; }
.chiffre.corail { background: var(--corail-doux); }
.chiffre.corail .val { color: #B45309; }
.chiffre.ambre { background: var(--ambre-doux); }
.chiffre.ambre .val { color: #9A5300; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 16px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--bleu); color: #fff; text-decoration: none;
  min-height: 46px;
}
.btn:active { transform: translateY(1px); }
.btn.corail { background: var(--corail); }
.btn.vert { background: var(--vert); }
.btn.clair { background: var(--bleu-doux); color: var(--bleu-fonce); }
.btn.danger { background: var(--rouge); }
.btn.contour { background: transparent; color: var(--bleu); box-shadow: inset 0 0 0 2px var(--bleu); }
.btn.plein { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.rangee-btn { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.rangee-btn .btn { flex: 1 1 auto; }

.actions-rapides { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.actions-rapides a {
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre);
  text-decoration: none; color: var(--texte); text-align: center;
  padding: 14px 6px; font-weight: 700; font-size: 13px;
}
.actions-rapides a .ico {
  display: grid; place-items: center; margin: 0 auto 6px;
  width: 40px; height: 40px; border-radius: 12px; font-size: 20px;
  background: var(--bleu); color: #fff;
}
.actions-rapides a:nth-child(2) .ico { background: var(--corail); }
.actions-rapides a:nth-child(3) .ico { background: var(--vert); }

.bandeau-cembe {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--bleu) 0%, var(--bleu-fonce) 100%);
  color: #fff; text-decoration: none;
  border-radius: var(--rayon); padding: 16px; margin: 6px 0 14px;
  box-shadow: var(--ombre);
}
.bandeau-cembe .pastille {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--corail); display: grid; place-items: center; font-size: 22px;
}
.bandeau-cembe strong { display: block; font-size: 16px; }
.bandeau-cembe span { font-size: 13px; color: #E6DAFF; }

/* Formulaires */
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  border: 2px solid var(--trait); border-radius: 12px;
  padding: 11px 12px; background: #fff; font-size: 16px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--bleu); }
textarea { min-height: 80px; resize: vertical; }
.aide { font-size: 13px; color: var(--texte-2); margin-top: 4px; }
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.onglets { display: flex; gap: 6px; background: var(--bleu-doux); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.onglets button, .onglets a {
  flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px;
  font-weight: 700; color: var(--bleu-fonce); cursor: pointer; text-align: center; text-decoration: none; font-size: 15px;
}
.onglets .actif { background: var(--carte); color: var(--bleu); box-shadow: var(--ombre); }

.filtres { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.filtres button {
  flex: none; border: 2px solid var(--trait); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--texte-2);
}
.filtres button.actif { border-color: var(--bleu); background: var(--bleu); color: #fff; }

/* Listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--trait);
}
.liste li:last-child { border-bottom: 0; }
.liste a.ligne { display: flex; align-items: center; gap: 12px; width: 100%; text-decoration: none; color: inherit; }
.liste .principal { flex: 1; min-width: 0; }
.liste .titre { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .detail { font-size: 13px; color: var(--texte-2); }
.liste .montant { font-weight: 800; white-space: nowrap; text-align: right; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--bleu-doux); color: var(--bleu-fonce);
  display: grid; place-items: center; font-weight: 800;
}

.etiquette {
  display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 9px; margin-top: 3px;
}
.etiquette.payee { background: var(--vert-doux); color: #086B4A; }
.etiquette.partielle { background: var(--ambre-doux); color: #9A5300; }
.etiquette.attente { background: var(--ambre-doux); color: #9A5300; }
.etiquette.annulee { background: #E7E9EF; color: #59607A; }
.etiquette.retard { background: var(--rouge-doux); color: var(--rouge); }
.etiquette.bleue { background: var(--bleu-doux); color: var(--bleu-fonce); }

.case-tache {
  flex: none; width: 28px; height: 28px; border-radius: 9px;
  border: 2px solid var(--bleu); background: #fff; cursor: pointer;
  display: grid; place-items: center; color: #fff; font-weight: 900;
}
.case-tache.faite { background: var(--vert); border-color: var(--vert); }
.tache-faite .titre { text-decoration: line-through; color: var(--texte-2); }
.vide { text-align: center; color: var(--texte-2); padding: 18px 8px; }
.vide .ico { font-size: 34px; display: block; margin-bottom: 6px; }

/* Lignes de document */
.ligne-doc {
  border: 2px solid var(--trait); border-radius: 12px; padding: 10px; margin-bottom: 10px; position: relative;
}
.ligne-doc .trois-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; }
.ligne-doc label { margin-top: 6px; font-size: 13px; }
.ligne-doc .suppr {
  position: absolute; top: 6px; right: 6px; border: 0; background: var(--rouge-doux); color: var(--rouge);
  width: 30px; height: 30px; border-radius: 9px; font-weight: 800; cursor: pointer;
}
.ligne-doc .sous-total { font-weight: 800; padding: 11px 0; text-align: right; }
.total-form {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bleu); color: #fff; border-radius: 12px; padding: 14px 16px; font-weight: 800; font-size: 18px; margin-top: 12px;
}

/* Document à imprimer */
.papier {
  background: #fff; border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 22px; margin-bottom: 14px; color: #111;
}
.papier .haut { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.papier .ent { display: flex; gap: 12px; align-items: flex-start; }
.papier .ent img { max-width: 110px; max-height: 80px; object-fit: contain; }
.papier .ent strong { font-size: 17px; display: block; }
.papier .ent div { font-size: 13px; color: #333; }
.papier .titre-doc { text-align: right; }
.papier .titre-doc .type { font-size: 24px; font-weight: 900; color: var(--bleu); letter-spacing: .5px; }
.papier .titre-doc div { font-size: 13px; }
.papier .client { margin: 18px 0; padding: 12px; border-left: 4px solid var(--corail); background: #F7F8FC; border-radius: 6px; font-size: 14px; }
.papier table { width: 100%; border-collapse: collapse; font-size: 14px; }
.papier th { background: var(--bleu); color: #fff; text-align: left; padding: 8px; font-size: 13px; }
.papier td { padding: 8px; border-bottom: 1px solid #E3E6EE; vertical-align: top; }
.papier .num { text-align: right; white-space: nowrap; }
.papier .totaux { margin-left: auto; margin-top: 12px; width: min(100%, 320px); font-size: 14px; }
.papier .totaux div { display: flex; justify-content: space-between; padding: 5px 0; }
.papier .totaux .grand { font-size: 17px; font-weight: 900; border-top: 2px solid var(--bleu); padding-top: 8px; color: var(--bleu-fonce); }
.papier .lettres { font-size: 13px; margin-top: 14px; font-style: italic; }
.papier .notes { font-size: 13px; margin-top: 12px; white-space: pre-wrap; }
.papier .pied { margin-top: 22px; padding-top: 10px; border-top: 1px solid #E3E6EE; font-size: 12px; color: #555; text-align: center; white-space: pre-wrap; }
.papier .tampon-annule { color: var(--rouge); font-weight: 900; font-size: 20px; border: 3px solid var(--rouge); display: inline-block; padding: 4px 12px; border-radius: 8px; transform: rotate(-4deg); margin-top: 8px; }

@media (max-width: 599px) {
  .papier { padding: 16px; }
  .papier .titre-doc { text-align: left; width: 100%; }
  .papier table { font-size: 13px; }
  .papier th, .papier td { padding: 6px 4px; }
}

/* Connexion */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; background: var(--bleu); }
.boite-connexion { width: 100%; max-width: 420px; }
.boite-connexion .marque { text-align: center; color: #fff; margin-bottom: 18px; }
.boite-connexion .marque .logo-app { margin: 0 auto 10px; width: 76px; height: 76px; border-radius: 18px; display: block; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.boite-connexion .marque h1 { margin: 0; font-size: 26px; }
.boite-connexion .marque p { margin: 6px 0 0; color: #E6DAFF; }
.lien-bouton { background: none; border: 0; color: var(--bleu); font-weight: 700; cursor: pointer; padding: 8px 0; text-decoration: underline; }

/* Retours : chargement, messages */
#voile {
  position: fixed; inset: 0; z-index: 100; background: rgba(20, 32, 56, .45);
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: #fff; font-weight: 700; text-align: center; padding: 20px;
}
#voile.visible { display: flex; }
.roue { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
#voile .lent { font-weight: 500; font-size: 14px; display: none; }

#messages { position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 110; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 900px) { #messages { bottom: 24px; } }
.message {
  pointer-events: auto; max-width: 460px; width: 100%;
  border-radius: 12px; padding: 12px 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(20,32,56,.2);
  animation: monte .25s ease-out;
}
.message.ok { background: var(--vert); color: #fff; }
.message.erreur { background: #fff; color: var(--rouge); border-left: 6px solid var(--rouge); }
@keyframes monte { from { transform: translateY(12px); opacity: 0; } }

#hors-ligne {
  display: none; position: sticky; top: 58px; z-index: 15;
  background: var(--ambre); color: #fff; text-align: center; font-weight: 700; padding: 8px; font-size: 14px;
}
#hors-ligne.visible { display: block; }

.dialogue-fond { position: fixed; inset: 0; z-index: 120; background: rgba(20,32,56,.5); display: grid; place-items: center; padding: 16px; }
.dialogue { background: #fff; border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); max-height: 90vh; overflow: auto; }
.dialogue h3 { font-size: 18px; }

.mois-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mois-nav button { border: 0; background: rgba(255,255,255,.18); color: #fff; width: 36px; height: 36px; border-radius: 10px; font-size: 18px; cursor: pointer; }
.mois-nav strong { font-size: 17px; text-transform: capitalize; }

.cache { display: none !important; }

/* Impression : seul le document sort */
@media print {
  body { background: #fff; }
  .entete, .nav-bas, .menu-lateral, .ne-pas-imprimer, #messages, #hors-ligne { display: none !important; }
  main { padding: 0; max-width: none; }
  .papier { box-shadow: none; border-radius: 0; padding: 0; }
  .papier th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
