/* ============================================
   Margueritte Design System — Sleek & Flat
   ============================================ */

/* Inter — auto-hebergee (spec design system v1, 1.5, decision Q3).
   Fonte variable (graisses 300-700) en deux subsets: latin couvre le
   francais courant, latin-ext apporte œ/Œ et la ponctuation etendue.
   unicode-range laisse le navigateur ne telecharger que le necessaire.
   Plus aucune dependance reseau tierce au chargement. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Les valeurs de design (palette, tokens semantiques --app-*, espacements,
   rayons, ombres, layout) vivent dans tokens.css, charge avant cette
   feuille par App.razor. La palette brute est privee a tokens.css: le CSS
   ci-dessous doit consommer les tokens --app-* (les references --slate-*
   restantes sont gelees en baseline par check-ui-design-tokens.ps1 et
   decroissent a chaque passe). */

/* ============================================
   Global overrides
   ============================================ */

body {
  font-family: 'Inter', sans-serif !important;
  background-color: var(--app-bg);
  cursor: default;
}

/* UI labels: selectable but no "editable" illusion.
   The fix is caret-color, not user-select. */
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
div,
td,
th,
label,
.mud-typography,
.badge,
.stat-card,
.stat-value,
.stat-label,
.section-title,
.page-header,
.list-card-title,
.list-card-subtitle,
.sidebar-contract-name,
.sidebar-contract-info,
.sidebar-section-label,
.empty-title,
.empty-text,
.readonly-banner,
.content-card {
  cursor: default;
  caret-color: transparent;
}

/* Pointer on interactive elements */
a,
button,
[role="button"],
.mud-button-root,
.mud-icon-button,
.mud-nav-link,
.mud-link,
.mud-list-item,
.mud-select,
.mud-checkbox,
.mud-radio,
.mud-switch,
.mud-tab,
.list-card,
.content-card-hover:hover,
.sidebar-nav-item,
.sidebar-toggle,
.sidebar-back-btn,
.sidebar-search-trigger {
  cursor: pointer;
}

/* Keep the pointer consistent over icons and text nested inside an interactive
   control. This must follow the generic span/div cursor reset above. */
a *,
button *,
[role="button"] *,
.mud-button-root *,
.mud-icon-button *,
.mud-nav-link *,
.mud-list-item-clickable *,
.mud-menu-item * {
  cursor: inherit;
}

/* Actual inputs: caret visible, text cursor */
input,
textarea,
[contenteditable="true"] {
  cursor: text;
  caret-color: auto;
}

/* Non-interactive elements should never show a focus ring */
h1,
h2,
h3,
h4,
h5,
h6,
p,
div,
span,
section,
main {
  outline: none;
}

/* Keyboard focus ring for interactive elements (accessibility) */
a.list-card:focus-visible,
.sidebar-nav-item:focus-visible,
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-menu-item:focus-visible {
  outline: 2px solid var(--app-info);
  outline-offset: 2px;
}

.mud-typography {
  font-family: 'Inter', sans-serif !important;
}

/* ============================================
   Content Card — flat card with border
   ============================================ */

.content-card {
  background: var(--app-surface);
  border-radius: 12px;
  border: 1px solid var(--app-border);
  padding: 20px;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.content-card-hover:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-hover);
  cursor: pointer;
}

.content-card-sm {
  padding: 16px;
}

.content-card-flush {
  padding: 0;
}

.subtitle-secondary-card {
  background: var(--app-surface-sunken);
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.subtitle-secondary-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--app-text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================
   Sidebar
   ============================================ */

/* MudDrawer handles position, width, background, color, overflow, flex layout
   natively (via DrawerBackground / DrawerText palette). We only re-tint a
   handful of palette variables so MudPaper, MudDivider and MudNavLink active
   states render correctly on the dark drawer. */
.app-sidebar {
  --mud-palette-primary: var(--app-sidebar-primary);
  --mud-palette-primary-rgb: var(--app-sidebar-primary-rgb);
  --mud-palette-action-default-hover: var(--app-sidebar-hover);
  --mud-palette-surface: var(--app-sidebar-surface);
  --mud-palette-lines-default: var(--app-sidebar-lines);
  --mud-palette-divider: var(--app-sidebar-divider);
  --mud-palette-text-primary: var(--app-sidebar-text);
  --mud-palette-text-secondary: var(--app-sidebar-text-secondary);
}

/* Mockup icon sizes: 18px for nav-link icons, 14px for niveau group chevron. */
.app-sidebar .mud-nav-link .mud-icon-root {
  font-size: 1.125rem;
  /* 18px */
}

.app-sidebar .mud-nav-link .mud-nav-link-expand-icon,
.app-sidebar .mud-nav-link .mud-nav-link-expand-icon .mud-icon-root {
  font-size: 0.875rem;
  /* 14px */
}

.app-sidebar .app-sidebar-hidden-nav-items {
  display: none !important;
}

.app-sidebar::-webkit-scrollbar {
  width: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: var(--mud-palette-lines-default);
  border-radius: 2px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--mud-palette-divider);
}

.sidebar-logo {
  color: var(--app-accent-contrast);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.5px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--app-text-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-speed), background var(--transition-speed);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: var(--app-accent-contrast);
  background: var(--mud-palette-action-default-hover);
}

/* Sidebar nav */
.sidebar-nav {
  flex: 0 0 auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mud-palette-text-secondary);
  padding: 12px 16px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-section-label.with-gap {
  margin-top: 8px;
}

.sidebar-item-group-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-faint);
  padding: 8px 12px 2px 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav-item+.sidebar-item-group-label {
  margin-top: 8px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--mud-palette-text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: all var(--transition-speed);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item.indented {
  padding-left: 24px;
}

.app-sidebar.collapsed .sidebar-nav-item.indented {
  padding-left: 12px;
}

.sidebar-nav-item:hover {
  background: var(--mud-palette-action-default-hover);
  color: var(--app-accent-contrast);
}

.sidebar-nav-item.active {
  background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
  color: var(--mud-palette-primary);
}

.sidebar-nav-item .nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-text-faint);
  transition: color var(--transition-speed);
}

.sidebar-nav-item:hover .nav-icon,
.sidebar-nav-item.active .nav-icon {
  color: var(--mud-palette-text-primary);
}

.sidebar-nav-item .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar workspace header */
.sidebar-workspace-header {
  padding: 14px 16px 10px;
}

.sidebar-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--app-text-faint);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  margin-bottom: 12px;
  transition: color var(--transition-speed);
}

.sidebar-back-btn .mud-icon-root {
  color: var(--app-text-muted);
  transition: color var(--transition-speed);
}

.sidebar-back-btn:hover {
  color: var(--app-accent-contrast);
}

.sidebar-back-btn:hover .mud-icon-root {
  color: var(--mud-palette-text-primary);
}

.sidebar-contract-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--app-accent-contrast);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-contract-info {
  font-size: 12px;
  color: var(--app-text-faint);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-version-card {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--mud-palette-surface);
  font-size: 12px;
}

.sidebar-version-card .version-label {
  color: var(--app-text-faint);
  margin-bottom: 2px;
}

.sidebar-version-card .version-value {
  color: var(--app-accent-contrast);
  font-weight: 500;
}

/* MudDivider only needs margin tweaks; color comes from --mud-palette-divider
   scoped on .app-sidebar. */
.sidebar-divider {
  margin: 4px 8px;
  width: auto;
}

/* ============================================
   Main content area
   ============================================ */

