/* ================================
   Variables (couleurs, etc.)
   ================================ */

:root {
  --brand-red: #ee3224;
  --brand-red-dark: #c6251a;
  --brand-dark: #111827;
  --brand-grey: #6b7280;
  --brand-border: #d1d5db;
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;

  --accent: #6366f1;
  --accent-soft: #4f46e5;
  --accent-muted: #a5b4fc;
}

/* ====== Reset simple ====== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background-color: var(--bg-body);
  color: var(--brand-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body,
.app-header,
.app-footer,
.card,
.table,
.nav-link,
.admin-tab {
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

/* ===========================
   Pagination des tableaux
   =========================== */

.table-pagination {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--brand-grey);
}

.table-pagination-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.table-pagination .page-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.table-pagination .page-number {
  font-weight: 500;
}

@media (max-width: 640px) {
  .table-pagination-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-pagination .page-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ===========================
   Layout global
   =========================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background-color: #ffffff;
  border-bottom: 1px solid var(--brand-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-text h1 {
  font-size: 1.1rem;
  margin: 0;
}

.header-text .subtitle {
  font-size: 0.8rem;
  color: var(--brand-grey);
  margin: 0.15rem 0 0 0;
}

.app-header-right {
  display: none; /* plus rien dans le header */
}


/* Logo dans le header */

.logo-circle {
  width: 60px;
  height: 60px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: transparent;
  border-radius: 0;
}

.site-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Mini logo (ex TB) */
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background-color: var(--brand-red);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* ===========================
   Navigation
   =========================== */

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto; /* pousse le menu à droite */
}


.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--brand-grey);
  border: 1px solid transparent;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.nav-link:hover {
  background-color: #f3f4f6;
  color: var(--brand-dark);
  border-color: #e5e7eb;
}

.nav-link.active {
  background-color: var(--brand-red);
  color: #ffffff;
  border-color: var(--brand-red);
}

/* Burger menu (mobile) */

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  position: relative;
}

.nav-toggle span {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  border-radius: 999px;
  background-color: var(--brand-dark);
  transition:
    transform 0.25s ease,
    opacity 0.2s ease;
  transform-origin: center;
}

.nav-toggle span:nth-child(1) { top: 9px; }
.nav-toggle span:nth-child(2) { top: 15px; }
.nav-toggle span:nth-child(3) { top: 21px; }

.nav-toggle.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ===========================
   Contenu principal
   =========================== */

.app-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  flex: 1;
}

.card {
  background-color: var(--bg-card);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  border: 1px solid #e5e7eb;
  margin-bottom: 1rem;
  width: 100%;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.card-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Textes */

.subtitle {
  font-size: 0.85rem;
  color: var(--brand-grey);
}

.help-text {
  font-size: 0.8rem;
  color: var(--brand-grey);
}

/* ===========================
   Formulaires
   =========================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem 1rem;
  align-items: flex-end;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select {
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--brand-border);
  font-size: 0.85rem;
}

input[type="file"] {
  font-size: 0.8rem;
}

input:focus,
select:focus {
  outline: 2px solid var(--brand-red);
  outline-offset: 1px;
  border-color: var(--brand-red);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Bloc import */

.import-row {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.import-row .form-group {
  flex: 1;
  min-width: 240px;
}

/* Sous-carte admin (ex: import historique) */

.admin-subsection-card {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px dashed var(--brand-border);
  background: #f9fafb;
}

.admin-subsection-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.admin-subsection-card .subtitle {
  margin: 0 0 0.75rem;
}

/* ===========================
   Boutons
   =========================== */

.btn,
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  background-color: #e5e7eb;
  color: var(--brand-dark);
  position: relative;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.05s ease;
}

.btn.small,
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* primaire */

.btn.primary,
.btn-primary {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
  color: #ffffff;
}

.btn.primary:hover,
.btn-primary:hover {
  background-color: var(--brand-red-dark);
  border-color: var(--brand-red-dark);
}

/* secondaire */

.btn.secondary,
.btn-secondary {
  background-color: #ffffff;
  border-color: var(--brand-border);
  color: var(--brand-dark);
}

.btn.secondary:hover,
.btn-secondary:hover {
  background-color: #f3f4f6;
}

/* danger */

.btn.danger,
.btn-danger {
  background-color: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn.danger:hover,
.btn-danger:hover {
  background-color: #fecaca;
}

.btn:active {
  transform: translateY(1px);
}

/* Effet de chargement */

.btn.loading {
  opacity: 0.8;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-top-color: transparent;
  margin-left: 0.35rem;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

a.btn,
a.btn:link,
a.btn:visited {
  text-decoration: none;
}

/* ===========================
   Tables
   =========================== */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.75rem;
  border-radius: 0.9rem;
  border: 1px solid var(--brand-border);
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.table thead {
  background: #f9fafb;
}

.table th,
.table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}

.table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-grey);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Zebra + hover */

.table tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

.table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

.table tbody tr:hover {
  background-color: #eef2ff;
}

/* Alignement des colonnes numériques */

#movements-table td:nth-child(1),
#movements-table td:nth-child(6),
#movements-by-item-table td:nth-child(5),
#movements-by-item-table td:nth-child(6),
#movements-by-item-table td:nth-child(7),
#movements-by-employee-table td:nth-child(2),
#movements-by-employee-table td:nth-child(3),
#movements-by-employee-table td:nth-child(4),
#movements-by-employee-table td:nth-child(5),
#availability-table td:nth-child(5),
#availability-table td:nth-child(6),
#availability-table td:nth-child(7),
#items-table td:nth-child(5),
#items-table td:nth-child(6),
#items-table td:nth-child(7),
#employee-detail-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#movements-table td:last-child,
#items-table td:last-child,
#employees-table td:last-child {
  text-align: right;
}

/* Pills type mouvement */

