/* ============================================================
   Facturation — feuille de style
   Palette et typographie calquees sur le PDF : creme chaud,
   encre presque noire, or pour les accents.
   ============================================================ */

:root {
  --ink:    #181512;
  --soft:   #6b6259;
  --line:   #e2dbd1;
  --bg:     #f4f1ec;
  --card:   #ffffff;
  --gold:   #b3823c;
  --gold-c: #f5ecdd;
  --pale:   #b8b0a5;
  --green:  #3d7a4e;
  --green-c:#e8f2ea;
  --rouge:  #a4342c;
  --rouge-c:#f8eae8;

  --serif: Georgia, "Times New Roman", Times, serif;
  --sans:  "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --r:     14px;
  --r-sm:  9px;
  --ombre: 0 1px 2px rgba(24,21,18,.04), 0 8px 24px rgba(24,21,18,.06);
  --ombre-f: 0 2px 4px rgba(24,21,18,.06), 0 16px 40px rgba(24,21,18,.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ─────────────── mise en page generale ─────────────── */

.app { display: flex; min-height: 100vh; }

.rail {
  width: 236px;
  flex: 0 0 236px;
  background: var(--ink);
  color: #efeae2;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail .marque {
  font-family: var(--serif);
  font-size: 23px;
  letter-spacing: -.01em;
  margin: 0 0 2px 8px;
}
.rail .marque-sous {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--pale);
  margin: 0 0 26px 8px;
}

.rail nav { display: flex; flex-direction: column; gap: 2px; }

.rail a.lien {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: #cfc7bc;
  text-decoration: none;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.rail a.lien:hover { background: rgba(255,255,255,.06); color: #fff; }
.rail a.lien.actif { background: rgba(255,255,255,.10); color: #fff; }
.rail a.lien .ic { width: 17px; text-align: center; opacity: .85; }

.rail .bas { margin-top: auto; }
.rail .bas a {
  font-size: 12.5px;
  color: var(--pale);
  text-decoration: none;
  padding: 8px 12px;
  display: block;
  border-radius: var(--r-sm);
}
.rail .bas a:hover { background: rgba(255,255,255,.06); color: #fff; }

.page {
  flex: 1 1 auto;
  min-width: 0;
  padding: 34px 40px 60px;
  max-width: 1240px;
}

/* ─────────────── titres ─────────────── */

.titre {
  font-family: var(--serif);
  font-size: 33px;
  margin: 0;
  letter-spacing: -.015em;
}
.filet { width: 118px; height: 2px; background: var(--gold); margin: 7px 0 0; border: 0; }
.entete-page { margin-bottom: 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.legende {
  font-size: 10.5px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 700;
  margin: 0 0 12px;
}

/* ─────────────── cartes ─────────────── */

.carte {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--ombre);
  padding: 26px 28px;
  margin-bottom: 20px;
}
.carte.serre { padding: 18px 20px; }

/* ─────────────── tuiles de statistiques ─────────────── */

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tuile {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--ombre);
  padding: 18px 20px;
}
.tuile .lab {
  font-size: 10px; letter-spacing: .15em; text-transform: uppercase;
  color: var(--soft); font-weight: 700; margin: 0 0 8px;
}
.tuile .val { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.tuile .val.or   { color: var(--gold); }
.tuile .val.vert { color: var(--green); }

/* ─────────────── formulaires ─────────────── */

.grille { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

label.champ { display: block; }
label.champ > span {
  display: block;
  font-size: 11.5px;
  color: var(--soft);
  margin-bottom: 5px;
  font-weight: 600;
}

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fdfcfa;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  background: #fff;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179,130,60,.15);
}
input::placeholder, textarea::placeholder { color: #b9b1a6; }
textarea { resize: vertical; min-height: 72px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%236b6259' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

/* ─────────────── boutons ─────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--soft);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { color: var(--gold); border-color: var(--gold); }

.btn.principal {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: 0 1px 2px rgba(24,21,18,.2);
}
.btn.principal:hover { background: #000; border-color: #000; color: #fff; }

.btn.danger:hover { color: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.barre-actions {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}

/* ─────────────── tableaux ─────────────── */

table.liste { width: 100%; border-collapse: collapse; }
table.liste th {
  text-align: left;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 700;
  padding: 0 12px 11px;
  border-bottom: 1px solid var(--line);
}
table.liste td {
  padding: 13px 12px;
  border-bottom: 1px solid #f0ebe4;
  font-size: 14px;
  vertical-align: middle;
}
table.liste tbody tr { transition: background .12s ease; }
table.liste tbody tr:hover { background: #fbf8f4; }
table.liste tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.vide { text-align: center; color: var(--soft); padding: 44px 12px; }
.vide .gros { font-family: var(--serif); font-size: 19px; color: var(--ink); margin-bottom: 6px; }

/* ─────────────── pastilles ─────────────── */

.pastille {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 999px;
}
.pastille.paye    { background: var(--green-c); color: var(--green); }
.pastille.attente { background: var(--gold-c);  color: var(--gold); }
.pastille.devis   { background: #eeeae4; color: var(--soft); }

/* ─────────────── messages ─────────────── */

.note {
  border-radius: var(--r-sm);
  padding: 12px 15px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.note.ok    { background: var(--green-c); color: #2c5b3a; border-color: #cfe4d5; }
.note.err   { background: var(--rouge-c); color: #7e2820; border-color: #efd3cf; }
.note.info  { background: #f1ece4; color: var(--soft); border-color: #e4dcd1; }

/* ─────────────── lignes de services ─────────────── */

.lignes-tete, .ligne-srv {
  display: grid;
  grid-template-columns: minmax(0,3fr) minmax(0,2.4fr) 128px 34px;
  gap: 10px;
  align-items: center;
}
.lignes-tete {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--soft); font-weight: 700; margin-bottom: 8px; padding: 0 2px;
}
.ligne-srv { margin-bottom: 8px; }
.ligne-srv .retirer {
  border: 0; background: none; color: var(--pale); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 6px; border-radius: 6px;
  transition: color .15s ease, background .15s ease;
}
.ligne-srv .retirer:hover { color: var(--rouge); background: var(--rouge-c); }

/* ─────────────── editeur : formulaire + apercu ─────────────── */

.editeur { display: grid; grid-template-columns: minmax(0,1fr) 468px; gap: 24px; align-items: start; }
.colonne-apercu { position: sticky; top: 34px; }

/* Apercu : reproduction fidele du PDF, a l'echelle. */
.apercu {
  background: #efeae2;
  border-radius: var(--r);
  box-shadow: var(--ombre-f);
  padding: 15px;
  overflow: hidden;
}
.feuille {
  position: relative;
  width: 100%;
  aspect-ratio: 612 / 792;
  background: #fff;
  border-radius: 9px;
  box-shadow: 0 2px 10px rgba(24,21,18,.10);
  overflow: hidden;
  container-type: inline-size;
}
/* Tout l'interieur est dimensionne en cqw : 1cqw = 1% de la largeur de la
   feuille. 612 pt de large => 1 pt = 0.16340 cqw. */
.feuille .zone {
  position: absolute;
  inset: 0;
  padding: 11.44cqw 14.38cqw;      /* 70pt / 88pt */
  font-size: 1.72cqw;
  color: var(--ink);
}
.feuille .ap-titre { font-family: var(--serif); font-size: 6.54cqw; line-height: 1; }
.feuille .ap-filet { width: 24.5cqw; height: .33cqw; background: var(--gold); margin-top: .6cqw; }
.feuille .ap-emet { text-align: right; }
.feuille .ap-emet .nom { font-family: var(--serif); font-size: 3.1cqw; }
.feuille .ap-caps {
  font-size: 1.15cqw; letter-spacing: .21em; text-transform: uppercase;
  font-weight: 700; color: var(--soft);
}
.feuille .ap-caps.or { color: var(--gold); }
.feuille .ap-petit { font-size: 1.39cqw; color: var(--soft); line-height: 1.5; }
.feuille .ap-rangee { display: flex; justify-content: space-between; align-items: flex-start; }
.feuille .ap-trait { height: .13cqw; background: var(--line); margin: 1.6cqw 0; }
.feuille .ap-srv { display: flex; justify-content: space-between; align-items: baseline; gap: 2cqw; }
.feuille .ap-srv .d { font-size: 1.72cqw; }
.feuille .ap-mnt { font-weight: 700; font-size: 1.72cqw; white-space: nowrap; }
.feuille .ap-total {
  background: var(--ink); color: #fff; border-radius: 1.15cqw;
  padding: 1.5cqw 2.4cqw; display: flex; justify-content: space-between;
  align-items: center; gap: 2cqw; margin-left: auto; width: 32.7cqw;
}
.feuille .ap-total .lab { font-size: 1.15cqw; letter-spacing: .19em; text-transform: uppercase; color: var(--pale); font-weight: 700; }
.feuille .ap-total .val { font-size: 2.29cqw; font-weight: 700; }
.feuille .ap-pied { position: absolute; left: 0; right: 0; bottom: 7.4cqw; text-align: center; }
.feuille .ap-pied .merci { font-family: var(--serif); font-size: 2.61cqw; }
.feuille .ap-pied .tiret { width: 4.9cqw; height: .2cqw; background: var(--gold); margin: 1.2cqw auto 0; }

.sous-apercu { font-size: 12px; color: var(--soft); text-align: center; margin-top: 11px; }

/* ─────────────── divers ─────────────── */

.rangee-filtres { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.rangee-filtres label.champ { min-width: 168px; }

.connexion {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.connexion .boite { width: 100%; max-width: 384px; }
.connexion .carte { padding: 34px 32px; }
.connexion .titre { font-size: 29px; }

.aide { font-size: 12.5px; color: var(--soft); margin-top: 6px; }

@media (max-width: 1100px) {
  .editeur { grid-template-columns: minmax(0,1fr); }
  .colonne-apercu { position: static; max-width: 468px; }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .rail { width: auto; flex: none; height: auto; position: static; flex-direction: row;
          align-items: center; gap: 6px; padding: 12px 14px; overflow-x: auto; }
  .rail .marque, .rail .marque-sous { display: none; }
  .rail nav { flex-direction: row; }
  .rail .bas { margin: 0 0 0 auto; }
  .page { padding: 22px 18px 48px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0,1fr); }
  .lignes-tete { display: none; }
  .ligne-srv { grid-template-columns: minmax(0,1fr) 34px; }
}

@media print { .rail, .barre-actions { display: none; } }
