/* ============================================================
   FEYS DIGITAL SERVICES — interface de gestion des devis
   Feuille dérivée de template-page-fds.html : mêmes variables,
   mêmes composants, plus ce qu'il faut pour les écrans de gestion.
   ============================================================ */
:root {
  --navy:    #213455;
  --or:      #BB8142;
  --ardoise: #5D6E8C;
  --sable:   #E3E0D6;
  --creme:   #F3F2ED;
  --blanc:   #FFFFFF;
  --encre:   #2B2B2B;
  --navy-clair: #9FAEC6;
  --rouge:   #9C3B2E;
  --vert:    #3F6B4A;

  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans:  'Public Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --mono:  ui-monospace, 'Cascadia Code', Consolas, monospace;

  --r:  6px;
  --r-l: 100px;
  --gap: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--creme);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 32px 28px 70px; }

/* ---------- En-tête ---------- */
.page-header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border-bottom: 2px solid var(--or); padding-bottom: 18px; margin-bottom: 12px;
}
.page-header img { width: 56px; height: 56px; border-radius: var(--r); display: block; }
.page-header-texte { flex: 1 1 auto; min-width: 200px; }
.kicker { font-size: 11px; letter-spacing: .14em; color: var(--or); font-weight: 600; }
.page-header h1 { font-family: var(--serif); font-size: 27px; font-weight: 600; margin: 3px 0 0; }
.deconnexion { display: flex; align-items: center; gap: 12px; margin: 0; }

nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 26px; }
nav a {
  font-size: 13px; color: var(--navy); text-decoration: none; background: var(--blanc);
  border: 1px solid var(--sable); border-radius: var(--r-l); padding: 7px 15px;
}
nav a:hover { border-color: var(--or); color: var(--or); }
nav a.actif { background: var(--navy); color: var(--creme); border-color: var(--navy); }

/* ---------- Texte ---------- */
h2 { font-family: var(--serif); font-size: 23px; font-weight: 600; margin: 0 0 6px; }
h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ardoise);
     font-weight: 600; margin: 22px 0 10px; }