.type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.type-depart {
  background-color: #fee2e2;
  color: #b91c1c;
}

.type-retour {
  background-color: #dcfce7;
  color: #166534;
}

/* ===========================
   Mode cartes sur mobile
   =========================== */

@media (max-width: 640px) {
  .table-wrapper {
    border: none;
    background: transparent;
    box-shadow: none;
  }

  #movements-table,
  #items-table,
  #availability-table,
  #movements-by-item-table,
  #movements-by-employee-table,
  #employees-table,
  #employee-detail-table {
    min-width: 0;
    border-spacing: 0;
  }

  #movements-table thead,
  #items-table thead,
  #availability-table thead,
  #movements-by-item-table thead,
  #movements-by-employee-table thead,
  #employees-table thead,
  #employee-detail-table thead {
    display: none;
  }

  #movements-table tbody,
  #items-table tbody,
  #availability-table tbody,
  #movements-by-item-table tbody,
  #movements-by-employee-table tbody,
  #employees-table tbody,
  #employee-detail-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  #movements-table tbody tr,
  #items-table tbody tr,
  #availability-table tbody tr,
  #movements-by-item-table tbody tr,
  #movements-by-employee-table tbody tr,
  #employees-table tbody tr,
  #employee-detail-table tbody tr {
    display: block;
    padding: 0.75rem 0.9rem;
    border-radius: 0.9rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  }

  #movements-table tbody td,
  #items-table tbody td,
  #availability-table tbody td,
  #movements-by-item-table tbody td,
  #movements-by-employee-table tbody td,
  #employees-table tbody td,
  #employee-detail-table tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.15rem 0;
    border-bottom: none;
    white-space: normal;
    font-size: 0.8rem;
    text-align: left;
  }

  #movements-table tbody td + td,
  #items-table tbody td + td,
  #availability-table tbody td + td,
  #movements-by-item-table tbody td + td,
  #movements-by-employee-table tbody td + td,
  #employees-table tbody td + td,
  #employee-detail-table tbody td + td {
    margin-top: 0.15rem;
  }

  #movements-table tbody td::before,
  #items-table tbody td::before,
  #availability-table tbody td::before,
  #movements-by-item-table tbody td::before,
  #movements-by-employee-table tbody td::before,
  #employees-table tbody td::before,
  #employee-detail-table tbody td::before {
    content: "";
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--brand-grey);
    margin-right: 0.75rem;
    flex-shrink: 0;
  }

  /* Historique global */
  #movements-table tbody td:nth-child(1)::before { content: "Date"; }
  #movements-table tbody td:nth-child(2)::before { content: "Type"; }
  #movements-table tbody td:nth-child(3)::before { content: "Employé"; }
  #movements-table tbody td:nth-child(4)::before { content: "Matériel"; }
  #movements-table tbody td:nth-child(5)::before { content: "Chantier"; }
  #movements-table tbody td:nth-child(6)::before { content: "Qté"; }
  #movements-table tbody td:nth-child(7)::before { content: ""; }

  #movements-table tbody td:nth-child(2) .type-pill {
    margin-left: 0.5rem;
  }

  /* Admin matériel */
  #items-table tbody td:nth-child(1)::before { content: "Désignation"; }
  #items-table tbody td:nth-child(2)::before { content: "Numéro"; }
  #items-table tbody td:nth-child(3)::before { content: "Type"; }
  #items-table tbody td:nth-child(4)::before { content: "Marque"; }
  #items-table tbody td:nth-child(5)::before { content: "Total"; }
  #items-table tbody td:nth-child(6)::before { content: "Disponible"; }
  #items-table tbody td:nth-child(7)::before { content: "En chantier"; }
  #items-table tbody td:nth-child(8)::before { content: ""; }

  /* Disponibilité */
  #availability-table tbody td:nth-child(1)::before { content: "Désignation"; }
  #availability-table tbody td:nth-child(2)::before { content: "Numéro"; }
  #availability-table tbody td:nth-child(3)::before { content: "Type"; }
  #availability-table tbody td:nth-child(4)::before { content: "Marque"; }
  #availability-table tbody td:nth-child(5)::before { content: "Total"; }
  #availability-table tbody td:nth-child(6)::before { content: "Dispo stock"; }
  #availability-table tbody td:nth-child(7)::before { content: "En chantier"; }

  /* Synthèse matériel */
  #movements-by-item-table tbody td:nth-child(1)::before { content: "Désignation"; }
  #movements-by-item-table tbody td:nth-child(2)::before { content: "Numéro"; }
  #movements-by-item-table tbody td:nth-child(3)::before { content: "Type"; }
  #movements-by-item-table tbody td:nth-child(4)::before { content: "Marque"; }
  #movements-by-item-table tbody td:nth-child(5)::before { content: "Total départs"; }
  #movements-by-item-table tbody td:nth-child(6)::before { content: "Total retours"; }
  #movements-by-item-table tbody td:nth-child(7)::before { content: "Solde (sorti)"; }
  #movements-by-item-table tbody td:nth-child(8)::before { content: "Dernier mouv."; }

  /* Synthèse employés */
  #movements-by-employee-table tbody td:nth-child(1)::before { content: "Employé"; }
  #movements-by-employee-table tbody td:nth-child(2)::before { content: "Total départs"; }
  #movements-by-employee-table tbody td:nth-child(3)::before { content: "Total retours"; }
  #movements-by-employee-table tbody td:nth-child(4)::before { content: "Solde (sorti)"; }
  #movements-by-employee-table tbody td:nth-child(5)::before { content: "Mouvements"; }

  /* Admin employés */
  #employees-table tbody td:nth-child(1)::before { content: "Nom"; }
  #employees-table tbody td:nth-child(2)::before { content: ""; }

  /* Détail employé */
  #employee-detail-table tbody td:nth-child(1)::before { content: "Matériel"; }
  #employee-detail-table tbody td:nth-child(2)::before { content: "Numéro"; }
  #employee-detail-table tbody td:nth-child(3)::before { content: "Type"; }
  #employee-detail-table tbody td:nth-child(4)::before { content: "Marque"; }
  #employee-detail-table tbody td:nth-child(5)::before { content: "Qté"; }
  #employee-detail-table tbody td:nth-child(6)::before { content: "Dernier mouv."; }

  #movements-table tbody td:last-child,
  #items-table tbody td:last-child,
  #employees-table tbody td:last-child {
    justify-content: flex-end;
    margin-top: 0.4rem;
  }
}

