/* ===========================================================
   Devis & Factures — feuille de style
   Palette : bleu #2a78d6 (identite), statuts dedies, encre neutre
   =========================================================== */

:root {
  color-scheme: light;
  --bleu: #2a78d6;
  --bleu-fonce: #184f95;
  --bleu-clair: #eaf2fd;
  --surface: #ffffff;
  --page: #f6f7fb;
  --encre: #14151a;
  --encre-secondaire: #52545e;
  --encre-muet: #8b8d97;
  --bordure: #e4e5ec;
  --bordure-forte: #cfd1dc;
  --bon: #0ca30c;
  --avertissement: #b9790a;
  --avertissement-fond: #fef3d9;
  --serieux: #c1502a;
  --serieux-fond: #fbe6dd;
  --critique: #d03b3b;
  --critique-fond: #fbe2e2;
  --rayon: 10px;
  --rayon-lg: 14px;
  --ombre: 0 1px 2px rgba(20, 21, 26, 0.04), 0 4px 16px rgba(20, 21, 26, 0.05);
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--encre);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0 0 4px 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 8px 0; }

.mise-en-page {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.barre-laterale {
  background: var(--surface);
  border-right: 1px solid var(--bordure);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px 10px;
}

.logo-app .pastille {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--bleu), var(--bleu-fonce));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.logo-app .titre {
  font-weight: 700;
  font-size: 15px;
  color: var(--encre);
  line-height: 1.2;
}
.logo-app .sous-titre {
  font-size: 11.5px;
  color: var(--encre-muet);
}

.nav-lien {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--encre-secondaire);
  font-size: 14px;
  font-weight: 500;
}
.nav-lien:hover { background: var(--page); color: var(--encre); }
.nav-lien.actif { background: var(--bleu-clair); color: var(--bleu-fonce); }
.nav-lien svg { flex-shrink: 0; width: 18px; height: 18px; }

.nav-section-titre {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--encre-muet);
  padding: 14px 12px 4px 12px;
  font-weight: 650;
}

.barre-laterale .bas {
  margin-top: auto;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--encre-muet);
  border-top: 1px solid var(--bordure);
  padding-top: 14px;
}

/* ---------- Contenu principal ---------- */
.contenu {
  padding: 28px 36px 60px 36px;
  max-width: 1180px;
}

.en-tete-page {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.en-tete-page .fil-ariane {
  font-size: 12.5px;
  color: var(--encre-muet);
  margin-bottom: 6px;
}
.en-tete-page h1 { font-size: 23px; }
.en-tete-page .actions { display: flex; gap: 10px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primaire { background: var(--bleu); color: #fff; }
.btn-primaire:hover { background: var(--bleu-fonce); }
.btn-secondaire { background: var(--surface); color: var(--encre); border-color: var(--bordure-forte); }
.btn-secondaire:hover { background: var(--page); }
.btn-discret { background: transparent; color: var(--encre-secondaire); }
.btn-discret:hover { background: var(--page); }
.btn-danger { background: var(--critique-fond); color: var(--critique); }
.btn-danger:hover { background: #f6cccc; }
.btn-petit { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cartes ---------- */
.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre);
  padding: 22px;
  margin-bottom: 20px;
}
.carte-titre {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Grille de stats (tableau de bord) ---------- */
.grille-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-tuile {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-lg);
  padding: 18px 20px;
  box-shadow: var(--ombre);
}
.stat-tuile .libelle {
  font-size: 12.5px;
  color: var(--encre-muet);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.stat-tuile .valeur {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-tuile .detail {
  font-size: 12.5px;
  color: var(--encre-muet);
  margin-top: 4px;
}
.stat-tuile.accent-bleu .valeur { color: var(--bleu-fonce); }
.stat-tuile.accent-critique .valeur { color: var(--critique); }
.stat-tuile.accent-avertissement .valeur { color: var(--avertissement); }
.stat-tuile.accent-bon .valeur { color: var(--bon); }

/* ---------- Graphique barres (SVG) ---------- */
.graphique-barres { width: 100%; overflow: visible; }
.graphique-barres .barre { fill: var(--bleu); }
.graphique-barres .barre:hover { fill: var(--bleu-fonce); }
.graphique-barres .grille { stroke: var(--bordure); stroke-width: 1; }
.graphique-barres .axe-libelle { fill: var(--encre-muet); font-size: 10.5px; font-family: system-ui, sans-serif; }
.graphique-barres .valeur-libelle { fill: var(--encre-secondaire); font-size: 10px; font-family: system-ui, sans-serif; font-weight: 600; }
.groupe-barre { cursor: default; }
.groupe-barre .valeur-libelle { opacity: 0; transition: opacity 0.1s ease; }
.groupe-barre:hover .valeur-libelle { opacity: 1; }
.groupe-barre:hover .barre { fill: var(--bleu-fonce); }

/* ---------- Tableaux ---------- */
table.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.tableau th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--encre-muet);
  font-weight: 650;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bordure);
}
table.tableau td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--bordure);
  vertical-align: middle;
}
table.tableau tbody tr:hover { background: var(--page); }
table.tableau td.num, table.tableau th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tableau a.lien-ligne { display: block; }
.tableau-vide {
  padding: 50px 20px;
  text-align: center;
  color: var(--encre-muet);
}
.tableau-vide .btn { margin-top: 14px; }

