:root {
  --noir: #14161a;
  --noir-2: #1d2026;
  --texte: #1a1d21;
  --gris: #6b7280;
  --bord: #e5e7eb;
  --fond: #f5f6f8;
  --blanc: #ffffff;
  --accent: #e8730c;
  --accent-fonce: #c75f05;
  --rouge: #c0392b;
  --vert: #1e8e4f;
  --rayon: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--texte);
  background: var(--fond);
  font-size: 15px;
  line-height: 1.5;
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0; }
.cache { display: none !important; }
.petit { font-size: 13px; color: var(--gris); }

/* Écrans centrés */
.ecran-centre {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.carte {
  background: var(--blanc);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 22px;
}
.carte-auth { width: 100%; max-width: 380px; }
.carte-large { width: 100%; max-width: 460px; }
.sous-titre { color: var(--gris); margin-bottom: 18px; }

/* Logo */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 20px; }
.logo-carre { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: inline-block; }
.logo-clair { color: var(--blanc); }

/* Onglets */
.onglets { display: flex; background: var(--fond); border-radius: 8px; padding: 4px; margin-bottom: 18px; }
.onglet {
  flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 6px;
  font: inherit; font-weight: 500; color: var(--gris); cursor: pointer;
}
.onglet.actif { background: var(--blanc); color: var(--texte); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Formulaires */
form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
label small { font-weight: 400; color: var(--gris); }
input, select {
  font: inherit; padding: 11px 12px; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--blanc); color: var(--texte); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 12px 16px; cursor: pointer;
}
.btn-principal { background: var(--accent); color: var(--blanc); }
.btn-principal:hover { background: var(--accent-fonce); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-fantome { background: transparent; color: #c9ccd2; border: 1px solid #3a3e46; width: 100%; }
.btn-fantome:hover { color: var(--blanc); border-color: #5a5f69; }
.lien { background: none; border: 0; color: var(--gris); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }

.message { margin-top: 14px; font-size: 14px; min-height: 1em; }
.message.erreur { color: var(--rouge); }
.message.ok { color: var(--vert); }

/* Chargement */
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--bord); border-top-color: var(--accent);
  border-radius: 50%; animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* Application */
#vue-app { display: flex; min-height: 100vh; }
.barre {
  width: 230px; background: var(--noir); color: #c9ccd2; padding: 20px 14px;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.barre nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lien-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 7px; color: #c9ccd2; text-decoration: none; cursor: pointer;
}
.lien-nav:hover { background: var(--noir-2); color: var(--blanc); }
.lien-nav.actif { background: var(--noir-2); color: var(--blanc); box-shadow: inset 3px 0 0 var(--accent); }
.lien-nav.bientot { opacity: .5; cursor: default; }
.lien-nav.bientot:hover { background: transparent; color: #c9ccd2; }
.lien-nav em { font-style: normal; font-size: 11px; }
.pied-barre { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid #2a2e35; padding-top: 14px; }
.pied-barre .petit { color: #8b9099; word-break: break-all; }

.contenu { flex: 1; padding: 28px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.entete { display: flex; justify-content: space-between; align-items: flex-end; }
.grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat .chiffre { font-size: 26px; font-weight: 700; margin-top: 4px; }

/* Téléphone */
@media (max-width: 760px) {
  #vue-app { flex-direction: column; }
  .barre { width: 100%; padding: 14px 16px; }
  .barre .logo { margin-bottom: 12px; }
  .barre nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .lien-nav { white-space: nowrap; }
  .lien-nav em { display: none; }
  .pied-barre { flex-direction: row; align-items: center; margin-top: 12px; }
  .pied-barre .btn-fantome { width: auto; padding: 8px 12px; }
  .contenu { padding: 16px; }
  .grille { grid-template-columns: 1fr; }
}

/* Pages */
.page { display: flex; flex-direction: column; gap: 16px; }
.entete { gap: 12px; flex-wrap: wrap; }
.contenu a { color: var(--accent-fonce); }
.lien-nav { color: #c9ccd2 !important; }
.recherche { max-width: 460px; }
.vide { color: var(--gris); text-align: center; padding: 28px 16px; }
.sans-marge { padding: 0; overflow: hidden; }

/* Listes */
table.liste { width: 100%; border-collapse: collapse; }
.liste th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--gris); padding: 11px 16px; border-bottom: 1px solid var(--bord); background: #fafafb;
}
.liste td { padding: 12px 16px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.liste tbody tr:last-child td { border-bottom: 0; }
.liste tbody tr[data-id] { cursor: pointer; }
.liste tbody tr[data-id]:hover { background: #fafafb; }
.liste .d { text-align: right; white-space: nowrap; }
.liste tr.inactif td { color: var(--gris); }
.groupe .titre-groupe { padding: 14px 16px 10px; margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: baseline; }

.etiquette {
  display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
  background: var(--fond); color: var(--gris); border: 1px solid var(--bord);
}
.etiquette.pro { background: #fff3e8; color: var(--accent-fonce); border-color: #fbd9b8; }

/* Boutons supplémentaires */
.btn-secondaire { background: var(--blanc); color: var(--texte); border: 1px solid var(--bord); }
.btn-secondaire:hover { background: var(--fond); }
.btn-danger { background: transparent; color: var(--rouge); border: 1px solid #f0c9c4; }
.btn-danger:hover { background: #fdf1ef; }

/* Fenêtres */
dialog.modale {
  border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 20px 50px rgba(0,0,0,.25); color: var(--texte);
}
dialog.modale::backdrop { background: rgba(20,22,26,.45); }
dialog.modale form { gap: 0; }
.modale-entete { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--bord); }
.modale-entete h2 { margin: 0; }
.fermer { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--gris); cursor: pointer; padding: 0 4px; }
.modale-corps { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: calc(100vh - 170px); }
.modale-pied { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--bord); background: #fafafb; }
.espace { flex: 1; }
.ligne { display: flex; gap: 12px; }
.ligne > label { flex: 1; min-width: 0; }
.ligne > label.etroit { flex: 0 0 120px; }
textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--bord); border-radius: 8px; resize: vertical; width: 100%; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.choix-type { display: flex; gap: 10px; }
.radio, .case { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.radio { border: 1px solid var(--bord); border-radius: 8px; padding: 9px 14px; flex: 1; }
.radio input, .case input { width: auto; margin: 0; accent-color: var(--accent); }
.champ-pro { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 760px) {
  .entete .btn-principal { width: 100%; }
  .recherche { max-width: none; }
  .ligne { flex-direction: column; }
  .ligne > label.etroit { flex: 1; }
  /* Listes en cartes sur téléphone */
  .liste thead { display: none; }
  .liste, .liste tbody, .liste tr, .liste td { display: block; width: 100%; }
  .liste tr { padding: 10px 14px; border-bottom: 1px solid var(--bord); }
  .liste tbody tr:last-child { border-bottom: 0; }
  .liste td { border: 0; padding: 2px 0; text-align: left !important; }
  .liste td:empty { display: none; }
  .liste td[data-libelle="Prix HT"]::before, .liste td[data-libelle="TVA"]::before, .liste td[data-libelle="Unité"]::before {
    content: attr(data-libelle) " : "; color: var(--gris);
  }
  .modale-pied { flex-wrap: wrap; }
}

/* Corrections */
.lien-nav:focus { outline: none; }
.lien-nav:focus-visible { outline: 2px solid var(--accent); }
a.btn { text-decoration: none; display: inline-block; }
.contenu a.btn-principal { color: var(--blanc); }

/* Étiquettes de statut */
.etiquette.bleu { background: #eaf2fd; color: #2563c9; border-color: #c8dbf6; }
.etiquette.orange { background: #fff3e8; color: var(--accent-fonce); border-color: #fbd9b8; }
.etiquette.vert { background: #e8f6ee; color: var(--vert); border-color: #c4e6d2; }
.etiquette.rouge { background: #fdf1ef; color: var(--rouge); border-color: #f0c9c4; }
h1 .etiquette { vertical-align: middle; margin-left: 6px; font-size: 13px; }

/* Liste des devis */
.barre-filtres { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; }
.filtre {
  font: inherit; font-size: 14px; padding: 7px 13px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--blanc); color: var(--gris);
}
.filtre.actif { background: var(--noir); color: var(--blanc); border-color: var(--noir); }
.barre-filtres .recherche { flex: 1; min-width: 220px; }

/* Éditeur de devis */
.retour { color: var(--gris) !important; text-decoration: none; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select { width: auto; }
.info { background: #eaf2fd; color: #1e4f9c; border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.carte > .ligne + .ligne { margin-top: 14px; }
.lignes-devis td { padding: 8px 10px; vertical-align: middle; }
.lignes-devis th { padding: 10px; }
.lignes-devis textarea { min-height: 40px; resize: none; overflow: hidden; line-height: 1.4; }
.lignes-devis input, .lignes-devis select, .lignes-devis textarea { padding: 8px 9px; }
.lignes-devis input.court { width: 76px; }
.lignes-devis input.moyen { width: 110px; text-align: right; }
.lignes-devis input[type=number] { text-align: right; }
.lignes-devis select { width: 86px; }
.lignes-devis td:first-child { width: 42%; }
.lignes-devis input:disabled, .lignes-devis select:disabled, .lignes-devis textarea:disabled,
.carte input:disabled, .carte select:disabled, .bas-devis textarea:disabled {
  background: var(--fond); color: var(--texte); border-color: transparent; opacity: 1;
}
.total-ligne { font-weight: 600; }
.supprimer-ligne { background: none; border: 0; font-size: 22px; color: var(--gris); cursor: pointer; padding: 0 6px; }
.supprimer-ligne:hover { color: var(--rouge); }
.ajout-lignes { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--bord); background: #fafafb; }
.ajout-lignes select { flex: 1; }
.bas-devis { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.totaux { display: flex; flex-direction: column; gap: 8px; }
.ligne-total { display: flex; justify-content: space-between; gap: 12px; }
.ligne-total.grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--bord); padding-top: 10px; margin-top: 2px; }

@media (max-width: 760px) {
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .bas-devis { grid-template-columns: 1fr; }
  .lignes-devis td:first-child { width: 100%; }
  .lignes-devis tr[data-i] { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; position: relative; padding-right: 36px; }
  .lignes-devis tr[data-i] td:first-child { grid-column: 1 / -1; }
  .lignes-devis tr[data-i] td::before { content: attr(data-libelle); display: block; font-size: 12px; color: var(--gris); }
  .lignes-devis tr[data-i] td:first-child::before, .lignes-devis tr[data-i] td:last-child::before { content: none; }
  .lignes-devis tr[data-i] td:last-child { position: absolute; top: 8px; right: 4px; width: auto; }
  .lignes-devis input.court, .lignes-devis input.moyen, .lignes-devis select { width: 100%; }
  .ajout-lignes { flex-direction: column; }
}

.etat-sauvegarde { margin-top: 4px; }

/* Réglages */
.reglages { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.reglages .carte { display: flex; flex-direction: column; gap: 14px; }
.reglages h2 { margin: 0; }
.logo-zone { display: flex; gap: 18px; align-items: center; }
.apercu-logo {
  width: 150px; height: 90px; border: 1px dashed var(--bord); border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; background: #fafafb; overflow: hidden;
}
.apercu-logo img { max-width: 90%; max-height: 80%; object-fit: contain; }
.apercu-logo span { color: var(--gris); font-size: 13px; }
.bouton-fichier { display: inline-block; cursor: pointer; font-size: 14px; font-weight: 600; }
.logo-zone .lien { margin-left: 8px; }
.logo-zone .petit { margin-top: 6px; }
.couleur { flex-direction: row; align-items: center; gap: 12px; }
.couleur input { width: 52px; height: 36px; padding: 2px; cursor: pointer; }
.pied-reglages { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; bottom: 0;
  background: var(--fond); padding: 12px 0; }
.pied-reglages .message { margin: 0; }
@media (max-width: 760px) {
  .logo-zone { flex-direction: column; align-items: flex-start; }
  .pied-reglages { flex-direction: column-reverse; align-items: stretch; }
}