/* ===========================
   Barre de recherche admin matériel
   =========================== */

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.4rem;
  flex-wrap: wrap;
}

.table-toolbar-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-grey);
}

.search-input-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background: #f3f4f6;
}

.search-input-wrapper input {
  border: none;
  background: transparent;
  padding: 0;
  min-width: 220px;
  font-size: 0.9rem;
}

.search-input-wrapper input:focus {
  outline: none;
  box-shadow: none;
}

.search-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--brand-grey);
  position: relative;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-grey);
  right: -4px;
  bottom: -2px;
  transform: rotate(45deg);
}

@media (max-width: 700px) {
  .table-toolbar {
    justify-content: flex-start;
  }

  .search-input-wrapper {
    width: 100%;
  }

  .search-input-wrapper input {
    width: 100%;
  }
}

/* ===========================
   Tables spécifiques
   =========================== */

/* Admin matériel */

#items-table {
  table-layout: fixed;
  width: 100%;
}

#items-table th,
#items-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#items-table .col-designation { width: 20%; }
#items-table .col-ref         { width: 8%; }
#items-table .col-type        { width: 8%; }
#items-table .col-brand       { width: 8%; }

#items-table th:last-child,
#items-table td:last-child {
  width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

#items-table tbody td:nth-child(1):hover,
#items-table tbody td:nth-child(4):hover {
  white-space: normal;
}

/* Triable */

#items-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.25rem;
}

#items-table th.sortable::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.35rem;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid #d1d5db;
  transform: translateY(-50%) rotate(180deg);
  opacity: 0.4;
}

#items-table th.sortable.sorted-asc::after {
  border-top-color: var(--brand-red);
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}

#items-table th.sortable.sorted-desc::after {
  border-top-color: var(--brand-red);
  transform: translateY(-50%);
  opacity: 1;
}

/* Disponibilité */

#availability-table {
  table-layout: fixed;
  width: 100%;
}

#availability-table th,
#availability-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#availability-table .col-designation { width: 30%; }
#availability-table .col-ref         { width: 14%; }
#availability-table .col-type        { width: 14%; }
#availability-table .col-brand       { width: 10%; }

#availability-table td:hover {
  white-space: normal;
}

/* Mouvements */

#movements-table {
  table-layout: fixed;
  width: 100%;
}

#movements-table th,
#movements-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#movements-table td:nth-child(4):hover {
  white-space: normal;
}

#movements-table th:nth-child(1),
#movements-table td:nth-child(1) {
  width: 150px;
}

#movements-table th:nth-child(2),
#movements-table td:nth-child(2) {
  width: 85px;
}

#movements-table th:nth-child(3),
#movements-table td:nth-child(3) {
  width: 150px;
}

#movements-table th:nth-child(5),
#movements-table td:nth-child(5) {
  width: 150px;
}

#movements-table th:nth-child(6),
#movements-table td:nth-child(6) {
  width: 60px;
  text-align: center;
}

#movements-table th:nth-child(7),
#movements-table td:nth-child(7) {
  width: 110px;
}

/* Synthèse par matériel */

#movements-by-item-table {
  table-layout: fixed;
  width: 100%;
}

#movements-by-item-table th,
#movements-by-item-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#movements-by-item-table th:nth-child(1),
#movements-by-item-table td:nth-child(1) { width: 32%; }
#movements-by-item-table th:nth-child(2),
#movements-by-item-table td:nth-child(2) { width: 10%; }
#movements-by-item-table th:nth-child(3),
#movements-by-item-table td:nth-child(3) { width: 10%; }
#movements-by-item-table th:nth-child(4),
#movements-by-item-table td:nth-child(4) { width: 10%; }
#movements-by-item-table th:nth-child(5),
#movements-by-item-table td:nth-child(5),
#movements-by-item-table th:nth-child(6),
#movements-by-item-table td:nth-child(6),
#movements-by-item-table th:nth-child(7),
#movements-by-item-table td:nth-child(7) { width: 8%; }
#movements-by-item-table th:nth-child(8),
#movements-by-item-table td:nth-child(8) { width: 14%; }

#movements-by-item-table td:nth-child(1):hover,
#movements-by-item-table td:nth-child(8):hover {
  white-space: normal;
}

/* Détail par employé (tableau) */

#employee-detail-table {
  table-layout: fixed;
  width: 100%;
}

#employee-detail-table th,
#employee-detail-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#employee-detail-table th:nth-child(1),
#employee-detail-table td:nth-child(1) { width: 40%; }
#employee-detail-table th:nth-child(2),
#employee-detail-table td:nth-child(2) { width: 10%; }
#employee-detail-table th:nth-child(3),
#employee-detail-table td:nth-child(3) { width: 12%; }
#employee-detail-table th:nth-child(4),
#employee-detail-table td:nth-child(4) { width: 13%; }
#employee-detail-table th:nth-child(5),
#employee-detail-table td:nth-child(5) { width: 7%; }
#employee-detail-table th:nth-child(6),
#employee-detail-table td:nth-child(6) { width: 18%; }

