:root {
  --uzaw-sidebar-bg: #171923;
  --uzaw-sidebar-bg-2: #222638;
  --uzaw-sidebar-link: rgba(255, 255, 255, .74);
  --uzaw-sidebar-link-hover: #fff;
  --uzaw-main-bg: #f5f6fb;
  --uzaw-border: rgba(15, 23, 42, .09);
  --uzaw-soft-shadow: 0 12px 35px rgba(15, 23, 42, .08);
  --uzaw-soft-shadow-sm: 0 8px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  background: var(--uzaw-main-bg);
  color: var(--bs-body-color);
}

a { text-decoration: none; }

.layout {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 282px;
  background: linear-gradient(180deg, var(--uzaw-sidebar-bg), var(--uzaw-sidebar-bg-2));
  color: #fff;
  padding: 1.25rem 1rem;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 1040;
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.brand {
  margin-bottom: 1.45rem;
  padding: .25rem .35rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 42px;
  border-radius: 14px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-info));
  box-shadow: 0 10px 22px rgba(var(--bs-primary-rgb), .28);
}

.brand-title {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  display: block;
  margin-top: .15rem;
  font-size: .78rem;
  color: rgba(255, 255, 255, .58);
}

.nav-section-title {
  color: rgba(255, 255, 255, .44);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin: 1.05rem .65rem .45rem;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--uzaw-sidebar-link);
  padding: .62rem .75rem;
  border-radius: .85rem;
  margin-bottom: .18rem;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus,
.sidebar .nav-link.active {
  color: var(--uzaw-sidebar-link-hover);
  background: rgba(255, 255, 255, .12);
}

.sidebar .nav-link:hover { transform: translateX(2px); }
.sidebar .nav-link.active { box-shadow: inset 3px 0 0 var(--bs-primary); }
.sidebar .nav-link.nav-danger { color: #ffd7d7; }

.nav-icon {
  width: 1.25rem;
  display: inline-flex;
  justify-content: center;
  opacity: .9;
}

.main {
  flex: 1;
  margin-left: 282px;
  padding: 1.35rem;
  min-width: 0;
}

.topbar,
.page-header,
.actions,
.search-form,
.topbar-left,
.topbar-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border: 1px solid var(--uzaw-border);
  border-radius: 1.15rem;
  padding: .85rem 1rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--uzaw-soft-shadow-sm);
}

.topbar-left,
.topbar-actions {
  align-items: center;
}

.topbar-date {
  padding-left: .25rem;
  white-space: nowrap;
}

.sidebar-toggle {
  display: none;
  border: 1px solid var(--uzaw-border);
  background: var(--bs-body-bg);
  border-radius: .8rem;
  min-width: 42px;
  min-height: 42px;
  font-size: 1.2rem;
}

.page-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.page-header h1,
.page-header h2,
.page-header h3 {
  margin-bottom: 0;
  letter-spacing: -.02em;
}

.card,
.login-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--uzaw-border);
  border-radius: 1.05rem;
  padding: 1.15rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--uzaw-soft-shadow-sm);
}

.card .card {
  box-shadow: none;
  background: var(--bs-tertiary-bg);
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-number {
  font-size: clamp(2rem, 3vw, 2.65rem);
  font-weight: 800;
  line-height: 1;
  margin-top: .35rem;
  letter-spacing: -.04em;
}

.muted { color: var(--bs-secondary-color); }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--uzaw-border);
  border-radius: .95rem;
  background: var(--bs-body-bg);
}

.table-wrapper > table,
.main table {
  width: 100%;
  margin-bottom: 0;
  color: var(--bs-body-color);
  vertical-align: top;
  border-color: var(--bs-border-color);
  background-color: var(--bs-body-bg);
}

.table-wrapper > table th,
.table-wrapper > table td,
.main table th,
.main table td {
  padding: .75rem .8rem;
  border-bottom: 1px solid var(--uzaw-border);
  vertical-align: middle;
}

.table-wrapper > table thead th,
.main table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 800;
  white-space: nowrap;
}

.table-wrapper > table tbody tr:last-child td,
.main table tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrapper > table tbody tr:hover td,
.main table tbody tr:hover td {
  background: rgba(var(--bs-primary-rgb), .035);
}

.actions {
  align-items: center;
}

.actions .btn,
td .btn,
.image-card .btn {
  padding: .35rem .62rem;
  font-size: .86rem;
  border-radius: .7rem;
}

.btn {
  border-radius: .75rem;
  font-weight: 700;
}

.btn-outline {
  --bs-btn-color: #475569;
  --bs-btn-border-color: #cbd5e1;
  --bs-btn-hover-color: #0f172a;
  --bs-btn-hover-bg: #f1f5f9;
  --bs-btn-hover-border-color: #94a3b8;
  --bs-btn-focus-shadow-rgb: var(--bs-secondary-rgb);
  --bs-btn-active-color: #0f172a;
  --bs-btn-active-bg: #e2e8f0;
  --bs-btn-active-border-color: #94a3b8;
  --bs-btn-disabled-color: var(--bs-secondary-color);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--bs-border-color);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .38rem .55rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: .75rem;
  background: #e2e8f0;
  color: #334155;
}