.main-content {
  height: 100vh;
  background: var(--app-bg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content-inner {
  /* Borne de contenu de la spec design system (3.8, decision Q4):
     colonne lisible centree; la derogation pleine largeur reste le cas
     :has(.garanties-page) ci-dessous jusqu'a la primitive d'ecran. */
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-content-inner:has(.garanties-page) {
  max-width: none;
}

@media (max-width: 959.98px) {
  .mud-layout .app-sidebar.mud-drawer {
    display: none !important;
  }

  .main-content {
    padding: 16px;
  }

  .mud-layout.mud-drawer-open-mini-xs-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-sm-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-md-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-lg-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-xl-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-xxl-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-none-left .mud-main-content,
  .mud-layout.mud-drawer-open-mini-always-left .mud-main-content {
    margin-left: 0 !important;
  }
}

/* ============================================
   Badges
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

.badge-sante {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.badge-prevoyance {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

.risk-action-button.mud-button-root {
  text-transform: none;
  font-weight: 600;
}

.risk-action-button-sante.mud-button-root.mud-button-outlined {
  color: var(--app-success-text);
  border-color: var(--app-success);
}

.risk-action-button-sante.mud-button-root.mud-button-outlined:hover {
  background: var(--app-success-bg);
  border-color: var(--app-success);
}

.risk-action-button-prevoyance.mud-button-root.mud-button-outlined {
  color: var(--app-highlight-text);
  border-color: var(--app-highlight);
}

.risk-action-button-prevoyance.mud-button-root.mud-button-outlined:hover {
  background: var(--app-highlight-bg);
  border-color: var(--app-highlight);
}

.badge-active,
.badge-validee {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.badge-brouillon {
  background: var(--app-warning-bg-strong);
  color: var(--app-warning-text);
}

.badge-obsolete {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
}

.badge-info {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.badge-danger {
  background: var(--app-danger-bg-strong);
  color: var(--app-danger-text);
}

.badge-groupe {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.badge-prospect {
  background: var(--app-warning-bg-strong);
  color: var(--app-warning-text);
}

.badge-client-sante {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.badge-client-prevoyance {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

.badge-client-prospect {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
}

.badge-client-none {
  background: var(--app-accent);
  color: var(--app-accent-contrast);
}

/* Badges du module Saisie Assureur (PRD 3.1, 3.3) : classes globales partagees entre
   le tableau de bord (SaisiesTable) et la vue detail (SaisieDetailPage), qui rendent
   chacun leur propre arbre scope - une classe .razor.css locale a l'un des deux ne
   serait pas visible par l'autre. */
.statut-badge--brouillon {
  background: var(--app-warning-bg-strong);
  color: var(--app-warning-text);
}

.statut-badge--envoyee {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.statut-badge--acceptee {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.statut-badge--acceptee-partiellement {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

.statut-badge--refusee {
  background: var(--app-danger-bg-strong);
  color: var(--app-danger-text);
}

.statut-badge--expiree {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
}

.canal-badge--lien {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.canal-badge--manuelle,
.reference-badge--par-societe {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
}

.badge-nouveau {
  background: var(--app-warning);
  color: var(--app-accent-contrast);
  font-weight: 700;
}

/* ============================================
   Clean Table (inside content-card)
   ============================================ */

.table-clean {
  width: 100%;
  border-collapse: collapse;
}

.table-clean th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--app-border);
}

.table-clean td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--app-text);
  border-bottom: 1px solid var(--app-border-subtle);
}

.table-clean tr:last-child td {
  border-bottom: none;
}

.table-clean tr:hover td {
  background-color: var(--app-surface-sunken);
}

.table-clean .td-label {
  font-weight: 500;
  color: var(--app-text-muted);
  width: 180px;
}

/* ============================================
   Table scroll region (contrat d'ecran de liste)
   ============================================
   Proprietaire de scroll d'une longue liste operationnelle: cette zone
   defile (verticalement, et horizontalement si le tableau l'exige) pendant
   que les cellules d'en-tete de `.table-clean` restent epinglees a son bord
   superieur. La zone doit vivre dans une chaine flex bornee en hauteur
   (flex: 1 + min-height: 0 sur chaque maillon depuis .main-content); sans
   maillon borne, rien ne peut defiler. Le sticky cible les <th>, pas le
   <thead>: avec border-collapse: collapse, sticky sur <thead> n'epingle pas
   de facon fiable dans Chromium (meme lecon que .siret-fixed-table-scroll).
   Le trait sous l'en-tete est peint en inset shadow pour voyager avec les
   cellules epinglees au lieu d'etre perdu par la grille de bordures. */
.table-scroll-region {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.table-scroll-region .table-clean thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--app-surface);
  box-shadow: inset 0 -1px 0 var(--app-border);
}

/* Tables de selection des plafonds (GarantiesPage, jumelles sante/prevoyance).
   Layout fixe obligatoire : en layout auto, les libelles de categorie longs
   (nowrap, cellules colspan) gonflent la colonne de selection. */
.prev-table.garanties-plafond-selection-table {
  table-layout: fixed;
  min-width: 100%;
}

.prev-table.garanties-plafond-selection-table .garanties-plafond-selection-cell {
  width: 105px;
  text-align: center;
  white-space: nowrap;
}

.prev-table.garanties-plafond-selection-table .prev-product-column,
.prev-table.garanties-plafond-selection-table .prev-product-cell {
  width: auto;
  min-width: 0;
}

.prev-table.garanties-plafond-selection-table tbody td.prev-product-cell {
  position: static;
  box-shadow: none;
}

.prev-table.garanties-plafond-selection-table .prev-group-label {
  position: static;
  white-space: normal;
}

/* Detail sub-rows for contract flux table */
.flux-detail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: baseline;
  min-height: 24px;
}

.flux-detail-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--app-text-faint);
  padding-top: 2px;
  line-height: 1.6;
}

.flux-detail-value {
  font-size: 12.5px;
  color: var(--app-text-muted);
  line-height: 1.6;
}

.flux-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
  line-height: 1.5;
  white-space: nowrap;
}

/* Contract flux rows: full-row navigation with keyboard focus affordance. */
.flux-table tr.flux-row-link,
.flux-table tr.flux-row-link td,
.flux-table tr.flux-row-link .mud-link,
.flux-table tr.flux-row-link span {
  cursor: pointer;
}

.table-clean tbody tr.flux-row-link:hover td {
  background: var(--app-surface-sunken);
}

.table-clean tbody tr.flux-row-link:focus-visible td {
  background: var(--app-selection-bg);
}

.flux-table tr.flux-row-link:focus-visible {
  outline: 2px solid var(--app-info);
  outline-offset: -2px;
}

/* ============================================
   Grid layouts
   ============================================ */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.service-table-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-custom-section {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.service-custom-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.service-custom-section__subtitle,
.service-custom-section__empty {
  color: var(--app-text-muted);
}

@media (max-width: 960px) {

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

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

  .service-custom-section__header {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============================================
   Page header
   ============================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--app-text);
  margin: 0;
}

.page-header .page-subtitle {
  font-size: 14px;
  color: var(--app-text-muted);
  margin: 2px 0 0 0;
}

/* Sidebar contract ambient tint */
.sidebar-workspace-header--reference {
  border-left: 3px solid var(--app-info);
  background: linear-gradient(90deg, color-mix(in srgb, var(--app-info) 8%, transparent) 0%, transparent 60%);
}

.sidebar-workspace-header--reference .sidebar-contract-name {
  color: var(--app-info-bg-strong);
}

.sidebar-workspace-header--reference .sidebar-contract-info {
  color: color-mix(in srgb, var(--app-info-bg-strong) 60%, var(--app-info));
}

/* Page header contract ambient tint */
.page-header--reference {
  background: var(--app-info-bg);
  border-left: 3px solid var(--app-info);
  border-radius: 10px;
  padding: 16px 20px;
}

.page-header--reference .page-subtitle {
  color: var(--app-info-text);
}

.contract-icon-wrapper {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--app-info) 8%, transparent);
  border-radius: 10px;
}

