:root {
  --fond: #f4f5f7;
  --carte: #ffffff;
  --encre: #1f2933;
  --discret: #5f6c7b;
  --bordure: #d9dee4;
  --accent: #b4530f;
  --accent-fonce: #8f4109;
  --danger: #b42318;
  --succes-fond: #e6f4ea;
  --succes: #1e6b34;
  --erreur-fond: #fdecea;
  --serie-recu: #2a78d6;
  --serie-depense: #eb6834;
  --grille: #e8ebef;
  --rayon: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
a { color: var(--accent-fonce); }

.barre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--encre);
}
.barre nav { display: flex; gap: 4px; overflow-x: auto; }
.barre a {
  color: #d5dbe2;
  text-decoration: none;
  padding: 14px 8px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.barre a.actif { color: #fff; border-bottom-color: #f0a35e; }
.barre .lien { color: #d5dbe2; font-size: .85rem; white-space: nowrap; }

.titre { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.titre > div { min-width: 0; }
.discret { color: var(--discret); margin: 0 0 12px; overflow-wrap: anywhere; }
.titre .discret { margin-bottom: 0; }
.vide { color: var(--discret); padding: 12px 0; }

.bouton {
  display: inline-block;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--carte);
  color: var(--encre);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton.principal:hover { background: var(--accent-fonce); }
.bouton.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.lien { background: none; border: 0; padding: 8px 0; font: inherit; cursor: pointer; text-decoration: underline; }
.danger-texte { color: var(--danger); }

.carte {
  display: block;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 14px;
  margin-bottom: 12px;
}

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 12px; }
label:last-child { margin-bottom: 0; }
input, select, textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid #aeb7c2;
  border-radius: 8px;
  background: #fff;
  color: var(--encre);
  font: inherit;
  font-weight: 400;
}
input[type=checkbox] { display: inline-block; width: auto; min-height: 0; margin: 0 6px 0 0; }
input[type=file] { padding: 9px; }
.case { font-weight: 400; }
:focus-visible { outline: 3px solid #f0a35e; outline-offset: 1px; }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions .bouton { flex: 1; }
.zone-suppression { margin-top: 26px; text-align: center; }

.message { padding: 11px 14px; border-radius: var(--rayon); margin: 0 0 14px; }
.message.succes { background: var(--succes-fond); color: var(--succes); }
.message.erreur { background: var(--erreur-fond); color: var(--danger); }

.chantier { color: inherit; text-decoration: none; }
.ligne-titre { display: flex; justify-content: space-between; gap: 8px; }
.chantier .discret { margin: 2px 0 0; }
.etiquette {
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: #e4e7eb;
  color: var(--discret);
  white-space: nowrap;
}

dl { margin: 0; }
dt { color: var(--discret); font-size: .8rem; }
dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.negatif { color: var(--danger); }
.chiffres { display: grid; gap: 3px; margin-top: 10px; }
.chiffres > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chiffres dt { font-size: .88rem; }
.chiffres dd { font-size: .92rem; white-space: nowrap; }

.totaux { display: grid; gap: 8px; margin: 12px 0 14px; }
.totaux > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 10px 12px;
}
.totaux dt { font-size: .92rem; }
.totaux dd { font-size: 1.1rem; white-space: nowrap; }

.actions-rapides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.actions-rapides .bouton:last-child { grid-column: 1 / -1; }

.onglets { display: flex; gap: 0; overflow-x: auto; border-bottom: 1px solid var(--bordure); margin-bottom: 14px; }
.onglets a {
  flex: 1 0 auto;
  padding: 10px 2px;
  font-size: .8rem;
  text-align: center;
  color: var(--discret);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.onglets a.actif { color: var(--encre); font-weight: 600; border-bottom-color: var(--accent); }

.lignes { list-style: none; margin: 0; padding: 0; }
.lignes > li { background: var(--carte); border: 1px solid var(--bordure); border-bottom-width: 0; }
.lignes > li:first-child { border-radius: var(--rayon) var(--rayon) 0 0; }
.lignes > li:last-child { border-bottom-width: 1px; border-radius: 0 0 var(--rayon) var(--rayon); }
.lignes > li:only-child { border-radius: var(--rayon); }
.ligne {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: inherit;
  text-decoration: none;
}
.ligne > span { min-width: 0; overflow-wrap: anywhere; }
.ligne small { display: block; color: var(--discret); }
.montant { white-space: nowrap; font-variant-numeric: tabular-nums; }

.ajout-rapide { display: flex; gap: 8px; margin-bottom: 12px; }
.ajout-rapide input { margin-top: 0; min-width: 0; }

.ligne-devis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ligne-devis label { margin: 0; }
.ligne-devis .designation { grid-column: 1 / -1; }
.ligne-devis label:nth-of-type(4) { grid-column: 1 / -1; }
.ligne-devis [data-retirer] { grid-column: 1 / -1; justify-self: end; padding: 0; }

.total-devis { font-size: 1.15rem; text-align: right; margin: 16px 0; }
.notes { white-space: pre-line; color: var(--discret); }
.logo { display: block; max-width: 160px; max-height: 90px; margin-bottom: 10px; }

.connexion { max-width: 380px; margin: 12vh auto 0; }
.connexion h1 { text-align: center; margin-bottom: 18px; }
.connexion .bouton { width: 100%; margin-top: 4px; }

.graphique h2 { margin: 0 0 2px; }
.graphique .discret { font-size: .88rem; margin-bottom: 10px; }

.legende { display: flex; gap: 16px; list-style: none; margin: 0 0 12px; padding: 0; font-size: .88rem; }
.legende li { display: flex; align-items: center; gap: 6px; }
.pastille { width: 12px; height: 12px; border-radius: 3px; }
.pastille.recu, .colonne.recu { background: var(--serie-recu); }
.pastille.depense, .colonne.depense { background: var(--serie-depense); }

.colonnes { position: relative; height: 210px; padding: 8px 0 26px 40px; }
.axe { position: absolute; inset: 8px 0 26px 0; }
.graduation { position: absolute; left: 40px; right: 0; border-top: 1px solid var(--grille); }
.graduation b {
  position: absolute;
  right: 100%;
  top: -.65em;
  padding-right: 6px;
  color: var(--discret);
  font-size: .72rem;
  font-weight: 400;
  white-space: nowrap;
}
.mois-liste { position: relative; display: flex; height: 100%; }
.mois { position: relative; flex: 1; min-width: 0; border-radius: 6px; cursor: default; }
.mois:hover { background: rgba(31, 41, 51, .05); }
.paire { display: flex; justify-content: center; align-items: flex-end; gap: 2px; height: 100%; }
.colonne { flex: 0 1 13px; max-width: 24px; min-width: 0; border-radius: 4px 4px 0 0; }
.colonne.non-nulle { min-height: 2px; }
.nom-mois {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding-top: 6px;
  color: var(--discret);
  font-size: .75rem;
  text-align: center;
}

.barres { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.barres li { border-radius: 6px; cursor: default; }
.barre-texte { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
.barre-texte span { min-width: 0; overflow-wrap: anywhere; }
.barre-texte strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.barre-piste { margin-top: 4px; }
.barre-valeur { display: block; height: 14px; min-width: 2px; background: var(--serie-depense); border-radius: 0 4px 4px 0; }
.barres li:hover .barre-valeur { filter: brightness(1.08); }

.chiffres-detail { margin-top: 12px; font-size: .9rem; }
.chiffres-detail summary { cursor: pointer; color: var(--accent-fonce); padding: 4px 0; }
.chiffres-detail table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chiffres-detail th, .chiffres-detail td { padding: 6px 0 6px 8px; border-top: 1px solid var(--grille); text-align: right; font-weight: 400; white-space: nowrap; }
.chiffres-detail th:first-child { padding-left: 0; text-align: left; white-space: normal; }
.chiffres-detail thead th { border-top: 0; color: var(--discret); font-size: .8rem; }

.infobulle {
  position: fixed;
  z-index: 10;
  max-width: 240px;
  padding: 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--carte);
  box-shadow: 0 4px 14px rgba(31, 41, 51, .16);
  font-size: .85rem;
  pointer-events: none;
}
.infobulle-titre { color: var(--discret); margin-bottom: 3px; overflow-wrap: anywhere; }
.infobulle-ligne { display: flex; align-items: center; gap: 6px; }
.infobulle-ligne::before { content: ""; width: 12px; height: 2px; background: var(--cle); }
.infobulle-ligne strong { font-variant-numeric: tabular-nums; }
.infobulle-ligne span { color: var(--discret); }

.deconnexion-mobile { margin-top: 12px; }
.deconnexion-mobile .bouton { width: 100%; }

@media (max-width: 639px) {
  .barre form { display: none; }
}

@media (min-width: 640px) {
  .deconnexion-mobile { display: none; }
  .colonne { flex-basis: 18px; }
  .totaux { grid-template-columns: repeat(3, 1fr); }
  .totaux > div { display: block; }
  .actions-rapides { display: flex; }
  .chiffres { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .chiffres > div { display: block; }
  .onglets a { flex: 0 0 auto; padding: 10px 12px; font-size: 1rem; }
  .actions, .zone-suppression { max-width: 380px; }
  .zone-suppression { text-align: left; }
  .ligne-devis { grid-template-columns: 3fr 1fr 1fr 2fr; }
  .ligne-devis label:nth-of-type(4) { grid-column: auto; }
}
