/* ==========================================================================
   ERP Altech — feuille de style principale
   Palette : bleu nuit institutionnel + accent ambre
   ========================================================================== */

:root {
  --encre:        #16233b;
  --texte:        #1f2937;
  --texte-doux:   #64748b;
  --fond:         #f1f5f9;
  --carte:        #ffffff;
  --bordure:      #e2e8f0;

  --primaire:      #1d4ed8;
  --primaire-fonce:#1e40af;
  --primaire-clair:#dbeafe;
  --accent:        #f59e0b;
  --succes:        #16a34a;
  --succes-clair:  #dcfce7;
  --danger:        #dc2626;
  --danger-clair:  #fee2e2;
  --alerte:        #ea580c;
  --alerte-clair:  #ffedd5;
  --info-clair:    #e0f2fe;

  --ombre:    0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
  --rayon:    10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, Ubuntu, sans-serif;
  background: var(--fond);
  color: var(--texte);
  font-size: 14.5px;
}

a { color: var(--primaire); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--encre); }
h2 { font-size: 17px; margin: 0 0 12px; }
.gris { color: var(--texte-doux); }
.petit { font-size: 12.5px; }
.droite { text-align: right; }
.centre { text-align: center; }
.gras { font-weight: 600; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espace-entre { justify-content: space-between; }

/* ============================ STRUCTURE ================================== */
.application { display: flex; min-height: 100vh; }

.barre-latérale {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #101c33 0%, #16233b 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none !important;
}
.logo-marque {
  width: 38px; height: 38px;
  background: var(--accent);
  color: #101c33;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
}
.logo-image {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
}

/* Paramètres : aperçu du logo téléversé */
.bloc-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.apercu-logo {
  max-width: 160px; max-height: 72px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 6px;
}
.logo-texte strong { display: block; color: #fff; font-size: 15px; letter-spacing: .4px; }
.logo-texte small { color: #94a3b8; font-size: 11px; }

.navigation { flex: 1; padding: 10px 10px 20px; overflow-y: auto; }
.navigation a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  margin: 2px 0;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  text-decoration: none !important;
  transition: background .15s, color .15s;
}
.navigation a:hover { background: rgba(255,255,255,.07); color: #fff; }
.navigation a.actif { background: var(--primaire); color: #fff; }
.icone { width: 22px; text-align: center; flex-shrink: 0; }

.nav-section {
  margin: 14px 11px 4px;
  font-size: 10.5px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}

.profil-utilisateur {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #101c33;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.profil-utilisateur .infos { min-width: 0; flex: 1; }
.profil-utilisateur strong { display: block; color: #f1f5f9; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profil-utilisateur small { color: #94a3b8; font-size: 11px; }
.deconnexion {
  color: #94a3b8 !important;
  font-size: 17px;
  padding: 5px 7px;
  border-radius: 7px;
}
.deconnexion:hover { background: rgba(220,38,38,.25); color: #fecaca !important; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.en-tete {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 26px;
  background: var(--carte);
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: 0;
  z-index: 30;
}
.en-tete h1 { font-size: 19px; margin: 0; flex: 1; }
.en-tete-actions { display: flex; gap: 8px; align-items: center; }
.bouton-menu { display: none; }

.contenu { flex: 1; padding: 24px 26px 40px; max-width: 1280px; width: 100%; }

.pied {
  padding: 12px 26px;
  color: var(--texte-doux);
  font-size: 12px;
  border-top: 1px solid var(--bordure);
  background: var(--carte);
}

/* ============================ CARTES ===================================== */
.carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.carte--remplie { padding: 0; overflow: hidden; }
.carte-en-tete {
  padding: 14px 20px;
  border-bottom: 1px solid var(--bordure);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.carte-en-tete h2 { margin: 0; }

.grille { display: grid; gap: 18px; }
.grille--kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grille--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grille--form { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* Indicateurs du tableau de bord */
.kpi {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-left: 4px solid var(--primaire);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 15px 17px;
}
.kpi .kpi-libelle { color: var(--texte-doux); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .kpi-valeur { font-size: 21px; font-weight: 750; color: var(--encre); margin-top: 5px; word-break: break-word; }
.kpi .kpi-detail { font-size: 12px; color: var(--texte-doux); margin-top: 3px; }
.kpi--vert   { border-left-color: var(--succes); }
.kpi--orange { border-left-color: var(--accent); }
.kpi--rouge  { border-left-color: var(--danger); }

/* ============================ TABLEAUX =================================== */
table.liste {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
}
table.liste th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--texte-doux);
  border-bottom: 2px solid var(--bordure);
  white-space: nowrap;
}
table.liste td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.liste tbody tr:hover { background: #f8fafc; }
table.liste td.actions { white-space: nowrap; text-align: right; }
table.liste .montant { font-variant-numeric: tabular-nums; white-space: nowrap; }

.vide {
  text-align: center;
  color: var(--texte-doux);
  padding: 44px 20px !important;
}
.vide .icone-grand { font-size: 34px; display: block; margin-bottom: 8px; opacity: .55; }

/* ============================ BADGES ===================================== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 99px;
  white-space: nowrap;
}
.badge--gris   { background: #e2e8f0; color: #475569; }
.badge--bleu   { background: var(--primaire-clair); color: var(--primaire-fonce); }
.badge--vert   { background: var(--succes-clair); color: #15803d; }
.badge--rouge  { background: var(--danger-clair); color: #b91c1c; }
.badge--orange { background: var(--alerte-clair); color: #c2410c; }

/* ============================ BOUTONS ==================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.8px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  line-height: 1.25;
  transition: filter .12s, background .12s;
  font-family: inherit;
}
.btn:hover { filter: brightness(.94); }
.btn--primaire { background: var(--primaire); color: #fff; }
.btn--secondaire { background: #fff; color: var(--encre); border-color: #cbd5e1; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--accent { background: var(--accent); color: #3b2503; }
.btn--lien { border: none; background: none; color: var(--primaire); padding: 6px 8px; }
.btn--petit { padding: 5px 10px; font-size: 12.5px; }
.btn--icone { padding: 5px 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ============================ FORMULAIRES ================================ */
.champ { margin-bottom: 15px; }
.champ label {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--encre);
  margin-bottom: 5px;
}
.champ label .obligatoire { color: var(--danger); }
.champ input[type="text"],
.champ input[type="number"],
.champ input[type="date"],
.champ input[type="email"],
.champ input[type="password"],
.champ input[type="tel"],
.champ select,
.champ textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--texte);
}
.champ textarea { resize: vertical; min-height: 70px; }
.champ input:focus, .champ select:focus, .champ textarea:focus {
  outline: none;
  border-color: var(--primaire);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .13);
}
.aide { font-size: 12px; color: var(--texte-doux); margin-top: 4px; }

.case-a-cocher { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.8px; padding: 5px 0; }
.case-a-cocher input { width: 16px; height: 16px; accent-color: var(--primaire); }

.formulaire-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ============================ MESSAGES =================================== */
.messages { margin-bottom: 16px; }
.message {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-weight: 550;
  border: 1px solid transparent;
}
.message button { border: none; background: none; font-size: 16px; cursor: pointer; color: inherit; }
.message--succes { background: var(--succes-clair); color: #166534; }
.message--erreur { background: var(--danger-clair); color: #991b1b; }
.message--info   { background: var(--info-clair); color: #075985; }

/* ============================ LIGNES DOCUMENTS =========================== */
.editeur-lignes table { width: 100%; border-collapse: collapse; }
.editeur-lignes th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--texte-doux);
  padding: 6px 6px;
  text-align: left;
  border-bottom: 2px solid var(--bordure);
}
.editeur-lignes td { padding: 4px 4px; vertical-align: top; }
.editeur-lignes input,
.editeur-lignes select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13.5px;
}
.editeur-lignes input:focus, .editeur-lignes select:focus {
  outline: none; border-color: var(--primaire);
}
.col-designation { width: 32%; }
.col-prix, .col-total { width: 130px; text-align: right; }
.col-qte, .col-unite, .col-produit { width: 90px; }
.col-action { width: 36px; }
.ligne-total-cell { font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 12px !important; }

.totaux-document {
  margin-left: auto;
  width: 330px;
  max-width: 100%;
  margin-top: 14px;
}
.totaux-document .rangee {
  display: flex;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 14px;
}
.totaux-document .rangee.total-ttc {
  background: var(--encre);
  color: #fff;
  border-radius: 8px;
  font-weight: 750;
  font-size: 16px;
}
.totaux-document input { width: 120px; padding: 6px 9px; border: 1px solid #cbd5e1; border-radius: 7px; text-align: right; }

/* ============================ DIVERS ===================================== */
.filtres {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filtres input, .filtres select {
  padding: 8px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  background: #fff;
}

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--bordure);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  text-decoration: none !important;
}
.pagination span.actuel { background: var(--primaire); color: #fff; border-color: var(--primaire); }

.detail-grille {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 7px 16px;
  font-size: 13.8px;
}
.detail-grille dt { color: var(--texte-doux); font-weight: 600; }
.detail-grille dd { margin: 0; }

.timeline-statuts { list-style: none; padding: 0; margin: 0; }
.timeline-statuts li { padding: 6px 0; display: flex; gap: 10px; align-items: baseline; }

.boite-vide {
  text-align: center;
  padding: 60px 20px;
  color: var(--texte-doux);
}
.boite-vide .icone-grand { font-size: 44px; display: block; margin-bottom: 10px; opacity: .5; }

.graphique-conteneur { position: relative; height: 280px; }
.graphique-conteneur--grand { height: 330px; }

/* Pages d'authentification */
.page-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #101c33 0%, #1d4ed8 160%);
  padding: 20px;
}
.carte-auth {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  padding: 34px 34px 28px;
}
.carte-auth .logo-haut { text-align: center; margin-bottom: 22px; }
.carte-auth .logo-marque { width: 52px; height: 52px; font-size: 20px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--accent); color: #101c33; border-radius: 12px; font-weight: 800; }
.carte-auth h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.carte-auth .sous-titre { text-align: center; color: var(--texte-doux); margin: 0 0 20px; font-size: 13.5px; }

/* Cases à cocher des modules (formulaire utilisateur) */
.matrice-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 4px 14px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
}

/* Responsive */
@media (max-width: 900px) {
  .barre-latérale {
    position: fixed;
    left: -260px;
    z-index: 100;
    transition: left .22s ease;
  }
  body.menu-ouvert .barre-latérale { left: 0; }
  body.menu-ouvert::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 90;
  }
  .bouton-menu {
    display: block;
    border: 1px solid var(--bordure);
    background: #fff;
    border-radius: 8px;
    font-size: 17px;
    padding: 5px 12px;
    cursor: pointer;
  }
  .contenu { padding: 16px 14px 30px; }
  .detail-grille { grid-template-columns: 1fr; }
  .detail-grille dt { margin-top: 6px; }
}
