/*
 * Chargeur Web — feuille de style principale (fichier unique, une seule requête).
 *
 * Sections, dans l'ordre : 1 jetons · 2 base · 3 gabarit · 4 formulaires ·
 * 5 composants · 6 listes de LV · 7 pages.
 * Couches : reset < tokens < base < layout < components < pages. La feuille de
 * marque (/css/<id>.css) est chargée ensuite, hors couche : elle l'emporte et ne
 * redéfinit que les variables « de marque » de la section 1.
 */
@layer reset, tokens, base, layout, components, pages;

/* ═══ 1. tokens.css ═══ */

/*
 * Design tokens de Chargeur Web.
 *
 * Contrat de thème : une feuille de marque (/css/<id>.css, chargée en dernier)
 * peut redéfinir uniquement les variables « de marque » ci-dessous.
 * Elle n'est pas dans un @layer : à spécificité égale elle l'emporte
 * sur toutes les couches de l'application.
 */

@layer tokens {
  :root {
    /* --- Marque (surchargeable par branding/<id>/css/<id>.css) --- */
    --brand: #1f4e8c;          /* couleur d'action principale */
    --brand-ink: #fff;         /* texte posé sur --brand */
    --brand-text: var(--brand);  /* --brand utilisée comme texte sur fond clair (liens, titres) */
    --brand-soft: #e8eef7;     /* teinte claire de --brand (survols, sélection) */
    --nav-bg: #fff;            /* fond du menu latéral */
    --nav-ink: #1b2330;        /* texte du menu latéral */
    --nav-accent: var(--brand);/* titres et repères du menu */
    --nav-soft: var(--surface-2);        /* fond du bloc utilisateur */
    --nav-user-ink: var(--ink-2);        /* texte du bloc utilisateur */
    --nav-sub-ink: var(--ink-2);         /* sous-menus, légende « via lgfbee » */
    --nav-hover-bg: var(--brand-soft);   /* survol d'une entrée de menu */
    --nav-hover-ink: var(--brand);
    --nav-border: var(--line);           /* filet du menu */
    --accent: #c0392b;         /* alerte douce, champs obligatoires */
    --logo-width: 9rem;

    /* --- Neutres --- */
    --bg: #f4f6f9;
    --surface: #fff;
    --surface-2: #f0f2f5;
    --line: #d9dee6;
    --line-strong: #b8c0cc;
    --ink: #1b2330;
    --ink-2: #4a5565;
    --ink-3: #6b7686;

    /* --- Statuts --- */
    --ok: #1e7b46;
    --ok-soft: #e4f4ea;
    --warn: #8a5a00;
    --warn-soft: #fff3d6;
    --danger: #b42318;
    --danger-soft: #fde8e6;
    --info: #1f5f99;
    --info-soft: #e5f1fb;

    /* --- Typographie --- */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --leading: 1.45;

    /* --- Espacement (échelle 4 px) --- */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;

    /* --- Formes, ombres, mouvement --- */
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;        /* cartes : plus arrondies que les contrôles qu'elles contiennent */
    --shadow-1: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
    --shadow-2: 0 4px 12px rgb(16 24 40 / 0.12);
    --ease: 160ms ease-out;
    --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

    /* --- Icônes (masques SVG, colorées par currentColor / background) --- */
    --ico-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4 4-6 8-6s8 2 8 6'/%3E%3C/svg%3E");
    --ico-package: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8l-9-5-9 5v8l9 5 9-5V8z'/%3E%3Cpath d='M3 8l9 5 9-5M12 13v8'/%3E%3C/svg%3E");
    --ico-contacts: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2 20c0-3.5 3-5.5 7-5.5s7 2 7 5.5'/%3E%3Cpath d='M16 4.5a3.5 3.5 0 010 7M18 14.8c2.5.6 4 2.2 4 5.2'/%3E%3C/svg%3E");
    --ico-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v6M12 7.5v.01'/%3E%3C/svg%3E");
    --ico-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpath d='M12 22s7-6.2 7-12a7 7 0 10-14 0c0 5.8 7 12 7 12z'/%3E%3Ccircle cx='12' cy='10' r='2.5' fill='%23fff'/%3E%3C/svg%3E");
    --ico-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E");
    --ico-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

    /* --- Gabarit --- */
    --nav-w: 14rem;
    --bar-h: 3.25rem;
    --content-max: 78rem;
    --control-h: 2.25rem;     /* hauteur des champs et boutons */
    --tap: 2.75rem;           /* cible tactile minimale sur mobile */
  }
}

/* ═══ 2. base.css ═══ */

/* Reset, typographie, contrôles de formulaire, boutons, tableaux, utilitaires. */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, fieldset { margin: 0; }
  fieldset { padding: 0; border: 0; min-width: 0; }
  img, svg, video, iframe { max-width: 100%; }
  img { height: auto; border: 0; }
  ul[class], ol[class] { list-style: none; padding: 0; }
  table { border-collapse: collapse; border-spacing: 0; }
  button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
  [hidden] { display: none !important; }
}

