h1:focus {
  outline: none;
}

#blazor-error-ui {
  background: var(--mud-palette-warning);
  color: var(--mud-palette-warning-text);
  bottom: 0;
  box-shadow: var(--mud-elevation-4);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 2000;
}

#blazor-error-ui .reload {
  color: inherit;
  font-weight: 600;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.blazor-error-boundary {
  background: var(--mud-palette-error);
  color: var(--mud-palette-error-text);
  padding: 1rem;
}

.blazor-error-boundary::after {
  content: "Une erreur est survenue.";
}

/* Pages de compte (rendu statique) */
.cse-compte {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--mud-palette-background);
}

.cse-compte-carte {
  width: 100%;
  max-width: 28rem;
}

.cse-champ {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.cse-champ label {
  font-weight: 500;
  color: var(--mud-palette-text-primary);
}

.cse-champ input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--mud-palette-lines-inputs);
  border-radius: var(--mud-default-borderradius);
  background: var(--mud-palette-surface);
  color: var(--mud-palette-text-primary);
}

.cse-champ input:focus-visible {
  outline: 2px solid var(--mud-palette-primary);
  outline-offset: 1px;
}

.cse-champ small {
  color: var(--mud-palette-text-secondary);
}

.cse-champ .validation-message {
  color: var(--mud-palette-error);
}

.cse-qrcode {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1rem;
}

.cse-qrcode svg {
  width: 200px;
  height: 200px;
  background: #ffffff; /* Fond blanc requis pour la lecture du QR code, même en thème sombre. */
}

.cse-cle,
.cse-codes {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
}

.cse-codes {
  columns: 2;
  margin: 0;
  padding-left: 1.25rem;
}

.cse-signature {
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px dashed var(--mud-palette-lines-default);
  border-radius: var(--mud-default-borderradius);
  background: #ffffff; /* La signature (encre foncée, fond transparent) reste lisible en thème sombre. */
}

.cse-signature img {
  max-width: 100%;
  max-height: 120px;
}

/* Exemple de fichier (format CSV du barème). */
.cse-code {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  border-radius: var(--mud-default-borderradius);
  background-color: var(--mud-palette-background-gray);
}

/* Saisie d'une note : grille façon tableur (SPEC §8 bis, écran 2). */
.cse-grille {
  overflow-x: auto;
}

.cse-saisie td,
.cse-saisie th {
  padding: 2px 6px !important;
  vertical-align: middle;
}

.cse-saisie .cse-nombre,
.cse-saisie .cse-col-nombre input,
.cse-saisie .cse-col-km input {
  text-align: right;
}

.cse-col-date { min-width: 140px; }
.cse-col-motif { min-width: 200px; }
.cse-col-divers { min-width: 120px; }
.cse-col-nombre { width: 84px; min-width: 72px; }
.cse-col-km { width: 116px; min-width: 104px; }
.cse-actions { white-space: nowrap; }

.cse-details td {
  background-color: var(--mud-palette-background-gray);
}

