/* Socle : jetons de design, éléments de base, formulaires, boutons, conteneurs, modales,
   messages, tables, visionneuse. Chargé par TOUTES les pages, en premier (base.html). */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ================================================================
   DESIGN TOKENS
   ================================================================ */

:root {
  /* Couleurs primaires */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #dbeafe;

  /* Accent (legacy compat) */
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-border: #dbeafe;

  /* Surfaces */
  --bg-page: #f1f5fb;
  --bg-page-2: #e7eef9;
  --bg-card: #ffffff;
  --bg-card-soft: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --bg-glass-strong: rgba(255, 255, 255, 0.94);

  /* Texte */
  --text-main: #0f172a;
  --text-strong: #0b1c44;
  --text-soft: #475569;
  --text-muted: #64748b;

  /* Bordures & ombres */
  --border-soft: #e2e8f0;
  --border-strong: #cbd5e1;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 14px 30px rgba(15, 23, 42, 0.10);
  --shadow-glass:
    0 12px 40px rgba(30, 50, 110, 0.10),
    0 2px 10px rgba(70, 140, 220, 0.08);

  /* Statuts */
  --success: #059669;
  --success-bg: #d1fae5;
  --success-border: #6ee7b7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-border: #fcd34d;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;

  /* Typographie
     ----------------------------------------------------------------
     Postes de pressing : écran partagé avec le logiciel de caisse, donc
     une demi-largeur, et lu debout à ~70 cm — plus loin qu'un bureau.
     La base passe de 16 à 17.5 px et l'échelle a un PLANCHER à 14 px :
     avant, les métadonnées des cartes descendaient à 10,6 px (.oc-*),
     illisibles à cette distance.

     L'échelle est resserrée par le haut (les titres ne suivent pas la
     hausse, cf. h1) : le corps de texte gagne en taille sans que la page
     gagne en hauteur, ce qui garde le contenu utile dans un demi-écran. */
  --fs-base: 17.5px;
  --fs-2xs:  0.80rem;   /* 14 px — plancher absolu, badges et libellés capitales */
  --fs-xs:   0.86rem;   /* 15 px — métadonnées, mentions secondaires */
  --fs-sm:   0.92rem;   /* 16 px — texte dense, listes, tableaux */
  --fs-md:   1rem;      /* 17.5 px — corps de texte */
  --fs-lg:   1.14rem;   /* 20 px — sous-titres */
  --fs-xl:   1.37rem;   /* 24 px — titres de section */

  /* Cible tactile
     ----------------------------------------------------------------
     Le poste est une tablette tactile de 7 pouces : tout ce qui se
     clique se touche au doigt, sans la précision d'un curseur. WCAG
     2.5.5 pose 44 px comme minimum ; on prend les 48 px de Material,
     parce qu'en pressing on manipule aussi des vêtements — le geste
     est rapide et la main pas toujours sèche. */
  --tap-min: 48px;

  /* Rayons */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-2xl: 28px;
  --radius-pill: 999px;

  /* Misc */
  --photo-size: 260px;
  --container-max: 1200px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* Renfort tactile.
   `pointer: coarse` = le pointeur principal est imprécis, donc un doigt.
   La requête est vraie sur la tablette et fausse sur un poste à souris, ce
   qui évite d'imposer des contrôles surdimensionnés aux écrans de bureau.

   Pourquoi 56 px et pas 48 : sur la tablette (1920x1280 en 7 pouces, ~330 dpi)
   la largeur du viewport CSS vaut 1920 / devicePixelRatio. Plus ce ratio est
   bas, plus le viewport est large et plus un pixel CSS est PETIT physiquement.
   À DPR 2 (viewport 960) un bouton de 48 px mesure ~7,4 mm, sous les 9 mm que
   demande une pulpe d'index. Les 56 px couvrent ce cas ; au-delà, c'est le
   viewport qu'il faudrait contraindre, pas le CSS. */
@media (pointer: coarse) {
  :root {
    --tap-min: 56px;
  }
}

/* ================================================================
   RESET / BASE
   ================================================================ */

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.35rem, 1.1rem + 0.9vw, 1.75rem);
  font-weight: 800;
  margin: 0 0 0.7em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  text-align: center;
  color: var(--text-strong);
}

h2 {
  font-size: var(--fs-xl);
  font-weight: 700;
}

h3 {
  font-size: var(--fs-lg);
  font-weight: 700;
}

p {
  margin: 0 0 0.8em;
}