.header-document-icon {
  font-size: 26px;
}

.page-header--reference .header-document-icon {
  color: var(--app-info-text);
}

/* Contract meta line (inline metadata below subtitle) */
.contract-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--app-text-muted);
}

.badge-header-risk {
  padding: 1px 8px;
  line-height: 18px;
  font-size: 12px;
  font-weight: 600;
}

.meta-separator {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--app-text-faint);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .contract-meta-line {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .page-header--reference {
    padding: 12px 14px;
  }
}

/* ============================================
   List cards (societes, contrats)
   ============================================ */

.list-card {
  background: var(--app-surface);
  border-radius: 12px;
  border: 1px solid var(--app-border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.list-card:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-hover);
}

.list-card .list-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-card .list-card-content {
  flex: 1;
  min-width: 0;
}

.list-card .list-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--app-text);
  margin-bottom: 2px;
}

.list-card .list-card-subtitle {
  font-size: 13px;
  color: var(--app-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card .list-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.list-card .list-card-right {
  flex-shrink: 0;
  text-align: right;
}

/* Clickable list card rows should keep pointer feedback on nested wrappers too,
   because global label cursor rules set many div/span nodes to default. */
.list-card-clickable,
.list-card-clickable .list-card-icon,
.list-card-clickable .list-card-content,
.list-card-clickable .list-card-title,
.list-card-clickable .list-card-subtitle,
.list-card-clickable .list-card-badges,
.list-card-clickable .list-card-right,
.list-card-clickable span {
  cursor: pointer;
}

/* Contrat d'ecran: le header de page reste fixe, la zone .demographie-scroll
   sous le header est l'unique proprietaire du scroll (doctrine: jamais de
   scroll de page entiere). Chaine flex bornee depuis .main-content (100vh,
   overflow hidden) via .main-content-inner. */
.demographie-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.demographie-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 2px;
}

.demographie-markdown {
  color: var(--app-text);
  font-size: 14px;
  line-height: 1.65;
}

.demographie-markdown strong {
  color: var(--app-text);
  font-weight: 600;
}

/* ============================================
   Empty state
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--app-surface-sunken-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--app-text-faint);
}

.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--app-text);
  margin-bottom: 4px;
}

.empty-state .empty-text {
  font-size: 14px;
  color: var(--app-text-muted);
  /* Mesure de lecture bornee: un etat vide n'etale jamais sa phrase sur
     toute la largeur de l'ecran (spec design system, etats standard). */
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}

/* L'action d'un etat vide respire par construction, quel que soit l'ecran. */
.empty-state .mud-button-root {
  margin-top: var(--app-space-4);
}

/* ============================================
   Search bar
   ============================================ */

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar .mud-input-control {
  flex: 1;
}

/* ============================================
   Scrollable list pages (societes, contrats)
   ============================================ */

/* Contrat d'ecran de liste: chaine flex bornee depuis .main-content (100vh,
   overflow hidden) via .main-content-inner (flex: 1 + min-height: 0). La zone
   de resultats est l'unique proprietaire du scroll; ni le document ni la page
   ne defilent, a aucune largeur d'ecran. */
.societe-page,
.contrat-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.societe-filters,
.contrat-filters {
  flex-shrink: 0;
}

.societe-results-scroll,
.contrat-results-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.societe-group-option {
  width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  color: var(--app-text);
}

.societe-group-option-create {
  background: var(--app-info-bg);
  color: var(--app-info-text);
  font-size: 13px;
  font-weight: 600;
}

/* ============================================
   OmniSearch
   ============================================ */

.global-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--app-text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.global-search-trigger:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-hover);
}

.global-search-trigger kbd {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  border: 1px solid var(--app-border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--app-surface-sunken);
  color: var(--app-text-muted);
}

/* Sidebar search trigger — matches NouveauMenu.html `searchButton` */
.sidebar-search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 16px 15px;
  width: calc(100% - 30px);
  border-radius: 8px;
  border: none;
  background: var(--app-sidebar-recess);
  color: var(--mud-palette-text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition-speed), color var(--transition-speed);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}

.sidebar-search-trigger .nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mud-palette-text-secondary);
  transition: color var(--transition-speed);
}

.sidebar-search-trigger .nav-icon .mud-icon-root {
  font-size: 18px;
}

.sidebar-search-trigger .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-search-trigger:hover {
  background: var(--app-sidebar-recess-hover);
  color: var(--app-accent-contrast);
}

/* En mode workspace, le declencheur suit la carte contrat (ou le bouton
   retour replie): l'ecart du haut reste compact. En mode standard, la
   marge 16px est symetrique au-dessus et en dessous. */
.sidebar-workspace-header + .sidebar-nav .sidebar-search-trigger,
.sidebar-retour + .sidebar-nav .sidebar-search-trigger {
  margin-top: 4px;
}

.sidebar-search-trigger:hover .nav-icon {
  color: var(--mud-palette-text-primary);
}

.sidebar-search-trigger:hover .sidebar-search-kbd {
  border-color: var(--mud-palette-text-secondary);
  color: var(--mud-palette-text-primary);
}

.sidebar-search-kbd {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--app-text-muted);
  background: transparent;
  border: 1px solid var(--mud-palette-lines-default);
  border-radius: 5px;
  padding: 3px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-account {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--mud-palette-divider);
  margin-top: auto;
}

.sidebar-account-menu {
  width: 100%;
  min-width: 0;
  align-self: stretch;
}

.sidebar-account-trigger {
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
  padding: 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--mud-palette-text-primary);
  text-align: left;
  text-transform: none;
  transition: background var(--transition-speed), color var(--transition-speed);
}

.sidebar-account-trigger .mud-button-label {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.sidebar-account-trigger.mud-button-root:hover,
.sidebar-account-trigger.mud-button-root:focus-visible {
  background: var(--mud-palette-action-default-hover);
  color: var(--app-accent-contrast);
}

.sidebar-account-avatar {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--app-info), var(--app-info-text));
  color: var(--app-accent-contrast);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-account-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sidebar-account-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-account-name,
.sidebar-account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--app-accent-contrast);
}

.sidebar-account-email {
  font-size: 11px;
  color: var(--app-text-faint);
}

.sidebar-account-menu-summary {
  padding: 12px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text);
}

.sidebar-account-menu-subtitle {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--app-text-muted);
}

.sidebar-account-menu-section-label {
  padding: 10px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-text-faint);
}

.sidebar-account-menu-list {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.sidebar-account-menu-list>.mud-menu-item {
  width: 100%;
}

.sidebar-account-menu-list>.mud-menu-item:not(.mud-disabled):hover,
.sidebar-account-menu-list>.mud-menu-item:not(.mud-disabled):focus-visible {
  background: var(--app-surface-sunken-strong);
}

.sidebar-organisation-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  box-sizing: border-box;
}

.sidebar-organisation-option.is-current .sidebar-organisation-switch {
  background: var(--app-selection-bg);
}

