/* Quittances : registre de loyers.
   Encre vert sapin sur papier, titres en serif comme un document officiel,
   trois couleurs d'état seulement (encaissé / à encaisser / partiel). */
:root {
  --papier: #f3f4f1;
  --carte: #ffffff;
  --encre: #17302a;          /* texte fort, boutons principaux */
  --encre-2: #3d524c;        /* texte courant */
  --encre-3: #6f7f7a;        /* texte secondaire */
  --trait: #dfe4e0;
  --trait-fort: #c6cfca;
  --surface: #eaeeeb;        /* boutons secondaires, fonds légers */
  --onglet-actif: #ffffff;
  --accent: #1f6b57;         /* liens, focus, onglet actif */
  --ok: #1f6b57;      --ok-fond: #e1efe9;
  --attente: #b4541f; --attente-fond: #fbeadf;
  --partiel: #a3263b; --partiel-fond: #f8e2e6;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rayon: 14px;
  --ombre: 0 1px 0 rgba(23, 48, 42, 0.04), 0 8px 24px -12px rgba(23, 48, 42, 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #111816; --carte: #18211e; --encre: #e8efe9; --encre-2: #c3cec9; --encre-3: #8b9a95;
    --trait: #26322e; --trait-fort: #34433e; --surface: #212c28; --onglet-actif: #34433e; --accent: #6cc3a6;
    --ok: #7fd1b2; --ok-fond: #183a30; --attente: #f0a46e; --attente-fond: #3a2516;
    --partiel: #f2909f; --partiel-fond: #3d1c23;
    --ombre: 0 1px 0 rgba(0, 0, 0, 0.3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); background: var(--papier); color: var(--encre-2); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); color: var(--encre); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 0; }
code { font-size: 0.85em; }

/* --- Ruban du haut ---
   Ordinateur : logo | onglets | compte, sur une ligne.
   Mobile : logo + compte, puis deux grands onglets pleine largeur avec
   icône (cibles de 48 px au pouce). La déconnexion est rangée dans le menu
   compte : jamais à côté des onglets, où on la toucherait par erreur. */
.ruban { background: var(--carte); border-bottom: 1px solid var(--trait); position: sticky; top: 0; z-index: 10; }
.ruban-ligne { display: flex; align-items: center; gap: 1rem; max-width: 880px; margin: 0 auto; padding: 0.55rem 1rem; }
.marque { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--encre); font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.marque svg { width: 30px; height: 30px; flex: none; }
.ruban .marque { margin-right: auto; }

.onglets { display: flex; gap: 0.25rem; background: var(--surface); padding: 4px; border-radius: 999px; }
.onglets a { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; padding: 0 1rem; border-radius: 999px; color: var(--encre-2); text-decoration: none; font-weight: 600; font-size: 0.93rem; }
.onglets a:hover { color: var(--encre); }
.onglets a.actif { background: var(--onglet-actif); color: var(--encre); box-shadow: 0 1px 3px rgba(23, 48, 42, 0.18); }
.onglets svg, .compte-menu svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglets a.actif svg { color: var(--accent); }

.compte { position: relative; }
.compte summary {
  list-style: none; cursor: pointer; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--encre); color: var(--carte); font-weight: 700; font-size: 0.9rem; text-transform: uppercase; user-select: none;
}
.compte summary::-webkit-details-marker { display: none; }
.compte[open] summary { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.compte-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(17rem, calc(100vw - 2rem));
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: 0 12px 32px -8px rgba(23, 48, 42, 0.3);
  padding: 0.9rem; display: grid; gap: 0.15rem;
}
.compte-menu strong { color: var(--encre); overflow-wrap: anywhere; }
.compte-menu .secondaire-texte { overflow-wrap: anywhere; }
.compte-menu form { margin-top: 0.7rem; }
.compte-menu button.sortir { width: 100%; justify-content: flex-start; color: var(--partiel); border-color: var(--trait); }

@media (max-width: 600px) {
  .ruban-ligne { flex-wrap: wrap; row-gap: 0.5rem; padding: 0.5rem 1rem 0.6rem; }
  .onglets { order: 3; flex: 1 1 100%; }
  .onglets a { flex: 1; justify-content: center; min-height: 44px; }
}

