:root {
  color-scheme: light;
  --fond: #f4f5f2;
  --surface: #fcfcfb;
  --surface-2: #eef0ec;
  --bordure: #dcded8;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --muet: #6b6a66;
  --accent: #1f4e8c;
  --accent-texte: #ffffff;
  --serie-1: #2a78d6;
  --grille: #e4e5e0;
  --ok: #0a7d0a;
  --ok-fond: #e5f3e3;
  --attente: #8a5a00;
  --attente-fond: #fdf1d6;
  --alerte: #b42d2d;
  --alerte-fond: #fbe6e4;
  --neutre-fond: #ecece8;
  --ombre: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .04);
  --rayon: 12px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #121211; --surface: #1a1a19; --surface-2: #232321; --bordure: #33332f;
    --texte: #f0efec; --texte-2: #c3c2b7; --muet: #9c9b93; --accent: #5b8fd6; --accent-texte: #0b0b0b;
    --serie-1: #3987e5; --grille: #2c2c29;
    --ok: #3fbf3f; --ok-fond: #17301a; --attente: #f0b23a; --attente-fond: #33290f; --alerte: #ef7a7a; --alerte-fond: #3a1a1a; --neutre-fond: #2a2a27;
    --ombre: 0 1px 2px rgb(0 0 0 / .4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muet { color: var(--muet); }

.entete { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--bordure); }
.marque { display: flex; gap: .6rem; align-items: center; }
.marque div { display: flex; flex-direction: column; line-height: 1.15; }
.marque span { font-size: .8rem; }
#navigation { display: flex; gap: .25rem; flex-wrap: wrap; }
.onglet { border: 0; background: none; color: var(--texte-2); font: inherit; padding: .45rem .8rem; border-radius: 8px; cursor: pointer; }
.onglet:hover { background: var(--surface-2); }
.onglet.actif { background: var(--accent); color: var(--accent-texte); }
.outils-entete { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
#maj { font-size: .8rem; }

main#contenu { max-width: 1200px; margin: 0 auto; padding: 1.5rem; outline: none; display: flex; flex-direction: column; gap: 1.25rem; }
.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 1.1rem 1.25rem; box-shadow: var(--ombre); min-width: 0; }
.grille-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.tuile { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 1rem 1.1rem; box-shadow: var(--ombre); }
.tuile h3 { font-size: .82rem; font-weight: 500; color: var(--texte-2); margin-bottom: .35rem; }
.tuile .valeur { font-size: 1.7rem; font-weight: 650; margin: 0; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tuile .detail { margin: .3rem 0 0; color: var(--muet); font-size: .85rem; }
.tuile.alerte { border-color: var(--alerte); }
.tuile.alerte .valeur { color: var(--alerte); }

.bouton { font: inherit; font-size: .9rem; border: 1px solid var(--bordure); background: var(--surface); color: var(--texte); padding: .45rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.bouton:hover { background: var(--surface-2); }
.bouton:disabled { opacity: .55; cursor: progress; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.discret { border-color: transparent; background: none; color: var(--texte-2); }
.bouton.petit { padding: .28rem .65rem; font-size: .82rem; }
button:focus-visible, a:focus-visible, input:focus-visible, .colonne:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.barre-outils { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.barre-outils h2 { margin: 0; }
.barre-outils .pousse { margin-left: auto; }
.titre-mois { min-width: 10ch; text-align: center; text-transform: capitalize; }

.defilement { overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th { text-align: left; font-weight: 550; color: var(--texte-2); font-size: .8rem; padding: .5rem .6rem; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
.tableau td { padding: .6rem; border-bottom: 1px solid var(--grille); vertical-align: middle; }
.tableau tfoot th, .tableau tfoot td { border-bottom: 0; padding-top: .8rem; }
.tableau .nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tableau .muet { font-size: .8rem; }
.tableau.compact td { padding: .4rem .5rem; }
.actions { text-align: right; }
.saisie { display: inline-flex; gap: .4rem; align-items: center; }
input[type="date"], input[type="password"] { font: inherit; padding: .35rem .5rem; border: 1px solid var(--bordure); border-radius: 8px; background: var(--surface); color: var(--texte); }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem .15rem .4rem; border-radius: 999px; font-size: .8rem; font-weight: 550; white-space: nowrap; text-decoration: none; }
.badge-icone { display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%; font-size: .7rem; color: #fff; }
.badge.ok { background: var(--ok-fond); color: var(--ok); } .badge.ok .badge-icone { background: var(--ok); }
.badge.attente { background: var(--attente-fond); color: var(--attente); } .badge.attente .badge-icone { background: var(--attente); }
.badge.alerte { background: var(--alerte-fond); color: var(--alerte); } .badge.alerte .badge-icone { background: var(--alerte); }
.badge.neutre { background: var(--neutre-fond); color: var(--texte-2); } .badge.neutre .badge-icone { background: var(--muet); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-icone { color: #0b0b0b; } }

.a-faire { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.a-faire li { display: flex; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--grille); }
.a-faire li:last-child { border-bottom: 0; }
.a-faire .texte { flex: 1; }
.puce { width: .55rem; height: .55rem; border-radius: 50%; flex: none; background: var(--muet); }
.a-faire .alerte .puce { background: var(--alerte); } .a-faire .attente .puce { background: var(--attente); } .a-faire .ok .puce { background: var(--ok); }

.legende { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--texte-2); margin: -.2rem 0 .4rem; }
.cle-barre { width: .8rem; height: .8rem; border-radius: 3px; background: var(--serie-1); }
.cle-cible { width: .9rem; height: 0; border-top: 2px dashed var(--texte-2); margin-left: .6rem; }
.graphique-cadre { position: relative; }
.graphique { width: 100%; height: auto; display: block; overflow: visible; }
.graphique .grille { stroke: var(--grille); stroke-width: 1; }
.graphique .axe { stroke: var(--bordure); stroke-width: 1; }
.graphique .etiquette { fill: var(--muet); font-size: 11px; }
.graphique .barre { fill: var(--serie-1); }
.graphique .cible { stroke: var(--texte-2); stroke-width: 2; stroke-dasharray: 3 3; }
.graphique .zone { fill: transparent; }
.graphique .colonne:hover .zone, .graphique .colonne:focus .zone { fill: var(--surface-2); }
.colonne { outline: none; cursor: default; }
.info-bulle { position: absolute; top: 0; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--bordure); box-shadow: var(--ombre); border-radius: 8px; padding: .45rem .65rem; font-size: .8rem; display: flex; flex-direction: column; pointer-events: none; white-space: nowrap; }
.info-bulle[hidden] { display: none; }
.info-bulle strong { text-transform: capitalize; }

.cartes-baux { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.carte-bail { text-align: left; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: .15rem; }
.carte-bail:hover { border-color: var(--accent); }
.carte-bail p { margin: 0; }
.ligne-titre { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.ligne-titre h3 { margin: 0; }
.montant { margin-top: .5rem !important; font-size: 1.2rem; font-weight: 650; }
.fiche { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.fiche dt { color: var(--muet); } .fiche dd { margin: 0; overflow-wrap: anywhere; }
.liste-simple { margin: 0; padding-left: 1.1rem; }
.grille-quittances td, .grille-quittances th { white-space: nowrap; }
.grille-quittances thead th { text-transform: capitalize; }

#notifications { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 10; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--surface); border: 1px solid var(--bordure); border-left: 4px solid var(--accent); padding: .7rem .9rem; border-radius: 8px; box-shadow: var(--ombre); }
.toast.ok { border-left-color: var(--ok); } .toast.erreur { border-left-color: var(--alerte); }
.vide, .chargement { text-align: center; padding: 3rem 1rem; }

.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.connexion { width: min(380px, 100%); text-align: center; padding: 2rem; }
.connexion h1 { font-size: 1.35rem; margin-top: .75rem; }
.connexion form { display: flex; flex-direction: column; gap: .6rem; text-align: left; margin-top: 1.25rem; }
.connexion input { width: 100%; padding: .6rem .7rem; }
.connexion .bouton { justify-content: center; padding: .6rem; }
.erreur { color: var(--alerte); min-height: 1.2em; margin: 0; font-size: .9rem; }

@media (max-width: 860px) {
  .grille-2 { grid-template-columns: 1fr; }
  .entete { padding: .6rem 1rem; position: static; }
  .outils-entete { margin-left: 0; width: 100%; }
  #maj { margin-right: auto; }
  main#contenu { padding: 1rem; }
  .saisie { flex-direction: column; align-items: stretch; }
}