.sidebar-organisation-switch {
  width: 100%;
  min-width: 0;
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  transition: background var(--transition-speed);
}

.sidebar-organisation-switch .mud-menu-item-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
}

.sidebar-organisation-switch:not(.mud-disabled):hover,
.sidebar-organisation-switch:not(.mud-disabled):focus-visible {
  background: var(--app-surface-sunken);
}

.sidebar-organisation-name {
  display: block;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-organisation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.sidebar-organisation-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-organisation-badge--current {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.sidebar-organisation-badge--default {
  background: var(--app-warning-bg-strong);
  color: var(--app-warning-text);
}

.sidebar-organisation-default-action,
.sidebar-organisation-default-indicator {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sidebar-organisation-default-action {
  color: var(--app-text-muted);
  transition: color var(--transition-speed), background var(--transition-speed);
}

.sidebar-organisation-default-action .mud-menu-item-icon {
  margin-inline-end: 0;
}

.sidebar-organisation-default-action .mud-menu-item-text {
  display: none;
}

.sidebar-organisation-default-action:not(.mud-disabled):hover,
.sidebar-organisation-default-action:not(.mud-disabled):focus-visible {
  color: var(--app-warning-text);
  background: var(--app-warning-bg);
}

.sidebar-organisation-default-indicator {
  color: var(--app-warning);
  background: var(--app-warning-bg);
  border: 1px solid var(--app-warning-bg-strong);
}

.workspace-contract-card {
  padding: 12px 14px;
}

.workspace-contract-company {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0;
  margin: 0 0 6px;
  border: 0;
  background: transparent;
  color: var(--app-text-faint);
  cursor: pointer;
}

.workspace-contract-company:disabled {
  cursor: default;
}

.workspace-contract-company-left {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  cursor: inherit;
}

.workspace-contract-company-left span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-contract-title {
  margin-bottom: 2px;
  color: var(--app-accent-contrast);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.workspace-contract-number {
  margin-bottom: 10px;
  color: var(--app-text-muted);
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
}

.workspace-contract-divider {
  margin: 0 0 10px !important;
}

.workspace-contract-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.workspace-contract-version-trigger {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--app-accent-contrast);
  cursor: pointer;
}

.workspace-contract-version-label {
  color: var(--app-text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.workspace-contract-version-number,
.workspace-version-menu-number,
.version-token {
  color: var(--app-accent-contrast);
  font-weight: 700;
}

.workspace-version-menu-item {
  display: grid;
  grid-template-columns: minmax(42px, auto) auto minmax(72px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.workspace-version-menu-date {
  color: var(--app-text-muted);
  font-size: 12px;
  text-align: right;
}

/* Niveau title (custom span inside MudNavGroup TitleContent slot) */
.workspace-niveau-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-sidebar .mud-nav-group>.mud-nav-link .workspace-niveau-title {
  color: var(--mud-palette-text-secondary);
  font-size: var(--mud-typography-caption-size, 12px);
  line-height: var(--mud-typography-caption-lineheight, 20px);
  text-transform: uppercase;
}

.app-sidebar .mud-nav-group>.mud-nav-link:hover .workspace-niveau-title,
.app-sidebar .mud-nav-group>.mud-nav-link.active .workspace-niveau-title {
  color: var(--mud-palette-text-primary);
}

.app-sidebar .mud-nav-group:has(.mud-collapse-container .mud-nav-link.active)>.mud-nav-link .workspace-niveau-title {
  color: var(--app-accent-contrast);
}

/* Status badges on the dark sidebar — translucent fills + warm fg
   (the global .badge-* classes are tuned for light backgrounds) */
.app-sidebar .badge-validee,
.app-sidebar .badge-active {
  background: color-mix(in srgb, var(--app-success) 18%, transparent);
  color: var(--app-success);
}

.app-sidebar .badge-brouillon {
  background: color-mix(in srgb, var(--app-warning) 16%, transparent);
  color: var(--app-warning);
}

.app-sidebar .badge-obsolete {
  background: color-mix(in srgb, var(--app-text-faint) 18%, transparent);
  color: var(--mud-palette-text-secondary);
}

/* The niveau version pill reuses the global .badge .badge-{statut} classes
   (same shape and color as the StatutVersionBadge in the contract card).
   We only add the chevron sizing and the cursor since the pill is clickable. */
.workspace-niveau-version-badge {
  gap: 4px;
  cursor: pointer;
}

.workspace-niveau-version-badge .mud-icon-root {
  font-size: 0.875rem;
  /* 14px chevron */
}

/* Push the niveau version badge to the right of the title (chevron stays
   at the extreme right of the nav-link, after .mud-nav-link-text). */
.app-sidebar .mud-nav-group>.mud-nav-link .mud-nav-link-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-sidebar .mud-nav-group>.mud-nav-link .workspace-niveau-title {
  flex: 1;
  min-width: 0;
}

/* MudMenu activator inside the contract card must take the row width
   so .workspace-contract-version-row's space-between aligns Brouillon right */
.workspace-contract-card .mud-menu {
  display: flex;
  flex: 1;
  min-width: 0;
}

.workspace-contract-card .mud-menu>button,
.workspace-contract-card .mud-menu>.mud-menu-activator {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  padding: 0;
  background: transparent;
  border: 0;
}

.workspace-contract-company-icon.mud-icon-root {
  font-size: 14px;
  color: var(--mud-palette-text-secondary);
  transform: translateY(-1px);
}

.workspace-versions-table tbody tr {
  cursor: pointer;
}

.omni-search-root {
  display: flex;
  flex-direction: column;
  height: min(760px, 88vh);
  min-height: 620px;
}

.omni-search-dialog .mud-dialog {
  width: min(1080px, 92vw);
  max-width: 1080px;
}

.omni-search-dialog .mud-dialog-content {
  padding: 16px 18px 12px;
}

.omni-search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--app-border);
  padding: 6px 4px 12px;
  color: var(--app-text-muted);
}

.omni-search-input {
  flex: 1;
}

.omni-search-input .mud-input {
  font-size: 15px;
}

.omni-search-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.omni-search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow-y: auto;
  padding: 12px 2px 4px 0;
}

.omni-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-faint);
  margin: 4px 0 8px;
}

.omni-group-title::after {
  content: "";
  height: 1px;
  background: var(--app-border);
  flex: 1;
}

.omni-result-item {
  width: 100%;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 5px;
  transition: border-color var(--transition-speed), background var(--transition-speed), box-shadow var(--transition-speed);
}

.omni-result-item:hover,
.omni-result-item.active {
  border-color: var(--app-info);
  background: var(--app-selection-bg);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--app-info) 12%, transparent);
}

.omni-result-leading {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.omni-result-leading.groupe {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text);
}

.omni-result-leading.societe {
  background: var(--app-info-bg-strong);
  color: var(--app-info-text);
}

.omni-result-leading.contrat {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.omni-result-leading.version {
  background: var(--app-warning-bg-strong);
  color: var(--app-warning-text);
}

.omni-result-leading.contact {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

.omni-result-leading.autre {
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
}

.omni-result-content {
  min-width: 0;
  flex: 1;
}

.omni-result-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text);
}

.omni-result-sub {
  font-size: 12px;
  color: var(--app-text-muted);
  margin-top: 3px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.omni-group:last-child .omni-result-item:last-child {
  margin-bottom: 0;
}

.omni-autres-organisations-intro {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-sunken);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--app-text-muted);
}