p.muted, .muted, .muted-note {
  color: var(--text-muted);
  font-size: 0.95em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

.ti {
  font-size: 1.25em;
  vertical-align: middle;
  color: var(--primary);
  line-height: 1;
}

h1 .ti {
  font-size: 1.1em;
}

/* ================================================================
   FORMULAIRES
   ================================================================ */

label {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-strong);
  margin-bottom: 6px;
}

input:not([type]),
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="file"],
select,
textarea,
.form-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  /* min-height plutôt qu'une hauteur fixe : le champ suit la police s'il la
     dépasse. Mesuré à 37 px avant, sous la cible tactile. */
  min-height: var(--tap-min);
  padding: 11px 14px;
  color: var(--text-main);
  background: #ffffff;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

input[type="file"] {
  padding: 8px;
  background: var(--bg-card-soft);
  cursor: pointer;
}

/* Les cases à cocher gardaient la taille native du navigateur — 13x13 px,
   soit un quart de la cible tactile minimale. C'était le contrôle le plus
   difficile à atteindre de toute l'interface (55 occurrences : « actif »,
   « critique » du catalogue de risques, filtres de modération…).
   La case grossit à 26 px, et une zone de touche transparente de --tap-min
   l'entoure sans déplacer la mise en page (outline-offset négatif inutile
   ici : le pseudo-élément déborde sans pousser les voisins). */
input[type="checkbox"],
input[type="radio"] {
  width: 26px;
  height: 26px;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus,
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: #ffffff;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ================================================================
   BOUTONS
   ================================================================ */

button {
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-soft);
  background: #ffffff;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), box-shadow var(--transition), color var(--transition);
  line-height: 1.2;
  /* Cible tactile : ≥ 44px (usage au comptoir sur tablette). */
  min-height: 44px;
}

button:hover {
  background: var(--bg-card-soft);
  border-color: var(--border-strong);
}

button:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Boutons primaire / secondaire / variantes */
.btn,
.btn-primary,
.order-validate-btn,
.btn-action {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn:hover,
.btn-primary:hover,
.order-validate-btn:hover,
.btn-action:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-strong);
  border-color: var(--border-soft);
  box-shadow: none;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-action.btn-secondary {
  background: #f1f5f9;
  color: var(--text-strong);
  border-color: var(--border-soft);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.22);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.22);
}

.btn-warning:hover {
  background: #b45309;
  border-color: #b45309;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.22);
}

.btn-success:hover {
  background: #047857;
  border-color: #047857;
}

.linklike {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
  min-height: auto;
  box-shadow: none;
}

.linklike:hover {
  background: none;
  color: var(--primary-hover);
}

/* Texte courant : lecture en drapeau (à gauche), jamais centré.
   `.container { text-align: center }

` convient aux titres et aux barres
   d'action, mais un paragraphe de plusieurs lignes centré coûte une
   fixation oculaire par ligne — sur un poste consulté debout, c'est la
   moitié du gain de lisibilité de cette échelle typographique. */
.garment-card .garment-desc,
.garment-card .garment-summary,
.oc-desc,
.hist-info {
  text-align: left;
}

/* ================================================================
   ARRIÈRE-PLAN & CONTENEURS
   ================================================================ */

.background {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 12% 0%, rgba(37, 99, 235, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(99, 102, 241, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-page) 0%, var(--bg-page-2) 100%);
}

.container {
  position: relative;
  z-index: 1;
  width: min(var(--container-max), 94vw);
  margin: 18px auto;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.container.glass {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-glass);
}

.main-content {
  padding: 0;
}

/* ================================================================
   CARTES
   ================================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow-x: auto;
  text-align: left;
}

.card-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-strong);
}

.preview-img {
  margin: 1.2em auto 1em;
  max-width: 240px;
  max-height: 240px;
  height: auto;
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-md);
  padding: 6px;
  object-fit: contain;
}

/* ================================================================
   BOUTONS FLOTTANTS (TOP RIGHT)
   ================================================================ */

.gear-btn,
.logout-btn {
  position: fixed;
  top: 16px;
  z-index: 1000;
  width: var(--tap-min);
  height: var(--tap-min);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-strong);
  text-decoration: none;
  font-size: var(--fs-lg);
  padding: 0;
  cursor: pointer;
  transition: all var(--transition);
}

.gear-btn:hover,
.logout-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  color: var(--primary);
}

.gear-btn { right: 16px; }

.logout-btn { right: 74px; }

