:root {
  --fond: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --texte: #1c2127;
  --discret: #66707a;
  --bord: #e4e2dc;
  --accent: #1d5a85;
  --accent-doux: #e6eff6;
  --barre: #17222e;
  --barre-texte: #c5cfd8;
  --barre-actif: #263445;
  --ok: #1b7444;
  --ok-fond: #e3f3e8;
  --partiel: #94600a;
  --partiel-fond: #fbefd8;
  --ouvert: #b0291f;
  --ouvert-fond: #fae6e3;
  --neutre-fond: #eef0f3;
  --ombre: 0 1px 2px rgba(20, 30, 40, .05), 0 1px 1px rgba(20, 30, 40, .03);
  --rayon: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121519;
    --surface: #1b1f24;
    --surface-2: #20252b;
    --texte: #e7e9ec;
    --discret: #98a1aa;
    --bord: #2f353c;
    --accent: #7fb6e0;
    --accent-doux: #1e2c3a;
    --barre: #0d1116;
    --barre-texte: #a9b4bf;
    --barre-actif: #1d2733;
    --ok: #7dcf9e;
    --ok-fond: #193022;
    --partiel: #eebd6c;
    --partiel-fond: #382c16;
    --ouvert: #f0a097;
    --ouvert-fond: #3b1e1b;
    --neutre-fond: #252a31;
    --ombre: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Structure : menu à gauche, contenu à droite --- */
.appli { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.barre {
  background: var(--barre);
  color: var(--barre-texte);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.marque { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 0 8px 22px; }
.marque .logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, #2f78ad, #1d5a85); font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.marque span:last-child { font-weight: 650; line-height: 1.2; }
.marque small { display: block; font-weight: 400; font-size: 12px; color: var(--barre-texte); }
.barre nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.groupe-menu {
  margin: 14px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: #6f7d8b;
}
.barre nav a, .deconnexion button {
  display: flex; align-items: center; gap: 11px;
  color: var(--barre-texte); text-decoration: none;
  padding: 9px 10px; border-radius: 8px; font-size: 14px;
}
.barre nav a:hover, .deconnexion button:hover { background: var(--barre-actif); color: #fff; }
.barre nav a.actif { background: var(--barre-actif); color: #fff; box-shadow: inset 3px 0 0 #4b97cf; }
.barre svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.barre .badge { margin-left: auto; background: #c2493e; color: #fff; }
.deconnexion button { width: 100%; background: none; border: none; cursor: pointer; font: inherit; font-size: 14px; }

main { padding: 28px 36px 56px; max-width: 1240px; width: 100%; }

.nav-mobile { display: none; }
@media (max-width: 860px) {
  .appli { grid-template-columns: minmax(0, 1fr); }
  /* Le menu latéral devient un panneau plein écran, ouvert par « Menu ». */
  .barre { display: none; }
  body.menu-ouvert .barre {
    display: flex; position: fixed; inset: 0 0 calc(76px + env(safe-area-inset-bottom)) 0; height: auto; z-index: 20;
    overflow-y: auto; padding: 20px 16px;
  }
  main { padding: 18px 16px calc(110px + env(safe-area-inset-bottom)); }
  .nav-mobile {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    min-height: 64px; z-index: 30; background: var(--barre);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  }
  .nav-mobile a, .nav-mobile button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--barre-texte); text-decoration: none; font: inherit; font-size: 11px;
    background: none; border: 0; border-radius: 0; padding: 0; position: relative;
  }
  .nav-mobile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .nav-mobile .actif, .nav-mobile [aria-expanded="true"] { color: #fff; }
  .nav-mobile .ticket svg { background: var(--accent); color: #fff; border-radius: 50%; padding: 6px; width: 34px; height: 34px; }
  .nav-mobile .badge { position: absolute; top: 6px; left: 52%; font-size: 10px; padding: 0 5px; }
  .entete-page { gap: 8px 14px; }
  .tableau-conteneur table { font-size: 14px; }
  th, td { padding: 9px 10px; }
}

/* --- Éléments communs --- */
.badge { border-radius: 10px; padding: 1px 7px; font-size: 12px; font-weight: 650; background: var(--ouvert-fond); color: var(--ouvert); }
.entete-page { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.entete-page h2 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.entete-page a { color: var(--accent); text-decoration: none; font-size: 14px; }
h3 { font-size: 15px; font-weight: 650; margin: 6px 0 12px; }
a { color: var(--accent); }

.resume { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 14px 18px; box-shadow: var(--ombre);
}
.carte .valeur { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.carte .etiquette { color: var(--discret); font-size: 13px; }

.tableau-conteneur {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--rayon); box-shadow: var(--ombre);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--bord); vertical-align: top; }
thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--discret);
  font-weight: 650; background: var(--surface-2);
}
tbody tr:hover > td { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.discret { color: var(--discret); font-size: 13px; }
td a, .entete-page h2 a { color: inherit; text-decoration: none; }
td a:hover { color: var(--accent); text-decoration: underline; }

.statut { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--neutre-fond); color: var(--discret); }
.statut.soldee { background: var(--ok-fond); color: var(--ok); }
.statut.partielle { background: var(--partiel-fond); color: var(--partiel); }
.statut.ouverte { background: var(--ouvert-fond); color: var(--ouvert); }
.etiquette-mini { background: var(--neutre-fond); color: var(--discret); border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-left: 6px; }
.positif { color: var(--ok); }
.negatif { color: var(--ouvert); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
button {
  font: inherit; font-size: 13px; border-radius: 7px; padding: 6px 12px;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover { background: var(--surface-2); border-color: var(--discret); }
button.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.principal:hover { filter: brightness(1.08); }
.resultat { font-size: 13px; color: var(--ok); }
.resultat.erreur { color: var(--ouvert); }
p.resultat { padding: 9px 12px; border-radius: 8px; background: var(--ok-fond); }
p.resultat.erreur { background: var(--ouvert-fond); }

.proposition { margin-top: 2px; }
.proposition ul { margin: 4px 0 0; padding-left: 18px; }
.filtres { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filtres a { color: var(--discret); text-decoration: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--bord); }
.filtres a.actif { background: var(--accent-doux); color: var(--accent); border-color: transparent; }
.vide { padding: 36px; text-align: center; color: var(--discret); }

/* --- Fiche bail et formulaires --- */
.grille-fiche { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; margin-bottom: 22px; }
.grille-fiche .carte table th, .grille-fiche .carte table td { padding: 7px 8px; }
dl.infos { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
dl.infos dt { color: var(--discret); font-size: 13px; }
dl.infos dd { margin: 0; }
.formulaire { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; max-width: 540px; }
.formulaire label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; font-size: 13px; color: var(--discret); }
.formulaire label.case { display: flex; gap: 8px; align-items: center; color: var(--texte); }
input, select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--bord); border-radius: 7px;
  background: var(--surface); color: var(--texte);
}
input:focus, select:focus { outline: 2px solid var(--accent-doux); border-color: var(--accent); }
.formulaire h3 { margin-top: 12px; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
tr.sous-ligne > td { padding-top: 0; background: var(--surface-2); }
tr.sous-ligne table td { border-bottom: none; padding: 4px 8px; font-size: 13px; }
tr.depliable, tr.lien-ligne { cursor: pointer; }
tr.depliable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chevron { display: inline-block; width: 14px; color: var(--discret); transition: transform .15s; }
tr.depliable[aria-expanded="true"] .chevron { transform: rotate(90deg); }
tr.depliable[aria-expanded="true"] > td { background: var(--surface-2); border-bottom-color: transparent; }

/* Boutons de décision : grille régulière de deux colonnes, largeurs égales. */
.decision { display: grid; grid-template-columns: repeat(2, minmax(88px, 1fr)); gap: 6px; min-width: 190px; }
.decision > button, .decision > a.bouton { width: 100%; text-align: center; }
.decision > .resultat { grid-column: 1 / -1; }
a.bouton, label.bouton {
  display: inline-block; font-size: 13px; border-radius: 7px; padding: 6px 12px;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); text-decoration: none;
}
a.bouton:hover, label.bouton:hover { background: var(--surface-2); border-color: var(--discret); }
tr.efface > td { opacity: 0; transition: opacity .3s; }

/* --- Fiche bail : frise des 12 derniers mois et mois non soldés --- */
.frise-carte { margin-bottom: 16px; }
.frise { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.pastille {
  display: grid; place-items: center; padding: 6px 0 4px; border-radius: 8px; text-decoration: none;
  background: var(--neutre-fond); color: var(--discret); font-weight: 650; line-height: 1.1;
}
.pastille small { font-weight: 400; font-size: 10.5px; opacity: .8; }
.pastille.soldee { background: var(--ok-fond); color: var(--ok); }
.pastille.partielle { background: var(--partiel-fond); color: var(--partiel); }
.pastille.ouverte { background: var(--ouvert-fond); color: var(--ouvert); }
.pastille.apl { background: var(--accent-doux); color: var(--accent); }
.pastille:hover { outline: 2px solid currentColor; outline-offset: -2px; }
.impayes { margin: 12px 0 0; font-size: 14px; }
.impayes a.du { color: var(--ouvert); font-weight: 600; }
.impayes a.apl { color: var(--accent); }
tr.eclaire > td { animation: eclaire 1.6s ease-out; }
@keyframes eclaire { from { background: var(--partiel-fond); } to { background: transparent; } }
@media (max-width: 600px) { .frise { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* --- Ventilation --- */
input.invalide { border-color: var(--ouvert); outline: 2px solid var(--ouvert-fond); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
tr.depliable > td:first-child { white-space: nowrap; }
.legende { margin: 10px 0 0; font-size: 12.5px; color: var(--discret); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.legende .pastille { display: inline-block; width: 12px; height: 12px; padding: 0; border-radius: 3px; margin-left: 6px; }
.legende .pastille:first-child { margin-left: 0; }
/* Lignes cliquables : surbrillance au survol, pour signaler l'action. */
tbody tr.lien-ligne:hover > td, tbody tr.depliable:hover > td { background: var(--accent-doux); }
tr.sous-ligne tr.lien-ligne:hover > td { background: var(--accent-doux); color: var(--accent); }
tr.sous-ligne tr.lien-ligne:hover .discret { color: var(--accent); }

/* Message affiché après une action qui a rechargé la page. */
#avis {
  position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: 420px;
  background: var(--ok-fond); color: var(--ok); border: 1px solid var(--ok);
  padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); font-size: 14px;
}

/* --- Dépenses --- */
.histogramme { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 140px; }
.barre-mois { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.barre-mois .remplissage { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.barre-mois small { color: var(--discret); font-size: 11px; margin-top: 4px; }
select.a-classer { border-color: var(--partiel); background: var(--partiel-fond); }

/* --- Tickets : saisie depuis le téléphone --- */
.ticket-envoi { display: grid; gap: 12px; max-width: 520px; }
.gros-bouton {
  display: block; text-align: center; padding: 16px; font-size: 17px; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--bord); background: var(--surface); cursor: pointer;
}
.gros-bouton.principal, button.gros-bouton.principal { background: var(--accent); color: #fff; border-color: var(--accent); }
.gros-bouton.occupe { opacity: .5; pointer-events: none; }
.ticket-validation { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.apercu-ticket img { width: 100%; height: auto; border-radius: 6px; }
.apercu-ticket iframe { width: 100%; height: 70vh; border: 0; }
.ticket-formulaire { max-width: none; margin-top: 0; }
.montant-saisi { font-size: 22px; font-weight: 650; }
.puces { gap: 6px; }
.qui-a-paye { border: 0; padding: 0; margin: 4px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qui-a-paye legend { font-size: 13px; color: var(--discret); margin-bottom: 6px; }
.gros-choix input { position: absolute; opacity: 0; }
.gros-choix span {
  display: block; text-align: center; padding: 14px 8px; border: 1px solid var(--bord); border-radius: 10px;
  font-weight: 600; font-size: 16px; color: var(--texte); cursor: pointer;
}
.gros-choix input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.gros-choix input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 860px) { .ticket-validation { grid-template-columns: minmax(0, 1fr); } .apercu-ticket iframe { height: 50vh; } }
button.danger { color: var(--ouvert); border-color: var(--ouvert); }
button.danger:hover { background: var(--ouvert-fond); }

/* --- Accueil --- */
a.lien-carte { display: block; color: inherit; text-decoration: none; }
a.lien-carte:hover { border-color: var(--accent); }
.pastille-point { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ouvert); margin-right: 8px; vertical-align: middle; }
.ligne-cc { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--bord); }
.ligne-cc:last-child { border-bottom: none; }
.avertissement-mini { font-size: 13px; color: var(--ouvert); margin-top: 2px; }
table.triable thead th.tri { cursor: pointer; user-select: none; white-space: nowrap; }
table.triable thead th.tri:hover { color: var(--texte); }
table.triable th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
table.triable th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
input.recherche { width: 100%; max-width: 420px; margin: 0 0 10px; }
.barre-periode { display: flex; gap: 10px 18px; align-items: center; flex-wrap: wrap; margin: -8px 0 18px; }
.periode { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.periode .fleche {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--bord); color: var(--texte); text-decoration: none;
  font-size: 22px; line-height: 1; background: var(--surface);
}
.periode a.fleche:hover { border-color: var(--accent); color: var(--accent); }
.periode .fleche.inactive { opacity: .35; }
.periode .titre-periode {
  font-size: 18px; font-weight: 650; padding: 4px 30px 4px 10px; min-height: 34px;
  border-radius: 8px; color: var(--texte); background-color: var(--surface);
}
.periode span.titre-periode { padding-right: 10px; }
.periode .vers-actuelle { font-size: 13px; color: var(--accent); }
.entete-page .periode { margin-left: 6px; }
.histogramme-cadre { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.histogramme-cadre .echelle {
  display: flex; flex-direction: column; justify-content: space-between; height: var(--hauteur, 140px);
  padding-bottom: 19px; font-size: 11px; color: var(--discret); text-align: right; white-space: nowrap;
}
.histogramme-cadre .echelle span { line-height: 0; }
.histogramme-cadre .histogramme {
  height: var(--hauteur, 140px);
  background-image: linear-gradient(var(--bord) 1px, transparent 1px);
  background-size: 100% calc((100% - 19px) / 4); background-repeat: repeat-y;
}
.barre-mois { position: relative; }
.barre-mois .bulle {
  display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--texte); color: var(--fond, #fff); font-size: 12px; padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; z-index: 5; pointer-events: none;
}
.barre-mois:hover .bulle, .barre-mois:focus .bulle { display: block; }
.barre-mois:hover .remplissage, .barre-mois:focus .remplissage { filter: brightness(1.15); }
tfoot tr.total td { border-top: 2px solid var(--bord); border-bottom: none; }

/* Zone de message vide (ex. erreur de clé d'accès pas encore survenue) : masquée. */
.resultat:empty { display: none; }

/* Champs masqués selon « Qui a payé » (attribut hidden, plus fort que display des labels). */
[hidden] { display: none !important; }

/* Liste de choix avec saisie libre (fournisseurs). */
.combo { position: relative; display: block; }
.combo > input { width: 100%; padding-right: 36px; }
.combo-fleche {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; padding: 4px 8px; color: var(--discret);
}
.combo-fleche:hover { background: transparent; color: var(--texte); }
.combo-liste {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px 0; list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.combo-liste li { padding: 8px 12px; cursor: pointer; font-weight: normal; }
.combo-liste li:hover, .combo-liste li.actif { background: var(--surface-2); }

/* Justificatif : bouton « Joindre » (le champ fichier est caché, la pièce part au choix). */
label.bouton.petit { display: inline-block; padding: 4px 10px; font-size: 13px; cursor: pointer; }
button.lien-discret { border: 0; background: transparent; padding: 0 4px; color: var(--discret); }
button.lien-discret:hover { color: var(--negatif, #c0392b); background: transparent; }

/* Justificatif joint : nom raccourci (titre complet au survol), croix sur la même ligne. */
.justif { display: flex; align-items: center; gap: 2px; max-width: 170px; margin-bottom: 4px; }
.justif a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.justif form { flex: none; }
select.nature-recette { max-width: 210px; }

/* Téléphone : les listes larges (table.cartes-mobile) deviennent des fiches, une par ligne,
   chaque valeur précédée du nom de sa colonne (data-label, posé par base.html). */
@media (max-width: 700px) {
  .tableau-conteneur:has(> table.cartes-mobile) { border: 0; background: none; overflow: visible; }
  table.cartes-mobile > thead { display: none; }
  table.cartes-mobile, table.cartes-mobile > tbody, table.cartes-mobile > tbody > tr,
  table.cartes-mobile > tbody > tr > td, table.cartes-mobile > tfoot > tr,
  table.cartes-mobile > tfoot > tr > td { display: block; width: 100%; }
  table.cartes-mobile > tfoot > tr {
    border: 1px solid var(--bord); border-radius: var(--rayon); padding: 8px 14px;
  }
  table.cartes-mobile > tfoot > tr > td {
    display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0;
  }
  table.cartes-mobile > tfoot > tr > td::before { content: attr(data-label); color: var(--discret); font-size: 13px; }
  table.cartes-mobile > tfoot > tr > td:first-child::before { content: none; }
  table.cartes-mobile > tbody > tr {
    background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
    margin-bottom: 10px; padding: 8px 14px;
  }
  table.cartes-mobile > tbody > tr > td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 5px 0; border: 0; text-align: right;
  }
  table.cartes-mobile > tbody > tr > td::before {
    content: attr(data-label); color: var(--discret); font-size: 13px; text-align: left; flex: none;
  }
  table.cartes-mobile > tbody > tr > td:not([data-label])::before,
  table.cartes-mobile > tbody > tr > td[data-label=""]::before { content: none; }
  /* Première colonne : titre de la fiche. */
  table.cartes-mobile > tbody > tr > td:first-child {
    font-weight: 650; text-align: left; justify-content: flex-start; flex-wrap: wrap;
  }
  table.cartes-mobile > tbody > tr > td:first-child::before { content: none; }
  table.cartes-mobile > tbody > tr > td > form, table.cartes-mobile select { max-width: 70%; }
  table.cartes-mobile > tbody > tr.sous-ligne { margin-top: -6px; }
  table.cartes-mobile > tbody > tr.sous-ligne > td { display: block; text-align: left; }
  table.cartes-mobile > tbody > tr > td[colspan] { display: block; text-align: left; }
  table.cartes-mobile > tfoot { display: block; }
}

/* Téléphone : chiffres clés côte à côte, plus compacts. */
@media (max-width: 700px) {
  .resume { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .resume .carte { padding: 12px 14px; }
  .resume .carte .valeur { font-size: 19px; }
  table.cartes-mobile > tbody > tr > td > div { margin-left: 6px; }
}

/* Téléphone : rien ne doit dépasser la largeur de l'écran (sinon la page défile de côté
   et le menu du bas est décalé). Les tableaux restants défilent dans leur cadre. */
@media (max-width: 700px) {
  main table:not(.cartes-mobile) { display: block; max-width: 100%; overflow-x: auto; }
  main select, main input, main textarea { max-width: 100%; }
  main dd { overflow-wrap: anywhere; }
  main .carte, main form { min-width: 0; }
}

@media (max-width: 700px) {
  /* Lot sous son immeuble : fiche en retrait. */
  table.cartes-mobile > tbody > tr.lot { margin-left: 16px; width: calc(100% - 16px); background: var(--surface-2); }
}