main { max-width: 880px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

/* --- Cartes, formulaires --- */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.1rem 1.2rem; box-shadow: var(--ombre); margin: 0.8rem 0; }
.formulaire-etroit { max-width: 360px; }
label { display: block; margin: 0.8rem 0; font-weight: 600; font-size: 0.88rem; color: var(--encre); }
input, select, textarea {
  width: 100%; padding: 0.65rem 0.75rem; margin-top: 0.3rem; font: inherit; font-weight: 400;
  color: var(--encre); background: var(--carte); border: 1px solid var(--trait-fort); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; }
.formulaire ul { list-style: none; padding: 0; margin: 0.3rem 0 0; }
.formulaire ul li label { font-weight: 400; display: flex; gap: 0.55rem; align-items: center; margin: 0.35rem 0; }
.formulaire ul li input { width: auto; margin: 0; accent-color: var(--accent); }
.formulaire fieldset { border: none; padding: 0; margin: 0.8rem 0; }
.formulaire legend { font-weight: 600; font-size: 0.88rem; color: var(--encre); }
.formulaire .aide { color: var(--encre-3); font-size: 0.8rem; font-weight: 400; display: block; margin-top: 0.25rem; }
.formulaire .errorlist { color: var(--partiel); margin: 0.2rem 0; padding: 0; list-style: none; font-size: 0.85rem; }

/* --- Boutons --- */
button, a.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; text-decoration: none; cursor: pointer;
  min-height: 44px; padding: 0.6rem 1.1rem; border-radius: 10px; border: 1px solid var(--trait-fort);
  background: var(--carte); color: var(--encre); transition: background 0.15s, border-color 0.15s;
}
button:hover, a.bouton:hover { background: var(--surface); }
button.principal, a.bouton.principal { background: var(--encre); border-color: var(--encre); color: var(--carte); }
button.principal:hover, a.bouton.principal:hover { background: var(--accent); border-color: var(--accent); }
button.secondaire { background: var(--surface); border-color: transparent; }
button.secondaire:hover { background: var(--trait); }
button.lien { min-height: 0; padding: 0.2rem 0; border: none; background: none; color: var(--encre-3); font-weight: 500; font-size: 0.85rem; text-decoration: underline; text-underline-offset: 2px; }
button.lien:hover { background: none; color: var(--encre); }
button.danger { color: var(--partiel); }
.inline { display: inline; }

/* --- Bandeau de page --- */
.entete-page { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.4rem 0 0.8rem; }
.entete-page h1 { flex: 1; margin: 0; }
.fleche { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--trait-fort); background: var(--carte); font-size: 1.3rem; text-decoration: none; color: var(--encre); }
.fleche:hover { background: var(--surface); }
.selecteur-mois { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.6rem; text-align: center; margin: 0.2rem 0 1rem; }
.selecteur-mois h1 { margin: 0; font-size: clamp(1.35rem, 6vw, 1.75rem); white-space: nowrap; }
.selecteur-mois .fleche { width: 44px; height: 44px; }
.selecteur-mois .secondaire-texte, .retour-courant { font-size: 0.82rem; font-weight: 600; }

/* --- Messages --- */
.messages p { margin: 0 0 0.6rem; padding: 0.65rem 0.9rem; border-radius: 10px; background: var(--ok-fond); color: var(--ok); font-weight: 500; }
.messages p.error { background: var(--partiel-fond); color: var(--partiel); }
.erreur { color: var(--partiel); }
.secondaire-texte { color: var(--encre-3); font-size: 0.85rem; display: block; }
.vide { text-align: center; padding: 2rem 1.2rem; }

/* --- Résumé du mois --- */
.resume { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.6rem; margin: 0 0 1rem; }
.resume > div { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 0.75rem 0.95rem; }
.resume strong { display: block; font-family: var(--serif); font-size: 1.45rem; font-weight: 600; color: var(--encre); font-variant-numeric: tabular-nums lining-nums; }
.resume span { color: var(--encre-3); font-size: 0.82rem; }
.jauge { height: 6px; border-radius: 999px; background: var(--surface); overflow: hidden; margin-top: 0.45rem; }
.jauge i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }

