/* Présentation uniquement : les champs et leurs événements restent inchangés. */
:root {
  color-scheme: light;
  --ink: #203449;
  --muted: #586b7d;
  --line: #d9e3eb;
  --accent: #087e83;
}
* { box-sizing: border-box; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: auto;
  margin: 0 auto;
  padding: 32px clamp(10px, 1.2vw, 24px) 24px;
  max-width: 1920px;
  background: linear-gradient(155deg, #e9f3f5 0, #f3f6fa 420px);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
main { flex: 1 0 auto; min-width: 0; }
footer { flex-shrink: 0; }
.other-apps-link:hover { text-decoration: none; }
.other-apps-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1 {
  max-width: 950px;
  margin: 0 auto 36px;
  font-size: clamp(18px, 1.6vw, 25px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 0 auto 20px;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.04em;
}
.brand img { flex-shrink: 0; width: clamp(44px, 4vw, 56px); height: auto; }
.brand-accent { color: var(--accent); }
section {
  margin-bottom: 24px;
  padding: clamp(20px, 2vw, 32px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 22px #20344905;
}
h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -.02em;
}
h2::before {
  content: "";
  width: 5px;
  height: 23px;
  border-radius: 4px;
  background: var(--accent);
  flex-shrink: 0;
}
h3 { margin: 28px 0 12px; font-size: 16px; }
p { color: var(--muted); }
label { color: #3a5064; font-weight: 500; }
input, select, button, textarea {
  margin: 3px;
  padding: 10px 12px;
  border: 1px solid #bfceda;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}
input, select, textarea { transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #65798a; }
input:hover, select:hover, textarea:hover { border-color: #7797aa; }
:is(input, select, textarea, button, a, .table-scroll):focus-visible {
  outline: 3px solid #168d99;
  outline-offset: 3px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
button {
  cursor: pointer;
  border-color: #b6d5d7;
  background: #edf7f7;
  color: #08656a;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
button:hover { background: #dceff0; border-color: var(--accent); }
button:active { background: #cde7e8; }
.section-spoiler > summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.section-spoiler > summary::-webkit-details-marker { display: none; }
.section-spoiler > summary::before { content: "▶"; color: var(--accent); font-size: 14px; }
.section-spoiler[open] > summary::before { content: "▼"; }
.section-spoiler > summary h2 { margin: 0; }
.section-spoiler > summary h2::before { display: none; }
.section-spoiler > summary:focus-visible { outline: 3px solid #168d99; outline-offset: 6px; border-radius: 4px; }
.section-spoiler > .section-content { margin-top: 22px; }
#identite .identity-fields { display: grid; gap: 18px; }
#identite .identity-context { display: flex; flex-wrap: wrap; gap: 18px 24px; }
#identite .identity-year { width: 120px; max-width: 100%; }
#identite .identity-unit { flex: 1 1 360px; min-width: 0; }
#identite #unite, #identite #activite {
  display: block;
  width: 360px;
  max-width: 100%;
  min-width: 120px;
  height: 42px;
  margin: 0;
  background: #f9fbfd;
  resize: horizontal;
}
#identite #activite { width: 480px; }
#identite .identity-activity { min-width: 0; }
#identite .identity-work { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr); gap: 18px 24px; }
#identite .identity-work > div { min-width: 0; }
#identite .identity-person { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }
#identite .identity-person > div { min-width: 0; }
#identite h2 { grid-column: 1 / -1; margin-bottom: 0; }
#identite label { display: block; min-width: 0; margin-bottom: 6px; font-size: 13px; }
#identite input { width: 100%; margin: 0; background: #f9fbfd; }
#identite #matricule { width: 160px; max-width: 100%; }
#identite #date_naissance { width: 170px; max-width: 100%; }
#search, #selectAllProducts, #searchAccident, #selectAccidentProducts {
  max-width: 520px;
  min-height: 43px;
  vertical-align: middle;
}
#results, #accidentResults { margin-top: 12px; }
.result {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 6px;
  background: #f8fbfc;
}
.result:hover { background: #eaf5f5; border-color: #77b6ba; }
.matching-synonyms { color: var(--muted); }
.table-scroll { overflow-x: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; }
table { margin: 0; border-collapse: separate; border-spacing: 0; }
th, td { border: 0; border-bottom: 1px solid var(--line); padding: 12px 9px; }
th { background: #edf3f7; color: #3c5368; font-size: 11px; font-weight: 700; line-height: 1.5; }
td { border-right: 1px solid #e9eef3; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #fafcfe; }
tbody tr:hover { background: #f2f8fa; }
td input[type="text"], td input[type="number"] { padding: 7px; }
td textarea { padding: 8px; }
td button { padding: 7px 9px; font-size: 11px; }
#selectedProducts > tr > td:last-child > button,
#accidentalExposures > tr > td:last-child > button { color: #a23846; background: #fff3f4; border-color: #edcbd0; }
#selectedProducts td.field-outdated { background: #ffe8e8; }
#selectedProducts td.field-missing { background: #fff5d9; }
#accidentalEmpty { padding: 14px 18px; border: 1px dashed #c6d6e1; border-radius: 9px; background: #f8fafc; }
#io p, #pdf p { line-height: 1.65 !important; }
body > hr { display: none; }
#pdf { background: #fff; border-color: var(--line); }
#pdf button[onclick="exportFIEToPDF()"] { background: #08777c; border-color: #08777c; color: #fff; }
#pdf button[onclick="exportFIEToPDF()"]:hover { background: #065e62; }
footer { color: var(--muted) !important; }
footer a { color: #08747c; text-underline-offset: 3px; }
/* Tableau compact : une seule ligne par produit, quelle que soit la fen?tre. */
#produits table { table-layout: fixed; min-width: 1000px; }
#produits th, #selectedProducts td { padding: 7px 5px; overflow-wrap: anywhere; }
#produits th:nth-child(1) { width: calc(20% - 38px); }
#produits th:nth-child(2) { width: 7%; }
#produits th:nth-child(3) { width: 7%; }
#produits th:nth-child(4) { width: 6%; }
#produits th:nth-child(5) { width: 6%; }
#produits th:nth-child(6), #produits th:nth-child(7) { width: 6%; }
#selectedProducts td[data-required-field="manips"].field-missing::after { white-space: nowrap; }
#produits th:nth-child(8), #produits th:nth-child(9) { width: 12%; }
#produits th:nth-child(10), #produits th:nth-child(11) { width: 9%; }
#produits th:nth-child(12) { width: 38px; }
#selectedProducts .product-identity-field + .product-identity-field { margin-top: 8px; }
#selectedProducts .product-identity-field.field-outdated { background: #ffe8e8; }
#selectedProducts .product-cas-label { display: block; min-width: 0; font-size: 11px; }
.product-identity-label { display: block; min-width: 0; font-size: 11px; }
#accidentalExposures .product-identity-label + .product-identity-label { margin-top: 8px; }
#accidentalExposures .product-identity-label input { display: block; margin: 0; }
#selectedProducts td input[type="text"],
#selectedProducts td input[type="number"],
#selectedProducts td textarea {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 5px;
  font-size: 12px;
}
#selectedProducts td textarea { min-height: 58px; resize: both; }
#selectedProducts .protection-picker { min-width: 0; max-width: none; }
#selectedProducts .protection-option { overflow-wrap: anywhere; }
#selectedProducts .product-state { white-space: normal; }
#selectedProducts td button { max-width: 100%; margin: 0; padding: 6px 3px; overflow-wrap: anywhere; }
#selectedProducts td:last-child { text-align: center; }
#selectedProducts td .remove-product {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #b8293b;
  border-radius: 6px;
  background: #c93043;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}
#selectedProducts td .remove-product:hover { background: #a91f32; }
#selectedProducts td textarea.protection-other {
  height: 29px;
  min-height: 29px;
  resize: both;
}
@media (max-width: 1050px) {
  #identite .identity-person { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #search, #selectAllProducts, #searchAccident, #selectAccidentProducts { display: block; max-width: 100%; margin: 8px 0; }
}
@media (max-width: 600px) {
  body { padding-top: 28px; }
  h1 { margin-bottom: 24px; }
  #identite .identity-fields { gap: 16px; }
  #identite .identity-person { grid-template-columns: 1fr; gap: 16px; }
  #identite .identity-work { grid-template-columns: 1fr; gap: 16px; }
  section { border-radius: 12px; }
  #io button, #pdf button { display: block; width: 100%; margin: 10px 0; white-space: normal; }
  #productSort { max-width: 100%; }
}
@media print {
  .other-apps-link { display: none; }
  body { display: block; min-height: 0; padding: 0; background: #fff; }
  section { box-shadow: none; border-radius: 0; break-inside: avoid; }
  .table-scroll { overflow: visible; }
}