#employee-detail-table td:nth-child(1):hover,
#employee-detail-table td:nth-child(6):hover {
  white-space: normal;
}

/* ===========================
   Disponibilité – détail
   =========================== */

#availability-detail {
  margin-top: 0.75rem;
}

.availability-detail-card {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--brand-border);
  background: #f9fafb;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  font-size: 0.85rem;
}

.availability-detail-card > p {
  margin: 0 0 0.35rem;
}

.availability-detail-card > p.help-text {
  margin-top: 0.15rem;
}

.availability-detail-card ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.availability-detail-card li {
  margin-bottom: 0.15rem;
}

/* Couleur de fond selon statut */

.availability-detail-card.availability-status-ok {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.availability-detail-card.availability-status-busy {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* Lignes de dispo */

#availability-table tbody tr.is-selected {
  background-color: #eef2ff;
}

#availability-table tbody tr.availability-row-ok {
  background-color: #ecfdf3;
}

#availability-table tbody tr.availability-row-busy {
  background-color: #fef2f2;
}

/* ===========================
   Indicateur matériel trouvé
   =========================== */

.found-item-banner {
  display: none;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #4b5563;
}

.found-item-banner.visible {
  display: block;
}

.found-item-banner.ok {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
  font-weight: 600;
}

.found-item-banner.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
  font-weight: 600;
}

/* ===========================
   Admin lock visuel
   =========================== */

.admin-section.locked {
  position: relative;
  opacity: 0.55;
}

.admin-section.locked::after {
  content: "Réservé à l'administrateur";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #b91c1c;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.75),
    rgba(255, 255, 255, 0.9)
  );
  pointer-events: none;
}

/* ===========================
   Pied de page
   =========================== */

.app-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--brand-border);
  background: linear-gradient(90deg, #f3f4f6, #e5e7eb);
}

.footer-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--brand-grey);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-logo-mini {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--brand-red);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  box-shadow: 0 0 0 3px rgba(238, 50, 36, 0.18);
}

.footer-text-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.footer-site-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--brand-dark);
}

.footer-site-desc {
  font-size: 0.78rem;
  color: var(--brand-grey);
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}
.footer-auth {
  padding: 0.4rem 1rem 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

/* optionnel : resserrer un peu les champs dans le footer */
.footer-auth #login-form input {
  padding: 0.25rem 0.4rem;
}

.footer-bullet {
  opacity: 0.6;
}

@media (max-width: 720px) {
  .footer-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .footer-left {
    justify-content: center;
  }

  .footer-right {
    justify-content: center;
  }
}

/* ===========================
   Responsive global
   =========================== */

@media (max-width: 900px) {
  .card-header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-main {
    padding-inline: 0.75rem;
  }
}

@media (max-width: 480px) {
  .app-main {
    max-width: 100%;
    padding-inline: 0.5rem;
  }

  .form-grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
  }

  .app-header-right {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
    margin-top: 0.3rem;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-left: 0;
    padding: 0.4rem 1rem 0.6rem;
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.12);
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .main-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

/* Grille spécifique "Enregistrer un mouvement" sur grand écran */

@media (min-width: 1024px) {
  #movement-form.form-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #movement-form .form-actions {
    grid-column: auto;
    align-self: end;
    justify-content: flex-start;
    margin-top: 0.2rem;
  }
}

/* ===========================
   Login header
   =========================== */

#login-form input {
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
}

#login-form input:focus {
  outline: 2px solid var(--brand-red);
  outline-offset: 1px;
  border-color: var(--brand-red);
}

/* ===========================
   Lignes cliquables & édition
   =========================== */

#movements-by-employee-table tbody tr {
  cursor: pointer;
}

#movements-by-employee-table tbody tr:hover {
  background-color: #eef2ff;
}

/* Lignes cliquables dans le tableau matériel (admin) */
#items-table tbody tr {
  cursor: pointer;
}

/* Indicateur mode édition */

.edit-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  margin-bottom: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 500;
}

.edit-indicator::before {
  content: "✏️";
  font-size: 0.9rem;
}

.edit-indicator[hidden] {
  display: none !important;
}

/* ============================= */
/* Intro / splash au démarrage   */
/* ============================= */

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

.intro-content {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  animation: intro-pop 1.2s ease-out forwards;
}

.intro-logo {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-logo-img {
  width: 300%;
  height: 300%;
  object-fit: contain;
  display: block;
}

.intro-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.intro-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #111827;
}

.intro-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
}