.logout-btn .ti { color: var(--text-soft); }

.logout-btn:hover .ti { color: var(--primary); }

/* ================================================================
   MODALES
   ================================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modal-fade 0.18s ease;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 440px;
  margin: 0;
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-pop 0.22s ease;
  text-align: left;
}

@keyframes modal-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content h2,
.modal-content h3 {
  margin-top: 0;
}

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

/* ===== Modale de confirmation (remplace window.confirm) =====
   Le confirm() natif s'affiche collé en haut de la webview, dans un cadre
   étroit à la taille système : hors de portée du regard comme du doigt sur la
   tablette du poste. Celle-ci est centrée (héritée de `.modal`), large sans
   déborder du demi-écran, et ses boutons respectent la cible tactile. */
.confirm-modal-content {
  max-width: 560px;
  width: min(560px, 100%);
  padding: 28px;
  text-align: left;
}

.confirm-title {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.3;
  color: var(--text-strong);
}

.confirm-message {
  margin: 12px 0 0;
  font-size: var(--fs-md);
  color: var(--text-soft);
}

/* Boutons pleine largeur, empilés en colonne dès que la fenêtre est étroite —
   le cas normal ici, la webview n'occupant qu'une moitié d'écran. « Annuler »
   d'abord : c'est la sortie, elle doit être la plus facile à trouver. */
.confirm-actions {
  margin-top: 24px;
  gap: 12px;
}

.confirm-actions button {
  min-height: var(--tap-min);
  font-size: var(--fs-md);
  padding: 12px 22px;
  flex: 1 1 180px;
}

/* Modale signalement (compatible historique/recherche) */
.signalement-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.signalement-modal-content {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 26px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  text-align: left;
  max-height: 90vh;
  overflow-y: auto;
}

.signalement-field {
  margin-bottom: 12px;
}

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

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

/* ================================================================
   LOADING & SUCCESS
   ================================================================ */

#loading {
  margin-top: 1.6em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
}

.loader {
  border: 5px solid var(--primary-border);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  animation: spin 0.9s linear infinite;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--primary-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

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

#success-check {
  display: none !important;
  align-items: center;
  justify-content: center;
  margin: 1.5em 0;
  flex-direction: column;
  gap: 0.5em;
}

.checkmark {
  width: 56px;
  height: 56px;
  display: block;
}

.checkmark-circle {
  stroke: var(--success);
  stroke-width: 4;
  fill: var(--success-bg);
  animation: fill 0.4s ease-in-out 0.2s forwards;
}

.checkmark-check {
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.5s cubic-bezier(0.65, 0.05, 0.36, 1) 0.6s forwards;
}

@keyframes fill {
  100% { fill: var(--success-bg); }
}

@keyframes stroke {
  100% { stroke-dashoffset: 0; }
}

#success-check span {
  font-size: 1.05em;
  color: var(--success);
  font-weight: 700;
}

/* ================================================================
   ALERTES & BANNIÈRES
   ================================================================ */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  text-align: left;
}

.banner.ok {
  background: var(--success-bg);
  color: #065f46;
  border-color: var(--success-border);
}

.banner.alert {
  background: var(--danger-bg);
  color: #991b1b;
  border-color: var(--danger-border);
}

