/* Facturette — feuille de style de l'application (espace de gestion).
   Même identité que le site vitrine : encre indigo, corail pour l'action, menthe pour « payé ». */
:root {
  --fond: #f5f6fa;
  --surface: #ffffff;
  --encre: #1d2440;
  --texte: #252b42;
  --doux: #6b7290;
  --trait: #e4e7ef;
  --trait-fort: #cfd4e2;
  --corail: #ff6b4a;
  --corail-fonce: #e5532f;
  --corail-pale: #fff0ec;
  --menthe: #1a9c80;
  --menthe-pale: #e4f5f0;
  --ambre: #c27c0e;
  --ambre-pale: #fdf3e1;
  --rouge: #c8362c;
  --rouge-pale: #fcebea;
  --indigo-pale: #eceefb;
  --rayon: 12px;
  --ombre: 0 1px 2px rgba(29, 36, 64, .05), 0 6px 20px -8px rgba(29, 36, 64, .12);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texte);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--corail-fonce); }
h1 { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; color: var(--encre); }
h2 { font-size: 1rem; font-weight: 700; margin: 0 0 1rem; color: var(--encre); }
.sous-titre { color: var(--doux); margin: .25rem 0 0; }

/* ---------- Coque : barre latérale + contenu ---------- */
.coque { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.barre { background: var(--encre); color: #c9cde0; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.marque { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; padding: 4px 8px 20px; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: #fff; position: relative; flex: none; }
.logo::before { content: ""; position: absolute; left: 9px; top: 7px; width: 12px; height: 16px; background: var(--encre); border-radius: 2px; }
.logo::after { content: ""; position: absolute; left: 11px; top: 12px; width: 8px; height: 2px; background: var(--corail); box-shadow: 0 4px 0 var(--corail), 0 8px 0 var(--corail); }
.nouveau { width: 100%; justify-content: center; margin-bottom: 18px; }
.ico-plus { width: 12px; height: 12px; position: relative; }
.ico-plus::before, .ico-plus::after { content: ""; position: absolute; background: currentColor; border-radius: 2px; }
.ico-plus::before { left: 5px; top: 0; width: 2px; height: 12px; }
.ico-plus::after { top: 5px; left: 0; height: 2px; width: 12px; }
.barre nav { display: flex; flex-direction: column; gap: 2px; }
.barre nav a { display: flex; align-items: center; gap: 12px; color: #b6bbd2; text-decoration: none; padding: 10px 12px; border-radius: 9px; font-weight: 550; }
.barre nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.barre nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.barre nav a.active { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 0 var(--corail); }
.barre-pied { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); padding: 16px 8px 0; font-size: .85rem; }
.entreprise { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.entreprise .initiales { width: 34px; height: 34px; border-radius: 50%; background: var(--corail); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; }
.entreprise b { color: #fff; display: block; font-weight: 650; line-height: 1.2; }
.entreprise small { color: #8f95b2; }
.retour { color: #8f95b2; text-decoration: none; }
.retour:hover { color: #fff; }

.contenu { min-width: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 32px 36px 90px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.actions.left { justify-content: flex-start; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--trait-fort); background: var(--surface); color: var(--texte); padding: .58rem 1rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #b4bbcf; background: #fafbfd; }
.btn.primary { background: var(--corail); border-color: var(--corail); color: #fff; box-shadow: 0 6px 16px -8px rgba(255, 107, 74, .8); }
.btn.primary:hover { background: var(--corail-fonce); border-color: var(--corail-fonce); }
.btn.sombre { background: var(--encre); border-color: var(--encre); color: #fff; }
.btn.sombre:hover { background: #2c3558; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: .38rem .75rem; font-size: .88rem; }
.icon { border: 0; background: none; color: var(--doux); cursor: pointer; font-size: 1.05rem; padding: .35rem .5rem; border-radius: 6px; }
.icon:hover { color: var(--rouge); background: var(--rouge-pale); }
.danger-text { color: var(--rouge); }
.muted { color: var(--doux); }
.small { font-size: .85rem; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 22px 24px; margin-bottom: 1.25rem; box-shadow: var(--ombre); }
.card-tete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.card-tete h2 { margin: 0; }
.card-tete a { font-size: .88rem; font-weight: 600; text-decoration: none; }
.callout { background: var(--indigo-pale); border: 1px solid #d5d9f3; padding: 13px 16px; border-radius: var(--rayon); margin-bottom: 1.25rem; color: var(--encre); }
.callout.danger { background: var(--rouge-pale); border-color: #f3c8c4; color: #8f2219; }
.callout.succes { background: var(--menthe-pale); border-color: #bfe6da; color: #0f6b56; }
.empty { text-align: center; color: var(--doux); padding: 52px 20px; background: var(--surface); border: 1px dashed var(--trait-fort); border-radius: var(--rayon); }
.empty b { display: block; color: var(--encre); font-size: 1.05rem; margin-bottom: .3rem; }
.empty .btn { margin-top: 1rem; }

/* ---------- Démarrage ---------- */
.demarrage { display: grid; grid-template-columns: 1fr 1.4fr; gap: 28px; align-items: center; background: linear-gradient(120deg, var(--encre), #333d6b); color: #fff; border: 0; }
.demarrage h2 { color: #fff; font-size: 1.25rem; margin-bottom: .4rem; }
.demarrage p { color: #c9cde0; margin: 0 0 1rem; }
.jauge-demarrage { height: 6px; background: rgba(255, 255, 255, .15); border-radius: 99px; overflow: hidden; }
.jauge-demarrage span { display: block; height: 100%; background: var(--corail); border-radius: 99px; }
.etapes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.etapes li a { display: flex; align-items: center; gap: 14px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); border-radius: 11px; padding: 12px 14px; color: #fff; text-decoration: none; }
.etapes li a:hover { background: rgba(255, 255, 255, .12); }
.etapes .puce { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; }
.etapes li.fait .puce { background: var(--menthe); border-color: var(--menthe); }
.etapes li.fait b { text-decoration: line-through; opacity: .65; }
.etapes small { display: block; color: #aab0cb; }
.etapes .fleche { margin-left: auto; opacity: .6; }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 18px 18px 16px; box-shadow: var(--ombre); display: flex; flex-direction: column; gap: .35rem; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--encre)); }
.kpi .kpi-titre { color: var(--doux); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi strong { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--encre); }
.kpi small { color: var(--doux); }
.kpi.encaisse { --accent: var(--menthe); }
.kpi.attente { --accent: #5b6bd6; }
.kpi.retard { --accent: var(--rouge); }
.kpi.retard.actif strong { color: var(--rouge); }
.kpi.devis { --accent: var(--ambre); }

.grille-tableau { display: grid; grid-template-columns: 1.65fr 1fr; gap: 1.25rem; align-items: start; }

.plafond-chiffre { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .7rem; }
.plafond-chiffre strong { font-size: 2rem; font-weight: 800; color: var(--encre); letter-spacing: -.03em; }
.progress { height: 10px; background: var(--fond); border-radius: 99px; overflow: hidden; margin-bottom: .7rem; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--menthe), #4cc3a6); border-radius: 99px; }
.progress.warn div { background: linear-gradient(90deg, var(--ambre), #e8a33a); }

/* ---------- Onglets et listes ---------- */
.tabs { display: inline-flex; gap: 2px; margin-bottom: 1rem; background: #eceef4; padding: 3px; border-radius: 10px; }
.tab { padding: .42rem .95rem; border-radius: 8px; text-decoration: none; color: var(--doux); font-weight: 600; font-size: .9rem; }
.tab.active { background: var(--surface); color: var(--encre); box-shadow: 0 1px 3px rgba(29, 36, 64, .12); }

table { width: 100%; border-collapse: collapse; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; border-collapse: separate; border-spacing: 0; box-shadow: var(--ombre); }
.card table.list { border: 0; box-shadow: none; border-radius: 0; }
table.list th { text-align: left; font-weight: 650; color: var(--doux); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; padding: 11px 16px; border-bottom: 1px solid var(--trait); background: #fafbfd; }
.card table.list th { background: transparent; padding-left: 0; }
table.list td { padding: 13px 16px; border-bottom: 1px solid var(--trait); }
.card table.list td { padding-left: 0; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tr[data-href] { cursor: pointer; }
table.list tr[data-href]:hover td { background: #f8f9fc; }
.numero { font-weight: 700; color: var(--encre); font-variant-numeric: tabular-nums; }
.client-ligne { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--indigo-pale); color: var(--encre); font-weight: 750; font-size: .74rem; display: grid; place-items: center; flex: none; }

.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 700; padding: .2rem .6rem; border-radius: 99px; background: #eef0f5; color: var(--doux); vertical-align: middle; letter-spacing: .01em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-sent { background: #eceffd; color: #4553c4; }
.badge-paid, .badge-accepted { background: var(--menthe-pale); color: #0f7a62; }
.badge-overdue, .badge-refused { background: var(--rouge-pale); color: var(--rouge); }
.badge-draft { background: var(--ambre-pale); color: var(--ambre); }

/* ---------- Formulaires ---------- */
label { display: flex; flex-direction: column; gap: .35rem; font-size: .84rem; font-weight: 600; color: var(--texte); margin-bottom: 1rem; }
label.check { flex-direction: row; align-items: center; gap: .6rem; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--texte); background: var(--surface); border: 1px solid var(--trait-fort); border-radius: 9px; padding: .58rem .75rem; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--encre); box-shadow: 0 0 0 3px rgba(29, 36, 64, .1); }
textarea { resize: vertical; }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--corail); }
.aide { font-weight: 400; color: var(--doux); font-size: .8rem; }
.row { display: flex; gap: .5rem; align-items: stretch; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form h2:not(:first-child) { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--trait); }
.form .actions { margin-top: .5rem; }

/* ---------- Éditeur avec aperçu ---------- */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 1.5rem; align-items: start; }
.apercu { position: sticky; top: 24px; }
.apercu-titre { display: flex; justify-content: space-between; align-items: center; color: var(--doux); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .6rem; }
.apercu-cadre { height: 600px; overflow: hidden; border-radius: 8px; box-shadow: 0 18px 40px -18px rgba(29, 36, 64, .35); border: 1px solid var(--trait); background: #fff; }
.apercu-cadre .paper { width: 794px; transform: scale(.553); transform-origin: top left; box-shadow: none; margin: 0; }
table.lines { border-collapse: separate; border-spacing: 0; margin-bottom: .75rem; }
table.lines th { text-align: left; font-weight: 650; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--doux); padding: 0 6px 8px; }
table.lines td { padding: 4px 6px; vertical-align: top; }
table.lines td.num { padding-top: 14px; font-weight: 650; }
.w-qty { width: 76px; } .w-price { width: 120px; } .w-vat { width: 84px; } .w-total { width: 110px; } .w-del { width: 40px; }
.totals table td { padding: 6px 0; }
.totals .grand td, .doc-totals .grand td { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--encre); padding-top: 10px; color: var(--encre); }
.mention { font-size: .82rem; color: var(--doux); margin: .5rem 0 0; }

/* ---------- Document A4 (aperçu, consultation, impression) ---------- */
.paper { background: #fff; color: #1b1f30; max-width: 794px; margin: 0 auto; padding: 0 0 48px; box-shadow: 0 18px 50px -20px rgba(29, 36, 64, .3); border-radius: 6px; font-size: 13px; overflow: hidden; }
.doc-bandeau { height: 8px; background: linear-gradient(90deg, var(--encre) 70%, var(--corail) 70%); }
.doc-corps { padding: 44px 56px 0; }
.doc-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 34px; }
.doc-emetteur { display: flex; gap: 14px; }
.doc-mono { width: 46px; height: 46px; border-radius: 10px; background: var(--encre); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; flex: none; }
.doc-seller { font-weight: 800; font-size: 17px; margin-bottom: 3px; color: var(--encre); }
.doc-coord { color: #4d5370; line-height: 1.55; }
.ei { font-size: 10px; font-weight: 700; border: 1px solid #a8adc2; border-radius: 3px; padding: 0 4px; color: #4d5370; margin-left: 4px; vertical-align: 2px; }
.doc-title { text-align: right; }
.doc-title h2 { font-size: 28px; letter-spacing: .14em; margin: 0 0 10px; color: var(--encre); font-weight: 800; }
.doc-meta { border-collapse: collapse; margin-left: auto; }
.doc-meta td { padding: 2px 0 2px 16px; text-align: right; }
.doc-meta td:first-child { color: #7a8098; }
.doc-client { margin-left: auto; width: 48%; background: #f6f7fb; border-radius: 8px; padding: 14px 16px; margin-bottom: 30px; line-height: 1.55; }
.doc-client .label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #7a8098; margin-bottom: 4px; }
.doc-lines th { background: var(--encre); color: #fff; text-align: left; padding: 9px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.doc-lines th:first-child { border-radius: 6px 0 0 6px; }
.doc-lines th:last-child { border-radius: 0 6px 6px 0; }
.doc-lines th.num { text-align: right; }
.doc-lines td { padding: 10px; border-bottom: 1px solid #eceef4; vertical-align: top; }
.doc-totals { display: flex; justify-content: flex-end; margin: 18px 0 26px; }
.doc-totals table { width: 290px; }
.doc-totals td { padding: 5px 10px; }
.doc-totals .grand td { background: #f6f7fb; border-top: 0; }
.doc-notes, .doc-bank { margin-bottom: 16px; padding: 12px 14px; border-left: 3px solid var(--corail); background: #fffaf8; border-radius: 0 6px 6px 0; }
.doc-legal { margin-top: 34px; border-top: 1px solid #e3e5ee; padding-top: 12px; font-size: 10.5px; color: #6a7089; }
.doc-legal p { margin: 2px 0; }
.doc-vide { color: #a0a6bd; font-style: italic; }

/* ---------- Divers ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px); background: var(--encre); color: #fff; padding: 12px 20px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 20; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); font-weight: 550; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--rouge); }

/* ---------- Écrans moyens et téléphones ---------- */
@media (max-width: 1180px) {
  .editeur { grid-template-columns: 1fr; }
  .apercu { position: static; }
  .apercu-cadre { height: auto; overflow: visible; box-shadow: none; border: 0; background: none; }
  .apercu-cadre .paper { transform: none; width: auto; box-shadow: 0 18px 50px -20px rgba(29, 36, 64, .3); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .coque { grid-template-columns: 1fr; }
  .barre { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; }
  .marque { padding: 0 6px 0 0; }
  .marque span:last-child { display: none; }
  .nouveau { width: auto; margin: 0; padding: .5rem .7rem; font-size: 0; gap: 0; }
  .nouveau .ico-plus { color: #fff; }
  .barre nav { flex-direction: row; overflow-x: auto; }
  .barre nav a { padding: 8px 10px; }
  .barre nav a span { display: none; }
  .barre nav a.active { box-shadow: inset 0 -3px 0 var(--corail); }
  .barre-pied { display: none; }
  main { padding: 22px 16px 80px; }
  .grille-tableau, .demarrage { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid2, .grid3, .kpis { grid-template-columns: 1fr; }
  table.list th:nth-child(2), table.list td:nth-child(2) { display: none; }
  .doc-corps { padding: 24px 18px 0; }
  .doc-head { flex-direction: column; gap: 1rem; }
  .doc-title { text-align: left; }
  .doc-meta { margin-left: 0; }
  .doc-meta td { text-align: left; padding: 2px 16px 2px 0; }
  .doc-client { width: 100%; }
  table.lines { display: block; overflow-x: auto; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .coque { display: block; }
  .no-print, .barre, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { box-shadow: none; max-width: none; border-radius: 0; }
  .doc-lines th, .doc-bandeau, .doc-mono { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Finitions : la designation grandit avec le texte ; le fond de la barre descend jusqu'en bas. */
table.lines textarea { field-sizing: content; min-height: 42px; }
@media (min-width: 901px) { .coque { background: linear-gradient(90deg, var(--encre) 248px, transparent 248px); } }
