:root {
  --vert: #1f3b2d; --vert-clair: #2f6f4f; --fond: #f6f7f5; --carte: #fff; --bord: #dfe3dd;
  --texte: #1d221f; --doux: #66706a; --rouge: #b3261e; --orange: #b26a00; --bleu: #1d5fa8;
  --rayon: 10px; --ombre: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte); background: var(--fond); }
a { color: var(--vert-clair); }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 6rem; }
main.etroit { max-width: 460px; padding-top: 3rem; }

/* Barre du haut */
.barre { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .8rem; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top)); background: var(--vert); color: #fff; }
.marque { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; letter-spacing: .5px; }
.choix-societe select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: .3rem .5rem; max-width: 46vw; font-size: .95rem; }
.choix-societe option { color: #000; }
.societe-seule { opacity: .85; font-size: .95rem; }
.menu-large { display: none; gap: 1rem; margin-left: auto; }
.menu-large a { color: #fff; text-decoration: none; opacity: .9; }
.menu-large a:hover { opacity: 1; text-decoration: underline; }
.plus { margin-left: auto; position: relative; }
.plus summary { list-style: none; cursor: pointer; font-size: 1.4rem; padding: 0 .3rem; }
.plus summary::-webkit-details-marker { display: none; }
.tiroir { position: absolute; right: 0; top: 2.2rem; background: #fff; border-radius: var(--rayon); box-shadow: 0 8px 30px rgba(0,0,0,.2); min-width: 250px; padding: .4rem 0; }
.tiroir a, .tiroir .lien { display: block; padding: .65rem 1rem; color: var(--texte); text-decoration: none; text-align: left; width: 100%; }
.tiroir a:hover, .tiroir .lien:hover { background: var(--fond); }
.pastille { background: #e8a13a; color: #000; border-radius: 9px; padding: 0 .45rem; font-size: .8rem; font-weight: 700; }

/* Onglets du bas (téléphone) */
.onglets { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.onglets a { flex: 1; text-align: center; padding: .45rem 0 .5rem; font-size: .72rem; color: var(--doux); text-decoration: none; }
.onglets a span { display: block; font-size: 1.25rem; line-height: 1.3; }
.onglets a.actif { color: var(--vert-clair); font-weight: 600; }
.onglets a.nouveau span { background: var(--vert-clair); color: #fff; border-radius: 50%; width: 2.2rem; height: 2.2rem; line-height: 2.2rem; margin: -0.2rem auto 0; }

@media (min-width: 900px) {
  .menu-large { display: flex; }
  .plus { margin-left: 1rem; }
  .onglets { display: none; }
  main { padding-bottom: 2rem; }
}

/* Composants */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem; box-shadow: var(--ombre); margin-bottom: 1rem; }
.grille { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.chiffre { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .8rem 1rem; box-shadow: var(--ombre); }
.chiffre .etiquette { color: var(--doux); font-size: .85rem; }
.chiffre .valeur { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; white-space: nowrap; }
.chiffre.alerte .valeur { color: var(--rouge); }
.entete { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.entete h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.btn, button.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--bord); background: #fff; color: var(--texte); text-decoration: none; font: inherit; font-size: .95rem; cursor: pointer; min-height: 44px; }
.btn.principal { background: var(--vert-clair); border-color: var(--vert-clair); color: #fff; font-weight: 600; }
.btn.danger { color: var(--rouge); border-color: #e9c3c0; }
.btn.petit { padding: .3rem .6rem; min-height: 34px; font-size: .88rem; }
button.lien { background: none; border: 0; font: inherit; cursor: pointer; color: var(--texte); }

.messages { margin-bottom: 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: #e8f3ec; border: 1px solid #bfdcc9; }
.msg.error { background: #fbeceb; border-color: #efc4c0; color: #7d1a14; }
.msg.info { background: #eaf1fa; border-color: #c3d6ee; }
.msg.warning { background: #fdf4e3; border-color: #f0d9a8; }

/* Formulaires */
form p, .champ { margin: 0 0 .85rem; }
label { display: block; font-size: .88rem; color: var(--doux); margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel], input:not([type]), select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #cfd6cf; border-radius: 8px; font: inherit; font-size: 16px; background: #fff; color: var(--texte);
}
textarea { resize: vertical; }
input[type=checkbox] { width: 1.2rem; height: 1.2rem; vertical-align: middle; }
input[type=color] { width: 4rem; height: 2.4rem; padding: 0; border: 1px solid #cfd6cf; border-radius: 6px; }
.helptext, .aide { display: block; font-size: .8rem; color: var(--doux); margin-top: .2rem; }
.errorlist { color: var(--rouge); margin: .2rem 0; padding-left: 1rem; font-size: .88rem; }
.deux-col { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .deux-col { grid-template-columns: 1fr 1fr; } }
.recherche { display: flex; gap: .5rem; margin-bottom: .8rem; }
.recherche input { flex: 1; }

/* Listes */
.liste { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; }
.liste li { border-bottom: 1px solid var(--bord); }
.liste li:last-child { border-bottom: 0; }
.liste a.ligne { display: flex; justify-content: space-between; gap: .8rem; padding: .75rem 1rem; color: inherit; text-decoration: none; }
.liste a.ligne:hover { background: #fafbf9; }
.liste .principal { font-weight: 600; }
.liste .secondaire { color: var(--doux); font-size: .85rem; }
.liste .droite { text-align: right; white-space: nowrap; }
.vide { color: var(--doux); padding: 1rem; text-align: center; }

.statut { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 10px; background: #eceeea; color: #444; font-weight: 600; }
.statut.brouillon { background: #eceeea; }
.statut.emis, .statut.envoye { background: #e3edf8; color: var(--bleu); }
.statut.accepte, .statut.paye { background: #e2f2e7; color: #1e6b3a; }
.statut.partiel { background: #fdf0d9; color: var(--orange); }
.statut.refuse, .statut.annule, .statut.expire { background: #f6e1df; color: var(--rouge); }
.statut.retard { background: var(--rouge); color: #fff; }
.statut.facture { background: #ece4f6; color: #5b3a8c; }

table.tableau { width: 100%; border-collapse: collapse; background: #fff; font-size: .93rem; }
table.tableau th, table.tableau td { padding: .55rem .6rem; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; }
table.tableau th { background: #f1f3ef; font-weight: 600; font-size: .85rem; color: #444; }
.n { text-align: right !important; white-space: nowrap; }
.defile { overflow-x: auto; border: 1px solid var(--bord); border-radius: var(--rayon); }

/* Édition des lignes */
.lignes-edition { display: flex; flex-direction: column; gap: .6rem; }
.ligne-edition { background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: .7rem; position: relative; }
.ligne-edition.titre-section { background: #f4f6f2; }
.ligne-edition .rangee { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; }
.ligne-edition .rangee > div label { font-size: .75rem; }
.ligne-edition .desig { margin-bottom: .5rem; }
.ligne-edition .outils { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; font-size: .9rem; }
.ligne-edition .montant { font-weight: 700; }
.ligne-edition.supprimee { opacity: .4; }
@media (min-width: 900px) {
  .ligne-edition .rangee { grid-template-columns: 1.2fr .8fr .9fr 1fr .8fr .8fr; }
}
.totaux-live { position: sticky; bottom: 4.2rem; background: var(--vert); color: #fff; border-radius: var(--rayon); padding: .7rem 1rem; display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 5; }
@media (min-width: 900px) { .totaux-live { bottom: 1rem; } }
.barre-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Signature */
.zone-signature { border: 2px dashed #9aa79e; border-radius: var(--rayon); background: #fff; touch-action: none; width: 100%; height: 200px; display: block; }
.recap-public { background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem; }

.jauge { height: 10px; background: #e6e9e4; border-radius: 6px; overflow: hidden; margin: .3rem 0 .6rem; }
.jauge div { height: 100%; background: var(--vert-clair); }
.jauge div.chaud { background: var(--orange); }
.jauge div.rouge { background: var(--rouge); }
.onglets-reglages { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.onglets-reglages a { padding: .45rem .8rem; border-radius: 20px; background: #fff; border: 1px solid var(--bord); text-decoration: none; color: var(--texte); font-size: .9rem; }
.onglets-reglages a.actif { background: var(--vert-clair); color: #fff; border-color: var(--vert-clair); }
.apercu-cadre { width: 100%; height: 75vh; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; }
.qr svg { width: 220px; height: 220px; background: #fff; }
.code-secret { font-family: ui-monospace, monospace; word-break: break-all; background: #fff; padding: .4rem .6rem; border-radius: 6px; border: 1px solid var(--bord); }
.discret { color: var(--doux); font-size: .88rem; }
details.repli summary { cursor: pointer; color: var(--vert-clair); margin: .4rem 0; }