.barre-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0 1rem; }
.barre-actions form { display: contents; }
@media (max-width: 560px) { .barre-actions > * { flex: 1 1 12rem; } }

/* --- Carte d'un bail dans le mois : la bordure gauche dit l'état --- */
.ligne-bail { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 1rem; align-items: start; border-left: 4px solid var(--trait-fort); }
.ligne-bail.etat-attente { border-left-color: var(--attente); }
.ligne-bail.etat-partiel { border-left-color: var(--partiel); }
.ligne-bail.etat-ok { border-left-color: var(--ok); }
.ligne-bail h3 a { color: var(--encre); text-decoration: none; }
.ligne-bail .montant { text-align: right; font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--encre); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.ligne-bail .montant .pastille { font-family: var(--sans); margin-top: 0.2rem; }
.ligne-bail .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding-top: 0.3rem; }
.ligne-bail .actions form { margin: 0; }
.ligne-bail .boutons { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1 1 100%; }
.ligne-bail .liens { display: flex; flex-wrap: wrap; gap: 0.1rem 1rem; align-items: center; flex: 1 1 100%; border-top: 1px dashed var(--trait); padding-top: 0.55rem; }
.ligne-bail .liens .secondaire-texte { flex: 1 1 100%; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .ligne-bail .boutons > *, .ligne-bail .boutons form { flex: 1 1 8rem; display: flex; }
  .ligne-bail .boutons form button { flex: 1; }
  .ligne-bail .actions > form { flex: 1 1 100%; display: flex; }
  .ligne-bail .actions > form > button { flex: 1; }
}

.pastille { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.18rem 0.6rem; border-radius: 999px; white-space: nowrap; text-decoration: none; background: var(--surface); color: var(--encre-2); }
.pastille.ok { background: var(--ok-fond); color: var(--ok); }
.pastille.attente { background: var(--attente-fond); color: var(--attente); }
.pastille.partiel { background: var(--partiel-fond); color: var(--partiel); }

details.partiel { flex: 1 1 100%; }
details.partiel summary { cursor: pointer; color: var(--encre-3); font-weight: 600; font-size: 0.88rem; padding: 0.35rem 0; }
details.partiel form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; margin-top: 0.3rem; }
details.partiel label { margin: 0; flex: 1 1 8rem; }

/* --- Tableaux et listes --- */
.defile { overflow-x: auto; padding: 0.4rem 0.6rem; }
.tableau { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tableau th { text-align: left; color: var(--encre-3); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--trait-fort); }
.tableau td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--trait); vertical-align: middle; }
.tableau tr:last-child td { border-bottom: none; }
.tableau .chiffre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.liste-simple { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.liste-simple li { padding: 0.6rem 0; border-bottom: 1px solid var(--trait); display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.liste-simple li:last-child { border-bottom: none; }
.liste-simple a { color: var(--encre); font-weight: 600; text-decoration: none; }
.liste-simple a:hover { color: var(--accent); }

/* --- Connexion --- */
.connexion { max-width: 380px; margin: 2.5rem auto 0; }
.connexion .marque { justify-content: center; width: 100%; font-size: 1.6rem; margin-bottom: 0.3rem; }
.connexion .marque svg { width: 40px; height: 40px; }
.connexion .accroche { text-align: center; color: var(--encre-3); margin: 0 0 1.2rem; }
.connexion button.principal { width: 100%; margin-top: 0.4rem; }
.separateur-ou { display: flex; align-items: center; gap: 0.6rem; color: var(--encre-3); font-size: 0.85rem; margin: 1.1rem 0; }
.separateur-ou::before, .separateur-ou::after { content: ""; flex: 1; border-top: 1px solid var(--trait); }
.bouton-microsoft { display: flex; align-items: center; justify-content: center; gap: 0.6rem; width: 100%; min-height: 44px; background: var(--carte); color: var(--encre); font-weight: 600; text-decoration: none; border: 1px solid var(--trait-fort); border-radius: 10px; }
.bouton-microsoft:hover { background: var(--surface); }
