:root {
  --teal: #1A5D68;
  --gold: #9F790B;
  --navy: #0F2B4C;
  --cream: #FDFBF7;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Inter", system-ui, sans-serif;
  background: var(--cream);
  color: var(--navy);
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  background: var(--teal);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
header h1 { font-size: 1.15rem; margin: 0; }
main { padding: 16px; max-width: 560px; margin: 0 auto; display: grid; gap: 18px; }
h2 { font-size: 1rem; margin: 0 0 8px; }
section { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
label { display: block; margin: 10px 0; font-size: .9rem; }
input, select {
  width: 100%; padding: 12px; margin-top: 4px;
  border: 1px solid #ccc; border-radius: 10px; font-size: 1rem; background: #fff;
}
button.primary {
  width: 100%; padding: 14px; margin-top: 10px;
  background: var(--teal); color: #fff; border: none; border-radius: 12px;
  font-size: 1.05rem; font-weight: 600;
}
button.primary:disabled { opacity: .45; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: #eee; }
.badge.ok { background: #d6f0d6; color: #1c6b1c; }
.badge.ko { background: #fbe0e0; color: #9b1c1c; }
.badge.sug { background: #fff0cc; color: #9F790B; }
.temoin { font-size: .85rem; color: #666; min-height: 1em; margin: 6px 0 0; }
.info { font-size: .85rem; color: #555; }
.alerte { background: #fff4d6; border: 1px solid var(--gold); color: var(--gold);
  padding: 10px; border-radius: 10px; font-size: .9rem; }
.en-attente ul { list-style: none; padding: 0; margin: 0; }
.en-attente li { padding: 8px 0; border-bottom: 1px solid #eee; font-size: .9rem; }

/* Navigation par onglets */
nav.tabs { display: flex; gap: 2px; background: #0d4a54; }
nav.tabs a { flex: 1; text-align: center; padding: 12px 6px; color: #cfe6ea;
  text-decoration: none; font-size: .92rem; font-weight: 600; }
nav.tabs a.actif { background: var(--cream); color: var(--teal); border-radius: 10px 10px 0 0; }

/* Écran À qualifier */
.carte .tete { margin-bottom: 10px; }
.carte .meta { font-size: .82rem; color: #666; margin-top: 3px; }
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ligne-check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; }
.ligne-check input[type=text] { flex: 1; min-width: 120px; }
.actions { display: flex; gap: 10px; }
.actions .primary { margin-top: 12px; }
.actions .f-ecrire { background: var(--gold); }
button.secondaire { padding: 14px; margin-top: 12px; background: #fff; color: var(--teal);
  border: 1px solid var(--teal); border-radius: 12px; font-weight: 600; }
button.secondaire:disabled { opacity: .5; }
.ia-retour { margin: 6px 0 0; }
.lien { color: var(--teal); font-weight: 600; }
.retour { margin: 8px 0 0; font-size: .9rem; }
.ok-txt { color: #1c6b1c; } .err-txt { color: #9b1c1c; }

/* Table documents */
#tbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
#tbl th, #tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; }
#tbl th { color: var(--teal); }

/* Bilan / synthèse */
#synth { width: 100%; border-collapse: collapse; }
#synth td { padding: 8px 4px; border-bottom: 1px solid #eee; }
#synth tr.total td { border-top: 2px solid var(--teal); font-size: 1.05rem; padding-top: 10px; }
#synth tr .sep, #synth td.sep { color: var(--gold); font-size: .8rem; text-transform: uppercase;
  border: none; padding-top: 12px; }
.en-attente ul, #liste-ecrire, #liste-audit { list-style: none; padding: 0; margin: 8px 0; }
#liste-ecrire li, #liste-audit li { padding: 6px 0; border-bottom: 1px solid #eee; font-size: .85rem; }
#annee { width: auto; display: inline-block; margin-left: 8px; padding: 6px 10px; }

/* Boutons-liens (export comptable) */
.bouton-lien { display: block; text-align: center; padding: 14px; margin: 8px 0 18px;
  background: var(--teal); color: #fff; border-radius: 12px; text-decoration: none; font-weight: 600; }
main h3 { font-size: .95rem; margin: 16px 0 4px; color: var(--navy); }

/* Vue grille pleine largeur (desktop) */
body.large main { max-width: 1550px; }
.grille-filtres { display: flex; gap: 16px; flex-wrap: wrap; align-items: end;
  background: #fff; padding: 14px 18px; border-radius: 14px; margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.grille-filtres label { margin: 0; font-size: .72rem; color: #888; text-transform: uppercase; letter-spacing: .04em; }
.grille-filtres select, .grille-filtres input { width: auto; min-width: 140px; margin-top: 4px; }
.grille-wrap { overflow: auto; max-height: 78vh; background: #fff; border-radius: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08); }
table.tableur { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
table.tableur th { position: sticky; top: 0; z-index: 1; background: var(--teal); color: #fff;
  padding: 10px; text-align: left; cursor: pointer; white-space: nowrap; user-select: none;
  font-weight: 600; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
table.tableur th:hover { background: #15505a; }
table.tableur td { padding: 8px 10px; border-bottom: 1px solid #ece8df; white-space: nowrap; vertical-align: middle; }
table.tableur tbody tr:nth-child(even) { background: #faf8f3; }
table.tableur tbody tr:hover { background: #eaf4f5; }
table.tableur .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tableur td.montant { font-weight: 600; }
table.tableur td.credit { color: #1c6b1c; }
table.tableur td.debit { color: #9b3a2f; }
table.tableur .col-libelle { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.tableur .puce { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem;
  background: #eee; color: #444; }
table.tableur .puce.recette { background: #d8f0d8; color: #1c6b1c; }
table.tableur .puce.depense { background: #fbe6df; color: #9b3a2f; }
table.tableur .puce.investissement { background: #e4e9f5; color: #2a4a8a; }
table.tableur .puce.neutre { background: #eee; color: #555; }
table.tableur .puce.deduc { background: #d8f0d8; color: #1c6b1c; }
table.tableur .puce.partiel { background: #fff0cc; color: #9F790B; }
table.tableur .puce.nondeduc { background: #fbe0e0; color: #9b1c1c; }
table.tableur tr.anomalie { background: #fff0f0; }
table.tableur td.cle-vide { color: #9F790B; font-style: italic; }
table.tableur td.col-cle { white-space: nowrap; min-width: 220px; }
.rep-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rep-edit > span { display: inline-flex; align-items: center; gap: 3px; font-size: .82rem; }
.rep-edit input { width: 52px; padding: 3px 5px; border: 1px solid var(--teal); border-radius: 4px;
  font-variant-numeric: tabular-nums; }
.rep-somme { font-size: .78rem; font-weight: 600; margin-left: 4px; }
.rep-ok { padding: 3px 10px; background: var(--teal); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: 700; }
.rep-cancel { padding: 3px 10px; background: #fff; color: #9b1c1c; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }

/* Formulaire à 2 colonnes pour la page Paramètres */
.formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.formulaire label { margin: 4px 0; font-size: .9rem; }
.formulaire label span { font-size: .75rem; color: #777; display: block; margin-bottom: 2px; }
button.cle-del { background: #fff; border: 1px solid #ddd; color: #9b1c1c; border-radius: 4px;
  padding: 2px 8px; cursor: pointer; font-weight: 700; }

/* Bilan détaillé : un bloc par activité */
.bloc-activite { margin: 18px 0; background: #fff; border: 1px solid #ece8df; border-radius: 12px; padding: 12px 16px; }
.bloc-activite h3 { margin: 0 0 10px; color: var(--teal); font-size: 1rem; }
.bloc-activite table { width: 100%; }
.bloc-activite tr.grp td { background: var(--teal); color: #fff; font-weight: 700; font-size: .78rem;
  letter-spacing: .04em; padding: 6px 12px; }
.bloc-activite tr.sub-total td { background: #f5efde; font-weight: 600; border-top: 1px solid #ddd; }
.bloc-activite tr.total td { background: var(--cream); border-top: 2px solid var(--teal);
  font-weight: 700; font-size: 1.02rem; padding: 10px 12px; }
.bloc-activite.consolide { border: 2px solid var(--teal); background: #faf8f3; }
.bloc-activite.consolide h3 { font-size: 1.1rem; }

/* Scanner ultra-minimal : un grand bouton plein écran */
.scan-zone { padding: 24px 8px 8px; }
.scan-bouton { display: block; width: 100%; padding: 36px 16px; background: var(--teal); color: #fff;
  border: none; border-radius: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.1);
  font-family: inherit; cursor: pointer; transition: transform .1s; }
.scan-bouton:active { transform: scale(0.98); }
.scan-bouton:disabled { opacity: .5; }
.scan-icone { font-size: 3.5rem; line-height: 1; }
.scan-titre { font-size: 1.3rem; font-weight: 700; margin-top: 10px; }
.scan-sous { font-size: .85rem; opacity: .85; margin-top: 4px; }
.scan-note { display: block; margin: 18px 0 4px; }
.scan-note span { font-size: .78rem; color: #888; display: block; margin-bottom: 4px; }
.scan-note input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 10px; font-size: 1rem; }
/* Zone de dépôt en lot (glisser-déposer) */
.drop-zone { border: 2px dashed var(--teal); border-radius: 14px; padding: 22px 16px;
  text-align: center; cursor: pointer; background: #fff; transition: background .12s, border-color .12s; }
.drop-zone.survol { background: #eef6f7; border-color: var(--gold); }
.drop-icone { font-size: 2.2rem; line-height: 1; }
.drop-titre { font-weight: 700; margin-top: 6px; color: var(--teal); }
.drop-sous { font-size: .8rem; color: #888; margin-top: 3px; }
.lot-resultats { list-style: none; padding: 0; margin: 12px 0 0; }
.lot-ligne { font-size: .85rem; padding: 6px 8px; border-radius: 8px; margin-top: 4px; }
.lot-ligne .lot-nom { color: #555; }
.lot-ligne.en-cours { color: #888; }
.lot-ligne.statut-importe { background: #e9f5ec; }
.lot-ligne.statut-doublon { background: #fff4d6; }
.lot-ligne.statut-refuse  { background: #fff4d6; color: var(--gold); }
.lot-ligne.statut-erreur  { background: #fde8e8; color: #b00020; }

.file-attente #att-bandeau { display: flex; justify-content: space-between; align-items: center;
  font-size: .95rem; padding-bottom: 8px; border-bottom: 1px solid #eee; margin-bottom: 6px; }
table.tableur tr.anomalie:hover { background: #ffe6e6; }
table.tableur tfoot td { position: sticky; bottom: 0; background: #f0ece2;
  border-top: 2px solid var(--teal); font-weight: 600; }
table.tableur td[data-edit-k] { cursor: pointer; }
table.tableur td[data-edit-k]:hover { outline: 1px dashed var(--teal); outline-offset: -2px; }
.edit-input { width: 100%; padding: 4px 6px; font-size: .88rem;
  border: 1px solid var(--teal); border-radius: 4px; box-sizing: border-box; }