/* ---------- Badges de statut ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-neutre { background: #eef0f4; color: var(--encre-secondaire); }
.badge-bleu { background: var(--bleu-clair); color: var(--bleu-fonce); }
.badge-bon { background: #e2f6e2; color: var(--bon); }
.badge-avertissement { background: var(--avertissement-fond); color: var(--avertissement); }
.badge-serieux { background: var(--serieux-fond); color: var(--serieux); }
.badge-critique { background: var(--critique-fond); color: var(--critique); }

/* ---------- Formulaires ---------- */
.grille-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grille-form.col-3 { grid-template-columns: repeat(3, 1fr); }
.champ { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.champ.pleine-largeur { grid-column: 1 / -1; }
.champ label { font-size: 13px; font-weight: 600; color: var(--encre-secondaire); }
.champ .aide { font-size: 12px; color: var(--encre-muet); }

input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=password], input[type=url], select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--bordure-forte);
  border-radius: 8px;
  background: var(--surface);
  color: var(--encre);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--bleu);
  box-shadow: 0 0 0 3px var(--bleu-clair);
}
textarea { resize: vertical; min-height: 70px; }

.case-cocher { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.case-cocher input { width: 16px; height: 16px; }

fieldset { border: none; padding: 0; margin: 0 0 20px 0; }
legend { font-size: 14px; font-weight: 650; margin-bottom: 10px; padding: 0; }

/* ---------- Table de lignes de devis/facture ---------- */
table.table-lignes { width: 100%; border-collapse: collapse; }
table.table-lignes th {
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--encre-muet);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--bordure);
}
table.table-lignes td { padding: 6px; vertical-align: top; }
table.table-lignes input, table.table-lignes select { padding: 7px 9px; font-size: 13.5px; }
table.table-lignes .col-designation { width: 34%; }
table.table-lignes .col-qte { width: 8%; }
table.table-lignes .col-prix { width: 13%; }
table.table-lignes .col-tva { width: 9%; }
table.table-lignes .col-remise { width: 9%; }
table.table-lignes .col-total { width: 13%; text-align: right; font-variant-numeric: tabular-nums; padding-top: 12px; font-weight: 600; }
table.table-lignes .col-suppr { width: 5%; text-align: center; }
.btn-suppr-ligne {
  background: none; border: none; cursor: pointer; color: var(--encre-muet);
  padding: 6px; border-radius: 6px;
}
.btn-suppr-ligne:hover { background: var(--critique-fond); color: var(--critique); }

.recap-totaux {
  margin-left: auto;
  width: 280px;
  margin-top: 14px;
}
.recap-totaux .ligne { display: flex; justify-content: space-between; padding: 6px 4px; font-size: 14px; color: var(--encre-secondaire); }
.recap-totaux .ligne.total {
  font-size: 18px; font-weight: 700; color: var(--bleu-fonce);
  border-top: 1px solid var(--bordure); margin-top: 4px; padding-top: 10px;
}

/* ---------- Messages flash ---------- */
.flash-liste { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  border: 1px solid transparent;
}
.flash-success { background: #e2f6e2; color: #0a6e0a; border-color: #bfe8bf; }
.flash-error { background: var(--critique-fond); color: var(--critique); border-color: #f2b9b9; }

/* ---------- Document PDF (page detail) ---------- */
.entete-document {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.bloc-client {
  background: var(--page);
  border-radius: var(--rayon);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
}
.bloc-client .titre-bloc {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--encre-muet); font-weight: 650; margin-bottom: 6px;
}

.details-cles { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 18px 0; }
.details-cles .item .libelle { font-size: 11.5px; color: var(--encre-muet); text-transform: uppercase; letter-spacing: 0.03em; }
.details-cles .item .val { font-size: 14.5px; font-weight: 600; }

.liste-paiements { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.ligne-paiement {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; background: var(--page); border-radius: 8px; font-size: 13.5px;
}

.onglets-statut { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

.select-statut-inline { display: flex; gap: 8px; align-items: center; }
.select-statut-inline select { width: auto; }

/* ---------- Divers ---------- */
.muet { color: var(--encre-muet); }
.centre { text-align: center; }
hr.separateur { border: none; border-top: 1px solid var(--bordure); margin: 20px 0; }
.grille-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.liste-simple { display: flex; flex-direction: column; }
.liste-simple .item-ligne {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--bordure); font-size: 13.5px;
}
.liste-simple .item-ligne:last-child { border-bottom: none; }
.pastille-logo-mini {
  width: 30px; height: 30px; border-radius: 8px; object-fit: contain;
  background: var(--page); border: 1px solid var(--bordure);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .mise-en-page { grid-template-columns: 1fr; }
  .barre-laterale {
    position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 12px 14px; gap: 2px;
  }
  .barre-laterale .bas { display: none; }
  .nav-section-titre { display: none; }
  .logo-app { padding: 0 10px 0 0; }
  .contenu { padding: 20px; }
  .grille-stats { grid-template-columns: repeat(2, 1fr); }
  .grille-form, .grille-form.col-3 { grid-template-columns: 1fr; }
  .grille-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grille-stats { grid-template-columns: 1fr; }
}