.lead { color: var(--ardoise); font-size: 14px; margin: 0 0 22px; max-width: 70ch; }
p { margin: 0 0 14px; }
a { color: var(--or); }
a:hover { color: #9C6A32; }
code { background: var(--sable); padding: 1px 6px; border-radius: 3px; font-family: var(--mono); font-size: .86em; }
strong, b { font-weight: 600; }
small, .muted { color: var(--ardoise); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.tronque { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.libelle { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ardoise); font-weight: 600; margin-bottom: 6px; }
.client-nom { font-size: 17px; font-weight: 600; }

/* ---------- Cartes ---------- */
.card { background: var(--blanc); border: 1px solid var(--sable); border-radius: 8px; padding: 22px 24px; margin-bottom: var(--gap); }
.card.vide { color: var(--ardoise); text-align: center; padding: 40px 24px; }
.card.zone-danger { border-color: #E8D5CF; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--gap); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }
.grid-form { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
.callout { background: var(--sable); border-radius: var(--r); padding: 14px 18px; font-size: 13px; line-height: 1.6; margin: 0 0 16px; }

/* ---------- Étiquettes ---------- */
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
       padding: 3px 10px; border-radius: var(--r-l); background: var(--sable); color: var(--navy); text-decoration: none; white-space: nowrap; }
.tag.or { background: var(--or); color: var(--navy); }
.tag.navy { background: var(--navy); color: var(--creme); }
a.tag:hover { border-color: var(--or); color: var(--or); }
a.tag.navy:hover { color: var(--creme); }
.tag.statut-brouillon { background: var(--sable); color: var(--ardoise); }
.tag.statut-envoye { background: #DCE4F0; color: var(--navy); }
.tag.statut-accepte { background: #DCE9DE; color: var(--vert); }
.tag.statut-refuse { background: #F0DCD8; color: var(--rouge); }
.tag.statut-expire { background: var(--creme); color: var(--ardoise); border: 1px solid var(--sable); }
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.etiquettes { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: var(--blanc); border: 1px solid var(--sable); border-radius: 8px; overflow: hidden; }
thead th {
  background: var(--navy); color: var(--creme); text-align: left; font-weight: 600;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 11px 14px;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--sable); font-size: 14px; vertical-align: top; }
tbody tr:nth-child(even) { background: var(--creme); }
tbody tr:last-child td { border-bottom: none; }
tr.total td { background: var(--navy); color: var(--creme); font-weight: 600; font-size: 15px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
tbody td a { color: var(--navy); text-decoration: none; }
tbody td a:hover { color: var(--or); }

table.reperes { border: none; background: transparent; }
table.reperes th { background: transparent; color: var(--ardoise); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 14px; padding: 5px 14px 5px 0; white-space: nowrap; }
table.reperes td { text-align: right; font-weight: 600; padding: 5px 0; border: none; background: transparent; font-variant-numeric: tabular-nums; }
table.reperes tr:nth-child(even) { background: transparent; }

/* ---------- Chiffres ---------- */
.stat { font-family: var(--serif); font-size: 38px; font-weight: 600; color: var(--navy); line-height: 1.1; }
.stat-label { color: var(--ardoise); font-size: 13px; }

/* ---------- Boutons ---------- */
button, .btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--navy); color: var(--creme); border: 1px solid var(--navy); border-radius: 5px;
  padding: 9px 16px; white-space: nowrap; text-decoration: none; display: inline-block; line-height: 1.3; text-align: center;
}
button:hover, .btn:hover { background: #2C4570; color: var(--creme); }
button.done, .btn.done { background: var(--or); border-color: var(--or); color: var(--navy); }
button.done:hover, .btn.done:hover { background: #CE9450; color: var(--navy); }
button.ghost, .btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--sable); }
button.ghost:hover, .btn.ghost:hover { background: var(--blanc); border-color: var(--or); color: var(--or); }
button.danger, .btn.danger { color: var(--rouge); }
button.danger:hover { border-color: var(--rouge); color: var(--rouge); }
.btn.petit, button.petit { font-size: 12px; padding: 6px 12px; }
.btn.desactive { opacity: .5; cursor: not-allowed; }
button:disabled, button.attente { opacity: .6; cursor: wait; }
button.icone { padding: 3px 7px; font-size: 14px; line-height: 1; background: transparent; color: var(--ardoise); border: 1px solid transparent; }
button.icone:hover { border-color: var(--sable); background: var(--blanc); color: var(--navy); }
button.icone.danger:hover { color: var(--rouge); }
.boutons { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.boutons form { margin: 0; }
.barre-outils { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.recherche { display: flex; gap: 8px; margin: 0; flex: 1 1 320px; max-width: 560px; }
.recherche input, .recherche select { width: auto; flex: 1 1 auto; }
.ligne-form { display: flex; gap: 8px; align-items: center; }
.ligne-form select, .ligne-form input { flex: 1 1 auto; width: auto; min-width: 0; }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ardoise); }
input, select, textarea {
  font-family: var(--sans); font-size: 14px; color: var(--navy);
  background: var(--blanc); border: 1px solid var(--sable);
  border-radius: 5px; padding: 8px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--or); box-shadow: 0 0 0 3px rgba(187,129,66,.15);
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"] { width: auto; }
.case-a-cocher { display: flex; gap: 8px; align-items: center; font-size: 14px; }

/* ---------- Formulaire de devis ---------- */
.grid-devis { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--gap); align-items: start; }
.colonne-totaux { position: sticky; top: 16px; }
.totaux-card .stat { font-size: 32px; }
table.lignes { table-layout: fixed; min-width: 740px; }
table.lignes th.col-qte { width: 66px; }
table.lignes th.col-unite { width: 86px; }
table.lignes th.col-pu { width: 102px; }
table.lignes th.col-tva { width: 80px; }
table.lignes th.col-total { width: 98px; }
table.lignes th.col-actions { width: 44px; }
table.lignes thead th { padding: 9px 8px; }
table.lignes tbody td { padding: 8px 6px; }
table.lignes tbody tr:nth-child(even) { background: var(--blanc); }
table.lignes input, table.lignes select, table.lignes textarea { padding: 6px 8px; font-size: 13.5px; }
table.lignes textarea.detail { margin-top: 5px; min-height: 40px; font-size: 12.5px; color: var(--ardoise); }
table.lignes input.num { text-align: right; }
table.lignes input, table.lignes select, table.lignes textarea { width: 100%; min-width: 0; }
table.lignes td.total-ligne { font-weight: 600; padding-top: 14px; }
td.actions-ligne { padding: 8px 2px; }
td.actions-ligne button { display: block; margin: 0 auto 2px; }

/* ---------- Fiche ---------- */
.fiche .card { margin-bottom: 0; }
.liste-simple { list-style: none; margin: 0; padding: 0; }
.liste-simple li { padding: 8px 0; border-bottom: 1px solid var(--sable); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.liste-simple li:last-child { border-bottom: none; }
.liste-simple a { color: var(--navy); text-decoration: none; }

/* ---------- Retours à la ligne respectés ---------- */
.prelignes { white-space: pre-line; }

/* ---------- Modale de confirmation ---------- */
dialog.confirmation {
  border: 1px solid var(--sable); border-radius: 8px; background: var(--blanc); color: var(--navy);
  padding: 26px 28px; width: min(440px, calc(100vw - 32px)); font-family: var(--sans);
}
dialog.confirmation::backdrop { background: rgba(33, 52, 85, .45); }
dialog.confirmation form { margin: 0; }
dialog.confirmation .confirmation-texte { font-size: 16px; margin: 8px 0 20px; }
dialog.confirmation .boutons { justify-content: flex-end; }
button.danger-plein { background: var(--rouge); border-color: var(--rouge); color: var(--blanc); }
button.danger-plein:hover { background: #7E2F24; border-color: #7E2F24; color: var(--blanc); }

/* ---------- Messages ---------- */
.flash { border-radius: var(--r); padding: 12px 18px; font-size: 14px; margin: 0 0 18px; transition: opacity .4s ease; }
.flash-ok { background: #DCE9DE; color: var(--vert); }
.flash-erreur { background: #F0DCD8; color: var(--rouge); }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash.efface { opacity: 0; }

/* ---------- Connexion ---------- */
.login { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; padding: 34px 36px; }
.login-logo { width: 64px; height: 64px; display: block; margin-bottom: 18px; }
.login-card h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; margin: 4px 0 6px; }
.login-card button { width: 100%; margin-top: 6px; }

/* ---------- Pied ---------- */
.page-footer { margin-top: 50px; padding-top: 16px; border-top: 1px solid var(--sable); font-size: 12px; color: var(--ardoise); }

@media (max-width: 900px) {
  .grid-devis { grid-template-columns: minmax(0, 1fr); }
  .colonne-totaux { position: static; }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 20px 14px 50px; }
  .tronque { max-width: 160px; }
}
