@charset "UTF-8";
/* =============================================================
   LabFood — feuille de styles unique (public + back-office)
   Mobile-first, thèmes clair et sombre.
   ============================================================= */

/* ---------- Jetons ---------- */
:root {
  --brand: #0f766e;
  /* Variante utilisée pour le TEXTE : en thème sombre, la couleur de marque
     est éclaircie afin de conserver un contraste suffisant sur fond foncé. */
  --brand-text: var(--brand);

  --bg:          #f6f7f9;
  --surface:     #ffffff;
  --surface-alt: #f2f4f7;
  --surface-sunk:#eceff3;
  --border:      #e2e5ea;
  --border-strong:#cfd4dc;

  --text:        #16181d;
  --text-soft:   #565d69;
  --text-faint:  #858c98;

  --ok:    #0f7a4d;
  --ok-bg: #e6f5ed;
  --ko:    #b02a2a;
  --ko-bg: #fdeaea;
  --warn:  #9a6206;
  --warn-bg:#fdf3e2;
  --info:  #1d4f91;
  --info-bg:#e9f1fc;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 28, .06);
  --shadow:    0 2px 8px rgba(16, 20, 28, .07), 0 1px 2px rgba(16, 20, 28, .05);
  --shadow-lg: 0 12px 32px rgba(16, 20, 28, .12);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --wrap: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-text: color-mix(in srgb, var(--brand) 45%, #ffffff);

    --bg:          #0f1115;
    --surface:     #171a20;
    --surface-alt: #1e222a;
    --surface-sunk:#13161b;
    --border:      #2a2f39;
    --border-strong:#3a414e;

    --text:      #e8eaee;
    --text-soft: #a3aab7;
    --text-faint:#7b8391;

    --ok:    #5fd39b;
    --ok-bg: #13291f;
    --ko:    #f98a8a;
    --ko-bg: #2c1717;
    --warn:  #e9b45c;
    --warn-bg:#2a2013;
    --info:  #8fb8f0;
    --info-bg:#151f2e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 2px 10px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  --brand-text: color-mix(in srgb, var(--brand) 45%, #ffffff);
  --bg: #0f1115; --surface: #171a20; --surface-alt: #1e222a; --surface-sunk:#13161b;
  --border: #2a2f39; --border-strong:#3a414e;
  --text: #e8eaee; --text-soft: #a3aab7; --text-faint:#7b8391;
  --ok:#5fd39b; --ok-bg:#13291f; --ko:#f98a8a; --ko-bg:#2c1717;
  --warn:#e9b45c; --warn-bg:#2a2013; --info:#8fb8f0; --info-bg:#151f2e;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.1rem); }
h2 { font-size: clamp(1.2rem, 1.05rem + .7vw, 1.5rem); }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

img, svg { max-width: 100%; height: auto; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
@media (min-width: 640px) { .wrap { width: min(100% - 3rem, var(--wrap)); } }

.muted     { color: var(--text-soft); }
.faint     { color: var(--text-faint); }
.small     { font-size: .875rem; }
.tiny      { font-size: .8rem; }
.mono      { font-family: var(--mono); font-size: .9em; }
.nowrap    { white-space: nowrap; }
.center    { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: 0; left: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: .6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  transform: translateY(-120%);
  transition: transform .15s;
}
.skip-link:focus { transform: translateY(0); }

/* ---------- En-tête / pied ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(180%) blur(8px);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 60px; flex-wrap: wrap;
}
.site-brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.site-brand__mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; background: var(--brand); color: #fff; flex: none;
}
.site-brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.site-brand__text strong { font-size: 1rem; letter-spacing: -.01em; }
.site-brand__text small { font-size: .74rem; color: var(--text-soft); }
.site-header__nav a { font-size: .9rem; font-weight: 500; text-decoration: none; }
.site-header__nav a:hover { text-decoration: underline; }

.site-footer {
  margin-top: 4rem; padding: 2.5rem 0;
  background: var(--surface); border-top: 1px solid var(--border);
}
.site-footer__inner { display: grid; gap: 1.5rem; }
@media (min-width: 760px) {
  .site-footer__inner { grid-template-columns: 1.6fr 1fr; align-items: start; }
  .site-footer__meta { text-align: right; }
}
.site-footer__title { font-weight: 650; margin-bottom: .35rem; }
.site-footer p { font-size: .85rem; margin-bottom: .4rem; }

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; min-height: 40px;
  font: inherit; font-size: .9rem; font-weight: 550; line-height: 1.2;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--radius);
  text-decoration: none; cursor: pointer;
  transition: filter .15s, background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn--primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: transparent; }
.btn--danger  { --btn-bg: transparent; --btn-fg: var(--ko); --btn-bd: var(--ko); }
.btn--ghost   { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-soft); }
.btn--sm      { min-height: 32px; padding: .3rem .65rem; font-size: .82rem; }
.btn--block   { width: 100%; }
.btn svg { flex: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; line-height: 1.5;
  background: var(--surface-alt); color: var(--text-soft);
  border: 1px solid transparent; white-space: nowrap;
}
.badge--ok      { background: var(--ok-bg);   color: var(--ok); }
.badge--ko      { background: var(--ko-bg);   color: var(--ko); }
.badge--warn    { background: var(--warn-bg); color: var(--warn); }
.badge--info    { background: var(--info-bg); color: var(--info); }
.badge--neutral { background: var(--surface-alt); color: var(--text-soft); }
.badge--bio     { background: var(--ok-bg); color: var(--ok); }
.badge--outline { background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__body { padding: 1.25rem; }
.card__head {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; }
@media (min-width: 640px) { .card__body { padding: 1.5rem; } }

/* =============================================================
   PAGES PUBLIQUES
   ============================================================= */

/* ---------- Accueil ---------- */
.home-hero { padding: 3rem 0 2rem; }
.home-hero h1 { max-width: 20ch; }
.home-hero p  { max-width: 60ch; font-size: 1.05rem; color: var(--text-soft); }

.company-grid {
  display: grid; gap: 1rem; padding-bottom: 2rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.company-tile {
  display: flex; flex-direction: column; gap: .5rem;
  padding: 1.25rem; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.company-tile:hover { border-color: var(--brand-text); box-shadow: var(--shadow); transform: translateY(-2px); }
.company-tile__name { font-weight: 650; font-size: 1.05rem; }

/* ---------- Bandeau société ---------- */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2rem 0 1.5rem;
}
.hero__inner { display: grid; gap: 1.25rem; }
.hero__identity { display: flex; align-items: flex-start; gap: 1rem; }
.hero__logo {
  width: 56px; height: 56px; flex: none; border-radius: 12px; object-fit: contain;
  background: var(--surface-alt); border: 1px solid var(--border); padding: 4px;
}
.hero__logo--placeholder {
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 1.35rem;
  border-color: transparent;
}
.hero h1 { margin-bottom: .25rem; }
.hero__sub { color: var(--text-soft); font-size: .95rem; margin: 0; }
.hero__desc { max-width: 68ch; color: var(--text-soft); margin-top: .75rem; }

.stat-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat {
  padding: .85rem 1rem; border-radius: var(--radius);
  background: var(--surface-alt); border: 1px solid var(--border);
}
.stat__value { font-size: 1.5rem; font-weight: 680; line-height: 1.15; letter-spacing: -.02em; }
.stat__label { font-size: .78rem; color: var(--text-soft); margin-top: .1rem; }

/* ---------- Barre de filtres ---------- */
.filters {
  position: sticky; top: 60px; z-index: 20;
  background: var(--bg); padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.filters__form { display: grid; gap: .6rem; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .filters__form { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
}
.filters .field { margin: 0; }
.filters__count { font-size: .85rem; color: var(--text-soft); padding-top: .75rem; }

/* ---------- Liste d'analyses ---------- */
.analyses { padding: 1.5rem 0 0; display: grid; gap: .85rem; }

.analysis-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 1rem 1.15rem;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.analysis-card:hover,
.analysis-card:focus-visible {
  border-color: var(--brand-text); box-shadow: var(--shadow); transform: translateY(-1px);
}
.analysis-card__top {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: .5rem .75rem; margin-bottom: .5rem;
}
/* Le bloc de titre peut rétrécir ; le badge, insécable, passe à la ligne
   plutôt que d'élargir la carte au-delà de la fenêtre. */
.analysis-card__top > div { flex: 1 1 58%; min-width: 0; }
.analysis-card__top > .badge { flex: 0 0 auto; }
.analysis-card__title {
  font-size: 1.08rem; font-weight: 650; margin: 0; letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.analysis-card__sub { font-size: .84rem; color: var(--text-faint); margin: .1rem 0 0; }

.analysis-card__meta {
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; min-width: 0;
  font-size: .86rem; color: var(--text-soft); margin: .5rem 0;
}
.analysis-card__meta span { display: inline-flex; align-items: center; gap: .35rem; }
.analysis-card__meta svg { flex: none; opacity: .65; }

.analysis-card__tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }

.analysis-card__highlights {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--border);
}
.chip {
  font-size: .78rem; padding: .25rem .55rem; border-radius: var(--radius-sm);
  background: var(--surface-alt); color: var(--text-soft);
  overflow-wrap: anywhere;
}
.chip strong { color: var(--text); font-weight: 620; }

.analysis-card__cta {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .85rem; font-weight: 550; color: var(--brand-text); margin-top: .7rem;
}

/* ---------- Détail d'analyse ---------- */
.breadcrumb { padding: 1rem 0 0; font-size: .85rem; color: var(--text-soft); }
.breadcrumb a { color: inherit; }

.report-head { padding: 1rem 0 1.5rem; }
.report-head__top {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 1rem;
}
.report-head h1 { margin-bottom: .3rem; }
.report-head__ref { font-family: var(--mono); font-size: .82rem; color: var(--text-faint); }

.verdict {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .9rem; border-radius: var(--radius); font-weight: 600; font-size: .9rem;
}
.verdict--ok      { background: var(--ok-bg);   color: var(--ok); }
.verdict--ko      { background: var(--ko-bg);   color: var(--ko); }
.verdict--warn    { background: var(--warn-bg); color: var(--warn); }
.verdict--neutral { background: var(--surface-alt); color: var(--text-soft); }

.summary-box {
  margin-top: 1rem; padding: 1rem 1.15rem;
  background: var(--info-bg); border-left: 3px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.summary-box p { margin: 0; font-size: .95rem; }

/* Grille d'informations clés.
   Les séparateurs sont portés par les cellules (box-shadow) et non par le fond
   du conteneur : une ligne incomplète ne laisse donc aucune zone grise vide. */
.facts {
  display: grid; gap: 1px; margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.fact {
  background: var(--surface); padding: .9rem 1.1rem;
  box-shadow: 0 0 0 1px var(--border);
}
.fact__label {
  font-size: .73rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 600; margin-bottom: .2rem;
}
.fact__value { font-size: .95rem; font-weight: 550; }
.fact__value--lg { font-size: 1.05rem; }

/* Sommaire des familles */
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.5rem; }
.toc a {
  font-size: .84rem; padding: .35rem .75rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); text-decoration: none;
}
.toc a:hover { border-color: var(--brand-text); color: var(--brand-text); }

/* Section par famille */
.family { margin-bottom: 1.25rem; }
.family__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); list-style: none;
}
.family__head::-webkit-details-marker { display: none; }
.family[open] .family__head { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
.family__title { display: flex; align-items: center; gap: .65rem; font-weight: 650; font-size: 1rem; }
.family__icon {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 9px; background: var(--surface-alt); font-size: 1rem;
}
.family__count { font-size: .8rem; color: var(--text-faint); font-weight: 500; }
.family__chevron { transition: transform .2s; color: var(--text-faint); }
.family[open] .family__chevron { transform: rotate(180deg); }
.family__body {
  background: var(--surface); border: 1px solid var(--border); border-top: 1px dashed var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden;
}
.family__note {
  padding: .75rem 1.25rem; font-size: .85rem; color: var(--text-soft);
  background: var(--surface-sunk); border-bottom: 1px solid var(--border);
}

/* Table de résultats.
   Sous 760px la ligne devient une carte : le nom et sa description occupent
   toute la largeur, puis la valeur et le statut partagent une seconde ligne. */
.results { width: 100%; border-collapse: collapse; font-size: .92rem; }
.results thead { display: none; }
.results tbody tr {
  display: grid; gap: .35rem .75rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.results tbody tr:last-child { border-bottom: 0; }
.results td { padding: 0; border: 0; min-width: 0; }

.results .r-name {
  grid-column: 1 / -1; font-weight: 600; line-height: 1.4;
}
.results .r-name small {
  display: block; font-weight: 400; color: var(--text-faint);
  font-size: .81rem; line-height: 1.45; margin-top: .15rem;
}
.results .r-value {
  grid-column: 1; text-align: left;
  font-variant-numeric: tabular-nums; font-weight: 650; font-size: 1.02rem;
}
.results .r-status { grid-column: 2; text-align: right; align-self: start; }
.results .r-extra  {
  grid-column: 1 / -1; font-size: .81rem; color: var(--text-faint);
  padding-top: .15rem;
}
.results .r-method { font-family: var(--mono); font-size: .78rem; }

@media (min-width: 760px) {
  .results thead { display: table-header-group; }
  .results thead th {
    text-align: left; padding: .65rem 1.25rem; font-size: .75rem;
    text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint);
    font-weight: 600; background: var(--surface-sunk); border-bottom: 1px solid var(--border);
  }
  .results thead th.num { text-align: right; }
  .results tbody tr { display: table-row; }
  .results td { display: table-cell; padding: .8rem 1.25rem; vertical-align: top; }
  .results .r-name { font-weight: 600; }
  .results .r-value {
    text-align: right; font-size: .95rem; white-space: nowrap;
  }
  .results .r-status { text-align: right; }
  .results .r-extra { color: var(--text-faint); max-width: 22rem; }
}

/* Jauge apport de référence */
.meter {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .35rem; font-size: .78rem; color: var(--text-soft);
}
.meter__track {
  flex: 1; max-width: 140px; height: 5px; border-radius: 3px;
  background: var(--surface-sunk); overflow: hidden;
}
.meter__fill { height: 100%; border-radius: 3px; background: var(--brand); }
.meter__fill--high { background: var(--ok); }

/* Additifs */
.additive-list { display: grid; gap: .6rem; padding: 1rem 1.25rem; }
.additive {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem .9rem; border-radius: var(--radius);
  background: var(--surface-alt); border: 1px solid var(--border);
}
.additive__code {
  font-family: var(--mono); font-weight: 700; font-size: .85rem;
  padding: .2rem .45rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-strong); flex: none;
}
.additive__name { font-weight: 600; font-size: .92rem; }
.additive__desc { font-size: .82rem; color: var(--text-soft); margin-top: .15rem; }

/* Blocs d'information secondaires */
.info-cards { display: grid; gap: 1rem; margin-top: 2rem; }
@media (min-width: 760px) { .info-cards { grid-template-columns: 1fr 1fr; } }

.dl { display: grid; gap: .55rem; margin: 0; font-size: .9rem; }
.dl > div { display: flex; justify-content: space-between; gap: 1rem; }
.dl dt { color: var(--text-soft); }
.dl dd { margin: 0; text-align: right; font-weight: 550; }

.disclaimer {
  margin-top: 2rem; padding: 1rem 1.15rem; font-size: .84rem;
  color: var(--text-soft); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: var(--radius);
}

/* ---------- États vides ---------- */
.empty {
  padding: 3rem 1.5rem; text-align: center;
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg); color: var(--text-soft);
}
.empty h2 { color: var(--text); }

/* =============================================================
   FORMULAIRES
   ============================================================= */
.field { display: block; margin-bottom: 1rem; }
.field > label,
.field__label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text-soft); margin-bottom: .3rem;
}
.field__hint { font-size: .78rem; color: var(--text-faint); margin-top: .25rem; }
.field__error { font-size: .8rem; color: var(--ko); margin-top: .25rem; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="url"], input[type="search"],
input[type="tel"], select, textarea {
  width: 100%; padding: .55rem .7rem; min-height: 40px;
  font: inherit; font-size: .92rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--ko); }
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23858c98' d='M1 1.5 6 6.5l5-5'/></svg>");
  background-repeat: no-repeat; background-position: right .7rem center;
}
input[type="color"] { padding: 2px; height: 40px; cursor: pointer; }
input[type="file"] { padding: .4rem; font-size: .85rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .9rem; cursor: pointer; }
.check input { width: auto; min-height: 0; margin-top: .25rem; accent-color: var(--brand); flex: none; }