@layer base {
  html { font-family: var(--font); }

  body {
    font-size: var(--text);
    line-height: var(--leading);
    color: var(--ink);
    background: var(--bg);
    min-height: 100dvh;
  }

  a { color: var(--brand-text); text-decoration: none; }
  a:hover { text-decoration: underline; }
  a img { text-decoration: none; }

  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
  h3 { font-size: var(--text); font-weight: 600; }
  h4 { font-size: var(--text-2xl); font-weight: 650; line-height: 1.25; }
  h5 { font-size: var(--text-lg); font-weight: 600; margin-block: var(--sp-4) var(--sp-2); }
  h6 { font-size: var(--text); font-weight: 600; margin-block: var(--sp-1); }
  p { margin-block: 0 var(--sp-3); }
  strong, b { font-weight: 650; }

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

  /* --- Champs --- */
  input:not([type=checkbox], [type=radio], [type=submit], [type=button], [type=reset], [type=file], [type=hidden], [type=image]),
  select,
  textarea {
    height: var(--control-h);
    padding: 0 var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    max-width: 100%;
    transition: border-color var(--ease), box-shadow var(--ease);
  }
  textarea { height: auto; min-height: 5rem; padding-block: var(--sp-2); }
  select { padding-right: var(--sp-2); }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus);
    background: var(--surface);
  }
  input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-3); }
  input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 1.05rem; height: 1.05rem; vertical-align: -0.2em; }
  /* Écran tactile : cible minimale de 24 px (WCAG 2.5.8). */
  @media (pointer: coarse) {
    input[type=checkbox], input[type=radio] { width: 1.5rem; height: 1.5rem; }
  }
  ::placeholder { color: var(--ink-3); }

  /* --- Boutons --- */
  button, .btn, #content > a[href*="/supprimeadresse/"],
  input[type=submit], input[type=button], input[type=reset] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--control-h);
    padding: 0 var(--sp-4);
    font-weight: 550;
    line-height: 1.2;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--ease), border-color var(--ease), box-shadow var(--ease);
  }
  button:hover, .btn:hover,
  input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover {
    background: var(--surface-2);
    text-decoration: none;
  }
  /*
   * Appui : assombrissement relatif plutôt qu'un fond gris fixe. Un fond fixe passait
   * devant le fond de marque des boutons d'envoi (.btn:active plus spécifique que
   * input[type=submit]) et rendait leur texte blanc illisible pendant l'appui.
   * filter n'est pas animé : le retour est immédiat dès l'appui.
   */
  button:active, .btn:active, #content > a[href*="/supprimeadresse/"]:active,
  input[type=submit]:active, input[type=button]:active, input[type=reset]:active { filter: brightness(0.9); }
  button:disabled, button[disabled], .btn[disabled], input[type=submit]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  button img, .btn img { width: 1.15rem; height: 1.15rem; object-fit: contain; vertical-align: middle; }

  /* Action principale : bouton d'envoi d'un formulaire. */
  input[type=submit], button[type=submit] {
    color: var(--brand-ink);
    background: var(--brand);
    border-color: var(--brand);
  }
  input[type=submit]:hover, button[type=submit]:hover {
    background: color-mix(in srgb, var(--brand) 88%, #000);
  }

  /* Envoi secondaire : « Annuler » (décorateur CancelButton, classe mx-1) et .input_cancel. */
  input[type=submit].mx-1, input.input_cancel, input[type=submit][name=annul] {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line-strong);
  }
  input[type=submit].mx-1:hover, input.input_cancel:hover, input[type=submit][name=annul]:hover { background: var(--surface-2); }

  /*
   * Action destructive. Le lien « Supprimer cette adresse » placé sous le formulaire de
   * modification d'adresse (carnet et profil) prend la forme d'un bouton : sa cible
   * tactile passe de 19 px de haut à la hauteur d'un contrôle.
   */
  button.delete-lv-confirm, button.demande-suppression-lv, button[name=supprimelv],
  #content > a[href*="/supprimeadresse/"] {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  }
  button.delete-lv-confirm:hover, button.demande-suppression-lv:hover, button[name=supprimelv]:hover,
  #content > a[href*="/supprimeadresse/"]:hover {
    background: var(--danger-soft);
  }
  #content > a[href*="/supprimeadresse/"] { margin-top: var(--sp-4); }

  /* --- Tableaux --- */
  th { font-weight: 600; text-align: left; }
  td, th { vertical-align: middle; }

  /* --- Séparateurs, divers --- */
  hr { border: 0; border-top: 1px solid var(--line); margin-block: var(--sp-4); }
  .errors li { color: var(--danger); }
  p.listevide { font-style: italic; color: var(--ink-2); max-width: 36rem; }
  .text-color-gray { color: var(--ink-3); }
}

/* --- Utilitaires hérités (utilisés dans les vues) --- */
@layer components {
  .m-0 { margin: 0 !important; }
  .m-1 { margin: 1rem !important; }
  .my-1 { margin-block: 1rem !important; }
  .mx-1 { margin-inline: 1rem !important; }
  .mt-1 { margin-top: 1rem !important; }
  .mb-1 { margin-bottom: 1rem !important; }
  .mb-0 { margin-bottom: 0 !important; }
  .ml-1 { margin-left: 1rem !important; }
  .p-0 { padding: 0 !important; }
  .pb-0 { padding-bottom: 0 !important; }
  .noborder { border: 0; }
  .leftalign { text-align: left; }
  .h-auto { height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ═══ 3. layout.css ═══ */

/*
 * Gabarit : menu latéral (≥ 64rem) / tiroir (< 64rem), zone de contenu,
 * pages sans menu (login, popup), messages techniques de l'accueil.
 * Le tiroir mobile fonctionne sans JavaScript (case #nav-state + label).
 */

@layer layout {
  /* --- Icônes en masque : couleur = background-color --- */
  .header-navigation::before,
  .fa-map-marker::before,
  #nav-toggle::before {
    content: "";
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    background-color: currentColor;
    -webkit-mask: var(--ico) center / contain no-repeat;
    mask: var(--ico) center / contain no-repeat;
    flex: none;
  }
  #profil-navigation { --ico: var(--ico-user); }
  #lv-navigation { --ico: var(--ico-package); }
  #carnet-navigation { --ico: var(--ico-contacts); }
  #about-navigation { --ico: var(--ico-info); }
  .fa-map-marker { --ico: var(--ico-pin); display: inline-block; font-style: normal; vertical-align: -0.15em; }
  #nav-toggle { --ico: var(--ico-menu); }

  /* --- Menu --- */
  #header.menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 900;
    width: var(--nav-w);
    padding: var(--sp-4) var(--sp-3) var(--sp-5);
    overflow-y: auto;
    overscroll-behavior: contain;
    color: var(--nav-ink);
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
  }
  #header-logo { text-align: center; }
  #header-logo h1 { min-height: 0; line-height: 0; margin: 0 0 var(--sp-1); }
  #header-logo h1 a { display: inline-block; }
  #petit_logo { width: var(--logo-width); max-height: 6rem; object-fit: contain; }
  #header-logo h2 { margin: 0; font-size: var(--text-xs); font-weight: 400; font-style: italic; color: var(--nav-sub-ink); }

  #user-profile {
    margin: var(--sp-3) 0 var(--sp-4);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-xs);
    font-weight: 500;
    text-align: left;
    color: var(--nav-user-ink);
    background: var(--nav-soft);
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
  }

  .menu-wrapper + .menu-wrapper { margin-top: var(--sp-2); }

  .header-navigation {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0;
    padding: var(--sp-2) var(--sp-2) var(--sp-1);
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    color: var(--nav-accent);
  }

  .ul.menu { margin: 0; padding: 0; list-style: none; }
  .ul.menu .li { position: relative; }
  .menu a { display: block; color: inherit; text-decoration: none; }
  .ul.menu .li > a {
    padding: 0.3rem var(--sp-3);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background-color var(--ease), color var(--ease);
  }
  .ul.menu .li > a:hover,
  .ul.menu .li > a:focus-visible { background: var(--nav-hover-bg); color: var(--nav-hover-ink); text-decoration: none; }

  /* Sous-menus toujours visibles : le survol n'existe pas au tactile. */
  .submenu { display: block; margin: 0 0 var(--sp-1) var(--sp-4); padding: 0; border-left: 2px solid var(--nav-border); }
  .submenu .li > a { padding-block: 0.2rem; font-size: var(--text-sm); font-weight: 400; color: var(--nav-sub-ink); }

  span.badge {
    display: inline-block;
    min-width: 1.25rem;
    padding: 0 var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 650;
    line-height: 1.25rem;
    text-align: center;
    color: var(--brand-ink);
    background: var(--accent);
    border-radius: 999px;
  }
  .menu span.badge { position: absolute; right: var(--sp-2); top: 50%; translate: 0 -50%; }

  /* --- Contenu --- */
  #content {
    margin-left: var(--nav-w);
    padding: var(--sp-5) var(--sp-6) var(--sp-6);
    max-width: calc(var(--content-max) + var(--nav-w));
    min-height: calc(100dvh - 2rem);
  }
  #content > h4 {
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--line);
  }
  p.chrono { margin: 0; padding: var(--sp-2) var(--sp-5); text-align: right; font-size: var(--text-xs); color: var(--ink-3); }

  /* --- Tiroir mobile (masqué sur grand écran) --- */
  .nav-state { position: absolute; opacity: 0; pointer-events: none; }
  @media (min-width: 64rem) { .nav-state { display: none; } }
  #topbar, #nav-backdrop { display: none; }

  @media (max-width: 63.99rem) {
    #topbar {
      display: flex;
      align-items: center;
      position: sticky;
      top: 0;
      z-index: 800;
      height: var(--bar-h);
      padding: 0 var(--sp-3);
      background: var(--nav-bg);
      border-bottom: 1px solid var(--nav-border);
    }
    #nav-toggle {
      display: inline-flex;
      align-items: center;
      gap: var(--sp-2);
      min-height: var(--tap);
      padding: 0 var(--sp-3);
      font-weight: 600;
      color: var(--nav-accent);
      cursor: pointer;
      border-radius: var(--radius-sm);
    }
    #nav-toggle:hover { background: var(--nav-hover-bg); }
    #nav-state:focus-visible ~ #topbar #nav-toggle { outline: 2px solid var(--brand); outline-offset: 2px; }

    #header.menu {
      width: min(20rem, 86vw);
      translate: -100% 0;
      visibility: hidden;
      transition: translate 220ms ease-out, visibility 0s linear 220ms;
      box-shadow: var(--shadow-2);
    }
    #nav-state:checked ~ #header.menu { translate: 0 0; visibility: visible; transition-delay: 0s; }

    #nav-backdrop {
      display: block;
      position: fixed;
      inset: 0;
      z-index: 850;
      background: rgb(16 24 40 / 0.45);
      opacity: 0;
      pointer-events: none;
      transition: opacity 220ms ease-out;
    }
    #nav-state:checked ~ #nav-backdrop { opacity: 1; pointer-events: auto; }

    .ul.menu .li > a { min-height: var(--tap); display: flex; align-items: center; }
    .submenu .li > a { min-height: 2.5rem; }

    #content { margin-left: 0; padding: var(--sp-4) var(--sp-3) var(--sp-5); max-width: none; min-height: 0; }
    #content > h4 { font-size: var(--text-xl); }
    p.chrono { padding-inline: var(--sp-3); }
  }

  /* --- Page de connexion : pas de menu, carte centrée --- */
  #header:not(.menu) { max-width: 30rem; margin: var(--sp-6) auto var(--sp-4); padding-inline: var(--sp-4); text-align: center; }
  #header:not(.menu) + #content {
    max-width: 30rem;
    margin: 0 auto var(--sp-6);
    padding: var(--sp-5);
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
  }
  #header:not(.menu) + #content > h4 { font-size: var(--text-xl); border-bottom: 0; padding-bottom: 0; }
  .login-phrase { color: var(--ink-2); font-size: var(--text-sm); }
  .lgf-login-warning { padding: var(--sp-3); margin-bottom: var(--sp-3); color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); }
  #controle { text-align: center; }
  #controle img { width: 4.5rem; }

  @media (max-width: 30rem) {
    #header:not(.menu) + #content { margin-inline: var(--sp-3); padding: var(--sp-4); }
  }

  /* --- Pages sans menu (pop-up) --- */
  #nomenu-content { padding: var(--sp-4); }
  /* Fenêtres sans menu (adresse ponctuelle) : même titre de page que le gabarit principal. */
  #nomenu-content > h4 { margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); }
  .popup { max-width: 38rem; margin: var(--sp-5) auto; padding: var(--sp-5); text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .popup h1 { font-size: var(--text-xl); margin-bottom: var(--sp-3); }
  .popup p { color: var(--ink-2); }

  /* --- Page d'erreur --- */
  .error_page { max-width: 60rem; }
  .error_page h1 { font-size: var(--text-lg); }
  .error_page h3 { font-weight: 400; color: var(--ink-2); margin-block: var(--sp-2); }
  .error_page pre { overflow: auto; padding: var(--sp-3); font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-2); border-radius: var(--radius-sm); }
}