.banner.risk-moderate {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.banner.risk-low {
  background: var(--warning-bg);
  color: #92400e;
  border-color: var(--warning-border);
}

.warning {
  background: var(--warning-bg);
  color: #92400e;
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 1.2em 0 0.8em;
  font-size: 1rem;
  text-align: left;
  box-shadow: var(--shadow-xs);
}

/* ================================================================
   TEXTE
   ================================================================ */

.summary {
  margin: 1em 0 0.7em;
  font-size: 1.05em;
  text-align: left;
}

.summary b {
  color: var(--text-strong);
}

.infos-list,
.etat-list {
  text-align: left;
  margin: 0.7em 0 0;
  font-size: 1rem;
  line-height: 1.7em;
  padding-left: 0.2em;
}

.tag-pending {
  font-size: 0.88em;
  opacity: 0.75;
  margin-left: 6px;
}

/* ================================================================
   TABLES
   ================================================================ */

.details-table,
.recap-table,
.compare-table,
.edit-all-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.details-table {
  margin-top: 0.4em;
}

.details-table td,
.details-table th,
.recap-table td,
.recap-table th,
.compare-table td,
.compare-table th,
.edit-all-table td,
.edit-all-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.details-table th,
.recap-table th,
.compare-table th,
.edit-all-table th {
  background: var(--bg-card-soft);
  color: var(--text-strong);
  font-weight: 700;
  font-size: 0.92em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.details-table tr:nth-child(even),
.recap-table tr:nth-child(even) {
  background: #fafbfd;
}

/* Pagination de l'historique (100 vêtements par page) */
.hist-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 10px 0;
}

.hist-pagination:empty {
  display: none;
}

.hist-pagination-info {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Boutons d'action des tableaux de correction (✏️ éditer, 💾 enregistrer) :
   cible tactile large et picto lisible — usage au comptoir sur écran tactile. */
.details-table td button,
.recap-table td button,
.edit-all-table td button {
  min-width: 52px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 1.35rem;  /* agrandit l'emoji, sinon ~15px illisible/imprécis */
  line-height: 1;
}

/* Page « UC mappés » : désignation du catalogue affichée entre parenthèses à
   côté du code UC — présente pour être lue, sans voler la vedette au code. */
.uc-libelle {
  color: var(--text-muted);
}

/* Localisation des taches : vignette de la carte d'attention du modèle défaut,
   rendue sous le verdict « Tâche » (cf. heatmap_tache.js). Cliquable → lightbox. */
.tache-heatmap {
  margin: 6px 0 0;
  max-width: 180px;
}

.tache-heatmap .heatmap-thumb {
  display: block;
  width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-xs);
  cursor: zoom-in;
}

.tache-heatmap figcaption {
  margin-top: 3px;
  font-size: 0.85em;
  color: var(--text-muted);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ================================================================
   TOASTS (feedback de sauvegarde)
   ================================================================ */

.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92em;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-ok {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.toast-err {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

/* ================================================================
   LIGHTBOX
   ================================================================ */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.88);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lb-fade-in 0.18s ease;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  cursor: default;
  animation: lb-zoom-in 0.18s ease;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  color: #fff;
  font-size: 2.4em;
  cursor: pointer;
  line-height: 1;
  opacity: 0.85;
  transition: opacity var(--transition);
  background: none;
  border: none;
  min-height: auto;
  padding: 0;
}

.lightbox-close:hover {
  opacity: 1;
  background: none;
}

@keyframes lb-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes lb-zoom-in {
  from { transform: scale(0.92); }
  to { transform: scale(1); }
}

.hist-img img,
.garment-thumb img,
img.garment-thumb,
img.oc-image-el,
.preview-img,
.scan-photo {
  cursor: zoom-in;
}

/* ================================================================
   GRID + CONNEXION
   ================================================================ */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.connexion-page {
  min-height: 100vh;
  padding: 20px;
}

.connexion-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 36px 32px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-glass);
  text-align: center;
}

.connexion-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.connexion-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.30);
}

.connexion-logo .ti {
  font-size: 1.8em;
  color: #fff;
}

.connexion-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-strong);
  display: block;
  text-align: center;
}

.connexion-subtitle {
  color: var(--text-soft);
  font-size: 0.95em;
  margin: 0;
}

.connexion-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.connexion-form button[type="submit"] {
  margin-top: 6px;
  width: 100%;
  padding: 13px 18px;
  font-size: 1.02em;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

.connexion-form button[type="submit"]:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.32);
}

.error-banner {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid var(--danger-border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.93em;
  margin-bottom: 4px;
  text-align: left;
}

/* ================================================================
   SWITCH (toggle) — utilisé sur risques
   ================================================================ */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0;
  /* Porte la cible tactile de la case qu'il englobe : un appui n'importe où
     sur le label bascule la case. La case elle-même fait 26 px — assez pour
     être lue, trop peu pour être visée au doigt — d'où la hauteur ici. */
  min-height: var(--tap-min);
  padding-right: 4px;
}

/* ================================================================
   Sélecteur de langue (FR / EN) — i18n
   ================================================================ */
/* Le sélecteur de langue est en `position: fixed` dans le coin haut-gauche : il
   flotte donc AU-DESSUS du contenu. Quand une page s'ouvre directement sur sa
   barre d'actions, sans titre au-dessus (cas de /a-verifier), le premier bouton
   passe dessous et devient illisible autant qu'incliquable. On lui réserve la
   gouttière plutôt que de le pousser vers le bas — la hauteur est la ressource
   rare sur un demi-écran, la largeur ne l'est pas ici. */
.container > .history-topbar:first-child {
  padding-left: 96px;
}