.badge-success { background-color: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.badge-danger { background-color: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.badge-warning { background-color: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.badge-primary { background-color: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }

.search-form {
  align-items: end;
  margin-bottom: 1rem;
  padding: .9rem;
  border-radius: .95rem;
  background: #f8fafc;
  border: 1px solid var(--uzaw-border);
}

.search-form input,
.search-form select {
  width: min(290px, 100%);
}

label {
  font-weight: 800;
  margin-bottom: .35rem;
  color: #334155;
}

.required { color: var(--bs-danger); }

.form-row {
  margin-bottom: 1rem;
}

.form-row.has-error input,
.form-row.has-error select,
.form-row.has-error textarea {
  border-color: var(--bs-danger);
}

.form-check-row .check-line {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.form-check-row label {
  margin-bottom: 0;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  display: block;
  width: 100%;
  padding: .55rem .8rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: 1px solid #cbd5e1;
  border-radius: .85rem;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

input[type="file"] {
  display: block;
  width: 100%;
  padding: .55rem .8rem;
  color: var(--bs-body-color);
  border: 1px solid #cbd5e1;
  border-radius: .85rem;
  background: var(--bs-body-bg);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: .35rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(var(--bs-primary-rgb), .65);
  outline: 0;
  box-shadow: 0 0 0 .22rem rgba(var(--bs-primary-rgb), .14);
}

textarea { min-height: 110px; }

.helptext {
  display: block;
  color: var(--bs-secondary-color);
  font-size: .875rem;
  margin-top: .25rem;
}

.errorlist {
  margin: .4rem 0 0;
  padding-left: 1.2rem;
  color: var(--bs-danger);
  font-size: .9rem;
}

.messages { margin-bottom: 1rem; }
.public-messages { max-width: 480px; margin: 20px auto; }

.message,
.form-alert {
  position: relative;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--bs-info-border-subtle);
  border-radius: .95rem;
  color: var(--bs-info-text-emphasis);
  background-color: var(--bs-info-bg-subtle);
}

.message.success {
  color: var(--bs-success-text-emphasis);
  background-color: var(--bs-success-bg-subtle);
  border-color: var(--bs-success-border-subtle);
}

.message.error,
.message.danger {
  color: var(--bs-danger-text-emphasis);
  background-color: var(--bs-danger-bg-subtle);
  border-color: var(--bs-danger-border-subtle);
}

.message.warning {
  color: var(--bs-warning-text-emphasis);
  background-color: var(--bs-warning-bg-subtle);
  border-color: var(--bs-warning-border-subtle);
}

.detail-list {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: .75rem 1rem;
}

.detail-label {
  color: #64748b;
  font-weight: 800;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .8rem;
}

.image-card {
  border: 1px solid var(--uzaw-border);
  border-radius: .95rem;
  padding: .6rem;
  background: var(--bs-body-bg);
}

.image-card img {
  width: 100%;
  height: 135px;
  object-fit: cover;
  border-radius: .75rem;
  display: block;
}

.product-thumb {
  width: 58px;
  height: 58px;
  border-radius: .8rem;
  object-fit: cover;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1px solid var(--uzaw-border);
}

.pagination {
  justify-content: center;
  margin-top: 1rem;
  gap: .35rem;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  position: relative;
  display: block;
  padding: .45rem .75rem;
  font-size: .92rem;
  color: #475569;
  text-decoration: none;
  background-color: var(--bs-body-bg);
  border: 1px solid #cbd5e1;
  border-radius: .75rem;
}

.pagination .current {
  color: var(--bs-primary-text-emphasis);
  background-color: var(--bs-primary-bg-subtle);
  border-color: var(--bs-primary-border-subtle);
  font-weight: 800;
}

.danger-zone {
  border-color: var(--bs-danger-border-subtle) !important;
  background: var(--bs-danger-bg-subtle) !important;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at top left, rgba(var(--bs-primary-rgb), .18), transparent 34%),
    linear-gradient(135deg, #f8fafc, #eef2ff);
}

.login-panel {
  width: 100%;
  max-width: 455px;
}

.login-brand {
  margin-bottom: 1rem;
}

.login-brand h1 {
  margin: 0;
  font-weight: 900;
  letter-spacing: -.03em;
}

.login-brand p {
  margin: .15rem 0 0;
  color: #64748b;
}

.login-card { width: 100%; }
.login-card h2 { margin-bottom: .25rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1030;
  background: rgba(15, 23, 42, .48);
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .sidebar-toggle {
    display: inline-grid;
    place-items: center;
  }

  .layout { display: block; }

  .main {
    margin-left: 0;
    padding: 1rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .topbar,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
  }

  .search-form input,
  .search-form select,
  .search-form button,
  .search-form a {
    width: 100%;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .main { padding: .75rem; }
  .card, .login-card { padding: .95rem; border-radius: .9rem; }
  .table-wrapper > table th,
  .table-wrapper > table td,
  .main table th,
  .main table td { padding: .65rem; }
  .topbar-date { width: 100%; }
}

/* Commercial: inlines intégrés façon admin Django */
.inline-formset-card {
  overflow: hidden;
}
.inline-header {
  margin-bottom: .75rem;
}
.inline-header p {
  margin: .25rem 0 0;
}
.inline-table-wrapper {
  max-width: 100%;
}
.inline-table th,
.inline-table td {
  min-width: 180px;
}
.inline-table th:last-child,
.inline-table td:last-child {
  min-width: 120px;
  width: 120px;
}
.inline-delete-cell .check-line {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-weight: 700;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(245, 246, 251, .92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--uzaw-border);
  border-radius: 1rem;
  padding: .85rem;
  box-shadow: var(--uzaw-soft-shadow-sm);
  margin-top: 1rem;
}
@media (max-width: 768px) {
  .inline-table th,
  .inline-table td {
    min-width: 220px;
  }
}

/* Sidebar : correction d'affichage et navigation propre */
:root {
  --uzaw-sidebar-width: 255px;
}

.sidebar {
  width: var(--uzaw-sidebar-width);
  padding: 1.05rem .85rem calc(2rem + env(safe-area-inset-bottom));
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .28) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .22);
  border-radius: 999px;
}

.brand {
  position: sticky;
  top: -1.05rem;
  z-index: 2;
  margin: -1.05rem -.85rem .8rem;
  padding: 1.05rem 1rem .85rem;
  background: linear-gradient(180deg, var(--uzaw-sidebar-bg), rgba(23, 25, 35, .96));
  backdrop-filter: blur(10px);
}

.sidebar-nav {
  padding-bottom: 1.5rem;
}

.nav-section-title {
  margin: .85rem .65rem .35rem;
  line-height: 1.1;
}

.sidebar .nav-link {
  position: relative;
  min-height: 43px;
  padding: .52rem .7rem;
  margin-bottom: .12rem;
  line-height: 1.22;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar .nav-link > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-link.active {
  font-weight: 800;
  box-shadow: inset 4px 0 0 var(--bs-primary);
}

.nav-icon {
  flex: 0 0 1.35rem;
}

.main {
  margin-left: var(--uzaw-sidebar-width);
}

@media (max-height: 780px) and (min-width: 993px) {
  .sidebar {
    padding-top: .8rem;
  }

  .brand {
    top: -.8rem;
    margin-top: -.8rem;
    padding-top: .8rem;
    padding-bottom: .7rem;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 12px;
  }

  .brand-title {
    font-size: 1.04rem;
  }

  .nav-section-title {
    margin-top: .68rem;
    margin-bottom: .28rem;
  }

  .sidebar .nav-link {
    min-height: 40px;
    padding-top: .46rem;
    padding-bottom: .46rem;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: min(var(--uzaw-sidebar-width), 86vw);
  }

  .main {
    margin-left: 0;
  }
}


/* Sidebar : factorisation Commercial en groupes Clients / Devis */
.sidebar-group {
  margin-bottom: .18rem;
}

.sidebar-group summary {
  list-style: none;
  cursor: pointer;
}

.sidebar-group summary::-webkit-details-marker {
  display: none;
}

.sidebar-parent {
  user-select: none;
}

.sidebar-parent::after {
  content: "›";
  margin-left: auto;
  font-size: 1.05rem;
  line-height: 1;
  opacity: .62;
  transition: transform .18s ease, opacity .18s ease;
}

.sidebar-group[open] .sidebar-parent::after {
  transform: rotate(90deg);
  opacity: .9;
}

.sidebar-submenu {
  margin: .18rem 0 .42rem 1.05rem;
  padding-left: .65rem;
  border-left: 1px solid rgba(255, 255, 255, .10);
}

.sidebar .nav-link.sidebar-child {
  min-height: 34px;
  padding: .38rem .6rem;
  margin-bottom: .08rem;
  border-radius: .65rem;
  font-size: .88rem;
  font-weight: 500;
  opacity: .84;
}

.sidebar .nav-link.sidebar-child:hover,
.sidebar .nav-link.sidebar-child:focus {
  opacity: 1;
  transform: translateX(1px);
}

.sidebar .nav-link.sidebar-child.active {
  opacity: 1;
  font-weight: 700;
  background: rgba(255, 255, 255, .10);
  box-shadow: inset 3px 0 0 var(--bs-primary);
}

.sidebar .nav-link.sidebar-child span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline avances : rendu compact sans scroll horizontal */
.avance-formset-card {
  overflow: visible;
}

.avance-formset-list {
  display: grid;
  gap: .85rem;
}

.avance-inline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .85rem;
  align-items: end;
  padding: .9rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .95rem;
  background: #f8fafc;
}

.avance-inline-grid {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(190px, 1fr) minmax(150px, .9fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(190px, 1fr) minmax(220px, 1.2fr);
  gap: .75rem;
  align-items: start;
}

.avance-inline-row .form-row {
  margin-bottom: 0;
}

.avance-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 110px;
}

.avance-inline-actions .check-line {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-weight: 800;
}

.avance-field[hidden] {
  display: none !important;
}

@media (max-width: 1400px) {
  .avance-inline-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .avance-inline-row {
    grid-template-columns: 1fr;
  }

  .avance-inline-grid {
    grid-template-columns: 1fr;
  }

  .avance-inline-actions {
    justify-content: flex-start;
  }
}

/* Sélecteurs avec recherche. Produits et variantes conservent leur vignette. */
.image-select {
  --image-select-trigger-size: 40px;
  --image-select-option-size: 48px;
  --image-select-trigger-height: 50px;
  position: relative;
  flex: 1 1 230px;
  min-width: 0;
  width: 100%;
}

/* Densité adaptée aux formulaires Quick CRUD. */
.image-select[data-density="quick"] {
  --image-select-trigger-size: 36px;
  --image-select-option-size: 44px;
  --image-select-trigger-height: 46px;
  flex-basis: 210px;
}

/* Densité compacte pour les lignes CRUD, tableaux et formsets. */
.image-select[data-density="compact"] {
  --image-select-trigger-size: 32px;
  --image-select-option-size: 40px;
  --image-select-trigger-height: 42px;
  flex-basis: 180px;
}

.image-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
}

.image-select-trigger {
  width: 100%;
  min-height: var(--image-select-trigger-height);
  display: grid;
  grid-template-columns: var(--image-select-trigger-size) minmax(0, 1fr) auto;
  align-items: center;
  gap: .6rem;
  padding: .3rem .6rem;
  color: var(--bs-body-color);
  text-align: left;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: .7rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

/* Les autres listes déroulantes utilisent le même moteur de recherche,
   mais sans réserver d'espace pour une image. */
.image-select[data-kind="generic"] .image-select-trigger {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 44px;
  padding: .55rem .7rem;
}

.image-select[data-kind="generic"][data-density="quick"] .image-select-trigger,
.image-select[data-kind="generic"][data-density="compact"] .image-select-trigger {
  min-height: 42px;
  padding: .45rem .6rem;
}

.image-select[data-kind="generic"] .image-select-trigger-thumb,
.image-select-menu[data-kind="generic"] .image-select-option-thumb {
  display: none;
}

.image-select[data-density="compact"] .image-select-trigger {
  gap: .48rem;
  padding: .25rem .5rem;
  border-radius: .6rem;
}

.image-select-trigger:hover,
.image-select-trigger:focus {
  border-color: rgba(var(--bs-primary-rgb), .65);
  box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .12);
  outline: 0;
}

.image-select-trigger.is-invalid {
  border-color: var(--bs-danger);
  box-shadow: 0 0 0 .2rem rgba(var(--bs-danger-rgb), .12);
}

.image-select-trigger:disabled {
  cursor: not-allowed;
  opacity: .65;
  background: var(--bs-secondary-bg);
}

.image-select-trigger-thumb,
.image-select-option-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 2px;
  background: #fff;
  border: 1px solid var(--uzaw-border);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .02);
}

.image-select-trigger-thumb {
  width: var(--image-select-trigger-size);
  height: var(--image-select-trigger-size);
  border-radius: .55rem;
}