.omni-autres-organisations-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text);
}

.omni-autres-organisations-hint {
  font-size: 12px;
  color: var(--app-text-muted);
  margin-top: 2px;
}

.omni-organisation-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--app-text-muted);
  margin: 4px 0 8px;
}

.omni-organisation-nom {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.omni-organisation-title::after {
  content: "";
  height: 1px;
  background: var(--app-border);
  flex: 1;
}

.omni-result-item .omni-result-organisation-action {
  color: var(--app-text-faint);
  flex-shrink: 0;
}

.omni-result-item:hover .omni-result-organisation-action,
.omni-result-item.active .omni-result-organisation-action {
  color: var(--app-info-text);
}

.omni-search-results::-webkit-scrollbar {
  width: 8px;
}

.omni-search-results::-webkit-scrollbar-thumb {
  background: var(--app-border-strong);
  border-radius: 99px;
}

.omni-search-results::-webkit-scrollbar-track {
  background: transparent;
}

.omni-result-type {
  font-size: 11px;
  color: var(--app-text-muted);
  background: var(--app-surface-sunken-strong);
  border-radius: 999px;
  padding: 3px 8px;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
}

.omni-search-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 4px;
  color: var(--app-text-muted);
  font-size: 14px;
}

.omni-search-loading {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-size: 11px;
  color: var(--app-text-muted);
  background: var(--app-veil);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  padding: 3px 8px;
}

.omni-search-hint {
  font-size: 11px;
  color: var(--app-text-faint);
  border-top: 1px solid var(--app-border);
  padding-top: 10px;
  margin-top: 8px;
}

/* ============================================
   Spacing utilities
   ============================================ */

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 12px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.mb-8 {
  margin-bottom: 32px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.gap-6 {
  gap: 24px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.text-center {
  text-align: center;
}

/* ============================================
   Workspace Layout — Sticky header + scrollable body
   ============================================ */

.workspace-sticky-header {
  flex-shrink: 0;
  z-index: 100;
  background: var(--app-bg);
  padding-bottom: 8px;
}

.workspace-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.workspace-scroll-area:has(.siret-fixed-scope-page) {
  overflow-y: hidden;
}

.siret-fixed-scope-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.siret-fixed-scope-page > .siret-scope-layout,
.siret-fixed-scope-page > .chargements-sante-layout,
.siret-fixed-scope-page .chargements-sante-layout > .siret-scope-layout {
  flex: 1;
  min-height: 0;
}

.siret-fixed-scope-page > .chargements-sante-layout {
  grid-template-rows: minmax(0, 1fr);
}

.siret-fixed-scope-page .siret-scope-layout {
  min-height: 0;
  align-items: stretch;
  /* Bound the single grid row to the available height so the SIRET column and the
     content column become height-constrained — otherwise the row is `auto`
     (content-sized), nothing downstream can scroll, and the sticky header has no
     bounded scroller to pin against. This is the keystone of the whole behaviour. */
  grid-template-rows: minmax(0, 1fr);
}

.siret-fixed-scope-page .siret-scope-tabs {
  min-height: 0;
  align-self: stretch;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
}

.siret-fixed-scope-page .siret-scope-tab {
  width: 100%;
  height: auto;
  min-height: 34px;
  align-self: start;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.25;
  white-space: normal;
}

.siret-fixed-scope-page .siret-scope-content {
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

/* Doctrine: jamais de scroll vertical dans une sous-partie. Les panneaux ne se
   compriment pas (flex-shrink: 0) et la zone de table n'a aucun plafond de
   hauteur: la colonne .siret-scope-content est l'unique ascenseur vertical de
   la page, la zone de table ne sert plus qu'au scroll horizontal d'une grille
   trop large. Cas particulier: quand la page n'a qu'un seul panneau
   (:only-child, cotisations prevoyance), ce panneau remplit la hauteur et la
   grille entiere defile a l'interieur avec ses en-tetes epingles — min-height: 0
   reste necessaire a ce cas pour autoriser le panneau a se borner. */
.siret-fixed-table-panel {
  min-height: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.siret-fixed-table-scroll {
  --siret-thead-row-h: 38px;
  min-height: 0;
  overflow: auto;
}

.siret-fixed-scope-page .siret-scope-content > .siret-fixed-table-panel:only-child {
  flex: 1;
}

.siret-fixed-scope-page .siret-scope-content > .siret-fixed-table-panel:only-child > .siret-fixed-table-scroll {
  flex: 1;
}

/* Pin the column headers while only the tbody rows scroll underneath.
   `.table-clean` uses `border-collapse: collapse`, where `position: sticky`
   on the <thead>/<tr> element does not reliably pin in Chromium — the robust
   target is the <th> cells. The bottom divider is painted with an inset shadow
   so it travels with the pinned header instead of being lost to the collapsed
   border grid. */
.siret-fixed-table-scroll .table-clean thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--app-surface);
  box-shadow: inset 0 -1px 0 var(--app-border);
}

/* Multi-line headers (cotisations prévoyance): the first header row stays at
   the top, the second header row pins immediately beneath it. */
.siret-fixed-table-scroll .table-clean thead tr:first-child th {
  top: 0;
  height: var(--siret-thead-row-h);
}

.siret-fixed-table-scroll .table-clean thead tr:nth-child(2) th {
  top: var(--siret-thead-row-h);
  z-index: 3;
}

@media (max-width: 900px) {
  .siret-fixed-scope-page .siret-scope-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }
}

/* ============================================
   Aperçu Page — Hero Identity Card
   ============================================ */

/* Page header */
.page-header--contract {
  align-items: flex-start;
  border-left: 3px solid var(--contract-header-accent);
  border-radius: 10px;
  padding: 16px 20px;
  background: var(--contract-header-bg);
  margin-bottom: 28px;
}

.page-header--contract .page-header-left {
  align-items: flex-start;
}

.page-header--contract h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--app-text);
  margin: 0;
  line-height: 1.3;
}

.page-header--contract .contract-icon-wrapper {
  background: var(--contract-icon-bg);
}

.page-header--contract .header-document-icon {
  color: var(--contract-header-accent);
}

.page-header--contract-sante {
  --contract-header-bg: var(--app-success-bg);
  --contract-header-accent: var(--app-success);
  --contract-icon-bg: color-mix(in srgb, var(--app-success) 12%, transparent);
}

.page-header--contract-prevoyance {
  --contract-header-bg: var(--app-highlight-bg);
  --contract-header-accent: var(--app-highlight);
  --contract-icon-bg: color-mix(in srgb, var(--app-highlight) 12%, transparent);
}

.header-pill {
  display: inline-flex;
  align-items: center;
  background: var(--app-surface-sunken-strong);
  color: var(--app-text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
}

.page-header--contract-sante .header-pill {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.page-header--contract-prevoyance .header-pill {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

.header-pill--link:hover {
  background: var(--app-border);
  color: var(--app-text);
}

.page-header--contract-sante .header-pill--link:hover {
  background: var(--app-success-bg-strong);
  color: var(--app-success-text);
}

.page-header--contract-prevoyance .header-pill--link:hover {
  background: var(--app-highlight-bg-strong);
  color: var(--app-highlight-text);
}

/* Edit button refinement */
.apercu-edit-btn {
  border-color: var(--app-border-strong) !important;
  color: var(--app-text) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.apercu-edit-btn:hover {
  border-color: var(--app-info) !important;
  color: var(--app-info) !important;
}

/* Flux chips row inside a contract header band (sante apercu) */
.contract-header-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.sante-global-header {
  margin-bottom: 24px;
  border: 1px solid #dbe7e0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--app-surface);
}

.sante-global-header__hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px 20px;
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(236, 253, 245, 0.96) 52%, #f4fbf7 100%);
}

.sante-global-header__hero-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.sante-global-header__hero-copy {
  min-width: 0;
}

.sante-global-header__hero h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: #10261d;
}

.sante-global-header__icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.16);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.12);
}

