/* =====================================================================
   IT & PRINT SERVICES — Dashboard opérationnel
   ===================================================================== */

:root {
  --encre:      #0d1b2a;
  --encre-800:  #16293d;
  --encre-600:  #2c4359;
  --gris-700:   #4a5b6d;
  --gris-500:   #7b8b9b;
  --gris-400:   #9aa8b6;
  --gris-300:   #cbd5e0;
  --gris-200:   #e2e8f0;
  --gris-100:   #eef2f6;
  --gris-50:    #f7f9fb;
  --blanc:      #fff;

  --orange:     #f4581d;
  --orange-doux:#fff3ee;

  /* Data-viz : bleu séquentiel (une seule teinte) */
  --serie:      #2a78d6;
  --serie-clair:#9ec5f4;

  /* Data-viz : palette d'état (réservée, jamais réutilisée en série) */
  --etat-bon:      #0ca30c;
  --etat-attention:#fab219;
  --etat-serieux:  #ec835a;
  --etat-critique: #d03b3b;

  /* Encre et chrome de graphique */
  --ink-1:      #0b0b0b;
  --ink-2:      #52514e;
  --ink-muet:   #898781;
  --grille:     #e1e0d9;
  --ligne-base: #c3c2b7;

  --rayon:      10px;
  --ombre:      0 1px 2px rgba(13,27,42,.05), 0 3px 12px rgba(13,27,42,.06);
  --largeur-nav: 240px;
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px; line-height: 1.55; color: var(--encre-800);
  background: var(--gris-50); -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 750; letter-spacing: -.015em; color: var(--encre); line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }

/* =====================================================================
   MISE EN PAGE
   ===================================================================== */
.app { display: flex; min-height: 100vh; }