.image-select-option-thumb {
  width: var(--image-select-option-size);
  height: var(--image-select-option-size);
  border-radius: .62rem;
}

.image-select-trigger-thumb img,
.image-select-option-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: calc(.55rem - 3px);
  display: block;
}

.image-select-placeholder {
  color: #64748b;
  font-size: 1.15rem;
  font-weight: 800;
}

.image-select-trigger-text,
.image-select-option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-select-trigger-text {
  white-space: nowrap;
  font-size: .94rem;
  font-weight: 650;
  line-height: 1.25;
}

.image-select[data-density="compact"] .image-select-trigger-text {
  font-size: .875rem;
}

.image-select-chevron {
  color: #64748b;
  font-size: 1rem;
}

.image-select-menu {
  --image-select-option-size: 48px;
  position: fixed;
  z-index: 10050;
  max-height: min(430px, calc(100vh - 24px));
  overflow: hidden;
  background: var(--bs-body-bg);
  border: 1px solid var(--uzaw-border);
  border-radius: .95rem;
  box-shadow: 0 24px 65px rgba(15, 23, 42, .24);
}

.image-select-menu[data-density="quick"] {
  --image-select-option-size: 44px;
}

.image-select-menu[data-density="compact"] {
  --image-select-option-size: 40px;
}

.image-select-menu[hidden] { display: none; }

.image-select-search-wrap {
  padding: .65rem;
  border-bottom: 1px solid var(--uzaw-border);
  background: var(--bs-tertiary-bg);
}

.image-select-search {
  width: 100%;
  min-height: 40px;
  padding: .5rem .7rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .65rem;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.image-select-options {
  max-height: 340px;
  overflow-y: auto;
  padding: .35rem;
}

.image-select-option {
  width: 100%;
  display: grid;
  grid-template-columns: var(--image-select-option-size) minmax(0, 1fr);
  align-items: center;
  gap: .7rem;
  min-height: calc(var(--image-select-option-size) + .7rem);
  padding: .35rem .45rem;
  border: 0;
  border-radius: .7rem;
  color: var(--bs-body-color);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.image-select-option[hidden] {
  display: none !important;
}

.image-select-menu[data-kind="generic"] .image-select-option {
  grid-template-columns: minmax(0, 1fr);
  min-height: 42px;
  padding: .55rem .65rem;
}

.image-select-menu[data-density="compact"] .image-select-option {
  gap: .55rem;
  font-size: .9rem;
}

.image-select-option:hover,
.image-select-option:focus,
.image-select-option[aria-selected="true"] {
  background: var(--bs-primary-bg-subtle);
  outline: 0;
}

.image-select-option[aria-selected="true"] .image-select-option-label {
  color: var(--bs-primary-text-emphasis);
  font-weight: 800;
}

.image-select-option:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.image-select-empty {
  padding: 1rem;
  color: var(--bs-secondary-color);
  text-align: center;
}

/* Le bouton Quick CRUD reste parfaitement aligné avec le sélecteur illustré. */
.field-with-action:has(.image-select) {
  align-items: stretch;
}

.field-with-action .image-select + .btn {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.inline-table .image-select,
[data-formset-row] .image-select {
  min-width: 165px;
}

@media (max-width: 640px) {
  .image-select {
    flex-basis: 100%;
  }

  .image-select-menu {
    max-width: calc(100vw - 24px);
  }

  .field-with-action:has(.image-select) {
    align-items: stretch;
  }
}

.stock-media-cell {
  width: 72px;
}

.stock-media-placeholder {
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 1.35rem;
}

.movement-product-card {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .8rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .95rem;
  background: var(--bs-tertiary-bg);
  margin-bottom: 1rem;
}

.movement-product-card .product-thumb {
  width: 86px;
  height: 86px;
  flex: 0 0 86px;
}

@media (max-width: 640px) {
  .image-select { flex-basis: 100%; }
  .image-select-menu { max-width: calc(100vw - 24px); }
}

/* Suppressions protégées -------------------------------------------------- */
.delete-blocked-panel {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--bs-danger-border-subtle);
  border-radius: 1rem;
  color: var(--bs-danger-text-emphasis);
  background: var(--bs-danger-bg-subtle);
}

.delete-blocked-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--bs-danger);
  font-size: 1.35rem;
  font-weight: 900;
}

.delete-blocked-panel h2 {
  margin: 0 0 .35rem;
  font-size: 1.1rem;
}

.delete-blocked-panel p {
  margin: 0;
}

.delete-blocker-list {
  display: grid;
  gap: .55rem;
  margin-top: .85rem;
}

.delete-blocker-item {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .65rem;
  padding: .65rem .75rem;
  border: 1px solid rgba(var(--bs-danger-rgb), .18);
  border-radius: .75rem;
  background: rgba(255, 255, 255, .55);
}

.delete-blocker-item .muted {
  width: 100%;
  overflow-wrap: anywhere;
}

.delete-help-text {
  margin-top: .85rem !important;
}

@media (max-width: 640px) {
  .delete-blocked-panel {
    grid-template-columns: 1fr;
  }
}

/* Dashboard : suivi commercial et stock */
.dashboard-heading {
  margin-bottom: 1.35rem;
}

.dashboard-subtitle,
.section-heading p,
.dashboard-outstanding-card .page-header p,
.grid-2 .page-header p {
  margin: .3rem 0 0;
}

.dashboard-quick-actions {
  justify-content: flex-end;
}

.dashboard-section {
  margin-bottom: 1.2rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
}

.section-heading h2 {
  margin: 0;
  letter-spacing: -.02em;
}

.dashboard-stats .card {
  margin-bottom: 0;
}

.stat-card {
  position: relative;
  min-height: 150px;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  right: -34px;
  top: -34px;
  background: rgba(100, 116, 139, .07);
}

.stat-card-primary { border-top: 3px solid var(--bs-primary); }
.stat-card-success { border-top: 3px solid var(--bs-success); }
.stat-card-warning { border-top: 3px solid var(--bs-warning); }
.stat-card-danger { border-top: 3px solid var(--bs-danger); }

.stat-card-primary::after { background: rgba(var(--bs-primary-rgb), .10); }
.stat-card-success::after { background: rgba(var(--bs-success-rgb), .10); }
.stat-card-warning::after { background: rgba(var(--bs-warning-rgb), .13); }
.stat-card-danger::after { background: rgba(var(--bs-danger-rgb), .10); }

.stat-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.stat-icon {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  border-radius: .8rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-weight: 900;
  font-size: 1.05rem;
}

.stat-money {
  font-size: clamp(1.45rem, 2.15vw, 2.15rem);
  white-space: nowrap;
}

.stat-money small {
  font-size: .43em;
  letter-spacing: 0;
}

.stat-caption {
  position: relative;
  z-index: 1;
  margin-top: .75rem;
  color: var(--bs-secondary-color);
  font-size: .84rem;
}

.dashboard-outstanding-card {
  margin-top: 1.15rem;
}

.dashboard-outstanding-card .page-header {
  margin-bottom: .85rem;
}

.remaining-amount {
  color: var(--bs-danger-text-emphasis);
}

.payment-cell {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 125px;
}

.payment-cell > span {
  min-width: 37px;
  color: var(--bs-secondary-color);
  font-size: .78rem;
  font-weight: 800;
}

.payment-progress {
  height: 8px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.payment-progress-bar {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bs-primary), var(--bs-success));
}

.payment-progress-large {
  height: 10px;
  margin-top: .4rem;
}

.row-expired td {
  background: rgba(var(--bs-danger-rgb), .035);
}

.dashboard-mini-badge {
  margin-top: .35rem;
  padding: .25rem .4rem;
  font-size: .66rem;
}

.dashboard-small-text {
  margin-top: .3rem;
  font-size: .75rem;
  white-space: nowrap;
}

.empty-state {
  padding: 2rem !important;
  text-align: center;
}

.dashboard-breakdown {
  margin-bottom: 1.3rem;
}

.dashboard-breakdown .card {
  margin-bottom: 0;
}

.collection-card-title,
.collection-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.collection-card-title h3 {
  margin: 0;
  font-size: 1.05rem;
}

.collection-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0 .9rem;
}

.collection-values > div {
  min-width: 0;
}

.collection-values span,
.collection-values strong {
  display: block;
}

.collection-values span {
  margin-bottom: .2rem;
  font-size: .76rem;
}

.collection-values strong {
  font-size: .93rem;
  word-break: break-word;
}

.collection-progress-label {
  color: var(--bs-secondary-color);
  font-size: .76rem;
  font-weight: 700;
}

.dashboard-stock-section {
  margin-top: 1.35rem;
}

.text-end { text-align: right; }
.text-nowrap { white-space: nowrap; }
.text-danger { color: var(--bs-danger) !important; }

@media (max-width: 1250px) {
  .dashboard-stats.grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-breakdown.grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard-quick-actions,
  .dashboard-quick-actions .btn {
    width: 100%;
  }

  .dashboard-stats.grid-4 {
    grid-template-columns: 1fr;
  }

  .collection-values {
    grid-template-columns: 1fr;
  }

  .collection-values > div {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--uzaw-border);
  }

  .collection-values span,
  .collection-values strong {
    margin: 0;
  }
}