.form-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 680px) {
  .form-grid--2 { grid-template-columns: 1fr 1fr; }
  .form-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .form-grid--4 { grid-template-columns: repeat(4, 1fr); }
  .span-2 { grid-column: span 2; }
  .span-full { grid-column: 1 / -1; }
}

fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; margin: 0 0 1.25rem;
}
legend {
  padding: 0 .5rem; font-weight: 650; font-size: .95rem;
}

/* =============================================================
   BACK-OFFICE
   ============================================================= */
.admin-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 900px) { .admin-shell { grid-template-columns: 240px 1fr; } }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1rem; padding: 1rem;
}
@media (min-width: 900px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }

.sidebar__brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; }
.sidebar__brand span { font-weight: 700; letter-spacing: -.015em; }
.sidebar nav { display: grid; gap: .15rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .7rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; color: var(--text-soft); text-decoration: none;
}
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar nav a.is-active { background: var(--brand); color: #fff; }
.sidebar nav a svg { flex: none; opacity: .85; }
.sidebar__group {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); font-weight: 650; padding: .9rem .7rem .25rem;
}
.sidebar__foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .82rem; }

.admin-main { min-width: 0; padding: 1.25rem; }
@media (min-width: 900px) { .admin-main { padding: 2rem; } }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0; }
.page-head p { margin: .25rem 0 0; color: var(--text-soft); font-size: .9rem; }