.lang-switcher {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 3px;
}

.lang-switcher .lang-opt {
  display: grid;
  place-items: center;
  min-width: var(--tap-min);
  height: var(--tap-min);
  padding: 0 8px;
  border-radius: calc(var(--radius-md) - 4px);
  color: var(--text-soft);
  text-decoration: none;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: all var(--transition);
}

.lang-switcher .lang-opt:hover {
  color: var(--primary);
}

.lang-switcher .lang-opt.active {
  background: var(--primary);
  color: #fff;
}

.connexion-page .lang-switcher {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.connexion-page .lang-switcher .lang-opt {
  color: rgba(255, 255, 255, 0.85);
}

.connexion-page .lang-switcher .lang-opt.active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
}

/* `hidden` doit l'emporter sur tout `display` posé par une classe : c'est
   l'attribut HTML qui dit qu'un élément est masqué, plus un style en ligne. */
[hidden] {
  display: none !important;
}

/* Zone dont le fragment est en cours de chargement. */
[aria-busy="true"] {
  opacity: 0.55;
  transition: opacity 0.15s;
}

.texte-gauche {
  text-align: left;
}

.titre-section {
  text-align: left;
  margin-top: 1.5em;
}

.conteneur-etroit {
  max-width: 640px;
}

.bouton-large {
  width: 100%;
}

.icone-alerte {
  color: var(--warning);
}

.texte-ok {
  color: #27ae60;
}

.texte-erreur {
  color: #d9534f;
}

/* Champ de saisie libre d'une liste « ou autre » (macro liste_ou_saisie). */
.saisie-libre {
  margin-top: 8px;
}

.signalement-field input[type="file"] {
  margin-bottom: 8px;
}

/* Message de retour d'un formulaire (succès / échec). */
.retour {
  margin-bottom: 1em;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid transparent;
}

.retour-ok {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.retour-erreur {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

/* Toute image agrandissable au clic (static/js/core/visionneuse.js). */
img[data-zoom] {
  cursor: zoom-in;
}

/* Briques partagées, remontées ici : plusieurs écrans les emploient. */

.admin-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1.2em;
  font-weight: 600;
  color: var(--text-strong);
  flex-wrap: wrap;
}
.admin-filter-bar select {
  padding: 9px 36px 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.97em;
  min-width: 200px;
  width: auto;
}
.loader-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 1.5em;
  color: var(--text-soft);
  font-size: 1em;
}
.admin-filter-bar label {
  margin-bottom: 0;
}
.risk-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-xs);
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-soft);
  font-size: 0.88em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* Puce à cocher : une vraie case, masquée, dont le libellé est la puce. */
.chip-case {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
label > .chip {
  display: inline-block;
  user-select: none;
}
.chip-case:checked + .chip {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip-case:focus-visible + .chip {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Saisie MULTI-matières (macro liste_multiple + js/composants/matieres.js) :
   puces retirables au-dessus de la liste d'ajout. La bulle est en « contour »
   (fond blanc, bord + texte bleus, croix nette), scopée au widget pour ne pas
   toucher les puces à cocher des règles (.chip-case). */
.mat-input { display: block; }
.mat-input .mat-chips:not(:empty) { margin-bottom: 6px; }
.mat-input .mat-add { width: 100%; }
.mat-input .mat-autre { margin-top: 6px; }
.mat-chips .chip.on.removable {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.mat-chips .chip.removable::after {
  content: "×";
  font-size: 1.15em;
  line-height: 1;
  opacity: 0.7;
}
.mat-chips .chip.removable:hover::after { opacity: 1; }

.field-hint {
  color: var(--text-muted);
  font-size: 0.85em;
  font-weight: 400;
}
.page-topbar {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.history-back-btn,
.page-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: #fff;
  color: var(--text-strong);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95em;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.history-back-btn:hover,
.page-back-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.history-back-btn .ti,
.page-back-btn .ti {
  font-size: 1.05em;
  color: inherit;
}
.risk-tech, .risk-client {
  margin-top: 4px;
}

/* Métadonnée discrète « picto + libellé » : le pressing d'origine et la date
   du scan, à l'écran « à vérifier » comme sur chaque ligne d'historique. Une
   seule règle pour les deux, afin que l'information se reconnaisse d'un écran
   à l'autre. */
.verif-meta-info,
.hist-pressing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.9em;
}

.verif-meta-info .ti,
.hist-pressing .ti {
  font-size: 1.1em;
}