/* Miniatures harmonisées dans les tables des pages de détail. */
.product-image-cell {
  width: 78px;
  min-width: 78px;
  text-align: center;
  vertical-align: middle;
}

.product-image-cell .product-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

/* Devis classique / HT : inlines tabulaires, alignés et responsives. */
.product-line-formset-card,
.avance-line-formset-card {
  overflow: visible;
}

.product-line-table-scroll,
.avance-line-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-radius: .85rem;
  scrollbar-width: thin;
}

.product-line-table-scroll:focus-visible,
.avance-line-table-scroll:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Les lignes produit gardent toujours une structure de tableau. */
.product-line-table {
  width: 100%;
  border: 1px solid var(--uzaw-border);
  border-radius: .85rem;
  background: #fff;
}

.product-line-table-with-remise {
  min-width: 1040px;
}

.product-line-table-without-remise {
  min-width: 980px;
}

.product-line-table-header,
.product-line-inline-row {
  display: grid;
  gap: .5rem;
  align-items: center;
}

.product-line-table-with-remise .product-line-table-header,
.product-line-table-with-remise .product-line-inline-row {
  grid-template-columns:
    36px
    minmax(205px, 2fr)
    minmax(195px, 1.8fr)
    minmax(165px, 1.4fr)
    minmax(78px, .55fr)
    minmax(112px, .75fr)
    minmax(90px, .62fr)
    52px;
}

.product-line-table-without-remise .product-line-table-header,
.product-line-table-without-remise .product-line-inline-row {
  grid-template-columns:
    36px
    minmax(220px, 2.05fr)
    minmax(205px, 1.85fr)
    minmax(180px, 1.45fr)
    minmax(82px, .58fr)
    minmax(120px, .78fr)
    52px;
}

.product-line-table-header,
.avance-line-table-header {
  position: relative;
  z-index: 2;
  padding: .58rem .65rem;
  border-bottom: 1px solid var(--uzaw-border);
  border-radius: .8rem .8rem 0 0;
  background: #f1f5f9;
  color: #475569;
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .025em;
  line-height: 1.2;
  text-transform: uppercase;
}

.product-line-formset-list,
.avance-line-formset-list {
  display: block;
}

.product-line-inline-row {
  position: relative;
  padding: .6rem .65rem;
  border-bottom: 1px solid var(--uzaw-border);
  background: #fff;
  transition: background-color .15s ease;
}

.product-line-inline-row:last-child,
.avance-line-row:last-child {
  border-bottom: 0;
  border-radius: 0 0 .8rem .8rem;
}

.product-line-inline-row:hover,
.product-line-inline-row:focus-within,
.avance-line-row:hover,
.avance-line-row:focus-within {
  background: #f8fafc;
}

.product-line-index-cell,
.product-line-actions-cell,
.avance-line-index-cell,
.avance-line-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.product-line-table-header .product-line-index-cell,
.product-line-table-header .product-line-actions-cell,
.avance-line-table-header .avance-line-index-cell,
.avance-line-table-header .avance-line-actions-cell {
  align-self: stretch;
}

.product-line-number,
.avance-line-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: .76rem;
  font-weight: 800;
}

.product-line-field,
.avance-line-field {
  min-width: 0;
  margin: 0;
}

.product-line-field > input,
.product-line-field > select,
.product-line-field > textarea,
.product-line-select-action,
.product-line-select-action > .image-select,
.avance-line-field > input,
.avance-line-field > select,
.avance-line-field > textarea,
.avance-line-payment-field > input {
  width: 100%;
  min-width: 0;
}

.product-line-field input,
.product-line-field select,
.product-line-select-action .image-select-trigger,
.avance-line-field input,
.avance-line-field select,
.avance-line-field textarea,
.avance-line-payment-field input {
  min-height: 40px;
}

.product-line-accessible-label,
.avance-line-accessible-label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.product-line-select-action {
  display: flex;
  align-items: stretch;
  gap: .32rem;
}

.product-line-select-action > select,
.product-line-select-action > .image-select {
  flex: 1 1 auto;
}

.product-line-quick-add {
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  padding-inline: 0;
  font-size: 1rem;
  font-weight: 800;
}

.inline-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: .55rem;
  font-size: 1.2rem;
  line-height: 1;
}

.product-line-delete-button {
  width: 34px;
  padding-inline: 0;
}

.product-line-errors .errorlist,
.product-line-field > .errorlist,
.avance-line-errors .errorlist {
  margin: .3rem 0 0;
  padding-left: .95rem;
  font-size: .73rem;
}

/* Avances des devis classique et HT : une ligne, des colonnes fixes. */
.avance-line-table {
  width: 100%;
  border: 1px solid var(--uzaw-border);
  border-radius: .85rem;
  background: #fff;
}

.avance-line-table-full {
  min-width: 1020px;
}

.avance-line-table-compact {
  min-width: 720px;
}

.avance-line-table-header,
.avance-line-row {
  display: grid;
  gap: .5rem;
  align-items: center;
}

.avance-line-table-full .avance-line-table-header,
.avance-line-row-full {
  grid-template-columns:
    36px
    minmax(118px, .72fr)
    minmax(180px, 1.05fr)
    minmax(132px, .8fr)
    minmax(190px, 1.08fr)
    minmax(220px, 1.35fr)
    52px;
}

.avance-line-table-compact .avance-line-table-header,
.avance-line-row-compact {
  grid-template-columns:
    36px
    minmax(125px, .75fr)
    minmax(190px, 1fr)
    minmax(270px, 1.65fr)
    52px;
}

.avance-inline-row.avance-line-row {
  position: relative;
  display: grid;
  padding: .6rem .65rem;
  border: 0;
  border-bottom: 1px solid var(--uzaw-border);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.avance-line-payment-detail-cell {
  position: relative;
  min-width: 0;
}

.avance-line-payment-field[hidden] {
  display: none !important;
}

.avance-line-payment-placeholder {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: .45rem .7rem;
  border: 1px dashed var(--uzaw-border);
  border-radius: .6rem;
  background: #f8fafc;
}

.avance-line-payment-placeholder[hidden] {
  display: none !important;
}

.avance-line-field-note textarea {
  height: 40px;
  min-height: 40px;
  max-height: 110px;
  resize: vertical;
  line-height: 1.25;
}

.avance-line-formset-card .avance-formset-empty {
  margin: 0;
  padding: .85rem 1rem;
  border: 0;
  border-radius: 0 0 .8rem .8rem;
  background: #fff;
  text-align: center;
}

.avance-formset-empty[hidden] {
  display: none !important;
}

/* Les extrémités restent visibles pendant le défilement horizontal. */
.product-line-inline-row > .product-line-index-cell,
.product-line-table-header > .product-line-index-cell,
.avance-line-row > .avance-line-index-cell,
.avance-line-table-header > .avance-line-index-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  background: inherit;
}

.product-line-inline-row > .product-line-actions-cell,
.product-line-table-header > .product-line-actions-cell,
.avance-line-row > .avance-line-actions-cell,
.avance-line-table-header > .avance-line-actions-cell {
  position: sticky;
  right: 0;
  z-index: 3;
  background: inherit;
  box-shadow: -7px 0 10px -10px rgba(15, 23, 42, .45);
}

@media (max-width: 768px) {
  .inline-header .btn {
    width: 100%;
  }

  .product-line-table-scroll,
  .avance-line-table-scroll {
    margin-inline: -.15rem;
    width: calc(100% + .3rem);
  }

  .product-line-table-header,
  .avance-line-table-header {
    font-size: .69rem;
  }

  .product-line-inline-row,
  .avance-inline-row.avance-line-row {
    padding-block: .55rem;
  }
}

/* Tableaux : en-têtes compacts, compteurs, aperçu limité et vue agrandie. */
.table-section-header {
  align-items: flex-start;
  gap: .8rem 1rem;
  margin-bottom: .75rem;
  padding-bottom: .72rem;
  border-bottom: 1px solid var(--uzaw-border);
}

.table-section-header > h1,
.table-section-header > h2,
.table-section-header > h3,
.table-section-header > div:first-child {
  min-width: 0;
}

.table-section-header h1,
.table-section-header h2,
.table-section-header h3 {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
}

.table-title-count {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: .2rem .55rem;
  border: 1px solid rgba(var(--bs-primary-rgb), .2);
  border-radius: 999px;
  background: rgba(var(--bs-primary-rgb), .08);
  color: var(--bs-primary);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.table-section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.table-section-actions .btn,
.detail-table-expand-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
  min-height: 36px;
  padding: .38rem .68rem;
  border-radius: .68rem;
  font-size: .8rem;
  line-height: 1.1;
  white-space: nowrap;
}

.detail-table-expand-icon {
  font-size: .96rem;
  line-height: 1;
}

.managed-table-wrapper {
  max-width: 100%;
  scrollbar-width: thin;
}

