:root {
  --fond: #f6f7f9; --carte: #fff; --encre: #1e293b; --doux: #64748b; --ligne: #e2e8f0;
  --accent: #0f766e; --accent-clair: #ccfbf1; --rouge: #b91c1c; --orange: #b45309; --bleu: #1d4ed8;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #0f172a; --carte: #1e293b; --encre: #e2e8f0; --doux: #94a3b8; --ligne: #334155;
          --accent: #2dd4bf; --accent-clair: #134e4a; --rouge: #f87171; --orange: #fbbf24; --bleu: #93c5fd; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--fond); color: var(--encre); }
a { color: var(--accent); }
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.6rem; margin: 8px 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 16px 0 8px; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; }
.sous { color: var(--doux); margin: 0 0 18px; }
.aide { color: var(--doux); font-size: .85rem; }

.barre { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--carte);
         border-bottom: 1px solid var(--ligne); position: sticky; top: 0; z-index: 2; flex-wrap: wrap; }
.marque { font-weight: 700; text-decoration: none; color: var(--encre); }
.barre nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.barre nav a { text-decoration: none; color: var(--doux); padding: 6px 10px; border-radius: 8px; font-size: .9rem; }
.barre nav a.actif, .barre nav a:hover { background: var(--accent-clair); color: var(--accent); }

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 18px; margin: 0 0 16px; }
.connexion { max-width: 360px; margin: 12vh auto; }
.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nav-annee { display: flex; gap: 12px; }

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 16px; }
.tuile { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; }
.tuile span { color: var(--doux); font-size: .85rem; }
.tuile strong { font-size: 1.35rem; }
.tuile small { color: var(--doux); }
.tuile.pos strong { color: var(--accent); } .tuile.neg strong, .neg { color: var(--rouge); }
.tuiles.petites .tuile strong { font-size: 1.1rem; }

.alertes { display: grid; gap: 8px; margin-bottom: 16px; }
.alerte { padding: 10px 14px; border-radius: 10px; border-left: 4px solid; background: var(--carte); margin-bottom: 12px; }
.alertes .alerte { margin: 0; }
.alerte.rouge { border-color: var(--rouge); } .alerte.orange { border-color: var(--orange); } .alerte.bleu { border-color: var(--bleu); }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--accent-clair); }
.flash.erreur { background: #fee2e2; color: #7f1d1d; }

.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.grille .large { grid-column: 1 / -1; }
.deux { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.bloc { border: 1px dashed var(--ligne); border-radius: 10px; padding: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--doux); }
label.case { flex-direction: row; align-items: center; gap: 8px; color: var(--encre); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--ligne); border-radius: 8px;
                          background: var(--fond); color: var(--encre); width: 100%; }
input[type=checkbox] { width: auto; }
button, .bouton { display: inline-block; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 0;
                  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; margin: 4px 4px 4px 0; }
@media (prefers-color-scheme: dark) { button, .bouton { color: #042f2e; } }
.secondaire { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.lien { background: none; color: var(--accent); padding: 0; font-weight: 400; margin: 0; text-decoration: underline; }
button.danger { color: var(--rouge); }
.enligne { display: inline; }
details summary { cursor: pointer; }
details > form { margin-top: 12px; }
form.mini { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--ligne); border-radius: 8px; margin-top: 6px; min-width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--doux); font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--ligne); padding: 6px 8px; }
td { border-bottom: 1px solid var(--ligne); padding: 8px; vertical-align: top; }
.num { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--encre); }
td.actions { white-space: nowrap; } td.actions > * { margin-right: 10px; }
.carte { overflow-x: auto; }

.pastille { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--accent-clair); color: var(--accent); }
.pastille.prevu { background: var(--ligne); color: var(--doux); }
.classe { display: inline-block; width: 24px; text-align: center; border-radius: 4px; color: #fff; font-weight: 700; }
.cA { background: #059669; } .cB { background: #22c55e; } .cC { background: #a3e635; color: #1e293b; } .cD { background: #facc15; color: #1e293b; }
.cE { background: #fb923c; } .cF { background: #ef4444; } .cG { background: #b91c1c; }

.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.galerie figure { margin: 0; } .galerie img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; }

.jauge { display: inline-block; width: 120px; height: 8px; background: var(--ligne); border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.jauge div { height: 100%; background: var(--accent); border-radius: 4px; }

.barres { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 200px; }
.barre-mois { display: grid; grid-template-rows: 1fr 1fr auto; text-align: center; font-size: .75rem; color: var(--doux); }
.barre-mois .haut { display: flex; align-items: flex-end; border-bottom: 1px solid var(--doux); }
.barre-mois .bas { display: flex; align-items: flex-start; }
.barre-mois .b { width: 100%; border-radius: 4px; } .b.pos { background: var(--accent); border-radius: 4px 4px 0 0; } .b.neg { background: var(--rouge); border-radius: 0 0 4px 4px; }

.liste-docs { list-style: none; padding: 0; margin: 0; }
.liste-docs li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--ligne); }
.liste-docs span { color: var(--doux); }

@media (max-width: 720px) {
  .barre { gap: 8px; }
  .barre nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .barre nav a { white-space: nowrap; }
  .barre form { margin-left: auto; }
  .barres { gap: 2px; } .barre-mois span { font-size: .6rem; }
}
@media print { .barre, button, .bouton, form { display: none !important; } .carte { border: 0; } }