@keyframes intro-pop {
  from {
    transform: translateY(10px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .intro-content {
    flex-direction: row;
    padding: 1rem 1.25rem;
  }

  .intro-title {
    font-size: 1.1rem;
  }

  .intro-subtitle {
    font-size: 0.8rem;
  }
}

/* ================================
   Détail par employé – page
   ================================ */

.employee-detail-page .page-header {
  margin-bottom: 1.5rem;
}

.employee-detail-page .page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.employee-detail-page .page-header p {
  margin: 0;
  font-size: 0.95rem;
  color: #6b7280;
}

.employee-detail-page .card {
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.employee-detail-page .card-header-row {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.employee-detail-page .card-title {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  font-weight: 600;
  text-transform: capitalize;
}

.employee-detail-page .card-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.employee-detail-page .card-header-row .btn.small {
  border-radius: 999px;
  padding-inline: 0.9rem;
}

.employee-detail-page #employee-detail-container {
  padding-top: 0.25rem;
}

.employee-detail-page #employee-detail-container .table {
  margin-top: 0.35rem;
}

.employee-detail-page #employee-detail-container .help-text {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: #6b7280;
  font-style: italic;
}

/* ================================
   Onglets admin & dashboard
   ================================ */

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 1.25rem;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.admin-tab:hover {
  background: #f3f4f6;
  box-shadow: 0 0 0 1px #e5e7eb;
}

.admin-tab.active {
  background: var(--brand-red);
  color: #ffffff;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.admin-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-tab-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.admin-tab-label {
  white-space: nowrap;
}

.admin-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.admin-dashboard-card {
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.admin-dashboard-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

.admin-dashboard-card p {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #4b5563;
}
/* MODE COMPACT POUR LES TABLEAUX SUR MOBILE (site entier) */
@media (max-width: 640px) {
  .table-wrapper {
    border: none;
    background: transparent;
    box-shadow: none;
  }

  /* Base "carte" pour tous les tableaux */
  #movements-table tbody tr,
  #items-table tbody tr,
  #availability-table tbody tr,
  #movements-by-item-table tbody tr,
  #movements-by-employee-table tbody tr,
  #employees-table tbody tr
   {
    margin-bottom: 0.55rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: none;
  }

  /* Layout par défaut (admin / synthèses) : pile avec labels */
  #items-table tbody tr,
  #availability-table tbody tr,
  #movements-by-item-table tbody tr,
  #movements-by-employee-table tbody tr,
  #employees-table tbody tr
 {
    display: block;
    padding: 0.55rem 0.7rem;
  }

  #items-table tbody td,
  #availability-table tbody td,
  #movements-by-item-table tbody td,
  #movements-by-employee-table tbody td,
  #employees-table tbody td
  {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.1rem 0;
    border-bottom: none;
    white-space: normal;
    font-size: 0.78rem;
    text-align: left;
  }

  #items-table tbody td + td,
  #availability-table tbody td + td,
  #movements-by-item-table tbody td + td,
  #movements-by-employee-table tbody td + td,
  #employees-table tbody td + td
  {
    margin-top: 0.15rem;
  }

  #items-table tbody td::before,
  #availability-table tbody td::before,
  #movements-by-item-table tbody td::before,
  #movements-by-employee-table tbody td::before,
  #employees-table tbody td::before
   {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: none;
    color: var(--brand-grey);
    margin-right: 0.5rem;
  } 
}
/* Historique global : Qté masquée (colonne 6) */
#movements-table thead th:nth-child(6),
#movements-table tbody td:nth-child(6) {
  display: none;
}
/* Colonne "Actions" visible uniquement pour les admins */
html:not(.role-admin) #movements-table thead th:last-child,
html:not(.role-admin) #movements-table tbody td:last-child {
  display: none;
}
/* Historique global (index) : design compact sans labels, haut sur une seule ligne */
@media (max-width: 640px) {
  #movements-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) auto auto;
    grid-template-areas:
      "employee date type"
      "item item item"
      "btn btn btn";
    row-gap: 0.2rem;
    padding: 0.55rem 0.7rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: none;
    margin-bottom: 0.55rem;
    align-items: center;          /* aligne les 3 éléments de la première ligne */
  }

  #movements-table tbody td {
    display: block;
    padding: 0;
    margin: 0;
    border-bottom: none;
    white-space: normal;
    font-size: 0.78rem;
    text-align: left;
  }

  /* pas de labels "Date / Type / ..." */
  #movements-table tbody td::before {
    content: "";
    display: none !important;
  }

  /* 1 = Date / heure */
  #movements-table tbody td:nth-child(1) {
    grid-area: date;
    font-size: 0.72rem;
    color: var(--brand-grey);
    white-space: nowrap;          /* toujours sur une ligne */
    justify-self: center;
    align-self: center;
  }

  /* 2 = Type (badge) */
  #movements-table tbody td:nth-child(2) {
    grid-area: type;
    justify-self: flex-end;
    align-self: center;
  }

  /* 3 = Employé */
  #movements-table tbody td:nth-child(3) {
    grid-area: employee;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    align-self: center;
  }

  /* 4 = Matériel (ligne du dessous) */
  #movements-table tbody td:nth-child(4) {
    grid-area: item;
    margin-top: 0.15rem;
    line-height: 1.35;
  }

  /* 5 = Chantier → masqué sur mobile */
  #movements-table thead th:nth-child(5),
  #movements-table tbody td:nth-child(5) {
    display: none;
  }

  /* 7 = Bouton supprimer */
  #movements-table tbody td:nth-child(7) {
    grid-area: btn;
    margin-top: 0.3rem;
    text-align: right;
  }

  /* petits ajustements */
  #movements-table .type-pill {
    padding: 0.12rem 0.6rem;
    font-size: 0.7rem;
  }

  #movements-table tbody td:nth-child(7) .btn.small.danger {
    padding: 0.22rem 0.7rem;
    font-size: 0.74rem;
    border-radius: 999px;
  }
}

/* Mobile : date + heure toujours sur une seule ligne */
@media (max-width: 640px) {
  #movements-table tbody td:nth-child(1) {
    white-space: nowrap;
  }
}
/* Historique global : carte rouge / verte selon le type de mouvement */
#movements-table tbody tr.movement-row-depart {
  background-color: #fef2f2;
  border-color: #fecaca;
}

#movements-table tbody tr.movement-row-retour {
  background-color: #ecfdf3;
  border-color: #bbf7d0;
}

/* Conserver un hover un peu plus marqué */
#movements-table tbody tr.movement-row-depart:hover {
  background-color: #fee2e2;
}

#movements-table tbody tr.movement-row-retour:hover {
  background-color: #dcfce7;
}