.sante-global-header__icon .header-document-icon {
  color: var(--app-success-text);
}

.sante-global-header__meta-line {
  margin-top: 8px;
  color: #3f5d52;
}

.sante-global-header__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sante-global-header__action {
  background: rgba(255, 255, 255, 0.74) !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.sante-global-header__footer {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.04) 0%, #ffffff 22%);
  border-top: 1px solid rgba(16, 185, 129, 0.14);
}

.sante-global-header__details {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.45fr);
  margin-left: 92px;
  position: relative;
}

.sante-global-header__details::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--emerald-500) 0%, var(--emerald-300) 100%);
}

.sante-global-header__detail {
  padding: 18px 24px 22px;
}

.sante-global-header__detail:not(:last-child) {
  border-right: 1px solid #edf2ee;
}

.sante-global-header__detail--population {
  padding-left: 28px;
}

.sante-global-header__label {
  color: #5c6f66;
}

.sante-global-header__value {
  margin-top: 6px;
  font-size: 19px;
  font-weight: 700;
  color: var(--app-text);
  line-height: 1.4;
}

.flux-chip--empty {
  color: var(--app-text-faint);
}

/* Identity card */
.apercu-identity-card {
  background: var(--app-surface);
  border-radius: 14px;
  border: 1px solid var(--app-border);
  overflow: hidden;
  min-height: fit-content;
  margin-bottom: 20px;
}

.apercu-identity-top {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--app-border-subtle);
}

.apercu-identity-cell {
  padding: 22px 28px;
  position: relative;
}

/* Vertical separator between cells */
.apercu-identity-cell:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: var(--app-surface-sunken-strong);
}

.apercu-cell-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-text-faint);
  margin-bottom: 6px;
}

.apercu-cell-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--app-text);
}

.apercu-cell-value--contract {
  font-size: 20px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.apercu-cell-helper {
  font-size: 12px;
  color: var(--app-text-faint);
  margin-top: 3px;
}

/* Assureur logo placeholder */
.apercu-assureur-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.apercu-assureur-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--app-info-text), var(--app-info));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-accent-contrast);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.apercu-assureur-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--app-text);
}

/* Version row: V0 + Active inline */
.apercu-version-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.apercu-active-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-success);
}

.apercu-active-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--app-success);
  flex-shrink: 0;
}

/* Bottom strip */
.apercu-identity-strip {
  display: flex;
  align-items: center;
  padding: 12px 28px;
  background: var(--app-surface-sunken);
}

.apercu-tag-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Details card */
.apercu-details-card {
  background: var(--app-surface);
  border-radius: 14px;
  border: 1px solid var(--app-border);
  margin-bottom: 24px;
}

.apercu-details-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--app-border-subtle);
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text);
}

.apercu-details-header .mud-icon-root {
  color: var(--app-text-faint);
  font-size: 20px;
}

.apercu-details-grid {
  display: flex;
  flex-direction: column;
}

.apercu-detail-item {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 6px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--app-border-subtle);
}

.apercu-detail-item--left-column {
  grid-column: auto;
  border-right: none;
}

.apercu-detail-item--affectations {
  align-items: flex-start;
}

.apercu-detail-item--population {
  grid-column: 1 / -1;
}

.apercu-detail-content {
  min-width: 0;
}

.apercu-detail-content--stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.apercu-population-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.apercu-population-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.apercu-population-line-label {
  min-width: 150px;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-faint);
}

.apercu-population-line-value {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.apercu-detail-item:last-child {
  border-bottom: none;
}

.apercu-detail-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--app-text-faint);
}

.apercu-detail-value {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--app-text);
  min-width: 0;
  line-height: 1.5;
  word-break: break-word;
}

.apercu-detail-value--empty {
  font-style: italic;
  color: var(--app-text-faint);
}

/* Canonical "general information" grid — shared by the sante dispositif
   apercu and the prevoyance perimetre card so both screens read identically. */
.apercu-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}

.apercu-info-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.apercu-info-field__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-text-muted);
}

.apercu-info-field__value {
  font-size: 18px;
  font-weight: 600;
  color: var(--app-text);
  word-break: break-word;
}

/* A field that must span the whole grid row (e.g. a wide table). */
.apercu-info-field--full {
  grid-column: 1 / -1;
}

.apercu-info-field__value--placeholder {
  font-size: 15px;
  font-weight: 500;
  font-style: italic;
  color: var(--app-text-faint);
}

.apercu-info-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Scalar-parameters zone inside a details card (padding wrapper for the grid) */
.apercu-details-params {
  padding: 20px 28px 24px;
}

.apercu-details-params--divided {
  border-top: 1px solid var(--app-border-subtle);
}

.apercu-affectations-table-wrapper {
  overflow-x: auto;
}

.apercu-affectations-table {
  display: grid;
  width: 100%;
  font-size: 12.5px;
}

.apercu-affectations-ligne {
  display: grid;
  grid-template-columns: repeat(4, max-content);
}

.apercu-affectations-ligne > span {
  text-align: left;
  padding: 0 22px 8px 0;
  white-space: nowrap;
}

.apercu-affectations-ligne:last-child > span {
  padding-bottom: 0;
}

.sante-dispositif-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sante-dispositif-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.sante-dispositif-card__title-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.sante-dispositif-card__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sante-dispositif-card__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--app-text);
}

.sante-dispositif-card__summary {
  font-size: 13px;
  color: var(--app-text-muted);
}

.sante-dispositif-card__actions,
.sante-dispositif-card__contrats-sante-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sante-dispositif-card__contrats-sante {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sante-dispositif-contrat-sante-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface);
}

.sante-dispositif-contrat-sante-row--active {
  background: var(--app-surface);
  border-color: color-mix(in srgb, var(--app-info) 30%, var(--app-surface));
}

.sante-dispositif-contrat-sante-row--interactive {
  cursor: pointer;
}

.sante-dispositif-contrat-sante-row--interactive .sante-dispositif-contrat-sante-row__main,
.sante-dispositif-contrat-sante-row--interactive .sante-dispositif-card__contrats-sante-chips,
.sante-dispositif-contrat-sante-row--interactive .sante-dispositif-contrat-sante-row__main div,
.sante-dispositif-contrat-sante-row--interactive .sante-dispositif-contrat-sante-row__main span {
  cursor: pointer;
}

.sante-dispositif-contrat-sante-row--interactive:hover {
  border-color: color-mix(in srgb, var(--app-info) 50%, var(--app-surface));
  background: var(--app-surface);
}

.sante-dispositif-contrat-sante-row__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sante-dispositif-card__contrats-sante-chips {
  align-items: center;
}

.sante-dispositif-contrat-sante-row__meta {
  font-size: 13px;
  color: var(--app-text-muted);
}

.sante-dispositif-contrat-sante-row__actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.sante-dispositif-contrat-sante-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--app-info) 50%, var(--app-surface));
  border-radius: 8px;
  background: var(--app-surface);
  color: var(--app-info-text);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.sante-dispositif-contrat-sante-action-btn:hover {
  background: var(--app-info-bg);
  border-color: var(--app-info);
  color: var(--app-info-text);
}