/* ═══ 4. forms.css ═══ */

/*
 * Formulaires Zend : balisage généré côté PHP (non modifiable).
 *  - dl.zend_form            : formulaire de connexion (dt / dd)
 *  - form.zend_form_extended : div.field_group > label.field_label + contrôle
 *
 * Contraintes JavaScript :
 *  - jQuery slideDown() impose display:block en ligne : .field_group reste donc
 *    un bloc (pas de flex/grid) et la mise en colonne passe par inline-block.
 *  - .lgf-type-dependant / .lgf-nouveau / .hidden_field sont masqués par défaut
 *    puis affichés par le JS (tiers.js, adresse.js).
 */

@layer components {
  /* --- Connexion : dt / dd --- */
  dl.zend_form { margin: var(--sp-4) 0; }
  dl.zend_form dt { margin-top: var(--sp-3); font-weight: 550; }
  dl.zend_form dd { margin: var(--sp-1) 0 0; }
  dl.zend_form dd input[type=text],
  dl.zend_form dd input[type=password] { width: 100%; height: var(--tap); }
  dl.zend_form dd input[type=submit] { width: 100%; height: var(--tap); margin-top: var(--sp-3); }
  dl.zend_form dt#submit-label { display: none; }
  dl.zend_form label.required::after { content: none; }

  /* --- Formulaire étendu --- */
  .zend_form_extended {
    max-width: 52rem;
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
  }

  .field_group { padding: var(--sp-2) 0; }
  .field_group + .field_group { border-top: 1px solid var(--surface-2); }
  .field_group.hidden_field,
  .field_group#id_group,
  .field_group#rhiadresse_group,
  .subform_group#rhicommandes_group,
  .subform_group#rhiconteneurs_group,
  p.subform_legend#rhicommandes_legend,
  p.subform_legend#rhiconteneurs_legend,
  .subform_end#rhicommandes_end,
  .subform_end#rhiconteneurs_end { display: none; }

  label.field_label {
    display: inline-block;
    width: 13rem;
    max-width: 100%;
    padding: 0.5rem var(--sp-3) 0 0;
    vertical-align: top;
    font-weight: 550;
    color: var(--ink-2);
  }
  label.required::after { content: " *"; color: var(--accent); }

  .field_group input:not([type=checkbox], [type=radio], [type=submit], [type=hidden]),
  .field_group select { width: min(100%, 22rem); }
  .field_group input.number { width: 8rem; }
  .field_group input[maxlength="9"],
  #codepostal, #adresse-codepostal, #siren { width: 8rem; }
  #telfixe, #fax, #telport, #reference, #adresse-libelle { width: 12rem; }
  .field_group input[type=checkbox] { margin-top: 0.7rem; }
  .field_group > label:not(.field_label) { margin-right: var(--sp-3); white-space: nowrap; }
  .field_group > label > input[type=radio] { margin-right: var(--sp-1); }
  /* Radios suivis d'un label frère (choix « au total / chacun ») : écart avec le champ et le texte. */
  .field_group > input[type=radio] { margin: 0 var(--sp-1) 0 var(--sp-3); }
  /* Labels enveloppant un radio (« Type de tiers ») : alignés sur la ligne du libellé de champ. */
  .field_group > label:not(.field_label):has(> input[type=radio]) { display: inline-block; padding-top: 0.5rem; }
  /* Bouton collé à une liste personnalisée : même écart que « Ajouter » (.ml-1). */
  .field_group button.adresseotf { margin-left: var(--sp-4); }
  .field_group > br { display: none; }
  .field_group button, .field_group input[type=submit] { margin-right: var(--sp-2); }
  .field_group ul:not([class]) { margin: var(--sp-2) 0 0; padding-left: 0; list-style: none; }
  .field_group ul:not([class]) li { padding: var(--sp-1) 0; }

  /* Champs dépendants du type (affichés par le JS) */
  .lgf-type-dependant { display: none; }

  /* --- Sous-formulaires --- */
  p.subform_legend {
    margin: var(--sp-4) 0 var(--sp-1);
    padding: var(--sp-2) 0 var(--sp-2);
    font-weight: 650;
    font-size: var(--text-lg);
    color: var(--brand-text);
    border-bottom: 2px solid var(--brand);
  }
  .subform_group { padding-left: 0; }
  .subform_end { height: var(--sp-2); font-size: 0; line-height: 0; overflow: hidden; }

  /* Options à cocher (formulaire d'options de LV) */
  div.subform_group#options_group { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); padding: var(--sp-2) 0; }
  div.subform_group#options_group .field_group { padding: 0; border: 0; white-space: nowrap; }
  div.subform_group#options_group .field_group label.field_label { width: auto; padding: 0 0 0 var(--sp-2); font-weight: 400; color: var(--ink); }
  div.subform_end#options_end, p.subform_legend#options_legend { display: none; }

  .zend_form p.description { max-width: 36rem; font-style: italic; color: var(--danger); }
  .zend_form fieldset { margin: var(--sp-2) 0; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius-sm); }
  .zend_form fieldset legend { padding: 0 var(--sp-2); font-weight: 650; }

  /* --- Erreurs de saisie --- */
  /* 13rem de libellé + l'espace HTML entre le libellé et le champ (≈ 0,28em) : message aligné sur le champ. */
  .errors_block { display: block; margin: var(--sp-1) 0 0 calc(13rem + 0.28em); }
  img.errors_sign { display: none; }
  ul.errors_list { display: block; margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); font-weight: 550; color: var(--danger); }
  .field_group:has(.errors_block) input:not([type=checkbox], [type=radio], [type=submit], [type=hidden]),
  .field_group:has(.errors_block) select { border-color: var(--danger); }

  @media (max-width: 40rem) {
    .zend_form_extended { padding-inline: var(--sp-3); }
    label.field_label { display: block; width: auto; padding: 0 0 var(--sp-1); }
    .field_group input:not([type=checkbox], [type=radio], [type=submit], [type=hidden]),
    .field_group select { width: 100%; height: var(--tap); }
    .field_group input.number, #codepostal, #adresse-codepostal, #siren { width: 9rem; }
    .field_group button, .field_group input[type=submit] { min-height: var(--tap); }
    /* Boutons passés sous leur champ : alignés à gauche, séparés verticalement. */
    .field_group button.adresseotf,
    .field_group .lgf-lister.ml-1 { margin: var(--sp-2) 0 0 !important; }
    .field_group > label:not(.field_label):has(> input[type=radio]) { padding-top: 0; }
    .errors_block { margin-left: 0; }
    div.subform_group#options_group { flex-direction: column; }
  }
}