/* Version mobile : même logique sur les "cartes" */
@media (max-width: 640px) {
  #movements-table tbody tr.movement-row-depart {
    background-color: #fef2f2;
    border-color: #fecaca;
  }

  #movements-table tbody tr.movement-row-retour {
    background-color: #ecfdf3;
    border-color: #bbf7d0;
  }
}
/* Détail par employé - carte mobile propre */
@media (max-width: 640px) {

  #employee-detail-table tbody tr {
    display: block;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.7rem;
    border-radius: 0.9rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  }

  #employee-detail-table tbody td {
    display: block;
    border-bottom: none;
    padding: 0;
    margin: 0;
    white-space: normal;
    font-size: 0.78rem;
    text-align: left;
  }

  /* On désactive les labels automatiques du mode compact */
  #employee-detail-table tbody td::before {
    content: none;
  }

  /* 1. Matériel : titre de la carte */
  #employee-detail-table tbody td:nth-child(1) {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.35;
    margin-bottom: 0.25rem;
  }

  /* 2–4. N°, Type, Marque sur une ligne de méta */
  #employee-detail-table tbody td:nth-child(2),
  #employee-detail-table tbody td:nth-child(3),
  #employee-detail-table tbody td:nth-child(4) {
    display: inline-block;
    margin-right: 0.75rem;
    margin-top: 0.05rem;
    font-size: 0.74rem;
    color: var(--brand-grey);
  }

  #employee-detail-table tbody td:nth-child(2)::before,
  #employee-detail-table tbody td:nth-child(3)::before,
  #employee-detail-table tbody td:nth-child(4)::before {
    display: inline;
    font-weight: 600;
    margin-right: 0.15rem;
  }

  #employee-detail-table tbody td:nth-child(2)::before { content: "N°"; }
  #employee-detail-table tbody td:nth-child(3)::before { content: "Type"; }
  #employee-detail-table tbody td:nth-child(4)::before { content: "Marque"; }

  /* 5. Qté mise en avant */
  #employee-detail-table tbody td:nth-child(5) {
    margin-top: 0.35rem;
    font-weight: 600;
  }

  #employee-detail-table tbody td:nth-child(5)::before {
    content: "Qté";
    display: inline;
    font-weight: 600;
    margin-right: 0.15rem;
    color: var(--brand-grey);
  }

  /* 6. Dernier mouvement en bas de carte */
  #employee-detail-table tbody td:nth-child(6) {
    margin-top: 0.25rem;
    font-size: 0.74rem;
    color: var(--brand-grey);
    line-height: 1.3;
  }

  #employee-detail-table tbody td:nth-child(6)::before {
    content: "Dernier mouvement";
    display: block;
    font-weight: 600;
    margin-bottom: 0.05rem;
  }
}


/* ===========================
   Détail par employé – carte mobile dédiée
   =========================== */
@media (max-width: 640px) {

  /* On neutralise le mode tableau "fixe" sur cette page */
  .employee-detail-page #employee-detail-table {
    table-layout: auto;
  }

  .employee-detail-page #employee-detail-table th,
  .employee-detail-page #employee-detail-table td {
    width: auto;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* On transforme chaque ligne en carte */
  .employee-detail-page #employee-detail-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .employee-detail-page #employee-detail-table tbody tr {
    display: block;
    padding: 0.75rem 0.85rem;
    border-radius: 0.9rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  }

  .employee-detail-page #employee-detail-table tbody td {
    display: block;
    border-bottom: none;
    padding: 0;
    margin: 0;
    font-size: 0.78rem;
  }

  /* Styles des labels (Matériel, N°, Type…) */
  .employee-detail-page #employee-detail-table tbody td::before {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: none;
    color: var(--brand-grey);
    margin-bottom: 0.05rem;
  }

  /* Libellés colonne par colonne */
  .employee-detail-page #employee-detail-table tbody td:nth-child(1)::before { content: "Matériel"; }
  .employee-detail-page #employee-detail-table tbody td:nth-child(2)::before { content: "N° interne"; }
  .employee-detail-page #employee-detail-table tbody td:nth-child(3)::before { content: "Type"; }
  .employee-detail-page #employee-detail-table tbody td:nth-child(4)::before { content: "Marque"; }
  .employee-detail-page #employee-detail-table tbody td:nth-child(5)::before { content: "Qté"; }
  .employee-detail-page #employee-detail-table tbody td:nth-child(6)::before { content: "Dernier mouvement"; }

  /* Un peu d’air entre les sections */
  .employee-detail-page #employee-detail-table tbody td:nth-child(1) {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.35;
    margin-bottom: 0.2rem;
  }

  .employee-detail-page #employee-detail-table tbody td:nth-child(5) {
    margin-top: 0.3rem;
    font-weight: 600;
  }

  .employee-detail-page #employee-detail-table tbody td:nth-child(6) {
    margin-top: 0.25rem;
    font-size: 0.74rem;
    color: var(--brand-grey);
    line-height: 1.3;
  }
}
/* Détail employé : masquer la quantité */
#employee-detail-table thead th:nth-child(5),
#employee-detail-table tbody td:nth-child(5) {
  display: none;
}
/* Détail employé : N° / Type / Marque alignés sur une même ligne en mobile */
@media (max-width: 640px) {
  .employee-detail-page #employee-detail-table tbody td:nth-child(2),
  .employee-detail-page #employee-detail-table tbody td:nth-child(3),
  .employee-detail-page #employee-detail-table tbody td:nth-child(4) {
    display: inline-block;
    margin-right: 0.75rem;
    font-size: 0.75rem;
    color: var(--brand-grey);
  }

  .employee-detail-page #employee-detail-table tbody td:nth-child(2)::before,
  .employee-detail-page #employee-detail-table tbody td:nth-child(3)::before,
  .employee-detail-page #employee-detail-table tbody td:nth-child(4)::before {
    display: inline;
    margin-right: 0.15rem;
    font-weight: 600;
  }

  /* petit espace au-dessus de la ligne de méta */
  .employee-detail-page #employee-detail-table tbody td:nth-child(2) {
    margin-top: 0.2rem;
  }
}
/* ===========================
   Stock par agence – cartes
   =========================== */

.stock-agency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stock-agency-card {
  padding: 1rem 1.1rem;
}

