:root {
  color-scheme: light;
  --fond: #f6f5f2;
  --surface: #fcfcfb;
  --bord: #e2e0da;
  --texte: #1b1b1a;
  --texte-2: #52514e;
  --texte-3: #7a7873;
  --accent: #2a78d6;
  --accent-texte: #ffffff;
  --piste: #ecebe6;
  --succes-fond: #e3f3e6; --succes: #1d6b2c;
  --alerte-fond: #fbf0d9; --alerte: #7a5400;
  --erreur-fond: #fbe4e1; --erreur: #a3271b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #121211; --surface: #1a1a19; --bord: #33322f;
    --texte: #f4f3ef; --texte-2: #c3c2b7; --texte-3: #94928a;
    --accent: #3987e5; --piste: #2a2a28;
    --succes-fond: #173a20; --succes: #9fd9aa;
    --alerte-fond: #3d2f10; --alerte: #f0cf86;
    --erreur-fond: #46201b; --erreur: #f3aba2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #121211; --surface: #1a1a19; --bord: #33322f;
  --texte: #f4f3ef; --texte-2: #c3c2b7; --texte-3: #94928a;
  --accent: #3987e5; --piste: #2a2a28;
  --succes-fond: #173a20; --succes: #9fd9aa;
  --alerte-fond: #3d2f10; --alerte: #f0cf86;
  --erreur-fond: #46201b; --erreur: #f3aba2;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
main { max-width: 960px; margin: 0 auto; padding: 16px 16px 48px; }
main.etroit { max-width: 380px; padding-top: 12vh; }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; line-height: 1.25; }
h1 .sous { font-weight: 400; color: var(--texte-2); font-size: 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.barre { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--bord); }
.marque { font-weight: 700; color: var(--texte); text-decoration: none; }
.barre nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.barre nav a { color: var(--texte-2); text-decoration: none; }
.barre nav a:hover { color: var(--texte); }
.barre nav a.envoyer { color: var(--accent); font-weight: 600; }
.barre form { margin: 0; }
.pastille { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 1em; text-align: center;
  background: var(--accent); color: var(--accent-texte); font-size: .8rem; font-weight: 600; }

.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; padding: 16px; margin: 0 0 16px; }
form.carte { display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
.facultatif { font-weight: 400; color: var(--texte-3); font-size: .85rem; }
input, select, button { font: inherit; color: inherit; }
input, select { padding: 8px 10px; border: 1px solid var(--bord); border-radius: 6px; background: var(--fond); width: 100%; }
input[type=file] { padding: 10px; }
button { padding: 9px 16px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-texte);
  font-weight: 600; cursor: pointer; }
button.secondaire { background: var(--piste); color: var(--texte); }
button.danger { background: transparent; color: var(--erreur); border: 1px solid var(--bord); }
button.lien { background: none; padding: 0; color: var(--texte-2); font-weight: 400; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bouton { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px;
  padding: 10px 12px; border-radius: 8px; background: var(--accent); color: var(--accent-texte); font-weight: 600; cursor: pointer; }
.bouton.secondaire { background: var(--piste); color: var(--texte); }
.bouton:focus-within { outline: 2px solid var(--texte); outline-offset: 2px; }
/* visually hidden but still focusable and clickable through its label */
.cache { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.selection { margin: 0; font-weight: 600; }
.aide { color: var(--texte-2); font-size: .9rem; margin: 0; }
.vide { color: var(--texte-3); }
.succes, .avertissement, .erreur, .note { padding: 10px 12px; border-radius: 8px; }
.succes { background: var(--succes-fond); color: var(--succes); }
.avertissement, .note { background: var(--alerte-fond); color: var(--alerte); }
.erreur { background: var(--erreur-fond); color: var(--erreur); }
.fil { margin: 0; font-size: .9rem; }
.fil a { color: var(--texte-2); text-decoration: none; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; font-weight: 600; color: var(--texte-2); font-size: .85rem; border-bottom: 1px solid var(--bord); padding: 6px 8px; }
td { padding: 7px 8px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.defile { overflow-x: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; }
.detail { color: var(--texte-3); font-size: .85rem; }

.filtres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filtres a { padding: 4px 12px; border-radius: 1em; background: var(--surface); border: 1px solid var(--bord);
  color: var(--texte-2); text-decoration: none; font-size: .9rem; }
.filtres a[aria-current] { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.statut { font-size: .85rem; padding: 1px 8px; border-radius: 1em; white-space: nowrap; background: var(--piste); color: var(--texte-2); }
.statut.en_attente { background: var(--alerte-fond); color: var(--alerte); }
.statut.traite { background: var(--succes-fond); color: var(--succes); }
.statut.illisible { background: var(--erreur-fond); color: var(--erreur); }

.ticket { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .ticket.avec-photo { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; } }
.photo img { width: 100%; border-radius: 8px; border: 1px solid var(--bord); display: block; }
.lignes { background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; padding: 8px; overflow-x: auto; }
.lignes .aide { padding: 8px; }
.classer { display: flex; align-items: center; gap: 6px; margin: 0; }
.classer select { padding: 4px 6px; font-size: .9rem; min-width: 9em; }
.mien { font-size: .8rem; color: var(--succes); white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions form { margin: 0; }

.periode { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.periode select { width: auto; }
.periode .perso { display: flex; flex-wrap: wrap; gap: 8px; }
.periode .perso[hidden] { display: none; }
.periode input { width: auto; }
.tete { margin: 0 0 20px; }
.tete .libelle { margin: 0; color: var(--texte-2); }
.tete .montant { margin: 0; font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }

/* monthly bars: one series, so one hue and no legend; the value shows on hover or focus */
.colonnes { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 24px; }
.col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; min-width: 0; outline: none; }
.col .zone { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.col .baton { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 1px; }
.col .axe { font-size: .7rem; line-height: 1.2; color: var(--texte-3); text-align: center; white-space: nowrap; overflow: hidden; margin-top: 4px; }
.col .court { display: none; }
@media (max-width: 600px) { .col .long { display: none; } .col .court { display: inline; } }
.col .info { position: absolute; top: -4px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .8rem;
  background: var(--texte); color: var(--fond); padding: 2px 6px; border-radius: 4px; display: none; z-index: 1; }
.col:hover .info, .col:focus .info { display: block; }
.col:hover .baton, .col:focus .baton { filter: brightness(1.15); }
details summary { cursor: pointer; color: var(--texte-2); font-size: .9rem; margin-top: 8px; }

.groupe { margin-bottom: 8px; }
.groupe > summary { display: flex; justify-content: space-between; gap: 8px; color: var(--texte); font-weight: 600; font-size: 1rem;
  padding: 6px 0; border-bottom: 1px solid var(--bord); list-style: none; }
.groupe > summary::-webkit-details-marker { display: none; }
.part { color: var(--texte-3); font-weight: 400; font-size: .85rem; }
.barre-cat { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 6px 0 6px 12px; color: var(--texte); text-decoration: none; }
.barre-cat:hover .nom { text-decoration: underline; }
.barre-cat .piste { grid-column: 1 / -1; height: 6px; background: var(--piste); border-radius: 3px; overflow: hidden; }
.barre-cat .rempli { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }

.cats { margin: 0; display: grid; gap: 10px; }
.cats dt { font-weight: 600; }
.cats dd { margin: 0; color: var(--texte-2); font-size: .9rem; }
.compte { font-weight: 400; color: var(--texte-3); font-size: .85rem; }