.managed-table-wrapper > table {
  width: 100%;
  min-width: 720px;
  table-layout: auto;
}

.managed-table-wrapper > table th,
.managed-table-wrapper > table td {
  padding: .64rem .72rem;
}

.managed-table-wrapper > table th {
  font-size: .72rem;
}

.managed-table-wrapper > table td {
  max-width: 330px;
  overflow-wrap: anywhere;
}

.managed-table-wrapper > table th:first-child,
.managed-table-wrapper > table td:first-child {
  padding-left: .82rem;
}

.managed-table-wrapper > table th:last-child,
.managed-table-wrapper > table td:last-child {
  padding-right: .82rem;
}

.managed-table-wrapper td.actions {
  display: table-cell;
  width: 1%;
  min-width: 118px;
  white-space: nowrap;
}

.managed-table-wrapper td.actions .btn {
  min-height: 31px;
  padding: .3rem .52rem;
  border-radius: .58rem;
  font-size: .75rem;
}

.managed-table-wrapper td.actions .btn + .btn {
  margin-left: .3rem;
}

.managed-table-wrapper .product-image-cell {
  width: 66px;
  min-width: 66px;
}

.detail-table-preview-hidden {
  display: none;
}

.detail-table-preview-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .58rem;
  padding: .42rem .15rem 0;
  color: var(--bs-secondary-color);
  font-size: .78rem;
}

.detail-table-preview-summary strong {
  flex: 0 0 auto;
  color: var(--bs-body-color);
  font-size: .76rem;
}

.detail-table-preview-summary[hidden],
.table-legacy-count-badge[hidden] {
  display: none !important;
}

.detail-table-modal[hidden] {
  display: none;
}

.detail-table-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.detail-table-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .68);
  backdrop-filter: blur(3px);
}

.detail-table-modal-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1500px, calc(100vw - 2rem));
  height: min(92vh, 980px);
  min-height: min(560px, calc(100vh - 2rem));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 1.15rem;
  background: var(--bs-body-bg);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .35);
}

.detail-table-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.05rem;
  border-bottom: 1px solid var(--uzaw-border);
  background: var(--bs-body-bg);
}

.detail-table-modal-header h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
}

.detail-table-modal-eyebrow {
  margin: 0 0 .15rem;
  color: var(--bs-primary);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.detail-table-modal-close {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--uzaw-border);
  border-radius: .72rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.detail-table-modal-close:hover,
.detail-table-modal-close:focus {
  border-color: rgba(var(--bs-primary-rgb), .5);
  background: rgba(var(--bs-primary-rgb), .08);
  outline: 0;
}

.detail-table-modal-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.05rem;
  border-bottom: 1px solid var(--uzaw-border);
  background: var(--bs-tertiary-bg);
}

.detail-table-search-area {
  display: grid;
  flex: 1 1 auto;
  gap: .3rem;
  min-width: 0;
  max-width: 900px;
}

.detail-table-search-label {
  color: var(--bs-body-color);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.15;
}

.detail-table-search-control {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 42px;
  align-items: stretch;
  min-width: 0;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  border-radius: .78rem;
  background: var(--bs-body-bg);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.detail-table-search-control:hover {
  border-color: rgba(var(--bs-primary-rgb), .42);
}

.detail-table-search-control:focus-within {
  border-color: rgba(var(--bs-primary-rgb), .72);
  background: var(--bs-body-bg);
  box-shadow: 0 0 0 .22rem rgba(var(--bs-primary-rgb), .13);
}

.detail-table-search-control input {
  grid-column: 2;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: .58rem .8rem !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--bs-body-color);
  font-size: .9rem;
  box-shadow: none !important;
  outline: 0 !important;
  appearance: none;
  -webkit-appearance: none;
}

.detail-table-search-control input::placeholder {
  color: var(--bs-secondary-color);
  opacity: .78;
}

.detail-table-search-control input::-webkit-search-decoration,
.detail-table-search-control input::-webkit-search-cancel-button,
.detail-table-search-control input::-webkit-search-results-button,
.detail-table-search-control input::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
}

.detail-table-search-icon {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 46px;
  min-width: 46px;
  height: 100%;
  color: var(--bs-secondary-color);
  border-right: 1px solid var(--uzaw-border);
  background: rgba(var(--bs-primary-rgb), .025);
  pointer-events: none;
}

.detail-table-search-control:focus-within .detail-table-search-icon {
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), .065);
}

.detail-table-search-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  vector-effect: non-scaling-stroke;
}

.detail-table-search-clear {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: .58rem;
  background: transparent;
  color: var(--bs-secondary-color);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.detail-table-search-clear[hidden] {
  display: none;
}

.detail-table-search-clear:hover,
.detail-table-search-clear:focus-visible {
  background: rgba(var(--bs-primary-rgb), .1);
  color: var(--bs-primary);
  outline: 0;
}

.detail-table-search-hint {
  color: var(--bs-secondary-color);
  font-size: .7rem;
  line-height: 1.2;
}

.detail-table-search-status {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 44px;
}

.detail-table-result-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: .35rem .7rem;
  border: 1px solid var(--uzaw-border);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-secondary-color);
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.detail-table-modal-content {
  min-height: 0;
  flex: 1 1 auto;
  padding: .85rem;
  overflow: hidden;
  background: var(--bs-tertiary-bg);
}

.detail-table-wrapper-expanded {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: auto;
  border-radius: .82rem;
  box-shadow: var(--uzaw-soft-shadow-sm);
}

.detail-table-wrapper-expanded > table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.detail-table-wrapper-expanded > table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--uzaw-border);
}

.detail-table-no-results td {
  padding: 2.5rem 1rem !important;
  background: var(--bs-body-bg) !important;
}

.detail-table-empty-state {
  display: grid;
  gap: .25rem;
  justify-items: center;
  color: var(--bs-secondary-color);
  text-align: center;
}

.detail-table-empty-state strong {
  color: var(--bs-body-color);
}

body.detail-table-modal-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .table-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-section-actions {
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }

  .table-section-actions .btn,
  .detail-table-expand-button {
    flex: 0 1 auto;
  }

  .managed-table-wrapper {
    margin-inline: -.15rem;
    width: calc(100% + .3rem);
    border-radius: .78rem;
  }

  .managed-table-wrapper > table {
    min-width: 680px;
  }

  .managed-table-wrapper > table th,
  .managed-table-wrapper > table td {
    padding: .56rem .62rem;
  }

  .detail-table-preview-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: .18rem;
  }

  .detail-table-modal {
    padding: 0;
  }

  .detail-table-modal-card {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .detail-table-modal-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: .58rem;
    padding: .72rem .78rem;
  }

  .detail-table-search-area {
    max-width: none;
  }

  .detail-table-search-status {
    justify-content: flex-end;
    min-height: auto;
  }

  .detail-table-modal-content {
    padding: .55rem;
  }
}

@media (max-width: 480px) {
  .table-section-actions .btn {
    flex: 1 1 calc(50% - .25rem);
  }

  .table-title-count {
    font-size: .68rem;
  }

  .detail-table-search-control {
    grid-template-columns: 40px minmax(0, 1fr) 38px;
    min-height: 42px;
  }

  .detail-table-search-control input {
    min-height: 40px;
    padding: .54rem .65rem !important;
    font-size: .84rem;
  }

  .detail-table-search-icon {
    width: 40px;
    min-width: 40px;
  }

  .detail-table-search-icon svg {
    width: 17px;
    height: 17px;
  }

  .detail-table-search-hint {
    display: none;
  }
}

/* Authentification */
.sidebar-logout-form { margin: 0; }
.sidebar-logout-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
}

.login-wrapper {
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 3rem);
}

.login-shell {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  gap: clamp(1.2rem, 4vw, 3.5rem);
  align-items: center;
}

.login-intro {
  padding: clamp(.25rem, 2vw, 1.5rem);
}

.login-intro .login-brand {
  align-items: flex-start;
  margin-bottom: 2rem;
}

.login-intro .brand-mark {
  width: 54px;
  height: 54px;
  flex-basis: 54px;
  border-radius: 17px;
  font-size: 1.25rem;
}

.login-intro h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.05em;
}

.login-intro .login-brand p {
  max-width: 590px;
  margin: .7rem 0 0;
  color: #64748b;
  font-size: 1.02rem;
  line-height: 1.65;
}

.login-points {
  display: grid;
  gap: .9rem;
}

.login-points > div {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: .75rem;
  align-items: start;
}

.login-points span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--bs-primary-text-emphasis);
  background: var(--bs-primary-bg-subtle);
  font-weight: 900;
}

.login-points p {
  margin: .2rem 0 0;
  color: #475569;
  line-height: 1.5;
}

.login-card {
  margin: 0;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: 1.35rem;
  box-shadow: 0 25px 65px rgba(15, 23, 42, .13);
}

.login-card-header {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  margin-bottom: 1.35rem;
}

.login-lock {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border-radius: 13px;
  color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  font-size: 1.25rem;
  font-weight: 900;
}