.flash { display: grid; gap: .5rem; margin-bottom: 1.25rem; }
.alert {
  padding: .75rem 1rem; border-radius: var(--radius); font-size: .9rem;
  border: 1px solid transparent;
}
.alert--success { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert--error   { background: var(--ko-bg);   color: var(--ko);   border-color: color-mix(in srgb, var(--ko) 30%, transparent); }
.alert--warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert--info    { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* Tableaux d'administration */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; padding: .7rem 1rem; white-space: nowrap;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 650;
  background: var(--surface-sunk); border-bottom: 1px solid var(--border);
}
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table__primary { font-weight: 600; }
.table__sub { font-size: .8rem; color: var(--text-faint); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: end;
  padding: 1rem; border-bottom: 1px solid var(--border); background: var(--surface-sunk);
}
.toolbar .field { margin: 0; min-width: 160px; }
.toolbar__grow { flex: 1 1 220px; }

/* Cartes statistiques admin */
.kpi-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.5rem; }
.kpi {
  padding: 1rem 1.15rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.kpi__value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi__label { font-size: .8rem; color: var(--text-soft); margin-top: .15rem; }
.kpi__hint { font-size: .75rem; color: var(--text-faint); margin-top: .35rem; }

/* Histogramme simple */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 54px; margin-top: .75rem; }
.spark__bar { flex: 1; background: var(--brand); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }

/* Saisie dynamique des résultats */
.result-rows { display: grid; gap: .6rem; }
.result-row {
  display: grid; gap: .5rem; padding: .85rem;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
  grid-template-columns: 1fr;
}
.result-row .field { margin: 0; }
.result-row__head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.result-row__index {
  font-size: .75rem; font-weight: 650; color: var(--text-faint);
  font-family: var(--mono);
}
.result-row__grid { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 680px) {
  .result-row__grid { grid-template-columns: 1.6fr 1fr .8fr .8fr 1fr; }
  .result-row__grid--wide { grid-template-columns: 1fr 1fr 1fr; }
}
.result-row__extra { display: none; gap: .5rem; grid-template-columns: 1fr; }
.result-row.is-expanded .result-row__extra { display: grid; }
@media (min-width: 680px) { .result-row.is-expanded .result-row__extra { grid-template-columns: repeat(3, 1fr); } }

.drag-handle { cursor: grab; color: var(--text-faint); user-select: none; padding: 0 .25rem; }

.family-block { margin-bottom: 1.25rem; }
.family-block__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .6rem; padding-bottom: .4rem;
  border-bottom: 2px solid var(--border);
}
.family-block__title { font-weight: 650; font-size: .95rem; display: flex; align-items: center; gap: .5rem; }