.sante-dispositif-contrat-sante-contract-tag {
  font-family: Consolas, "SFMono-Regular", Menlo, Monaco, "Liberation Mono", "Courier New", monospace;
}

.sante-dispositif-contrat-sante-contract-tag--missing {
  font-style: italic;
}

/* Responsive: collapse at <=800px */
@media (max-width: 800px) {
  .apercu-identity-top {
    grid-template-columns: 1fr;
  }

  .apercu-identity-cell:not(:last-child)::after {
    display: none;
  }

  .apercu-identity-cell:not(:last-child) {
    border-bottom: 1px solid var(--app-border-subtle);
  }

  .apercu-detail-item--left-column {
    grid-column: auto;
    border-right: none;
  }

  .apercu-population-line {
    flex-direction: column;
    gap: 4px;
  }

  .apercu-population-line-label {
    min-width: 0;
  }

  .apercu-identity-strip {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .sante-global-header__hero {
    flex-direction: column;
    padding: 20px 20px 18px;
  }

  .sante-global-header__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .sante-global-header__details {
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .sante-global-header__details::before {
    left: 20px;
    right: 20px;
    top: 0;
    bottom: auto;
    width: auto;
    height: 4px;
  }

  .sante-global-header__detail:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid var(--app-border-subtle);
  }

  .sante-global-header__detail--population {
    padding-left: 24px;
  }

  .sante-dispositif-card__header,
  .sante-dispositif-contrat-sante-row {
    flex-direction: column;
  }

  .sante-dispositif-contrat-sante-row__version {
    text-align: left;
  }
}

.filldown-table td.prev-fill-cell {
  position: relative;
  transition: background-color 0.15s ease;
}

.filldown-table td.prev-fill-selected {
  background: var(--app-selection-bg) !important;
  box-shadow: inset 0 0 0 1px var(--app-focus-ring);
}

.filldown-table td.prev-fill-selected-single {
  background: transparent !important;
}

.filldown-table td.prev-fill-source {
  background: var(--app-selection-bg);
  box-shadow: inset 0 0 0 1px var(--app-focus-ring);
}

.filldown-table td.prev-fill-target {
  background: var(--app-selection-bg) !important;
  box-shadow: inset 0 0 0 1px var(--app-focus-ring);
}

.filldown-table td.prev-fill-cell-copied {
  background: var(--app-success-bg) !important;
}

.prev-fill-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--app-accent-contrast);
  border-radius: 1px;
  background: var(--mud-palette-primary);
  cursor: ns-resize;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.12s ease, transform 0.12s ease, background-color 0.12s ease;
  z-index: 2;
  touch-action: none;
}

.filldown-table td.prev-fill-cell:hover .prev-fill-handle,
.filldown-table td.prev-fill-selected-end .prev-fill-handle,
.filldown-table td.prev-fill-source .prev-fill-handle {
  opacity: 1;
  transform: scale(1);
}

.prev-fill-selection-active .filldown-table td.prev-fill-cell .prev-fill-handle {
  opacity: 0;
  transform: scale(0.85);
}

.prev-fill-selection-active .filldown-table td.prev-fill-selected-end .prev-fill-handle,
.prev-fill-selection-active .filldown-table td.prev-fill-source .prev-fill-handle {
  opacity: 1;
  transform: scale(1);
}

.filldown-table td.prev-fill-source .prev-fill-handle,
.filldown-table td.prev-fill-selected-end .prev-fill-handle,
.filldown-table td.prev-fill-target .prev-fill-handle {
  background: var(--app-info-text);
}

.documents-juridiques-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.documents-juridiques-page__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 2px 2px;
}

.documents-juridiques-page .page-header {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.documents-juridiques-page .page-header,
.documents-juridiques-page .section-heading,
.documents-juridiques-page .row-actions {
  gap: 10px;
}

.documents-juridiques-page .section-heading,
.documents-juridiques-page .row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* Action buttons: keep label left-aligned with the icon pinned top-left
   so long labels (e.g. "Marquer comme à corriger") wrap tidily instead of
   rendering as a bulky, centered two-line block. */
.documents-juridiques-page .row-actions .mud-button-root {
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
}

.documents-juridiques-page .section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.documents-juridiques-page .section-heading h2,
.documents-juridiques-page .section-heading p {
  margin: 0;
}

.documents-juridiques-page .stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.documents-juridiques-page .mandats-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.documents-juridiques-page .pool-list {
  display: grid;
  gap: 8px;
}

.documents-juridiques-page .pool-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  color: var(--app-text);
  padding: 10px 12px;
  text-align: left;
}

.documents-juridiques-page .pool-row.selected {
  border-color: var(--app-info-text);
  background: var(--app-selection-bg);
}

.documents-juridiques-page .pool-main,
.documents-juridiques-page .pool-counts {
  min-width: 0;
}

.documents-juridiques-page .pool-main {
  display: grid;
  gap: 2px;
}

.documents-juridiques-page .pool-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.documents-juridiques-page .pool-subtitle {
  color: var(--app-text-muted);
  font-size: 0.875rem;
}

.documents-juridiques-page .pool-counts {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--app-text-muted);
  font-size: 0.8125rem;
}

.documents-juridiques-page .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.documents-juridiques-page .mandat-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.documents-juridiques-page .mandat-detail-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface-sunken);
}

.documents-juridiques-page .mandat-detail-item span {
  color: var(--app-text-muted);
  font-size: 0.8125rem;
}

.documents-juridiques-page .mandat-detail-item strong {
  color: var(--app-text);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.section-heading.compact {
  margin-bottom: 10px;
}

.section-heading.compact h3,
.section-heading.compact p {
  margin: 0;
}

.section-heading.compact h3 {
  font-size: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-field label,
.form-label {
  color: var(--app-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .documents-juridiques-page .page-header,
  .documents-juridiques-page .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .documents-juridiques-page .mandats-layout {
    grid-template-columns: 1fr;
  }

  .documents-juridiques-page .pool-row {
    flex-direction: column;
  }

  .documents-juridiques-page .pool-counts {
    justify-content: flex-start;
  }

  .mandat-form-grid,
  .checkbox-list {
    grid-template-columns: 1fr;
  }

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

  .wizard-steps {
    grid-template-columns: 1fr;
  }

  .choice-grid,
  .wizard-summary {
    grid-template-columns: 1fr;
  }
}

/* Upload / replace dialogs */
.document-file-drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  position: relative;
  width: 100%;
  padding: 20px;
  border: 1px dashed var(--app-border-strong);
  border-radius: 8px;
  color: var(--app-text-muted);
  cursor: pointer;
  background: var(--app-surface-sunken);
}

.document-file-drop__title {
  color: var(--app-text);
  font-weight: 600;
}

.document-file-drop__meta {
  color: var(--app-text-muted);
  font-size: 12px;
}

.document-file-drop__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.document-dialog-file {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--app-text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.document-dialog-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px);
  gap: 12px;
  margin: 12px 0;
}

/* Responsive: keep the real table on desktop, stack only on small screens */
@media (max-width: 900px) {
  .document-dialog-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .documents-toolbar {
    flex-wrap: wrap;
  }

  .documents-toolbar__actions {
    margin-left: auto;
  }

  .document-detail {
    padding-left: 14px;
  }

  .document-versions__head {
    display: none;
  }

  .document-versions__row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .document-versions__actions {
    justify-content: flex-start;
  }
}

/* ============================================
   AppDialogSurface — largeurs standard (spec design system v1, 3.5)
   ============================================
   Le dialog est rendu par le MudDialogProvider, hors de la portee du CSS
   scope .razor.css: ces classes doivent vivre dans la feuille globale. */
.mud-dialog.app-dialog-sm {
  width: 480px;
  max-width: calc(100vw - 32px);
}

.mud-dialog.app-dialog-md {
  width: 640px;
  max-width: calc(100vw - 32px);
}

.mud-dialog.app-dialog-lg {
  width: 880px;
  max-width: calc(100vw - 32px);
}

/* ============================================
   AppTable — etats chargement / erreur (spec design system v1, 3.4)
   ============================================ */
.app-table-etat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--app-text-muted);
  font-size: 13px;
}