.nav {
  width: var(--largeur-nav); flex-shrink: 0; background: var(--encre); color: rgba(255,255,255,.72);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.nav__logo {
  display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.nav__marque {
  width: 34px; height: 34px; border-radius: 9px; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .72rem; flex-shrink: 0;
}
.nav__logo img { max-height: 36px; width: auto; max-width: 178px; object-fit: contain; }
.nav__logo strong { display: block; color: #fff; font-size: .88rem; line-height: 1.25; }
.nav__logo span { font-size: .68rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .07em; }

.nav__groupe { padding: 1.1rem 0 .3rem; }
.nav__titre {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255,255,255,.35); padding: 0 1.2rem .5rem; font-weight: 650;
}
.nav a.nav__lien {
  display: flex; align-items: center; gap: .7rem; padding: .58rem 1.2rem;
  font-size: .88rem; border-left: 3px solid transparent; transition: .15s;
}
.nav a.nav__lien:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.nav__lien.actif { background: rgba(244,88,29,.14); border-left-color: var(--orange); color: #fff; font-weight: 600; }
.nav a.nav__lien svg { flex-shrink: 0; opacity: .85; }
.nav__pastille {
  margin-left: auto; background: var(--orange); color: #fff; font-size: .68rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px;
}
.nav__pastille--alerte { background: var(--etat-critique); }

.nav__pied { margin-top: auto; padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .82rem; }
.nav__user { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.nav__avatar {
  width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .78rem; flex-shrink: 0;
}
.nav__user strong { display: block; color: #fff; font-size: .84rem; }
.nav__user span { font-size: .72rem; color: rgba(255,255,255,.5); }

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

.topbar {
  background: #fff; border-bottom: 1px solid var(--gris-200);
  padding: .9rem 1.6rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.28rem; }
.topbar__sous { font-size: .82rem; color: var(--gris-500); }
.topbar__actions { margin-left: auto; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.contenu { padding: 1.6rem; flex: 1; }

/* =====================================================================
   COMPOSANTS
   ===================================================================== */
.carte {
  background: #fff; border: 1px solid var(--gris-200); border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.carte__entete {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--gris-100);
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
}
.carte__entete h2 { font-size: 1rem; }
.carte__entete .lien { margin-left: auto; font-size: .82rem; color: var(--orange); font-weight: 600; }
.carte__corps { padding: 1.2rem; }
.carte__corps--serre { padding: 0; }

.grille { display: grid; gap: 1.1rem; }
.grille--4 { grid-template-columns: repeat(4, 1fr); }
.grille--3 { grid-template-columns: repeat(3, 1fr); }
.grille--2 { grid-template-columns: repeat(2, 1fr); }
.grille--2-1 { grid-template-columns: 2fr 1fr; }

/* ---------- Tuiles KPI ---------- */
.kpi {
  background: #fff; border: 1px solid var(--gris-200); border-radius: var(--rayon);
  padding: 1.1rem 1.2rem; box-shadow: var(--ombre);
}
.kpi__tete { display: flex; align-items: center; gap: .55rem; color: var(--gris-500); font-size: .8rem; font-weight: 600; }
.kpi__tete svg { color: var(--gris-400); }
.kpi__valeur {
  font-size: 1.85rem; font-weight: 800; color: var(--encre); letter-spacing: -.025em;
  margin-top: .35rem; line-height: 1.1;
}
.kpi__valeur small { font-size: .95rem; font-weight: 650; color: var(--gris-500); }
.kpi__note { font-size: .79rem; color: var(--gris-500); margin-top: .3rem; display: flex; align-items: center; gap: .35rem; }
.kpi__note--bon { color: #006300; font-weight: 600; }
.kpi__note--alerte { color: var(--etat-critique); font-weight: 600; }
.kpi--alerte { border-color: #f5c6c6; background: #fffafa; }

/* ---------- Tableaux ---------- */
.table-enveloppe { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th {
  text-align: left; font-size: .71rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--gris-500); font-weight: 700; padding: .7rem 1rem;
  border-bottom: 1px solid var(--gris-200); background: var(--gris-50); white-space: nowrap;
}
table.data td { padding: .78rem 1rem; border-bottom: 1px solid var(--gris-100); vertical-align: middle; }
table.data tbody tr:hover { background: var(--gris-50); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data a.ref { font-weight: 700; color: var(--encre); }
table.data a.ref:hover { color: var(--orange); }
table.data .sec { font-size: .78rem; color: var(--gris-500); }

tr.retard td { background: #fffafa; }
tr.retard td:first-child { box-shadow: inset 3px 0 0 var(--etat-critique); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem;
  border-radius: 999px; font-size: .73rem; font-weight: 650; white-space: nowrap;
}
.badge--gris   { background: #eef2f6; color: #475569; }
.badge--ambre  { background: #fef3c7; color: #92400e; }
.badge--bleu   { background: #dbeafe; color: #1e40af; }
.badge--violet { background: #ede9fe; color: #5b21b6; }
.badge--indigo { background: #e0e7ff; color: #3730a3; }
.badge--vert   { background: #dcfce7; color: #14532d; }
.badge--rouge  { background: #fee2e2; color: #991b1b; }
.badge--cyan   { background: #cffafe; color: #155e75; }
.badge--orange { background: var(--orange-doux); color: #9a3412; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: .86rem; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn--primaire { background: var(--orange); color: #fff; }
.btn--primaire:hover { background: #d3430c; }
.btn--encre { background: var(--encre); color: #fff; }
.btn--encre:hover { background: var(--encre-800); }
.btn--fantome { border-color: var(--gris-300); background: #fff; color: var(--encre-800); }
.btn--fantome:hover { border-color: var(--gris-500); background: var(--gris-50); }
.btn--danger { border-color: #fecaca; background: #fff; color: var(--etat-critique); }
.btn--danger:hover { background: #fef2f2; }
.btn--sm { padding: .35rem .7rem; font-size: .79rem; }
.btn--bloc { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Formulaires ---------- */
.champ { margin-bottom: .95rem; }
.champ label { display: block; font-size: .8rem; font-weight: 650; margin-bottom: .32rem; color: var(--encre-800); }
.champ input, .champ select, .champ textarea {
  width: 100%; padding: .52rem .7rem; border: 1px solid var(--gris-300); border-radius: 8px;
  background: #fff; font-size: .88rem; outline: none; transition: .15s;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
  border-color: var(--orange); box-shadow: 0 0 0 3px rgba(244,88,29,.12);
}
.champ textarea { min-height: 90px; resize: vertical; }
.champ__aide { font-size: .75rem; color: var(--gris-500); margin-top: .25rem; }
.champs { display: grid; gap: 0 1rem; }
.champs--2 { grid-template-columns: 1fr 1fr; }
.champs--3 { grid-template-columns: repeat(3, 1fr); }

.filtres {
  display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap;
  padding: .9rem 1.2rem; background: #fff; border: 1px solid var(--gris-200);
  border-radius: var(--rayon); margin-bottom: 1.1rem;
}
.filtres .champ { margin: 0; min-width: 150px; }

/* ---------- Alertes ---------- */
.alerte {
  padding: .75rem 1rem; border-radius: 8px; font-size: .87rem; margin-bottom: 1rem;
  border-left: 3px solid; display: flex; gap: .6rem; align-items: flex-start;
}
.alerte--succes { background: #f0fdf4; border-color: var(--etat-bon); color: #14532d; }
.alerte--erreur { background: #fef2f2; border-color: var(--etat-critique); color: #7f1d1d; }
.alerte--info   { background: #eff6ff; border-color: var(--serie); color: #1e3a8a; }
.alerte--attention { background: #fffbeb; border-color: var(--etat-attention); color: #78350f; }
.alerte svg { flex-shrink: 0; margin-top: 2px; }

/* =====================================================================
   GRAPHIQUES
   ===================================================================== */
.viz { --surface: #fff; }
.viz__titre { font-size: .95rem; font-weight: 700; color: var(--ink-1); }
.viz__sous  { font-size: .79rem; color: var(--ink-2); margin-top: .15rem; }

/* Histogramme CA — série unique, une seule teinte, pas de légende */
.barres { display: flex; align-items: flex-end; gap: 10px; height: 190px; margin-top: 1.2rem; }
.barres__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.barres__piste { width: 100%; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.barres__barre {
  width: 100%; max-width: 46px; background: var(--serie);
  border-radius: 4px 4px 0 0;   /* extrémité arrondie côté données, ancrée à la ligne de base */
  min-height: 3px; transition: .15s;
}
.barres__col:hover .barres__barre { background: #1c5cab; }
.barres__legende { font-size: .72rem; color: var(--ink-muet); margin-top: .5rem; text-align: center; white-space: nowrap; }
.barres__valeur {
  font-size: .74rem; color: var(--ink-2); font-weight: 650; margin-bottom: .3rem;
  font-variant-numeric: tabular-nums;
}
.barres__base { border-top: 1px solid var(--ligne-base); margin-top: -1px; }

.info-bulle {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -8px);
  background: var(--encre); color: #fff; font-size: .76rem; padding: .4rem .6rem;
  border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: .12s; z-index: 5;
}
.barres__col:hover .info-bulle { opacity: 1; }

/* Pipeline de production — tuiles, pas un camembert */
.pipeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: .55rem; }
.pipeline__etape {
  border: 1px solid var(--gris-200); border-radius: 9px; padding: .8rem .7rem;
  text-align: center; background: #fff; transition: .15s; position: relative;
}
.pipeline__etape:hover { border-color: var(--gris-400); transform: translateY(-2px); }
.pipeline__nb { font-size: 1.55rem; font-weight: 800; color: var(--encre); line-height: 1; }
.pipeline__nom { font-size: .73rem; color: var(--gris-500); margin-top: .35rem; font-weight: 600; }
.pipeline__jauge { height: 3px; border-radius: 2px; margin-top: .6rem; background: var(--gris-200); }
.pipeline__jauge i { display: block; height: 100%; border-radius: 2px; background: var(--serie); }

/* Jauges de stock — couleurs d'état + icône + libellé (jamais la couleur seule) */
.jauge { margin-bottom: .95rem; }
.jauge:last-child { margin-bottom: 0; }
.jauge__tete { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; font-size: .84rem; }
.jauge__tete b { font-weight: 600; color: var(--encre-800); }
.jauge__tete span { font-variant-numeric: tabular-nums; color: var(--gris-500); font-size: .79rem; white-space: nowrap; }
.jauge__piste { height: 7px; border-radius: 4px; background: var(--gris-200); margin-top: .35rem; overflow: hidden; }
.jauge__valeur { height: 100%; border-radius: 4px; }
.jauge__etat { display: inline-flex; align-items: center; gap: .25rem; font-size: .73rem; font-weight: 650; }
.etat-bon       { color: #006300; }
.etat-attention { color: #8a5a00; }
.etat-critique  { color: var(--etat-critique); }
.f-bon       { background: var(--etat-bon); }
.f-attention { background: var(--etat-attention); }
.f-critique  { background: var(--etat-critique); }

/* Vue tableau alternative des graphiques (accessibilité) */
details.viz-table { margin-top: 1rem; }
details.viz-table summary { font-size: .79rem; color: var(--gris-500); cursor: pointer; }
details.viz-table table { margin-top: .7rem; }

/* =====================================================================
   KANBAN PRODUCTION
   ===================================================================== */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(205px, 1fr)); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.colonne { background: var(--gris-100); border-radius: var(--rayon); padding: .7rem; min-height: 220px; }
.colonne__tete { display: flex; align-items: center; gap: .45rem; margin-bottom: .7rem; padding: 0 .2rem; }
.colonne__tete h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris-700); }
.colonne__nb { margin-left: auto; background: #fff; border-radius: 999px; padding: 0 .5rem; font-size: .74rem; font-weight: 700; color: var(--gris-700); }

.ticket {
  display: block; background: #fff; border: 1px solid var(--gris-200); border-radius: 8px;
  padding: .7rem .8rem; margin-bottom: .55rem; box-shadow: 0 1px 2px rgba(13,27,42,.05); transition: .15s;
}
.ticket:hover { border-color: var(--gris-400); transform: translateY(-1px); box-shadow: var(--ombre); }
.ticket--retard { border-left: 3px solid var(--etat-critique); }
.ticket--urgent { border-left: 3px solid var(--orange); }
.ticket__ref { font-weight: 700; font-size: .82rem; color: var(--encre); }
.ticket__client { font-size: .78rem; color: var(--gris-500); margin-top: .1rem; }
.ticket__pied { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-top: .55rem; font-size: .74rem; flex-wrap: wrap; }
.ticket__date { color: var(--gris-500); display: flex; align-items: center; gap: .25rem; white-space: nowrap; }
.ticket__date.tard { color: var(--etat-critique); font-weight: 650; }
.ticket__montant { font-weight: 700; color: var(--encre-800); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }

/* =====================================================================
   FICHE COMMANDE
   ===================================================================== */
.etapes-prod { display: flex; gap: .35rem; margin: 0 0 1.2rem; flex-wrap: wrap; }
.etapes-prod button, .etapes-prod span.etape {
  flex: 1; min-width: 100px; padding: .55rem .5rem; border-radius: 8px; border: 1px solid var(--gris-300);
  background: #fff; font-size: .78rem; font-weight: 600; color: var(--gris-500); cursor: pointer;
  text-align: center; transition: .15s;
}
.etapes-prod button:hover { border-color: var(--orange); color: var(--orange); }
.etapes-prod .fait { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.etapes-prod .actuel { background: var(--orange); border-color: var(--orange); color: #fff; }

.journal { position: relative; padding-left: 1.6rem; }
.journal::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--gris-200); }
.journal li { position: relative; padding-bottom: 1rem; font-size: .85rem; }
.journal li::before {
  content: ""; position: absolute; left: -1.6rem; top: 5px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 2px solid var(--gris-300);
}
.journal li:first-child::before { background: var(--orange); border-color: var(--orange); }
.journal b { display: block; }
.journal span { color: var(--gris-500); font-size: .78rem; }

.liste-def { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.2rem; font-size: .87rem; }
.liste-def dt { color: var(--gris-500); }
.liste-def dd { margin: 0; font-weight: 600; }

.fichier {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
  border: 1px solid var(--gris-200); border-radius: 8px; margin-bottom: .5rem; font-size: .85rem;
}
.fichier svg { color: var(--gris-500); flex-shrink: 0; }
.fichier b { display: block; font-weight: 600; }
.fichier small { color: var(--gris-500); font-size: .76rem; }
.fichier .actions { margin-left: auto; display: flex; gap: .35rem; }

/* =====================================================================
   DIVERS
   ===================================================================== */
.vide { text-align: center; padding: 2.5rem 1rem; color: var(--gris-500); }
.vide svg { margin: 0 auto .8rem; opacity: .35; }
.vide h3 { color: var(--gris-700); margin-bottom: .3rem; }

.pagination { display: flex; gap: .35rem; justify-content: center; padding: 1rem; }
.pagination a, .pagination span {
  padding: .35rem .7rem; border-radius: 7px; border: 1px solid var(--gris-200);
  font-size: .82rem; background: #fff;
}
.pagination .actif { background: var(--encre); color: #fff; border-color: var(--encre); font-weight: 650; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--gris-200); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a {
  padding: .6rem .9rem; font-size: .87rem; font-weight: 600; color: var(--gris-500);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--encre); }
.tabs a.actif { color: var(--orange); border-bottom-color: var(--orange); }

/* ---------- Connexion ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(760px 420px at 82% 8%, rgba(244,88,29,.28), transparent 60%),
    radial-gradient(620px 380px at 12% 100%, rgba(0,166,200,.22), transparent 60%),
    linear-gradient(150deg, #0d1b2a 0%, #16293d 60%, #1d3a54 100%);
}
.login-carte { width: min(100%, 400px); background: #fff; border-radius: 14px; padding: 2rem; box-shadow: 0 22px 60px rgba(0,0,0,.3); }
.login-carte .logo { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.6rem; }
.login-carte .logo img { max-height: 50px; width: auto; max-width: 230px; object-fit: contain; }
.login-carte .logo strong { display: block; font-size: .95rem; color: var(--encre); }
.login-carte .logo span { font-size: .7rem; color: var(--gris-500); text-transform: uppercase; letter-spacing: .07em; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grille--4 { grid-template-columns: repeat(2, 1fr); }
  .grille--2-1 { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .nav { position: fixed; left: -100%; z-index: 100; transition: left .2s; }
  .nav.ouvert { left: 0; }
  .grille--3, .grille--2 { grid-template-columns: 1fr; }
  .champs--2, .champs--3 { grid-template-columns: 1fr; }
  .contenu { padding: 1rem; }
}
@media (max-width: 620px) {
  .grille--4 { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .nav, .topbar__actions, .btn { display: none !important; }
  body { background: #fff; }
  .carte { box-shadow: none; border-color: #ddd; }
}