/* Panneau QR code */
.qr-layout { display: grid; gap: 1.5rem; }
@media (min-width: 860px) { .qr-layout { grid-template-columns: 340px 1fr; align-items: start; } }

.qr-preview {
  display: grid; place-items: center; gap: 1rem; padding: 1.5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.qr-preview img { width: 100%; max-width: 260px; border-radius: var(--radius); }
.qr-url {
  font-family: var(--mono); font-size: .8rem; word-break: break-all;
  padding: .6rem .75rem; background: var(--surface-sunk);
  border: 1px solid var(--border); border-radius: var(--radius); width: 100%;
}

/* Affiche prête à imprimer */
.poster {
  background: #fff; color: #111827; padding: 2.5rem 2rem; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  max-width: 420px; margin-inline: auto;
}
.poster__title { font-size: 1.35rem; font-weight: 700; margin: 0 0 .35rem; }
.poster__sub { font-size: .92rem; color: #4b5563; margin: 0 0 1.25rem; }
.poster__qr { width: 220px; margin: 0 auto 1.25rem; display: block; }
.poster__steps { font-size: .85rem; color: #4b5563; text-align: left; display: grid; gap: .4rem; }
.poster__foot { margin-top: 1.25rem; font-size: .75rem; color: #6b7280; }

@media print {
  .site-header, .site-footer, .sidebar, .page-head, .toolbar,
  .btn, .filters, .no-print { display: none !important; }
  body { background: #fff; }
  .admin-main { padding: 0; }
  .poster { border: 0; max-width: none; }
  .family__body { display: block !important; }
  .family[open] .family__head { border-bottom: 1px solid #ddd; }
  a[href]::after { content: ""; }
}

/* Utilitaires d'espacement */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.wrap-flex { flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