.app-table-etat-erreur {
  flex-wrap: wrap;
}

/* Rapport d'import en masse: zone bornee dans le dialog */
.import-rapport-scroll {
  max-height: 280px;
}

/* Lignes de table cliquables (navigation au clic, AppTable) */
.table-clean tr.row-clickable td {
  cursor: pointer;
}

/* Cellules numeriques (montants, effectifs): alignees a droite, chiffres tabulaires */
.table-clean .td-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Titre de section (spec design system v1.1, decision D)
   ============================================
   Role overline de la spec (1.5) pour titrer un groupe de champs dans un
   dialog ou une carte. Classe globale: les dialogs sont rendus par le
   MudDialogProvider, hors de la portee du CSS scope .razor.css. */
.app-titre-section {
  color: var(--app-text-muted);
}

/* ============================================
   AppGrilleEditeur — editeur matriciel (spec design system v1.2, 3.4bis)
   ============================================
   Zone proprietaire des DEUX axes: une grille large defile dans sa zone,
   jamais la page. Premier etage d'en-tete epingle par defaut; l'offset du
   second etage (top) reste au CSS scope de l'ecran, qui connait sa
   hauteur d'en-tete. */
.grille-scroll-region {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.grille-editeur {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}

.grille-editeur th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--app-surface);
  box-shadow: inset 0 -1px 0 var(--app-border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-text-muted);
  text-align: left;
  padding: var(--app-space-2) var(--app-space-3);
}

.grille-editeur td {
  padding: var(--app-space-1) var(--app-space-3);
  border-bottom: 1px solid var(--app-border-subtle);
  color: var(--app-text);
}

.grille-editeur tbody th {
  position: static;
  box-shadow: none;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  color: var(--app-text);
  background: var(--app-surface-sunken);
  border-bottom: 1px solid var(--app-border-subtle);
}

.grille-editeur .grille-montant {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Notes de garantie - partagees entre la cellule (GarantieNoteCell) et le
   dialog de note (rendu hors du sous-arbre scope de GarantiesPage). */

.prev-note-preview {
    display: -webkit-box;
    min-width: 0;
    max-width: 38rem;
    overflow: hidden;
    color: var(--app-text);
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.prev-note-editor {
    width: 100%;
}

.prev-note-button {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.prev-note-button--editable {
    min-height: 42px;
    max-width: none;
    padding: 6px 8px;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    background: var(--app-surface);
    box-sizing: border-box;
}

.prev-note-button:hover {
    color: var(--mud-palette-primary);
}

.prev-note-button--editable:hover {
    border-color: var(--mud-palette-primary);
    background: var(--app-surface-sunken);
}

.prev-note-button:focus-visible {
    outline: 2px solid var(--app-focus-ring);
    outline-offset: 2px;
    border-radius: 4px;
}

.prev-note-button--editable:focus-visible {
    outline: 0;
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px var(--app-selection-bg);
}

.prev-note-preview--empty {
    color: var(--app-text-faint);
    font-style: italic;
}

/* Dialog de note de garantie et editeur rich-text (rendu dans le portail
   MudDialog, hors de tout sous-arbre scope): regles globales aux tokens. */

.garantie-note-dialog {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 68ch;
}

.garantie-note-dialog-meta {
    display: grid;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--app-border);
}

.garantie-note-dialog-label {
    display: block;
    margin-bottom: 2px;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.garantie-note-dialog-value {
    color: var(--app-text);
    font-size: 14px;
    font-weight: 600;
}

.garantie-note-dialog-text {
    color: var(--app-text);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.rich-text-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rich-text-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    width: fit-content;
    padding: 2px;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    background: var(--app-surface);
}

.rich-text-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
}

.rich-text-surface {
    min-height: 170px;
    max-height: 360px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--app-border-strong);
    border-radius: 6px;
    color: var(--app-text);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    caret-color: var(--app-text);
    cursor: text;
    user-select: text;
    background: var(--app-surface);
}

.rich-text-surface * {
    caret-color: var(--app-text);
}

.rich-text-surface:focus {
    border-color: var(--mud-palette-primary);
    outline: 0;
    box-shadow: 0 0 0 2px var(--app-selection-bg);
}

.rich-text-surface a,
.garantie-note-dialog-text a,
.prev-note-preview a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

/* Texte secondaire attenue (tokens), utilisable dans les portails de dialog. */
.texte-attenue {
  color: var(--app-text-muted);
}

/* Utilitaires de dialogs (portail MudDialog, hors sous-arbres scopes). */
.bouton-aligne-champ {
  margin-top: 4px;
  height: 40px;
}

.texte-important {
  font-weight: 600;
}

.fiche-descriptive {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.champ-fixe-90 {
  flex: 0 0 90px;
}

.champ-fixe-140 {
  flex: 0 0 140px;
}

.pile-verticale {
  display: grid;
  gap: var(--app-space-3);
}

/* Lien qui herite integralement de la typographie de son conteneur
   (specificite a.- pour passer devant les classes MudLink). */
a.lien-herite {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* ============================================
   Coquille wizard Saisie Assureur (PRD 3.2, 3.5)
   Classes globales : la creation (SaisieWizardPage) et la modification
   (SaisieModifierPage) rendent chacune leur propre arbre scope mais partagent le meme
   stepper/pied de navigation - une classe .razor.css locale a l'une ne serait pas
   visible par l'autre (meme raison que les badges Saisie Assureur ci-dessus).
   ============================================ */

.wizard-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-etapes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.wizard-etape {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  color: var(--app-text);
  text-align: left;
  cursor: pointer;
}

.wizard-etape:disabled {
  cursor: default;
  opacity: 0.68;
}

.wizard-etape-pastille {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--app-radius-pill);
  background: var(--app-surface-sunken-strong);
  color: var(--app-text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.wizard-etape-libelle {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* PRD 3.2 : coche verte pour les etapes franchies, numero orange pour l'etape en
   cours, numero grise pour les etapes a venir. */
.wizard-etape--franchie {
  border-color: var(--app-success);
  background: var(--app-success-bg);
  color: var(--app-success-text);
}

.wizard-etape--franchie .wizard-etape-pastille {
  background: var(--app-success);
  color: var(--app-accent-contrast);
}

.wizard-etape--courante {
  border-color: var(--app-warning);
  background: var(--app-warning-bg);
  color: var(--app-warning-text);
}

.wizard-etape--courante .wizard-etape-pastille {
  background: var(--app-warning);
  color: var(--app-accent-contrast);
}

.wizard-etape--avenir {
  color: var(--app-text-muted);
}

.wizard-corps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.wizard-pied {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--app-border);
}

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