.stock-agency-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.stock-agency-card .subtitle {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--brand-grey);
}

/* mini tableau à l'intérieur de la carte */
.stock-agency-card .table-wrapper {
  margin-top: 0.5rem;
  box-shadow: none;
}

.stock-agency-card .table {
  font-size: 0.78rem;
}

.stock-agency-card .table th,
.stock-agency-card .table td {
  padding: 0.35rem 0.5rem;
}
/* Cartes agences cliquables */
.stock-agency-card {
  padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.stock-agency-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.stock-agency-card .subtitle {
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}
/* Cartes agences – icônes & couleurs */
.stock-agency-card {
  border-left-width: 4px;
  border-left-color: var(--brand-red);
  background: linear-gradient(135deg, #fee2e2 0%, #ffffff 55%);
}

.stock-agency-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.stock-agency-text {
  flex: 1;
  min-width: 0;
}

.stock-agency-text h3 {
  margin: 0;
  font-size: 1rem;
}

.stock-agency-text .subtitle {
  margin-top: 0.15rem;
  margin-bottom: 0;
  font-size: 0.8rem;
  color: var(--brand-grey);
}

.stock-agency-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--brand-red);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(238, 50, 36, 0.35);
  flex-shrink: 0;
}


.stock-agency-pill {
  align-self: flex-start;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stock-agency-card .stock-agency-hint {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .stock-agency-card {
    padding: 1rem;
  }

  .stock-agency-icon {
    width: 2.1rem;
    height: 2.1rem;
    font-size: 0.8rem;
  }

  .stock-agency-pill {
    font-size: 0.7rem;
  }
}
/* Stock par agence – titre stylé */
.stock-by-agency-page .card > h2 {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.stock-by-agency-page .card > h2::before {
  content: "";
  width: 0.45rem;
  height: 1.6rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  box-shadow: 0 8px 20px rgba(238, 50, 36, 0.4);
}

.stock-by-agency-page .card > h2::after {
  content: "Vue globale";
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--brand-red-dark);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
/* ===========================
   Page Exploitation – carte principale
   =========================== */

.movement-card {
  max-width: 780px;
  margin-inline: auto;
}

.movement-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.movement-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.movement-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: var(--brand-red);
  font-size: 1.1rem;
  font-weight: 700;
}

.movement-card-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  font-size: 0.75rem;
  font-weight: 500;
  color: #b91c1c;
  white-space: nowrap;
}

.movement-card-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}

/* ===========================
   Formulaire mouvement – grille
   =========================== */

.movement-form-grid {
  margin-top: 0.75rem;
  row-gap: 0.6rem;
}

.movement-form-grid .form-group {
  margin-bottom: 0;
}

/* Sur grand écran : 2 lignes bien structurées */
@media (min-width: 1024px) {
  #movement-form.movement-form-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 0.75rem;
  }

  /* 1re ligne : Type (2) / Employé (2) / Réf (2) */
  #movement-form.movement-form-grid .form-group:nth-child(1) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(2) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(3) { grid-column: span 2; }

  /* 2e ligne : Chantier (3) / Date (2) / Bouton (1) */
  #movement-form.movement-form-grid .form-group:nth-child(4) { grid-column: span 3; }
  #movement-form.movement-form-grid .form-group:nth-child(5) { grid-column: span 2; }

  #movement-form.movement-form-grid .form-actions {
    grid-column: auto;
    align-self: stretch;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    margin-top: 0;
  }
}

/* Texte d'aide sous le formulaire */
.movement-help-text {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--brand-grey);
}

/* ===========================
   Bandeau "matériel trouvé"
   =========================== */

.found-item-name {
  font-size: 0.85rem;
  margin-top: 0.6rem;
  min-height: 0;
  line-height: 1.3;
}

/* Invisible tant qu'il n'y a pas de texte */
.found-item-name:empty {
  display: none;
}

/* Style badge quand il y a un message */
.found-item-name:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: var(--brand-grey);
}

.found-item-name:not(:empty)::before {
  content: "🔍";
  font-size: 0.95rem;
}

/* OK = vert */
.found-item-name.ok:not(:empty) {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
  font-weight: 600;
}
.found-item-name.ok:not(:empty)::before {
  content: "✅";
}

/* Erreur = rouge */
.found-item-name.error:not(:empty) {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
  font-weight: 600;
}
.found-item-name.error:not(:empty)::before {
  content: "⚠️";
}
/* ===========================
   Page Exploitation – carte principale
   =========================== */

.movement-card {
  max-width: 780px;
  margin-inline: auto;
}

.movement-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.movement-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.movement-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: var(--brand-red);
  font-size: 1.1rem;
  font-weight: 700;
}

.movement-card-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  font-size: 0.75rem;
  font-weight: 500;
  color: #b91c1c;
  white-space: nowrap;
}

.movement-card-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}

@media (max-width: 640px) {
  .movement-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .movement-card-pill {
    margin-top: 0.35rem;
  }
}

/* ===========================
   Formulaire mouvement – grille
   =========================== */

.movement-form-grid {
  margin-top: 0.75rem;
  row-gap: 0.6rem;
}

.movement-form-grid .form-group {
  margin-bottom: 0;
}

/* Sur grand écran : 2 lignes bien structurées */
@media (min-width: 1024px) {
  #movement-form.movement-form-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 0.75rem;
  }

  /* 1re ligne : Type (2) / Employé (2) / Réf (2) */
  #movement-form.movement-form-grid .form-group:nth-child(1) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(2) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(3) { grid-column: span 2; }

  /* 2e ligne : Chantier (3) / Date (2) / Bouton (1) */
  #movement-form.movement-form-grid .form-group:nth-child(4) { grid-column: span 3; }
  #movement-form.movement-form-grid .form-group:nth-child(5) { grid-column: span 2; }

  #movement-form.movement-form-grid .form-actions {
    grid-column: auto;
    align-self: stretch;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    margin-top: 0;
  }
}
/* ===========================
   Page Exploitation – carte mouvement (version "jolie")
   =========================== */

