:root {
  --bleu: #00a6de;
  --bleu-fonce: #0087b5;
  --bleu-clair: #e8f7fd;
  --encre: #1e2d3d;
  --gris: #64748b;
  --trait: #dfe7ee;
  --fond: #f4f7fa;
  --carte: #ffffff;
  --rouge: #c0392b;
  --vert: #1e8e5a;
  --orange: #b7791f;
  --rayon: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--encre);
  background: var(--fond);
}
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); }
a { color: var(--bleu-fonce); }

/* ── Barre du haut ── */
.barre {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.5rem; background: var(--encre); color: #fff;
}
.marque { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: inherit; text-decoration: none; }
.marque.grande { font-size: 1.4rem; justify-content: center; margin-bottom: 1rem; }
.pastille { width: 14px; height: 14px; border-radius: 4px; background: var(--bleu); }
.barre nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.barre nav a { color: #cfd8e3; text-decoration: none; padding: .35rem .75rem; border-radius: 6px; }
.barre nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.barre nav a.actif { color: #fff; background: rgba(0,166,222,.35); }

/* ── Mise en page ── */
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.page.large { max-width: 1400px; }
.page.etroite { max-width: 380px; padding-top: 12vh; }
.entete-page { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.carte.vide { text-align: center; padding: 3rem 1rem; color: var(--gris); }
.aide { color: var(--gris); margin: -.4rem 0 1rem; font-size: .9rem; }
.flash { background: var(--bleu-clair); border: 1px solid #b6e4f6; padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; }

/* ── Boutons et champs ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--trait);
  background: #fff; color: var(--encre); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--bleu); color: var(--bleu-fonce); }
.btn.principal { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.principal:hover { background: var(--bleu-fonce); color: #fff; }
.btn.petit { padding: .3rem .65rem; font-size: .85rem; }
.btn.danger:hover { border-color: var(--rouge); color: var(--rouge); }
.btn.icone { padding: .25rem .5rem; font-size: .85rem; color: var(--gris); border-color: transparent; background: transparent; }
.btn.icone:hover { color: var(--rouge); background: #fdf1f0; }
.lien { color: var(--gris); }

input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: .45rem .6rem; border: 1px solid var(--trait); border-radius: 7px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0,166,222,.35); border-color: var(--bleu); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--gris); }
label input, label select, label textarea { font-weight: 400; color: var(--encre); font-size: .95rem; }
label.plein { margin-bottom: .8rem; }
label.court { max-width: 320px; }
.champs { display: grid; gap: .8rem; margin-bottom: .8rem; }
.champs.trois { grid-template-columns: repeat(3, 1fr); }
.champs.quatre { grid-template-columns: repeat(4, 1fr); }
.pct, .euro { position: relative; display: block; }
.pct::after, .euro::after { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); color: var(--gris); pointer-events: none; font-weight: 400; }
.pct::after { content: "%"; }
.euro::after { content: "€"; }
.pct input, .euro input { padding-right: 1.6rem; }

/* ── Liste des devis ── */
.chiffres { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.chiffre {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: .8rem 1rem; text-decoration: none; color: inherit; border-top: 3px solid var(--c);
}
.chiffre.choisi { outline: 2px solid var(--c); }
.chiffre .libelle { font-size: .8rem; color: var(--gris); }
.chiffre .valeur { font-size: 1.6rem; font-weight: 700; }
.chiffre .montant { font-size: .85rem; color: var(--gris); }
.statut-brouillon { --c: #94a3b8; }
.statut-envoyé { --c: var(--bleu); }
.statut-accepté { --c: var(--vert); }
.statut-refusé { --c: var(--rouge); }

.recherche { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.recherche input { max-width: 460px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); padding: .5rem; border-bottom: 1px solid var(--trait); }
td { padding: .5rem; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.centre { text-align: center; }
.nowrap { white-space: nowrap; }
.actions { display: inline-flex; gap: .3rem; }
.liste td.projet { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gris); }
.liste td a { text-decoration: none; }
.tableau-defilant { overflow-x: auto; }
.carte.tableau-defilant { padding: .4rem .8rem; }

select.badge {
  width: auto; padding: .2rem 1.6rem .2rem .6rem; font-size: .82rem; font-weight: 600; border-radius: 999px;
  color: var(--c); border-color: var(--c); background-color: #fff; cursor: pointer;
}

/* ── Éditeur ── */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.2rem; align-items: start; }
.colonne-totaux { position: sticky; top: 1rem; }
.entete-section { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.nom-section { font-weight: 700; font-size: 1.05rem; border-color: transparent; background: var(--bleu-clair); }
.total-section { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lignes td { padding: .3rem; }
table.lignes th:nth-child(2) { width: 64px; }
table.lignes th:nth-child(3) { width: 100px; }
table.lignes th:nth-child(4) { width: 110px; }
table.lignes th:nth-child(5) { width: 132px; }
table.lignes th:nth-child(6) { width: 104px; }
table.lignes th:nth-child(7) { width: 36px; }
table.lignes input.quantite { text-align: center; }
table.lignes input.prix { text-align: right; }
table.lignes select { padding-left: .35rem; padding-right: .2rem; }
td.montant { font-weight: 600; white-space: nowrap; }
.ligne-producteur td { color: var(--gris); font-style: italic; background: #fafcfd; }
.pied-section { display: flex; gap: .6rem; margin-top: .6rem; align-items: center; }
.pied-section select { max-width: 360px; }
.ajout-section { display: flex; gap: .6rem; margin-bottom: 1rem; }
.ajout-section input { max-width: 320px; }

.totaux dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem .8rem; margin: 0 0 1rem; font-variant-numeric: tabular-nums; }
.totaux dt { color: var(--gris); }
.totaux dd { margin: 0; text-align: right; }
.totaux .fort { font-weight: 700; color: var(--encre); border-top: 1px solid var(--trait); padding-top: .35rem; }
.totaux .grand { font-size: 1.2rem; color: var(--bleu-fonce); }
.boutons { display: flex; flex-direction: column; gap: .5rem; }
.boutons.secondaires { flex-direction: row; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--trait); }
.etat { min-height: 1.2em; font-size: .85rem; margin: .6rem 0 0; color: var(--gris); }
.etat.ok { color: var(--vert); }
.etat.attente { color: var(--orange); }
.etat.erreur { color: var(--rouge); font-weight: 600; }

/* ── Clients et tarifs ── */
.grille-form { display: grid; gap: .5rem; align-items: center; padding: .3rem 0; }
.grille-form.entetes { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); font-weight: 600; }
.grille-form.ajout { border-top: 1px dashed var(--trait); margin-top: .5rem; padding-top: .8rem; }
.clients-grille { grid-template-columns: 1.3fr 1.5fr 1.2fr 1.2fr 1fr auto; }
.tarifs-grille { grid-template-columns: 2.4fr 120px 140px 1.4fr auto; }

.connexion { display: flex; flex-direction: column; gap: 1rem; padding: 2rem; }

/* ── Petits écrans ── */
@media (max-width: 960px) {
  .editeur { grid-template-columns: 1fr; }
  .colonne-totaux { position: static; }
  .champs.quatre { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .page { padding: 1rem; }
  .chiffres { grid-template-columns: repeat(2, 1fr); }
  .champs.trois, .champs.quatre { grid-template-columns: 1fr; }
  .clients-grille, .tarifs-grille { grid-template-columns: 1fr; padding: .8rem 0; border-bottom: 1px solid var(--trait); }
  .grille-form.entetes { display: none; }
  .pied-section, .ajout-section, .recherche { flex-wrap: wrap; }
}

/* ── Réglages ── */
.reglages { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ligne-couleur { display: flex; align-items: center; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid #eef2f6; }
.ligne-couleur input[type="color"] { width: 46px; height: 34px; padding: 2px; flex: none; cursor: pointer; }
.libelle-couleur { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: .5rem; color: var(--encre); font-weight: 500; font-size: .92rem; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; color: var(--gris); }
.modifie { font-size: .72rem; color: var(--orange); background: #fdf6e9; padding: 0 .4rem; border-radius: 99px; }
#form-presentation .pied-section { margin-top: 1rem; flex-wrap: wrap; }
table.apercu { border-collapse: collapse; color: var(--a-texte); }
table.apercu td { padding: .45em .5em; border: 0; }
.apercu td.num, .apercu td.centre { white-space: nowrap; }
.apercu .a-entete td { font-size: .85em; }
.colle { overflow-x: auto; }
table.apercu.avec-traits td { border: 1px solid #d0e8f5; }
.apercu .a-entete td { background: var(--a-entete); color: var(--a-entete-texte); font-weight: 700; }
.apercu .a-section td { background: var(--a-section); color: var(--a-section-texte); font-weight: 700; }
.apercu .a-total td { background: var(--a-total); color: var(--a-total-texte); font-weight: 700; }
.apercu .a-claire td { background: var(--a-ligne-claire); }
.colle { position: sticky; top: 1rem; }
.champs.deux { grid-template-columns: repeat(2, 1fr); }
label.case { flex-direction: row; align-items: center; gap: .5rem; color: var(--encre); font-weight: 500; font-size: .92rem; }
label.case input { width: auto; }
h2.espace { margin-top: 1.4rem; }
input.large { max-width: 520px; }
.logo-zone { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.logo-cadre { width: 220px; height: 110px; border: 1px dashed var(--trait); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: .5rem; background: #fff; }
.logo-cadre img { max-width: 100%; max-height: 100%; }
@media (max-width: 1000px) { .reglages { grid-template-columns: 1fr; } .colle { position: static; } }
.petit-lien { display: block; font-size: .85rem; margin-top: .6rem; }