/* ═══ 5. components.css ═══ */

/*
 * Composants réutilisables : pagination, barre d'actions, combos (scombo/ecombo),
 * messages techniques, tableaux de données, blocs d'information.
 */

@layer components {
  /* --- Pagination --- */
  .lgf-pages-contacts, .lgf-pages-lv {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-1);
    margin-block: var(--sp-3);
    font-weight: 600;
    color: var(--ink-2);
  }
  .lgf-page-link, .lgf-pages-lv > span, .lgf-pages-contacts > span {
    display: inline-block;
    min-width: 2.25rem;
    padding: 0.35rem var(--sp-2);
    text-align: center;
    border-radius: var(--radius-sm);
  }
  .lgf-page-link { color: var(--brand-text); background: var(--surface); border: 1px solid var(--line); }
  .lgf-page-link:hover { background: var(--brand-soft); text-decoration: none; }
  .lgf-pages-lv > span, .lgf-pages-contacts > span { color: var(--ink-3); }
  .lgf-pages-lv > span:not(:has(a)), .lgf-pages-contacts > span:not(:has(a)) { font-weight: 700; }
  .paginationControl { margin-block: var(--sp-3); color: var(--ink-3); }
  .compteur-lv { margin: var(--sp-2) 0 var(--sp-4); font-size: var(--text-sm); color: var(--ink-3); }

  /* --- Barre d'actions sous un titre --- */
  div.subsection-action { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-block: var(--sp-2) var(--sp-4); }
  div.subsection-action a:not(.btn) {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-h);
    padding: 0 var(--sp-3);
    font-weight: 550;
    color: var(--brand-text);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
  }
  div.subsection-action a:not(.btn):hover { background: var(--brand-soft); text-decoration: none; }

  /* --- Blocs d'information --- */
  .attention-enlevement {
    max-width: 52rem;
    padding: var(--sp-3) var(--sp-4);
    color: var(--warn);
    background: var(--warn-soft);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    border-radius: var(--radius);
  }
  .apropos-texte, .apropos-liste { max-width: 48rem; }
  .apropos-liste { padding-left: var(--sp-5); }
  img.right { float: right; margin: 0 0 var(--sp-3) var(--sp-4); }
  img.left { float: left; margin: 0 var(--sp-4) var(--sp-3) 0; }
  .img-tracabilite { text-align: center; }
  .legende-traca { max-width: 100%; }

  /* --- Combos : liste filtrable (scombo) et éditable (ecombo) ---
     Ouverture au survol uniquement (comportement d'origine) : un focus qui
     garde la liste ouverte recouvrirait le bouton suivant. */
  div.lgf-scombo, div.lgf-ecombo { position: relative; display: inline-block; width: min(100%, 22rem); vertical-align: top; }
  div.lgf-scombo input.lgf-scombo-value, div.lgf-ecombo input.lgf-ecombo-value {
    width: 100%;
    padding-right: 2rem;
    background: var(--surface) var(--ico-chevron) no-repeat right 0.6rem center / 0.8rem;
  }
  ul.lgf-scombo-values, ul.lgf-ecombo-values {
    display: none;
    position: absolute;
    inset: 100% auto auto 0;
    z-index: 20;
    width: 100%;
    max-height: 14rem;
    margin: 2px 0 0;
    padding: var(--sp-1);
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
  }
  div.lgf-scombo:hover ul.lgf-scombo-values,
  div.lgf-ecombo:hover ul.lgf-ecombo-values { display: block; }
  ul.lgf-scombo-values li, ul.lgf-ecombo-values li { border-radius: 4px; }
  ul.lgf-scombo-values li label, ul.lgf-ecombo-values li label { display: block; padding: 0.4rem var(--sp-2); cursor: pointer; white-space: normal; }
  ul.lgf-scombo-values li:hover, ul.lgf-ecombo-values li:hover { background: var(--brand-soft); }
  ul.lgf-scombo-values li.lgf-scombo-value-selected, ul.lgf-ecombo-values li.lgf-ecombo-value-selected { background: var(--surface-2); font-weight: 600; }
  ul.lgf-scombo-values input[type=radio], ul.lgf-ecombo-values input[type=radio], div.lgf-ecombo input[type=radio] { display: none; }
  .lgf-nomatch { background-color: var(--danger-soft) !important; }

  /* --- Messages techniques (accueil) ---
     Le JS de index/index.phtml ajuste lui-même opacity, width et height. */
  #onload.info {
    position: fixed;
    right: var(--sp-4);
    bottom: var(--sp-4);
    z-index: 700;
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    box-shadow: var(--shadow-2);
  }
  .info img { width: 2rem; height: 2rem; object-fit: contain; }
  #overlay { position: fixed; inset: 0; z-index: 950; display: none; background: #000; overflow: hidden; }
  #ajout {
    position: fixed;
    top: 5dvh;
    left: 50%;
    z-index: 960;
    display: none;
    box-sizing: border-box;
    width: min(36rem, 92vw);
    max-height: 88dvh;
    margin: 0;
    padding: var(--sp-4);
    overflow: auto;
    translate: -50% 0;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    text-align: left;
    cursor: pointer;
  }
  #ajout img { width: 1.75rem; height: 1.75rem; vertical-align: middle; }
  #ajout hr { margin-block: var(--sp-3); }
  .messagetechnique-Nouveaute { color: var(--brand-text) !important; }
  .messagetechnique-Information { color: var(--info) !important; }
  .messagetechnique-Maintenance { color: var(--warn) !important; }
  .messagetechnique-Avertissement { color: var(--danger) !important; }
  #messagetechnique-aide { font-size: var(--text-xs); font-style: italic; font-weight: 400; color: var(--ink-3); }

  /* --- Accueil --- */
  #lgf-fond-placer { padding-top: var(--sp-5); text-align: center; }
  /* Image de fond de la marque : toute la largeur disponible, ratio conservé. */
  #lgf-fond { display: block; width: 100%; height: auto; }
  /* Repli (fond<id>.png absent, voir onerror) : logo lgfbee centré, sans déformation. */
  #lgf-fond.lgf-fond-defaut { width: auto; max-width: 100%; margin-inline: auto; }
  #messageaccueil { margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

  /* --- Journal technique (niveaux de log) --- */
  .log_debug { color: var(--ink-3); }
  .log_info { color: var(--info); }
  .log_notice { color: var(--warn); }
  .log_warn { color: var(--accent); }
  .log_error { color: var(--danger); }
}