.movement-card {
  position: relative;
  max-width: 960px;
  margin-inline: auto;
  padding: 1.3rem 1.4rem 1.6rem;
  border-radius: 1rem;
  border: 1px solid #fecaca;
  background:
    radial-gradient(circle at 0 0, rgba(254, 226, 226, 0.9) 0, rgba(254, 226, 226, 0) 55%),
    #ffffff;
  box-shadow: 0 18px 40px rgba(248, 113, 113, 0.22);
}

/* Liseré rouge à gauche, comme une carte importante */
.movement-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1rem;
  bottom: 1rem;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    var(--brand-red),
    var(--brand-red-dark)
  );
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.25);
}

/* Header de la carte */

.movement-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.movement-card-title {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.movement-card-title h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.movement-card-title .subtitle {
  margin-top: 0.15rem;
}

/* Icône ronde rouge à gauche du titre */
.movement-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: var(--brand-red);
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(248, 113, 113, 0.35);
}

/* Pastille "Mouvement rapide" */

.movement-card-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  font-size: 0.75rem;
  font-weight: 500;
  color: #b91c1c;
  white-space: nowrap;
}

.movement-card-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}

/* Aide sous le formulaire */

.movement-help-text {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--brand-grey);
  font-style: italic;
}

/* Formulaire "Enregistrer un mouvement" */

.movement-form-grid {
  margin-top: 0.75rem;
  row-gap: 0.7rem;
}

.movement-form-grid .form-group {
  margin-bottom: 0;
}

/* Grille bien structurée sur grand écran : 2 lignes lisibles */
@media (min-width: 1024px) {
  #movement-form.movement-form-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 0.8rem;
  }

  /* 1re ligne : Type (2) / Employé (2) / Réf (2) */
  #movement-form.movement-form-grid .form-group:nth-child(1) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(2) { grid-column: span 2; }
  #movement-form.movement-form-grid .form-group:nth-child(3) { grid-column: span 2; }

  /* 2e ligne : Chantier (3) / Date (2) / Bouton (1) */
  #movement-form.movement-form-grid .form-group:nth-child(4) { grid-column: span 3; }
  #movement-form.movement-form-grid .form-group:nth-child(5) { grid-column: span 2; }

  #movement-form.movement-form-grid .form-actions {
    grid-column: auto;
    align-self: stretch;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    margin-top: 0;
  }
}

/* Mobile : on garde quelque chose de simple et empilé */
@media (max-width: 640px) {
  .movement-card {
    padding: 1.1rem 1rem 1.3rem;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
  }

  .movement-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .movement-card::before {
    top: 0.9rem;
    bottom: 0.9rem;
  }
}
/* ===================================
   Ajustements carte "Enregistrer un mouvement"
   =================================== */

/* Bords rouges + ombre légèrement rouge */
.card.movement-card {
  border-radius: 18px;
  border: 1px solid #f97373;           /* rouge clair sur tout le contour */
  box-shadow: 0 18px 40px rgba(248, 113, 113, 0.22);
}

/* Alignement propre de l'icône ↔ avec le titre */
.movement-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.movement-card-title h2 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
}

.movement-card-title .subtitle {
  margin: 0.2rem 0 0;
}

/* Icône bien centrée et qui ne se déforme pas */
.movement-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0;   /* au cas où un style précédent le décale */
}

/* On cache la pastille "Mouvement rapide" qui ne sert à rien pour l'instant */
.movement-card-pill {
  display: none;
}
/* Corrige le bug dans l'angle de la carte mouvement */
.card.movement-card {
  position: relative;
  border-radius: 18px;        /* ou la valeur que tu utilises déjà */
  border: 1px solid #f97373;  /* bord rouge tout autour */
  overflow: hidden;           /* IMPORTANT : coupe le liseré dans les coins */
}

/* On crée un liseré rouge propre, arrondi en haut/bas */
.card.movement-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px; /* épaisseur du liseré */
  background: linear-gradient(
    180deg,
    var(--brand-red),
    var(--brand-red-dark)
  );
}
/* ================================
   Détail stock par agence
   ================================ */

#stock-by-agency-table {
  table-layout: fixed;
  width: 100%;
}

#stock-by-agency-table th,
#stock-by-agency-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Répartition des largeurs :
   1: Matériel
   2: Numéro
   3: Type
   4: Marque
   5: Stock agence
*/
#stock-by-agency-table th:nth-child(1),
#stock-by-agency-table td:nth-child(1) {
  width: 40%;
}

#stock-by-agency-table th:nth-child(2),
#stock-by-agency-table td:nth-child(2) {
  width: 110px;
}

#stock-by-agency-table th:nth-child(3),
#stock-by-agency-table td:nth-child(3),
#stock-by-agency-table th:nth-child(4),
#stock-by-agency-table td:nth-child(4) {
  width: 140px;
}

#stock-by-agency-table th:nth-child(5),
#stock-by-agency-table td:nth-child(5) {
  width: 80px;
  text-align: center;
}

/* Version mobile : on laisse respirer, on autorise le scroll horizontal,
   et on simplifie un peu en masquant Type + Marque si l'écran est étroit. */
@media (max-width: 768px) {
  #agency-detail-container .table-wrapper {
    overflow-x: auto;
  }

  #stock-by-agency-table th:nth-child(3),
  #stock-by-agency-table td:nth-child(3),
  #stock-by-agency-table th:nth-child(4),
  #stock-by-agency-table td:nth-child(4) {
    display: none; /* on garde l’essentiel : Matériel, Numéro, Stock */
  }
}