.login-card-header h2 { margin: 0 0 .2rem; }
.login-card-header p { margin: 0; }
.login-card .form-row { margin-bottom: 1rem; }
.login-card input[type="text"],
.login-card input[type="password"] { min-height: 48px; }

.password-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: -.15rem 0 1rem;
  color: var(--bs-secondary-color);
  font-size: .9rem;
  cursor: pointer;
}

.password-toggle input { margin: 0; }
.login-submit { min-height: 48px; font-weight: 800; }
.login-help {
  margin: 1.15rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--uzaw-border);
  color: var(--bs-secondary-color);
  font-size: .86rem;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .login-shell {
    max-width: 500px;
    grid-template-columns: 1fr;
  }
  .login-intro { padding: 0; }
  .login-points { display: none; }
  .login-intro .login-brand { margin-bottom: 0; }
  .login-intro .brand-mark {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }
  .login-intro h1 { font-size: 2rem; }
  .login-intro .login-brand p { font-size: .94rem; }
}

/* Gestion des utilisateurs et profil */
.topbar-profile-link {
  display: inline-flex;
  align-items: baseline;
  gap: .25rem;
  color: inherit;
  text-decoration: none;
  border-radius: .6rem;
}
.topbar-profile-link:hover strong { color: var(--bs-primary); }

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.account-stat {
  display: grid;
  gap: .2rem;
  padding: 1.15rem 1.25rem;
}
.account-stat > span {
  color: var(--bs-secondary-color);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.account-stat strong {
  font-size: 2rem;
  line-height: 1;
}
.account-stat small { color: var(--bs-secondary-color); }

.account-search-form {
  grid-template-columns: minmax(220px, 1fr) minmax(170px, .35fr) auto auto;
}
.account-search-form select { min-width: 170px; }

.user-cell {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-width: 180px;
}
.user-cell > div { display: grid; gap: .12rem; }
.user-cell small {
  width: fit-content;
  padding: .08rem .38rem;
  border-radius: 999px;
  color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  font-size: .68rem;
  font-weight: 800;
}
.user-avatar,
.profile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--bs-primary), #3657c9);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(49, 83, 198, .18);
}
.user-avatar { width: 38px; height: 38px; font-size: .9rem; }
.username-code {
  display: inline-block;
  padding: .28rem .48rem;
  border-radius: .42rem;
  color: #334155;
  background: #f1f5f9;
  font-size: .8rem;
  white-space: nowrap;
}
.user-contact { display: grid; gap: .12rem; min-width: 160px; }
.user-contact small { color: var(--bs-secondary-color); }
.role-badge,
.status-dot {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
  white-space: nowrap;
}
.role-badge { padding: .35rem .62rem; }
.role-admin { color: #6d28d9; background: #ede9fe; }
.role-magasinier { color: #075985; background: #e0f2fe; }
.status-dot { gap: .38rem; }
.status-dot::before {
  content: "";
  width: .48rem;
  height: .48rem;
  border-radius: 50%;
}
.status-active { color: #166534; }
.status-active::before { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.status-inactive { color: #991b1b; }
.status-inactive::before { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }

.account-form-layout,
.profile-layout {
  display: grid;
  gap: 1rem;
  align-items: start;
}
.account-form-layout { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .7fr); }
.account-form-card { padding: clamp(1rem, 3vw, 1.5rem); }
.account-help-card {
  position: sticky;
  top: 1rem;
  padding: 1.35rem;
}
.account-help-card h2 { margin: .65rem 0 .55rem; }
.account-help-card > p { color: var(--bs-secondary-color); line-height: 1.55; }
.account-help-icon,
.profile-lock {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  font-weight: 900;
}
.role-note {
  display: grid;
  gap: .2rem;
  margin-top: .8rem;
  padding: .8rem .9rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .8rem;
  background: #f8fafc;
}
.role-note span { color: var(--bs-secondary-color); font-size: .84rem; line-height: 1.4; }

.credential-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.credential-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .65);
  backdrop-filter: blur(4px);
}
.credential-modal-card {
  position: relative;
  width: min(100%, 520px);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: 1.35rem;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .32);
  text-align: center;
  animation: credential-in .2s ease-out;
}
@keyframes credential-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-open { overflow: hidden; }
.credential-success-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto .85rem;
  border-radius: 50%;
  color: #166534;
  background: #dcfce7;
  font-size: 1.55rem;
  font-weight: 900;
}
.credential-eyebrow {
  margin: 0 0 .25rem;
  color: #166534;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.credential-modal-card h2 { margin: 0 0 .45rem; }
.credential-field {
  margin-top: .9rem;
  padding: .75rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .85rem;
  background: #f8fafc;
  text-align: left;
}
.credential-field > span {
  display: block;
  margin-bottom: .45rem;
  color: var(--bs-secondary-color);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}
.credential-field > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: center;
}
.credential-field code {
  overflow-wrap: anywhere;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 800;
}
.credential-password code { font-size: 1.08rem; letter-spacing: .025em; }
.copy-button {
  padding: .42rem .62rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .55rem;
  color: var(--bs-primary);
  background: #fff;
  font-size: .75rem;
  font-weight: 800;
  cursor: pointer;
}
.copy-button:hover { border-color: var(--bs-primary); }
.credential-warning {
  display: grid;
  gap: .2rem;
  margin: 1rem 0;
  padding: .8rem .9rem;
  border-radius: .8rem;
  color: #92400e;
  background: #fffbeb;
  text-align: left;
  font-size: .84rem;
}
.credential-close { width: 100%; min-height: 46px; }

.profile-layout { grid-template-columns: minmax(250px, .65fr) minmax(0, 1.35fr); }
.profile-summary {
  display: grid;
  justify-items: center;
  padding: 1.5rem;
  text-align: center;
}
.profile-avatar { width: 72px; height: 72px; font-size: 1.45rem; }
.profile-summary h2 { margin: .8rem 0 .4rem; }
.profile-details {
  width: 100%;
  margin: 1.25rem 0 0;
  text-align: left;
}
.profile-details > div {
  display: grid;
  gap: .15rem;
  padding: .75rem 0;
  border-top: 1px solid var(--uzaw-border);
}
.profile-details dt { color: var(--bs-secondary-color); font-size: .73rem; font-weight: 800; text-transform: uppercase; }
.profile-details dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.profile-password-card { padding: clamp(1rem, 3vw, 1.5rem); }
.profile-card-header {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: 1.1rem;
}
.profile-card-header h2 { margin: 0 0 .2rem; }
.profile-card-header p { margin: 0; }
.profile-password-toggle { margin-top: .2rem; }

.access-denied-card {
  max-width: 560px;
  margin: 10vh auto 0;
  padding: 2rem;
  text-align: center;
}
.access-denied-card > span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto .8rem;
  border-radius: 50%;
  color: #991b1b;
  background: #fee2e2;
  font-size: 1.5rem;
  font-weight: 900;
}

@media (max-width: 900px) {
  .account-form-layout,
  .profile-layout { grid-template-columns: 1fr; }
  .account-help-card { position: static; }
}
@media (max-width: 760px) {
  .account-stats { grid-template-columns: 1fr; }
  .account-search-form { grid-template-columns: 1fr; }
  .account-search-form select { width: 100%; }
  .users-table { min-width: 850px; }
}
@media (max-width: 520px) {
  .credential-field > div { grid-template-columns: 1fr; }
  .copy-button { width: 100%; }
}

/* CRUD utilisateurs */
.user-actions-heading { min-width: 255px; }
.user-row-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.btn-sm {
  min-height: 32px;
  padding: .35rem .58rem;
  border-radius: .48rem;
  font-size: .74rem;
}
.locked-account-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--uzaw-border);
}
.locked-account-fields > div {
  display: grid;
  gap: .32rem;
  padding: .8rem .9rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .8rem;
  background: #f8fafc;
}
.locked-account-fields span {
  color: var(--bs-secondary-color);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.locked-account-fields code,
.locked-account-fields strong {
  color: #0f172a;
  font-size: .92rem;
  overflow-wrap: anywhere;
}
.user-detail-layout {
  display: grid;
  grid-template-columns: minmax(250px, .62fr) minmax(0, 1.38fr);
  gap: 1rem;
  align-items: start;
}
.user-detail-summary { min-height: 290px; }
.user-detail-status { margin-top: .85rem; }
.user-detail-card { padding: clamp(1rem, 3vw, 1.5rem); }
.user-detail-header > div {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: 1.15rem;
}
.user-detail-header h2 { margin: 0 0 .2rem; }
.user-detail-header p { margin: 0; }
.user-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.2rem;
  margin: 0;
}
.user-detail-grid > div {
  display: grid;
  gap: .25rem;
  padding: .9rem 0;
  border-top: 1px solid var(--uzaw-border);
}
.user-detail-grid dt {
  color: var(--bs-secondary-color);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.user-detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}