/* Texte réservé aux lecteurs d'écran. */
.cse-masque {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Panneau des totaux, fixe pendant le défilement sur grand écran. */
@media (min-width: 1920px) {
  .cse-totaux {
    position: sticky;
    top: 80px;
  }
}

.cse-liste-totaux {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  margin: 0;
}

.cse-liste-totaux dd {
  margin: 0;
  text-align: right;
}

.cse-liste-totaux .cse-total {
  font-weight: 600;
  padding-top: 0.25rem;
  border-top: 1px solid var(--mud-palette-lines-default);
}

/* Mobile (< 768 px, SPEC §8 bis) : cartes à la place de la grille, barre du montant et bouton « + ». */
.cse-mobile {
  display: none;
}

.cse-mobile-inline {
  display: none !important;
}

/* Aperçu PDF de la note dans le panneau latéral. */
.cse-apercu-pdf {
  width: 100%;
  height: calc(100vh - 4rem);
  border: 0;
}

/* Justificatifs : zone de dépôt, bouton « Prendre une photo » réservé au mobile. */
.cse-depot {
  position: relative;
  border: 2px dashed var(--mud-palette-lines-default);
  border-radius: var(--mud-default-borderradius);
}

/* Champ fichier invisible étendu à toute la zone pendant un glisser-déposer, pour recevoir le dépôt. */
.cse-depot-cible {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 10;
  cursor: copy;
}

.cse-depot-actif {
  border-color: var(--mud-palette-primary);
  background-color: var(--mud-palette-action-default-hover);
}

.cse-photo {
  display: none !important;
}

@media (max-width: 767.98px) {
  .cse-bureau {
    display: none !important;
  }

  .cse-mobile {
    display: block;
    padding-bottom: 7rem;
  }

  .cse-mobile-inline {
    display: inline-flex !important;
  }

  .cse-carte-contenu {
    cursor: pointer;
  }

  .cse-photo {
    display: inline-flex !important;
  }

  .cse-barre-montant {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
  }

  .cse-fab.mud-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(56px + 3.5rem);
    z-index: 1101;
  }
}

/* Barre de navigation du bas, mobile uniquement. */
.cse-nav-mobile {
  display: none;
}

@media (max-width: 767.98px) {
  .cse-nav-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    height: 56px;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    background-color: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
  }

  .cse-nav-mobile-lien {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    text-decoration: none;
  }

  .cse-nav-mobile-lien.active {
    color: var(--mud-palette-primary);
  }

  .cse-contenu {
    padding-bottom: 56px;
  }
}

/* Titres plus compacts sur téléphone. */
@media (max-width: 767.98px) {
  .mud-main-content h1.mud-typography-h4 {
    font-size: 1.5rem;
  }

  .cse-titre-appli {
    font-size: 1.05rem;
    white-space: nowrap;
  }
}

/* Texte réservé aux lecteurs d'écran (équivalent textuel des graphiques). */
.cse-lecteur-ecran {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Jauge de cumul km : repère du changement de tranche du barème. */
.cse-jauge {
  position: relative;
}

.cse-jauge-repere {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--mud-palette-text-primary);
}

/* Texte long sur une ligne, coupé par des points de suspension. */
.cse-tronque {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Page d'aide à l'installation (F14) : étapes numérotées et icône alignée sur le titre. */
.cse-etapes {
  margin: 0;
  padding-left: 1.25rem;
}

.cse-etapes li + li {
  margin-top: 0.5rem;
}

.cse-icone-titre {
  vertical-align: middle;
}

/* Boîte de réception (F14) : miniature de la photo, recadrée. */
.cse-capture-miniature {
  display: block;
  width: 100%;
  height: 10rem;
  object-fit: cover;
  background: var(--mud-palette-background-gray);
}

/* Vérification d'un document (SPEC §F16). */
.cse-verification {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
}

.cse-verification dt {
  font-weight: 600;
}

.cse-verification dd {
  margin: 0;
  min-width: 0;
}

.cse-empreinte {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* Logo du CSE (SPEC §F11) : en-tête de l'application et pages de compte. */
.cse-logo-entete {
  height: 32px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
}

.cse-compte-marque {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cse-logo-compte {
  height: 48px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

/* Écran Organisation et logo (SPEC §F11). */
.cse-logo-apercu {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 0.5rem;
  border: 1px dashed var(--mud-palette-lines-default);
  border-radius: 4px;
  /* Damier : la transparence du logo reste visible. */
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
}

.cse-logo-apercu img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
}

.cse-icone-apercu {
  width: 96px;
  height: 96px;
}

.cse-logo-vignette {
  height: 32px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
}

/* Mention d'information RGPD (SPEC §8) : texte long, carte élargie sur la page de compte. */
.cse-compte-carte:has(.cse-page-mention) {
  max-width: 48rem;
}

.cse-mention ul {
  padding-left: 1.5rem;
}

.cse-pied-de-page {
  text-align: center;
  padding-bottom: 1rem;
}