/* ═══ 6. lv-list.css ═══ */

/*
 * Listes de lettres de voiture (en cours, planifiées, historique) et
 * template templates/lv.phtml.
 *
 * Le balisage reste un <table> : on le met en grille par CSS pour qu'une ligne
 * (case + carte) tienne sur mobile. Chaque carte .lgf-lv est un conteneur de
 * requêtes : sa mise en page dépend de la place disponible, pas de l'écran.
 * Le JS (lv-magiclist.js) bascule la classe .lgf-lv-active au clic.
 */

@layer pages {
  /* --- Tableau → grille --- */
  #lgf-liste-lv, #lgf-liste-lv > tbody { display: block; width: 100%; }
  #lgf-liste-lv > tbody > tr { display: grid; grid-template-columns: 2rem minmax(0, 1fr); align-items: start; gap: 0 var(--sp-2); margin-bottom: var(--sp-2); }
  #lgf-liste-lv td { display: block; padding: 0; border: 0; min-width: 0; }
  #lgf-liste-lv > tbody > tr > td:first-child { padding-top: var(--sp-3); text-align: center; }
  #lgf-liste-lv > tbody > tr > td:last-child { container-type: inline-size; }
  #lgf-liste-lv > tbody > tr:last-child { display: none; }

  /* Ligne d'en-tête : sélection globale + actions de masse */
  #lgf-liste-lv > tbody > tr:first-child { align-items: center; margin-bottom: var(--sp-3); }
  #lgf-liste-lv > tbody > tr:first-child > td:first-child { padding-top: 0; }
  #lgf-liste-lv > tbody > tr:first-child > td:last-child { display: flex; flex-wrap: wrap; gap: var(--sp-2); container-type: normal; }
  button.delete-lv-confirm, button.demande-suppression-lv { margin-left: auto; }
  .lv_historique input.checkbox-selectall { display: none; }

  /* Sélection par flux : menu ouvert au survol / focus */
  #checkbox-selectflux-cell { position: relative; }
  #checkbox-selectflux-box {
    display: none;
    position: absolute;
    z-index: 30;
    top: 100%;
    left: 0;
    min-width: 12rem;
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
  }
  .lv_encours #checkbox-selectflux-cell:hover #checkbox-selectflux-box,
  .lv_encours #checkbox-selectflux-cell:focus-within #checkbox-selectflux-box { display: block; }
  #checkbox-selectflux-box br { display: none; }
  #checkbox-selectflux-box label { display: inline-block; margin: 0 0 0 var(--sp-1); }
  #checkbox-selectflux-box input + label + input { margin-left: var(--sp-3); }

  /* --- Carte LV : socle (étroit) --- */
  .lgf-lv {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num   flux"
      "exp   exp"
      "dest  dest"
      "infos infos"
      "val   val"
      "suivi suivi"
      "dates dates"
      "act   act"
      "car   car"
      "opt   opt";
    column-gap: var(--sp-3);
    padding: var(--sp-3);
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
  }
  .lgf-lv:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
  /* Appui immédiat ; réduction plus faible que les cartes, la ligne étant très large. */
  .lgf-lv:active { transform: scale(0.995); transition-duration: 0s; }
  @media (prefers-reduced-motion: reduce) { .lgf-lv:active { transform: none; } }
  /* Sélection en neutre : avec une marque rouge, une bordure --brand se lisait comme une erreur. */
  .lgf-lv-active { border-color: var(--ink-3); box-shadow: var(--shadow-2); }

  .lgf-lv-numero { grid-area: num; justify-self: start; align-self: center; padding: 0.1rem 0.5rem; font-family: var(--font-mono); font-size: var(--text); letter-spacing: 0.02em; color: #fff; background: var(--ink); border-radius: 4px; }
  .lgf-lv-flux { grid-area: flux; align-self: center; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: 600; color: var(--brand-text); }
  .lgf-lv-tiers { margin: var(--sp-2) 0 0; min-width: 0; font-size: var(--text-sm); }
  .lgf-lv-expediteur { grid-area: exp; }
  .lgf-lv-destinataire { grid-area: dest; }
  .lgf-lv-expediteur::before, .lgf-lv-destinataire::before { display: block; font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
  .lgf-lv-expediteur::before { content: "Expéditeur"; }
  .lgf-lv-destinataire::before { content: "Destinataire"; }
  .lgf-lv-nomcomplet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .lgf-lv-complement { display: none; color: var(--ink-2); }

  .lgf-lv-infos { grid-area: infos; }
  .lgf-lv-valeurs { grid-area: val; }
  .lgf-lv-caracteristiques { grid-area: car; display: none; }
  .lgf-lv-actions { grid-area: act; display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
  .lgf-lv-suivi { grid-area: suivi; }
  .lgf-lv-dates { grid-area: dates; font-size: var(--text-sm); color: var(--ink-2); }
  .lgf-lv-options { grid-area: opt; display: none; }
  .lgf-lv-infos, .lgf-lv-valeurs, .lgf-lv-suivi, .lgf-lv-dates { margin-top: var(--sp-2); min-width: 0; }

  img.icon16 { width: 1rem; height: 1rem; object-fit: contain; vertical-align: -0.2em; margin-right: 0.15rem; }
  .lgf-lv-detail { display: none; font-size: var(--text-sm); }
  .lgf-lv-info-label { font-weight: 650; color: var(--ink-3); }
  .lgf-lv-crcorrige, .lgf-lv-poidscorrige { color: var(--danger); text-decoration: line-through; }
  .lgf-lv-planifiee .lgf-lv-plan-hide { display: none; }
  .lgf-lv-planifiee .lgf-lv-plan-show { display: inline; }
  .lgf-lv-planifiee.lgf-lv-active img.lgf-lv-plan-hide { display: inline; }
  .logoCamion { margin-right: var(--sp-1); }

  .lgf-lv-actions a { display: inline-flex; align-items: center; gap: 0.2rem; min-height: 2rem; padding: 0 var(--sp-2); color: var(--ink); border-radius: var(--radius-sm); }
  .lgf-lv-actions a:hover { background: var(--surface-2); text-decoration: none; }
  .lgf-lv-actions a.delete-lv-confirm { color: var(--danger); }
  .lgf-lv-action-label { display: none; }
  .lgf-lv-dates a { display: inline-flex; align-items: center; gap: 0.2rem; }

  .lgf-lv-options h1 { margin: 0 0 var(--sp-1); font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
  .lgf-lv-options ul { margin: 0; padding-left: var(--sp-4); }

  /* --- Carte ouverte --- */
  .lgf-lv-active .lgf-lv-nomcomplet { display: inline; white-space: normal; }
  .lgf-lv-active .lgf-lv-complement { display: inline; }
  .lgf-lv-active .lgf-lv-detail { display: inline; }
  .lgf-lv-active .lgf-lv-detail::after { content: "\A"; white-space: pre; }
  .lgf-lv-active .lgf-lv-caracteristiques { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-5); margin-top: var(--sp-3); padding-top: var(--sp-3); font-size: var(--text-sm); border-top: 1px solid var(--line); }
  .lgf-lv-active .lgf-lv-options { display: block; margin-top: var(--sp-3); }
  .lgf-lv-active .lgf-lv-action-label { display: inline; }
  .lgf-lv-active .lgf-lv-poidsCorrige { display: none; }

  /* --- Carte large : une ligne --- */
  @container (min-width: 52rem) {
    .lgf-lv {
      align-items: center;
      grid-template-columns: 5.5rem 9.5rem minmax(0, 1fr) minmax(0, 1fr) auto auto auto;
      grid-template-areas: "flux num exp dest infos val act";
      padding: var(--sp-2) var(--sp-3);
    }
    .lgf-lv-cloturee { grid-template-columns: 5.5rem 9.5rem minmax(0, 1fr) minmax(0, 1fr) auto auto auto auto; grid-template-areas: "flux num exp dest infos val suivi dates"; }
    .lgf-lv-tiers, .lgf-lv-infos, .lgf-lv-valeurs, .lgf-lv-suivi, .lgf-lv-dates, .lgf-lv-actions { margin-top: 0; }
    .lgf-lv-flux { max-width: none; }
    .lgf-lv-expediteur::before, .lgf-lv-destinataire::before { content: none; }
    .lgf-lv-infos, .lgf-lv-valeurs { white-space: nowrap; }

    .lgf-lv-active {
      align-items: start;
      grid-template-columns: 5.5rem 9.5rem minmax(0, 1fr) minmax(0, 1fr) auto;
      grid-template-areas:
        "flux num  exp   dest  act"
        "car  car  infos val   val"
        "opt  opt  opt   opt   opt";
    }
    .lgf-lv-cloturee.lgf-lv-active {
      grid-template-columns: 5.5rem 9.5rem minmax(0, 1fr) minmax(0, 1fr) auto;
      grid-template-areas:
        "flux num  exp   dest  dates"
        "car  car  infos val   suivi"
        "opt  opt  opt   opt   opt";
    }
    .lgf-lv-active .lgf-lv-caracteristiques { flex-direction: column; margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 0; }
    .lgf-lv-active .lgf-lv-infos, .lgf-lv-active .lgf-lv-valeurs { margin-top: var(--sp-2); white-space: normal; }
    .lgf-lv-active .lgf-lv-numero { align-self: start; }
    .lgf-lv-active .lgf-lv-flux { align-self: start; }
  }

  /* --- Recherche et filtres --- */
  /* Recherche : même panneau que les filtres placés juste en dessous. */
  #search-fields { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); max-width: 40rem; margin: var(--sp-2) 0 var(--sp-4); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  #search-fields br { display: none; }
  #fields-reference { width: min(100%, 16rem); }
  #filters-list { display: grid; gap: var(--sp-3); max-width: 40rem; margin: var(--sp-2) 0 var(--sp-4); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  #filters-list dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
  #filters-list dd br { flex-basis: 100%; height: 0; }
  #filter-nomclient { display: none; }
  #filter-du, #filter-au { width: 7.5rem; }
  #filter-champ { width: 8rem; }

  @media (max-width: 40rem) {
    #lgf-liste-lv > tbody > tr { grid-template-columns: 1.75rem minmax(0, 1fr); gap: 0 var(--sp-1); }
    #lgf-liste-lv > tbody > tr > td:first-child { padding-top: var(--sp-4); }
    .lgf-lv-actions a { min-height: var(--tap); min-width: var(--tap); justify-content: center; }
    .lgf-lv-active .lgf-lv-actions a { justify-content: flex-start; }
    #filters-list { padding: var(--sp-3); }
    #filters-list dd > input[type=text], #filters-list dd > select { flex: 1 1 8rem; }
  }
}

/* ═══ 7. pages.css ═══ */

/*
 * Pages hors liste LV : profil, carnet d'adresses, adresses, journaux,
 * détail de LV (suivi, conteneurs, cartes), formulaires LV (conteneurs,
 * références), demande de suppression, à propos.
 *
 * Plusieurs de ces pages posent leurs cartes dans un <table> généré par une
 * boucle PHP (3 ou N cartes par ligne) : le tableau devient une grille CSS qui
 * se replie seule sur petit écran.
 */

@layer pages {
  /* --- Tableaux de cartes → grille responsive --- */
  table:has(.lgf-address), table:has(.lgf-journal), #lgf-liste-contacts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--sp-3);
    width: 100%;
    margin-block: var(--sp-3);
  }
  table:has(.lgf-address) > tbody, table:has(.lgf-journal) > tbody, #lgf-liste-contacts > tbody,
  table:has(.lgf-address) tr, table:has(.lgf-journal) tr, #lgf-liste-contacts tr { display: contents; }
  table:has(.lgf-address) td, table:has(.lgf-journal) td, #lgf-liste-contacts td { display: block; padding: 0; border: 0; min-width: 0; }
  #lgf-liste-contacts th { grid-column: 1 / -1; padding: 0; text-align: center; }
  #lgf-liste-contacts a { color: inherit; text-decoration: none; display: block; height: 100%; }

  /* --- Cartes : socle commun (contact, adresse, journal) ---
   * Une seule anatomie : surtitre, titre, sous-titre, corps séparé par un filet, pied.
   * La hiérarchie vient du poids, de la taille et de l'espacement ; la couleur de marque
   * reste réservée aux actions et à la sélection.
   */
  .lgf-bcard, .lgf-address, .lgf-journal {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
  }

  /* Pastille : libellé d'adresse, flux d'un journal */
  .lgf-bcard-adresse-libelle, .lgf-address-libelle, .lgf-journal-flux {
    align-self: flex-start;
    margin: 0;
    padding: 0.125rem var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 650;
    line-height: 1.4;
    color: var(--ink-2);
    background: var(--surface-2);
    border-radius: 999px;
  }
  .lgf-bcard-adresse-libelle, .lgf-address-libelle { letter-spacing: 0.04em; text-transform: uppercase; }

  /* Cartes cliquables : survol, appui immédiat, focus clavier */
  #lgf-liste-contacts a:hover .lgf-bcard,
  .whole-address-link:hover .lgf-address,
  label[id^="label-adresse-dest-"]:hover .lgf-address { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
  #lgf-liste-contacts a:active .lgf-bcard,
  .whole-address-link:active .lgf-address,
  label[id^="label-adresse-dest-"]:active .lgf-address { transform: scale(0.985); transition-duration: 0s; }
  #lgf-liste-contacts a:focus-visible,
  .whole-address-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-lg); }

  /* --- Fiche contact (carnet) : même structure que le journal de ramasse ---
   * référence ↔ numéro, nom complet ↔ date, libellé d'adresse ↔ flux,
   * adresse ↔ totaux, « + n autres adresses » ↔ pied « réimprimer ».
   */
  .lgf-bcard-reference { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: 0.02em; color: var(--ink); overflow-wrap: anywhere; }
  .lgf-bcard-contact { margin: 0; }
  .lgf-bcard-nomcomplet { font-size: var(--text-sm); font-style: normal; font-weight: 400; color: var(--ink-2); }
  .lgf-bcard-adresse { display: flex; flex-direction: column; margin: var(--sp-3) 0 var(--sp-3); }
  .lgf-bcard-adresse-texte { margin: var(--sp-2) 0 0; font-size: var(--text-sm); line-height: 1.45; color: var(--ink-2); }
  .lgf-bcard-nbadresses { display: block; margin-top: auto; padding-top: var(--sp-3); font-size: var(--text-sm); color: var(--ink-2); border-top: 1px solid var(--line); }
  .lgf-bcard > p:empty { display: none; }

  /* --- Fiche adresse --- */
  .lgf-address { position: relative; gap: var(--sp-2); }
  .lgf-address-corps { margin: 0; line-height: 1.45; color: var(--ink); }
  .lgf-address-nomcomplet { font-weight: 650; }
  .lgf-address-tag { color: var(--ink-3); }
  .lgf-address-actions { display: flex; gap: var(--sp-1); position: absolute; top: var(--sp-2); right: var(--sp-2); }
  .lgf-address-actions a, .lgf-address-actions > img { display: inline-flex; padding: var(--sp-1); border-radius: var(--radius-sm); }
  .lgf-address-actions a:hover { background: var(--surface-2); }
  .lgf-address-actions img { width: 1.25rem; height: 1.25rem; object-fit: contain; }
  .address-links .lgf-address-actions, .address-links .lgf-address-libelle { display: none; }
  .whole-address-link { display: block; height: 100%; color: inherit; text-decoration: none; }
  /* Adresses du destinataire sélectionnables à la saisie d'une LV */
  input.adresse-updater { display: none; }
  .destinataire-adresses label { float: left; margin: var(--sp-1); }
  label.adresse-dest-selected div.lgf-address { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

  /* --- Journaux de ramasse --- */
  .lgf-journal-numero { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: 0.02em; color: var(--ink); }
  .lgf-journal-dateramasse { font-size: var(--text-sm); color: var(--ink-2); }
  .lgf-journal-flux { margin-top: var(--sp-3); }
  .lgf-journal-totaux { margin: var(--sp-2) 0 var(--sp-3); font-size: var(--text-sm); color: var(--ink-2); }
  /* Pied de carte calé en bas, séparé du contenu par un filet comme sur la fiche contact. */
  .lgf-journal-reimprimer { margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--line); }
  .lgf-journal-reimprimer a { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-3); font-weight: 550; color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); transition: background-color var(--ease); }
  .lgf-journal-reimprimer a:hover { background: var(--surface-2); text-decoration: none; }
  .lgf-journal-reimprimer a:active { filter: brightness(0.9); transition-duration: 0s; }
  .lgf-journal-reimprimer img { width: 1.15rem; height: 1.15rem; object-fit: contain; }

  @media (prefers-reduced-motion: reduce) {
    #lgf-liste-contacts a:active .lgf-bcard,
    .whole-address-link:active .lgf-address,
    label[id^="label-adresse-dest-"]:active .lgf-address { transform: none; }
  }

  /* --- Profil --- */
  #lgf-popup-aide { max-width: 44rem; color: var(--ink-2); }
  #lgf-cartes-selecteur { border-collapse: separate; border-spacing: 2px; }
  .lgf-cartes-colonne { width: 3rem; height: 1.5rem; background: var(--line); border: 1px solid var(--line-strong); }
  .lgf-cartes-colonne.active { background: var(--surface); }
  .lgf-cartes-colonne.right-limit { border-right-color: var(--accent); }
  .lgf-cartes-colonne.bottom-limit { border-bottom-color: var(--accent); }

  /* --- Conteneurs en cours de saisie (construits par lv-conteneurs.js) --- */
  #conteneurs-liste_group { display: none; }
  #conteneurs-liste_group, #conteneurs-liste_group > label.field_label { height: auto !important; }
  #conteneurs-liste-label { display: none; }
  #detail_conteneurs { display: grid; gap: var(--sp-1); width: min(100%, 32rem); }
  .lgf-conteneur {
    position: relative;
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 1fr);
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
  }
  .lgf-conteneur:hover { border-color: var(--danger); }
  .lgf-conteneur > div { min-width: 0; padding: 0.3rem var(--sp-2); }
  .lgf-conteneur-numero { display: flex; align-items: center; justify-content: flex-end; padding: 0 var(--sp-2) !important; font-weight: 650; color: var(--ink-2); background: var(--surface-2) url(/img/conteneur.png) no-repeat left 0.3rem center / 1rem; }
  .lgf-conteneur:hover .lgf-conteneur-numero { background-image: url(/img/supprconteneur.png); }
  .lgf-conteneur-numero-etiquette { grid-row: 2; grid-column: 1 / -1; padding: 0.2rem var(--sp-2); font-family: var(--font-mono); font-size: var(--text-sm); color: #fff; background: var(--ink); }
  .lgf-conteneur-label { font-size: var(--text-xs); font-style: normal; color: var(--ink-3); }
  .lgf-conteneur-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }

  /* --- Références de commande (liste ajoutable) --- */
  #commande-list { display: grid; gap: var(--sp-1); width: min(100%, 22rem); margin: var(--sp-2) 0 0; padding: 0; }
  #commande-list li, .lgf-lister-item { position: relative; list-style: none; padding: var(--sp-1) var(--sp-2); padding-right: 2.5rem; background: var(--surface-2); border-radius: var(--radius-sm); }
  .lgf-lister-remove { position: absolute; right: var(--sp-1); top: 50%; translate: 0 -50%; min-height: 1.75rem; padding: 0 var(--sp-2); }
  /* lv-commandes.js fixe des hauteurs en ligne calculées pour l'ancienne mise en page. */
  #commande_group, #commande_group > label.field_label { height: auto !important; }
  img.lgf-lister-remove { width: 1.5rem; height: 1.5rem; padding: 0.25rem; cursor: pointer; object-fit: contain; }
  #instructions-edition-value, #message { width: min(100%, 28rem); }
  div.lgf-ecombo:has(#instructions-edition-value) { width: min(100%, 28rem); }
  #adresses_legend, #adresses_group, #adresses_end, #destinataire_adresse-element { display: none; }
  #adresses_group { padding: 0; }
  #adresses_group label { display: inline-block; width: min(100%, 15rem); margin: var(--sp-1); vertical-align: top; text-align: left; }
  .warning { padding: var(--sp-2) var(--sp-3); color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); }

  /* --- Modifier LV : formulaire (balisage sans classe, d'où le sélecteur sur l'action) --- */
  /* La carte de la LV est directement dans #content : il devient le contexte de requête
     de conteneur, comme .lgf-lv-solo sur la page de détail. */
  #content:has(> .lgf-lv) { container-type: inline-size; }
  #content > form[action^="/lv/modifielv"] {
    max-width: 52rem;
    margin-top: var(--sp-4);
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
  }
  form[action^="/lv/modifielv"] h5 { margin: var(--sp-4) 0 var(--sp-2); }
  form[action^="/lv/modifielv"] #commande + .lgf-lister { margin-left: var(--sp-4); }
  form[action^="/lv/modifielv"] input[name=valider] { margin-right: var(--sp-2); }

  /* Conteneurs cochables : case et carte sur une ligne, carte à la largeur du formulaire de saisie. */
  .conteneur-checkbox { margin: 0 var(--sp-2) 0 0; vertical-align: middle; }
  .conteneur-label { display: inline-block; width: min(calc(100% - 2rem), 32rem); margin-bottom: var(--sp-2); vertical-align: middle; }
  /* État « sera supprimé » quand la case est cochée. */
  .conteneur-checkbox:checked + .conteneur-label .lgf-conteneur { border-color: var(--danger); background: var(--danger-soft); }

  /* --- Cibles tactiles (WCAG 2.5.8) : zone de clic agrandie au doigt, rendu souris inchangé --- */
  @media (pointer: coarse) {
    .field_group > input[type=radio] + label,
    #filters-list input[type=radio] + label { display: inline-block; padding-block: var(--sp-1); }
    .lgf-lv a[href*="/detailslv/"] { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; }
    .lgf-lv-suivi a { display: inline-block; padding-block: var(--sp-1); }
  }

  /* --- Détail LV : conteneurs consultés (modèle conteneurhisto) --- */
  .lgf-conteneur-histo {
    display: grid;
    grid-template-columns: minmax(9rem, auto) repeat(3, minmax(0, 1fr)) auto;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
  }
  .lgf-conteneur-histo:hover { border-color: var(--brand); }
  .lgf-conteneur-numero-etiquette-histo { padding: 0.1rem var(--sp-2); font-family: var(--font-mono); text-align: center; color: #fff; background: var(--ink); border-radius: 4px; }
  .lgf-conteneur-label-histo { color: var(--ink-2); }
  .lgf-conteneur-contenu-histo, .lgf-conteneur-poids-histo { font-weight: 550; }
  .lgf-conteneur-camion-histo img { width: 1.5rem; height: 1.5rem; object-fit: contain; }
  .accordionItem.hide table { display: none; }

  /* --- Détail LV : tableaux de suivi --- */
  table.lv-traces, table.conteneur-traces { width: 100%; margin: var(--sp-2) 0 var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; border-collapse: separate; border-spacing: 0; }
  .lv-traces th, .conteneur-traces th { padding: var(--sp-2) var(--sp-3); font-size: var(--text-xs); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); }
  .lv-traces td, .conteneur-traces td { padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--surface-2); vertical-align: top; }
  .conteneur-trace-coordonnees { width: 2.5rem; text-align: center; }
  .conteneur-trace-date { white-space: nowrap; color: var(--ink-2); }
  .conteneur-trace-note { font-style: italic; color: var(--ink-2); }
  .fa-map-marker.ok { color: var(--danger); }
  .fa-map-marker.not-ok { color: var(--line-strong); }
  .conteneur-trace-coordonnees a { display: inline-flex; padding: var(--sp-1); }
  .grande-imprimante { display: block; width: 3rem; margin: var(--sp-3) 0; transition: transform var(--ease); }
  .grande-imprimante:hover { transform: scale(1.15); cursor: pointer; }
  .contenu-emarge img#emarge { max-width: min(100%, 40rem); }

  /* Fenêtre de carte : ouverte par le JS inline (display:block) */
  #fond_noir, #fond_noir_cont { position: fixed; inset: 0; z-index: 940; display: none; width: 100%; background: rgb(16 24 40 / 0.6); }
  .positionneur { position: fixed; inset: 0; z-index: 970; display: none; overflow: auto; }
  #vue { width: min(60rem, 94vw); margin: 4dvh auto; padding: var(--sp-2); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-2); }
  #maps { display: block; width: 100%; height: min(70dvh, 38rem); border: 0; border-radius: var(--radius-sm); }
  .precision { margin: var(--sp-2) 0 0; text-align: center; font-size: var(--text-sm); color: var(--ink-3); }

  /* --- Demande de suppression --- */
  #css-motif { width: min(100%, 40rem); margin-inline: auto; padding-top: var(--sp-4); text-align: center; }
  #css-motif ul.listeLv { max-height: 15rem; margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3); overflow: auto; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
  #motif { width: min(100%, 34rem); }

  /* --- À propos --- */
  #lgfbee-presentation, #lgfbee-contact { padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius); }
  #lgfbee-contact > img { max-width: 100%; }
  #commande-rouleaux { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0; }
  #commande-rouleaux #nombre { width: 6rem; }
  img.illustration { max-width: min(100%, 16rem); border-radius: var(--radius); }

  /* Carte LV seule (détail) : contexte de requête de conteneur, comme la cellule des listes. */
  .lgf-lv-solo { container-type: inline-size; }

  @media (max-width: 52rem) {
    .lgf-conteneur-histo { grid-template-columns: 1fr 1fr; }
    .lgf-conteneur-numero-etiquette-histo { grid-column: 1 / -1; }
  }

  /* Suivi : chaque ligne devient une fiche (date, justification, note) sur mobile. */
  @media (max-width: 40rem) {
    table.lv-traces, table.conteneur-traces, .lv-traces tbody, .conteneur-traces tbody,
    .lv-traces tr, .conteneur-traces tr, .lv-traces td, .conteneur-traces td { display: block; }
    .lv-traces tr:has(th), .conteneur-traces tr:has(th) { display: none; }
    .lv-traces tr + tr, .conteneur-traces tr + tr { border-top: 1px solid var(--line); }
    .lv-traces td, .conteneur-traces td { padding: 0.15rem var(--sp-3); border: 0; }
    .lv-traces tr, .conteneur-traces tr { padding-block: var(--sp-2); }
    td.conteneur-trace-coordonnees:not(:has(a, i)) { display: none; }
    .conteneur-trace-coordonnees { width: auto; text-align: left; }
    .conteneur-trace-date { font-weight: 650; }
  }
}