.user-detail-notice {
  display: grid;
  gap: .22rem;
  margin-top: 1rem;
  padding: .85rem .95rem;
  border-radius: .8rem;
  color: #1e3a8a;
  background: #eff6ff;
  font-size: .86rem;
}
.user-delete-card {
  max-width: 620px;
  margin: 4vh auto 0;
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
}
.user-delete-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto .85rem;
  border-radius: 50%;
  color: #991b1b;
  background: #fee2e2;
  font-size: 1.5rem;
  font-weight: 900;
}
.user-delete-card h2 { margin: 0 0 .5rem; }
.user-delete-card .actions { justify-content: center; margin-top: 1.2rem; }

@media (max-width: 900px) {
  .user-detail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .locked-account-fields,
  .user-detail-grid { grid-template-columns: 1fr; }
}

/* Journal d'activité */
.audit-stats,
.user-activity-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .85rem;
  margin-bottom: 1rem;
}
.user-activity-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.audit-stat {
  display: grid;
  gap: .18rem;
  min-width: 0;
  padding: 1rem;
  border-left: 4px solid #64748b;
}
.audit-stat > span {
  color: var(--bs-secondary-color);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.audit-stat strong { color: #0f172a; font-size: 1.55rem; line-height: 1.1; }
.audit-stat small { color: var(--bs-secondary-color); }
.audit-stat-create { border-left-color: #16a34a; }
.audit-stat-update { border-left-color: #2563eb; }
.audit-stat-delete { border-left-color: #dc2626; }
.audit-card { padding: 1rem; }
.audit-search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(150px, .85fr)) auto auto;
  gap: .65rem;
  align-items: center;
  margin-bottom: 1rem;
}
.audit-search-form input,
.audit-search-form select { width: 100%; min-width: 0; }
.audit-table { min-width: 1180px; }
.audit-table th:nth-child(1) { width: 105px; }
.audit-table th:nth-child(2) { width: 210px; }
.audit-table th:nth-child(3) { width: 120px; }
.audit-table th:nth-child(4) { width: 230px; }
.audit-table th:nth-child(6) { width: 185px; }
.audit-date-cell,
.audit-origin-cell,
.user-activity-table td:first-child {
  display: grid;
  gap: .15rem;
}
.audit-date-cell small,
.audit-origin-cell small,
.user-activity-table small { color: var(--bs-secondary-color); }
.audit-user-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: inherit;
  text-decoration: none;
}
.audit-user-link > span:last-child { display: grid; gap: .08rem; min-width: 0; }
.audit-user-link small { color: var(--bs-secondary-color); overflow-wrap: anywhere; }
a.audit-user-link:hover strong { color: var(--bs-primary); text-decoration: underline; }
.audit-avatar { width: 34px; height: 34px; flex: 0 0 34px; font-size: .76rem; }
.audit-system-user { opacity: .78; }
.audit-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 94px;
  padding: .32rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
}
.audit-action-create { color: #166534; background: #dcfce7; }
.audit-action-update { color: #1e40af; background: #dbeafe; }
.audit-action-delete { color: #991b1b; background: #fee2e2; }
.audit-object-name,
.audit-origin-cell > span,
.user-activity-table td:nth-child(3) span,
.user-activity-table td:nth-child(4) span {
  display: block;
  margin-top: .15rem;
  overflow-wrap: anywhere;
}
.audit-table td:nth-child(4) small { display: block; margin-top: .16rem; color: var(--bs-secondary-color); }
.audit-subject-link { display: inline-block; margin-top: .35rem; font-size: .76rem; font-weight: 750; }
.audit-details summary {
  color: var(--bs-primary);
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.audit-change-list {
  display: grid;
  gap: .5rem;
  min-width: 320px;
  max-width: 520px;
  margin-top: .6rem;
  padding: .65rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .7rem;
  background: #f8fafc;
}
.audit-change-item {
  display: grid;
  grid-template-columns: minmax(105px, .7fr) minmax(0, 1fr) auto minmax(0, 1fr);
  gap: .35rem;
  align-items: start;
  font-size: .75rem;
}
.audit-change-item strong { overflow-wrap: anywhere; }
.audit-value-old,
.audit-value-new {
  padding: .18rem .3rem;
  border-radius: .35rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.audit-value-old { color: #991b1b; background: #fff1f2; }
.audit-value-new { color: #166534; background: #f0fdf4; }
.audit-change-arrow { color: var(--bs-secondary-color); }
.audit-origin-cell small { max-width: 180px; overflow-wrap: anywhere; }
.user-activity-section { margin-top: 1rem; }
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
}
.section-heading h2,
.section-heading p { margin: 0; }
.section-heading p { margin-top: .2rem; }
.user-activity-card { padding: 0; overflow: hidden; }
.user-activity-table { min-width: 850px; margin: 0; }
.user-activity-table th:nth-child(1) { width: 110px; }
.user-activity-table th:nth-child(2) { width: 125px; }
.user-activity-table td:nth-child(3) { max-width: 340px; }

@media (max-width: 1200px) {
  .audit-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .audit-search-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .audit-stats,
  .user-activity-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { align-items: stretch; flex-direction: column; }
}
@media (max-width: 560px) {
  .audit-stats,
  .user-activity-stats,
  .audit-search-form { grid-template-columns: 1fr; }
}

/* Harmonisation des pages utilisateurs, profil et journal d'activité */
.management-page-header {
  align-items: flex-start;
  gap: 1rem;
}
.management-page-header > div:first-child { min-width: 0; }
.management-page-header p { margin: .3rem 0 0; }
.management-page-actions {
  justify-content: flex-end;
  gap: .45rem;
}

.management-table-card {
  padding: 1rem;
  overflow: hidden;
}
.management-table-card > .management-table-wrapper {
  margin: 0;
}
.management-filters {
  margin-bottom: 1rem;
  padding: .8rem;
  border-radius: .85rem;
}
.management-filters .btn {
  min-height: 42px;
  padding-inline: .8rem;
  white-space: nowrap;
}

.management-table-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: .85rem;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  -webkit-overflow-scrolling: touch;
}
.management-table-wrapper:focus-visible {
  outline: 3px solid rgba(var(--bs-primary-rgb), .15);
  outline-offset: 2px;
}
.management-table-wrapper::-webkit-scrollbar { height: 8px; }
.management-table-wrapper::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}
.management-table {
  width: 100%;
  table-layout: fixed;
}
.management-table th,
.management-table td {
  padding: .68rem .72rem;
}
.management-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}
.management-table tbody td {
  line-height: 1.35;
}
.management-table tbody tr:nth-child(even) td {
  background: rgba(248, 250, 252, .58);
}
.management-table tbody tr:hover td {
  background: rgba(var(--bs-primary-rgb), .045);
}
.table-primary-cell strong,
.audit-object-cell > strong {
  color: #0f172a;
}
.table-break-text,
.audit-object-name,
.audit-change-item,
.account-information-grid dd,
.account-summary-details dd {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table-date-value { white-space: nowrap; }
.table-empty-state {
  padding: 2.2rem 1rem !important;
  color: var(--bs-secondary-color);
  text-align: center;
  background: #f8fafc !important;
}

/* Tableau des utilisateurs */
.users-table { min-width: 960px; }
.users-table th:nth-child(1) { width: 19%; }
.users-table th:nth-child(2) { width: 13%; }
.users-table th:nth-child(3) { width: 20%; }
.users-table th:nth-child(4) { width: 12%; }
.users-table th:nth-child(5) { width: 10%; }
.users-table th:nth-child(6) { width: 14%; }
.users-table th:nth-child(7) { width: 190px; }
.user-actions-heading {
  width: 190px;
  min-width: 190px;
  text-align: right;
}
.user-actions-cell { text-align: right; }
.user-row-actions {
  justify-content: flex-end;
  gap: .3rem;
  white-space: nowrap;
}
.user-row-actions .btn-sm {
  min-height: 30px;
  padding: .3rem .48rem;
  border-radius: .5rem;
  font-size: .7rem;
}
.user-contact { min-width: 0; }
.user-cell { min-width: 0; }
.user-cell > div { min-width: 0; }
.user-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tableau du journal */
.audit-card { padding: 1rem; }
.audit-table { min-width: 980px; }
.audit-table th:nth-child(1) { width: 105px; }
.audit-table th:nth-child(2) { width: 190px; }
.audit-table th:nth-child(3) { width: 110px; }
.audit-table th:nth-child(4) { width: 245px; }
.audit-table th:nth-child(5) { width: auto; }
.audit-user-link { min-width: 0; }
.audit-user-link > span:last-child { overflow: hidden; }
.audit-user-link strong,
.audit-user-link small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audit-action {
  min-width: 86px;
  padding: .3rem .5rem;
}
.audit-object-cell { min-width: 0; }
.audit-object-name {
  display: -webkit-box;
  max-height: 2.8em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.audit-changes-cell { vertical-align: top !important; }
.audit-details summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: .25rem .5rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .55rem;
  background: #fff;
  list-style-position: inside;
}
.audit-details[open] summary {
  border-color: var(--bs-primary-border-subtle);
  background: var(--bs-primary-bg-subtle);
}
.audit-change-list {
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-top: .5rem;
  padding: .55rem;
}
.audit-change-item {
  grid-template-columns: minmax(90px, .65fr) minmax(0, 1fr) auto minmax(0, 1fr);
  gap: .3rem;
}
.audit-value-old,
.audit-value-new { max-height: 7rem; overflow: auto; }

/* Tableau d'activité dans le détail utilisateur */
.user-activity-card {
  padding: 1rem;
  overflow: hidden;
}
.user-activity-table { min-width: 760px; }
.user-activity-table th:nth-child(1) { width: 110px; }
.user-activity-table th:nth-child(2) { width: 110px; }
.user-activity-table th:nth-child(3) { width: 260px; }
.user-activity-table th:nth-child(4) { width: auto; }
.user-activity-table td:nth-child(3) { max-width: none; }

/* Présentation commune du profil et du détail utilisateur */
.account-page-layout {
  display: grid;
  grid-template-columns: minmax(250px, .62fr) minmax(0, 1.38fr);
  gap: 1rem;
  align-items: start;
}
.account-summary-card {
  min-height: 100%;
  padding: 1.4rem;
}
.account-summary-username { margin: .05rem 0 .65rem; }
.account-summary-details { margin-top: 1.2rem; }
.account-summary-details > div {
  padding: .7rem 0;
}
.account-information-card {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.45rem);
}
.account-section-header {
  margin-bottom: .8rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--uzaw-border);
}
.account-section-header > div {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.account-section-header h2,
.account-section-header p { margin: 0; }
.account-section-header p { margin-top: .2rem; }
.account-section-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: 900;
}
.account-information-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.2rem;
  margin: 0;
}
.account-information-grid > div {
  display: grid;
  grid-template-columns: minmax(110px, .72fr) minmax(0, 1fr);
  gap: .7rem;
  align-items: start;
  padding: .8rem 0;
  border-bottom: 1px solid var(--uzaw-border);
}
.account-information-grid dt {
  color: var(--bs-secondary-color);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.account-information-grid dd {
  margin: 0;
  min-width: 0;
  font-weight: 700;
}
.profile-card-header.account-section-header {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
}
.profile-card-header.account-section-header > div {
  display: block;
}
.profile-form-actions {
  justify-content: flex-end;
  padding-top: .3rem;
}

@media (max-width: 1180px) {
  .users-table { min-width: 900px; }
  .audit-search-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .audit-search-form .btn { width: 100%; }
  .audit-change-item {
    grid-template-columns: minmax(90px, .8fr) minmax(0, 1fr);
  }
  .audit-change-arrow { display: none; }
}

@media (max-width: 900px) {
  .account-page-layout,
  .user-detail-layout,
  .profile-layout {
    grid-template-columns: 1fr;
  }
  .account-summary-card { min-height: auto; }
  .management-page-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .management-page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .management-page-header > .btn,
  .management-page-actions,
  .management-page-actions .btn { width: 100%; }
  .management-page-actions .btn { text-align: center; }
  .account-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-table-card,
  .audit-card,
  .user-activity-card { padding: .75rem; }
  .management-table th,
  .management-table td { padding: .62rem .65rem; }
  .users-table { min-width: 840px; }
  .audit-table { min-width: 900px; }
  .user-activity-table { min-width: 720px; }
  .account-information-grid > div {
    grid-template-columns: 1fr;
    gap: .25rem;
  }
  .profile-form-actions .btn { width: 100%; }
}

@media (max-width: 560px) {
  .account-stats,
  .audit-stats,
  .user-activity-stats { grid-template-columns: 1fr; }
  .management-filters,
  .account-search-form,
  .audit-search-form { grid-template-columns: 1fr; }
  .management-filters .btn,
  .management-filters input,
  .management-filters select { width: 100%; }
  .account-information-grid { grid-template-columns: 1fr; }
  .account-information-grid > div:last-child { border-bottom: 0; }
  .section-heading .btn { width: 100%; }
}

/* Correctif d'affichage : journal et activité utilisateur */
.audit-date-cell,
.audit-origin-cell,
.user-activity-table td:first-child {
  display: table-cell;
  vertical-align: middle !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.audit-date-cell > strong,
.audit-date-cell > small,
.audit-origin-cell > strong,
.audit-origin-cell > span,
.audit-origin-cell > small,
.user-activity-table td:first-child > strong,
.user-activity-table td:first-child > small {
  display: block;
  width: max-content;
  max-width: 100%;
}
.audit-date-cell > strong,
.user-activity-table td:first-child > strong {
  line-height: 1.2;
}
.audit-date-cell > small,
.user-activity-table td:first-child > small {
  margin-top: .2rem;
  line-height: 1.2;
}

.audit-table {
  min-width: 1080px;
}
.audit-table th:nth-child(1) { width: 126px; }
.audit-table th:nth-child(2) { width: 205px; }
.audit-table th:nth-child(3) { width: 125px; }
.audit-table th:nth-child(4) { width: 32%; }
.audit-table th:nth-child(5) { width: auto; }
.audit-table td,
.user-activity-table td {
  vertical-align: middle;
}
.audit-table .audit-changes-cell,
.user-activity-table .audit-changes-cell {
  vertical-align: middle !important;
}
.audit-details summary {
  white-space: nowrap;
}

.user-activity-table {
  min-width: 860px;
}
.user-activity-table th:nth-child(1) { width: 126px; }
.user-activity-table th:nth-child(2) { width: 130px; }
.user-activity-table th:nth-child(3) { width: 38%; }
.user-activity-table th:nth-child(4) { width: auto; }

@media (max-width: 760px) {
  .audit-table { min-width: 920px; }
  .user-activity-table { min-width: 760px; }
}


/* Ajustement final — détail utilisateur */
.user-detail-layout {
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
.user-detail-summary,
.account-summary-card.user-detail-summary {
  min-height: 0;
  height: auto;
  align-content: start;
  gap: .8rem;
  padding: 1.5rem 1.25rem;
}
.user-detail-summary .profile-avatar {
  width: 76px;
  height: 76px;
  margin: 0 0 .25rem;
}
.user-detail-summary h2 {
  margin: .15rem 0 0;
  line-height: 1.2;
}
.account-summary-identifier {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  margin: 0;
  padding: .45rem .65rem;
  border: 1px solid var(--uzaw-border);
  border-radius: .65rem;
  background: #f8fafc;
  font-size: .76rem;
}
.account-summary-identifier > span {
  color: var(--bs-secondary-color);
  font-weight: 700;
}
.account-summary-identifier .account-summary-username {
  margin: 0;
}
.user-detail-summary .role-badge {
  margin-top: .1rem;
}
.user-detail-status {
  margin-top: .15rem;
}
.user-detail-card {
  min-width: 0;
}
.user-detail-header > div {
  margin-bottom: .85rem;
}
.account-information-grid.user-detail-grid {
  gap: 0 1.4rem;
}
.account-information-grid.user-detail-grid > div {
  grid-template-columns: minmax(135px, .72fr) minmax(0, 1fr);
  align-items: center;
  min-height: 60px;
  padding: .72rem 0;
}
.account-information-grid.user-detail-grid dt {
  line-height: 1.3;
}
.account-information-grid.user-detail-grid dd {
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
}
.account-password-row dd {
  display: grid;
  gap: .08rem;
}
.account-password-row dd strong {
  white-space: nowrap;
}
.account-password-row dd small {
  color: var(--bs-secondary-color);
  font-size: .75rem;
  font-weight: 500;
}
.account-information-grid.user-detail-grid > div:nth-child(7) dd,
.account-information-grid.user-detail-grid > div:nth-child(8) dd {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.user-detail-notice {
  margin-top: .85rem;
}

@media (max-width: 1100px) {
  .user-detail-layout {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  }
  .account-information-grid.user-detail-grid > div {
    grid-template-columns: 1fr;
    gap: .22rem;
    align-items: start;
  }
}

@media (max-width: 900px) {
  .user-detail-layout {
    grid-template-columns: 1fr;
  }
  .user-detail-summary,
  .account-summary-card.user-detail-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "avatar name role"
      "avatar identifier status";
    justify-items: start;
    align-items: center;
    text-align: left;
  }
  .user-detail-summary .profile-avatar { grid-area: avatar; margin: 0; }
  .user-detail-summary h2 { grid-area: name; }
  .account-summary-identifier { grid-area: identifier; }
  .user-detail-summary .role-badge { grid-area: role; }
  .user-detail-status { grid-area: status; justify-self: end; }
}

@media (max-width: 620px) {
  .user-detail-summary,
  .account-summary-card.user-detail-summary {
    grid-template-columns: 1fr;
    grid-template-areas: none;
    justify-items: center;
    text-align: center;
  }
  .user-detail-summary .profile-avatar,
  .user-detail-summary h2,
  .account-summary-identifier,
  .user-detail-summary .role-badge,
  .user-detail-status {
    grid-area: auto;
    justify-self: center;
  }
  .account-information-grid.user-detail-grid {
    grid-template-columns: 1fr;
  }
  .account-information-grid.user-detail-grid > div:nth-child(7) dd,
  .account-information-grid.user-detail-grid > div:nth-child(8) dd {
    white-space: normal;
  }
}
