/* styles.css — design system bon.kerlam.fr
 *
 * Palette FINALE (validée Manu) : orange #FD8008 (action), orange foncé
 * #D46B06 (hover/active), gris de marque #808080, gris texte #595959,
 * anthracite #2B2B2B, fond #F4F4F2, blanc, vert #2E7D32, rouge #C62828,
 * bleu #1565C0.
 *
 * Règles WCAG (AA) à respecter dans tout ajout :
 * - Bouton primaire = fond orange + texte ANTHRACITE (jamais blanc : échoue AA).
 * - Jamais d'orange comme texte courant sur fond clair (échoue AA, ~3.5:1).
 *   L'orange reste réservé aux surfaces, au logo « LAM », aux icônes/accents
 *   (bordures, puces de statut sur fond teinté avec texte anthracite dessus).
 * - Gris de marque #808080 : logo « KER », filets, bordures, accents NON
 *   textuels UNIQUEMENT (contraste ~3.5:1 sur blanc : échoue AA pour du texte).
 * - Gris texte #595959 pour le texte secondaire sur fond clair (contraste ~7:1,
 *   AA/AAA). En sombre, #B8B6B2.
 * - Logo « KER » = #808080 exactement, « LAM » = #FD8008 exactement, IDENTIQUES
 *   en clair et en sombre (demande Manu).
 *
 * Police : Sarpanch (900 / Black) auto-hébergée, réservée au logo "KERLAM".
 *
 * Thème : clair par défaut, sombre automatique via prefers-color-scheme,
 * override manuel via [data-theme="clair"|"sombre"] sur <html> (Auto = pas
 * d'attribut forcé -> on suit le système).
 */

@font-face {
  font-family: "Sarpanch";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/assets/fonts/sarpanch-900.woff2") format("woff2");
}

:root {
  --c-orange: #FD8008;
  --c-orange-dark: #D46B06;
  --c-grey: #808080;        /* gris de marque : logo KER, filets, accents NON textuels */
  --c-grey-text: #595959;   /* gris texte secondaire sur blanc (AA ~7:1) */
  --c-grey-light: #C9C9C9;
  --c-anthracite: #2B2B2B;
  --c-bg: #F4F4F2;
  --c-white: #FFFFFF;
  --c-green: #2E7D32;
  --c-red: #C62828;
  --c-blue: #1565C0;

  /* Statuts d'échéance (documents, camions, chauffeurs) */
  --status-ok-bg: rgba(46,125,50,0.12);
  --status-ok-text: var(--c-green);
  --status-soon-bg: rgba(253,128,8,0.18);
  --status-soon-text: var(--c-anthracite);
  --status-expired-bg: rgba(198,40,40,0.12);
  --status-expired-text: var(--c-red);

  --logo-ker: var(--c-grey);

  --bg: var(--c-bg);
  --surface: var(--c-white);
  --text: var(--c-anthracite);
  --text-muted: var(--c-grey-text);
  --border: #DDDAD4;
  --shadow: 0 1px 3px rgba(43,43,43,0.12);

  --radius: 10px;
  --gap: 12px;
  --control-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1B1A;
    --surface: #262625;
    --text: #F1F0EE;
    --text-muted: #B8B6B2;
    --border: #3A3A38;
    --shadow: 0 1px 3px rgba(0,0,0,0.5);
    --logo-ker: var(--c-grey); /* KER = #808080 exact, identique clair/sombre */
  }
}

html[data-theme="clair"] {
  --bg: var(--c-bg);
  --surface: var(--c-white);
  --text: var(--c-anthracite);
  --text-muted: var(--c-grey-text);
  --border: #DDDAD4;
  --shadow: 0 1px 3px rgba(43,43,43,0.12);
  --logo-ker: var(--c-grey);
}

html[data-theme="sombre"] {
  --bg: #1B1B1A;
  --surface: #262625;
  --text: #F1F0EE;
  --text-muted: #B8B6B2;
  --border: #3A3A38;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
  --logo-ker: var(--c-grey); /* KER = #808080 exact, identique clair/sombre */
}

* { box-sizing: border-box; }

/* Garde-fou : des règles auteur comme `.screen-auth{display:flex}` ou
   `.app-shell{display:flex}` ont la même spécificité que la règle UA
   `[hidden]{display:none}` mais gagnent quand même (origine auteur > UA) —
   sans cette règle, un écran masqué par `hidden` restait visuellement affiché
   (bug préexistant : écran de connexion peint derrière/au-dessus de l'app). */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text); margin: 0 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--text-muted); }

a { color: var(--c-blue); }

.skip-link {
  position: absolute; left: -999px; top: auto;
}
.skip-link:focus {
  left: 8px; top: 8px; z-index: 1000;
  background: var(--surface); padding: 8px 12px; border-radius: 6px;
}

/* --------------------------------------------------------------------- Logo */
.logo {
  font-family: "Sarpanch", "Arial", sans-serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.5px;
  display: inline-flex;
}
.logo-ker { color: var(--logo-ker); }
.logo-lam { color: var(--c-orange); }
.logo-lg { font-size: 40px; margin-bottom: 8px; }

/* ----------------------------------------------------------------- Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h);
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background-color .15s, border-color .15s;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }

.btn-primary {
  background: var(--c-orange);
  color: var(--c-anthracite);
  border-color: var(--c-orange);
}
.btn-primary:hover, .btn-primary:focus-visible { background: var(--c-orange-dark); border-color: var(--c-orange-dark); }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover, .btn-secondary:focus-visible { background: var(--bg); }

.icon-btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px;
  font-size: 20px; cursor: pointer; color: var(--text);
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--bg); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ------------------------------------------------------------- Écrans d'auth */
.screen-auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.auth-tagline { color: var(--text-muted); margin-bottom: 24px; }
.auth-error { color: var(--c-red); margin-top: 16px; }
.auth-email { color: var(--text-muted); font-size: 14px; word-break: break-all; }

.login-choice { display: flex; flex-direction: column; gap: 14px; }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 0; color: var(--text-muted); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.otp-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.otp-form .field { margin-bottom: 0; }
.otp-resend { margin: 0; text-align: center; }

.btn-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  background: none; border: none;
  color: var(--text);
  font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: underline;
}
.btn-link:hover, .btn-link:focus-visible { color: var(--c-anthracite); text-decoration-color: var(--c-orange); }
.btn-link:disabled { color: var(--text-muted); text-decoration: none; cursor: default; }

/* -------------------------------------------------------------- Coquille app */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  /* Collé en haut + sous l'encoche/barre d'état en mode installé (iOS). */
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .logo { flex-shrink: 0; }
.topbar-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar .sync-indicator { overflow: hidden; text-overflow: ellipsis; max-width: 96px; }

.sync-indicator {
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}
.sync-saved   { background: rgba(46,125,50,0.12); color: var(--c-green); }
.sync-sending { background: rgba(21,101,192,0.12); color: var(--c-blue); }
.sync-offline { background: rgba(198,40,40,0.12); color: var(--c-red); }

.profil-badge { font-size: 13px; color: var(--text-muted); margin-left: 6px; }

.app-body { flex: 1; display: flex; min-height: 0; }

.side-nav {
  display: none; /* visible en desktop, cf. media query */
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 0;
}
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav a {
  display: block; padding: 12px 20px;
  color: var(--text); text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent;
}
.side-nav a:hover { background: var(--bg); }
.side-nav a.is-active {
  border-left-color: var(--c-orange);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
}

.main-content {
  flex: 1; min-width: 0;
  padding: 16px;
  padding-bottom: 88px; /* place pour la bottom-bar mobile */
  overflow-y: auto;
}

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.lv-numero {
  font-weight: 900; color: var(--text);
  font-family: "Sarpanch", Arial, sans-serif;
  border-left: 4px solid var(--c-orange);
  padding-left: 8px;
}

.bottom-bar {
  display: flex;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-bar-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 60px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
}
.bottom-bar-item.is-active { color: var(--c-orange-dark); font-weight: 700; }
.bb-icon { font-size: 22px; }

/* --------------------------------------------------------------- Dashboard */
.dashboard-welcome { margin-bottom: 16px; }
.dashboard-cards {
  display: grid; gap: var(--gap);
  grid-template-columns: 1fr;
}
.dashboard-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.dashboard-card { border-left: 3px solid var(--c-orange); }
.dashboard-card strong { display: block; margin-bottom: 4px; color: var(--text); }
.dashboard-card span { color: var(--text-muted); font-size: 14px; }

.placeholder-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- Formulaires */
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.field-checkbox label { flex-direction: row; align-items: center; display: flex; gap: 8px; font-weight: 500; }

input[type="text"], input[type="date"], input[type="time"], input[type="number"],
input[type="email"], input[type="tel"], input[type="search"], select, textarea {
  min-height: var(--control-h);
  font-size: 16px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--c-orange);
  outline-offset: 1px;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }

.lv-header-form { display: grid; gap: 0; grid-template-columns: 1fr; margin-bottom: 20px; }

.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.field-group legend { font-weight: 700; padding: 0 6px; }
.radio-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 16px; }

/* -------------------------------------------------------------- Tour cards */
.tours-list { display: flex; flex-direction: column; gap: var(--gap); margin-bottom: var(--gap); }
.tour-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.tour-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.site-row { display: flex; gap: 6px; align-items: center; }
.site-row input { flex: 1; }
.nav-link { text-decoration: none; }

.lignes-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.ligne-row { display: grid; grid-template-columns: 1fr 90px 90px 44px; gap: 6px; align-items: center; }
.ligne-row select, .ligne-row input { min-height: 48px; padding: 0 10px; }

/* --------------------------------------------------------------- Jauge poids */
.weight-gauge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.weight-gauge-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.weight-gauge-bar {
  height: 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.weight-gauge-fill {
  height: 100%;
  width: 0%;
  background: var(--c-green);
  transition: width .2s, background-color .2s;
}
.weight-gauge-fill.is-warn   { background: var(--c-orange); }
.weight-gauge-fill.is-danger { background: var(--c-red); }
.weight-gauge-note { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }

/* ------------------------------------------------------------------ Mes LV */
.mes-lv-list { display: flex; flex-direction: column; gap: 8px; }
.lv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 15px;
}
.lv-row:hover { background: var(--bg); }
.lv-row .lv-row-main { display: flex; flex-direction: column; }
.lv-row .lv-row-numero { font-weight: 700; }
.lv-row .lv-row-date { color: var(--text-muted); font-size: 13px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-en_cours   { background: rgba(21,101,192,0.12); color: var(--c-blue); }
.badge-preparee   { background: rgba(94,94,94,0.12);   color: var(--c-grey); }
.badge-cloturee   { background: var(--status-soon-bg); color: var(--status-soon-text); }
.badge-a_signer   { background: var(--status-soon-bg); color: var(--status-soon-text); }
.badge-envoyee    { background: rgba(21,101,192,0.12); color: var(--c-blue); }
.badge-signee     { background: rgba(46,125,50,0.12);  color: var(--c-green); }
.badge-facturee   { background: rgba(46,125,50,0.12);  color: var(--c-green); }
.badge-annulee    { background: rgba(198,40,40,0.12);  color: var(--c-red); }

/* Puces de statut d'échéance (camions/chauffeurs/documents) : l'orange est ici
   une SURFACE (fond teinté) avec un texte anthracite dessus, jamais du texte
   orange nu sur fond clair (cf. règle WCAG en tête de fichier). */
.status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-ok      { background: var(--status-ok-bg);      color: var(--status-ok-text); }
.status-soon    { background: var(--status-soon-bg);    color: var(--status-soon-text); }
.status-expired { background: var(--status-expired-bg); color: var(--status-expired-text); }

/* ------------------------------------------------------------------ Contrôle */
.controle-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.controle-content h2 { font-size: 16px; margin-top: 16px; }
.controle-content dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.controle-content dt { color: var(--text-muted); }
.controle-content dd { margin: 0; font-weight: 600; }

/* ------------------------------------------------------------- Barre d'outils */
.view-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.view-toolbar .filter-input { flex: 1; min-width: 160px; }
.view-toolbar .btn { flex-shrink: 0; }
.filter-input { min-height: var(--control-h); font-size: 16px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }

/* ---------------------------------------------------------- Listes génériques */
.entity-list { display: flex; flex-direction: column; gap: var(--gap); }
.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.entity-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  padding: 14px 16px;
  background: none; border: none; cursor: pointer;
  min-height: 56px;
  color: var(--text); font-size: 16px;
}
.entity-card-head:hover, .entity-card-head:focus-visible { background: var(--bg); }
.entity-card-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entity-card-title strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.entity-card-title span { color: var(--text-muted); font-size: 13px; }
.entity-card-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.entity-card-chevron { transition: transform .15s; color: var(--text-muted); }
.entity-card.is-open .entity-card-chevron { transform: rotate(180deg); }
.entity-card-body { display: none; padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.entity-card.is-open .entity-card-body { display: block; padding-top: 14px; }
.entity-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.entity-empty { color: var(--text-muted); text-align: center; padding: 24px 12px; }

.field-grid { display: grid; grid-template-columns: 1fr; gap: 0 20px; }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row > .field { flex: 1; margin-bottom: 0; }

/* --------------------------------------------------------- Rôles / multiselect */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; user-select: none;
}
.chip-check input { width: 16px; height: 16px; margin: 0; }
.chip-check.is-checked { border-color: var(--c-orange); background: var(--status-soon-bg); font-weight: 700; }

/* ------------------------------------------------------- Documents chauffeur */
.doc-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.doc-section > legend, .doc-section-title { font-weight: 700; margin-bottom: 8px; }
.doc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.doc-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }
.doc-cat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.doc-cat-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: 8px; align-items: center; margin-bottom: 8px; }
.doc-cat-row:has(.f-caces-type) { grid-template-columns: 90px 1fr 140px 44px; }
.upload-row { display: flex; gap: 6px; flex-wrap: wrap; }
.upload-row input[type="file"] { display: none; }
.upload-label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer;
}
.upload-label:hover { background: var(--bg); }

/* ----------------------------------------------------------- Adresse autocomplétion */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px;
}
.autocomplete-item {
  padding: 10px 12px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.autocomplete-item:hover, .autocomplete-item.is-active { background: var(--bg); }
.geoloc-row { display: flex; gap: 8px; margin: 6px 0 12px; }

/* --------------------------------------------------------------- Tableau de bord */
.dash-section { margin-bottom: 20px; }
.dash-section h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 10px; }
.dash-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; }
.dash-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
/* Chiffres des cartes : police système en gras (la Sarpanch est réservée au LOGO). */
.dash-tile strong { display: block; font-size: 26px; font-weight: 800; }
.dash-tile span { color: var(--text-muted); font-size: 13px; }
.dash-alert-list { display: flex; flex-direction: column; gap: 8px; }
.dash-alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px;
}
.dash-alert-row.is-expired { border-left-color: var(--c-red); }
.dash-alert-row.is-expired .dash-alert-status { color: var(--status-expired-text); font-weight: 700; }
.dash-alert-row.is-soon { border-left-color: var(--c-orange); }
.dash-alert-row.is-soon .dash-alert-status { color: var(--status-soon-text); font-weight: 700; }
.dash-alert-main { display: flex; flex-direction: column; }
.dash-alert-main span { color: var(--text-muted); font-size: 12px; }

/* ------------------------------------------------------------------ Planning */
.planning-row { display: flex; align-items: center; gap: 10px; }
.planning-row .field-checkbox input { width: 22px; height: 22px; }

/* ----------------------------------------------------------- Feuille (sheet) */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-overlay[hidden] { display: none; }
.sheet-panel {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 560px) {
  .sheet-overlay { align-items: center; }
  .sheet-panel { border-radius: 16px; }
}
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-header h2 { margin: 0; }
.sheet-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 14px 0 6px; }
.sheet-list { display: flex; flex-direction: column; gap: 6px; }
.sheet-item {
  display: block; width: 100%; text-align: left;
  min-height: 52px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 15px;
}
.sheet-item:hover { background: var(--bg); }
.sheet-item span { display: block; color: var(--text-muted); font-size: 12px; }

/* ----------------------------------------------------------------- Signature */
.bulk-send-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}

@media print {
  .topbar, .side-nav, .bottom-bar, .view-header button { display: none !important; }
  .main-content { padding: 0; }
}

/* ------------------------------------------------------------------ Mobile / Desktop */
/* Mobile (< 900px) : PAS de menu latéral fixe. Navigation par barre d'onglets en
   bas + tiroir « Plus » plein écran. Ordinateur (>= 900px) : menu latéral. */
.main-content { overflow-x: hidden; }

@media (min-width: 900px) {
  .side-nav { display: block; }
  .bottom-bar, .nav-drawer { display: none !important; }
  .main-content { padding: 24px 32px; padding-bottom: 24px; }
  .dashboard-cards { grid-template-columns: repeat(3, 1fr); }
  .lv-header-form { grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 899px) {
  .side-nav { display: none; }
  .bottom-bar { display: flex; }
  .main-content { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .view-header h1 { font-size: 23px; line-height: 1.2; }
  .view-header { flex-wrap: wrap; }
  h1 { font-size: 23px; line-height: 1.2; }
}

/* Barre d'onglets : items affichés selon le rôle (l'onglet LV est commun). */
.bottom-bar-item { display: none; }
.bottom-bar-item[data-route="lv"] { display: flex; }
body.has-bureau .bb-bureau,
body.has-bureau .bb-more { display: flex; }
body.has-chauffeur:not(.has-bureau) .bb-chauffeur { display: flex; }

/* Tiroir « Plus » : menu plein écran (mobile), fermé par défaut. */
.nav-drawer { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); display: flex; }
.nav-drawer[hidden] { display: none; }
.nav-drawer-panel {
  margin-left: auto; width: min(320px, 85vw); height: 100%;
  background: var(--surface); display: flex; flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  box-shadow: -2px 0 12px rgba(0,0,0,.2);
}
.nav-drawer-list { display: flex; flex-direction: column; overflow-y: auto; }
.nav-drawer-list a {
  display: flex; align-items: center; min-height: 48px; padding: 10px 14px;
  color: var(--text); text-decoration: none; font-weight: 600;
  border-radius: 10px; border-left: 3px solid transparent;
}
.nav-drawer-list a:hover, .nav-drawer-list a.is-active { background: var(--bg); border-left-color: var(--c-orange); }

/* ======================================== Pied de page auth + liens utiles == */
.auth-wrap {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 380px;
}
.auth-wrap .auth-card { max-width: none; }
.auth-footer {
  width: 100%;
  margin-top: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.install-cta { width: 100%; }
.footer-links {
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center;
  margin: 0; font-size: 13px;
}
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover, .footer-links a:focus-visible { color: var(--text); text-decoration: underline; }
.reglages-links { margin-top: 20px; }

/* ====================================== Fiche d'aide à l'installation (PWA) == */
.install-help-block { font-size: 15px; }
.install-help-block > p { margin-bottom: 12px; }
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.install-step { display: flex; gap: 12px; align-items: flex-start; }
.install-step-icon {
  flex-shrink: 0; width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--c-orange);
}
.install-step-icon svg { width: 22px; height: 22px; }
.install-step-num { color: var(--c-orange-dark); margin-right: 2px; }
.install-step-body { flex: 1; min-width: 0; }
.install-step-body strong { display: block; }
.install-step-body span { color: var(--text-muted); font-size: 14px; }
.install-device { font-weight: 700; margin-bottom: 10px; }
.install-note { font-size: 13px; margin-top: 10px; }
.install-actions { margin-top: 12px; }
.install-others { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.install-others summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.install-other-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.install-other-link {
  display: block; width: 100%; text-align: left; min-height: 44px;
  background: none; border: none; color: var(--c-blue); cursor: pointer;
  font-size: 15px; padding: 8px 4px;
}
.install-other-link:hover { text-decoration: underline; }
.install-other-detail { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }
.doc-platform { margin-bottom: 8px; }

/* ================================= Pages autonomes (installer, mentions légales) */
.doc-page { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.doc-back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px;
  color: var(--text-muted); text-decoration: none; font-size: 14px;
}
.doc-back:hover, .doc-back:focus-visible { color: var(--text); text-decoration: underline; }
.doc-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 20px;
}
.doc-card h1 { font-size: 26px; line-height: 1.25; margin-bottom: 4px; }
.doc-card h2 { font-size: 19px; margin: 24px 0 8px; }
.doc-card p, .doc-card li { margin: 0 0 10px; }
.doc-card ul { padding-left: 20px; margin: 0 0 10px; }
.doc-date { color: var(--text-muted); margin-bottom: 20px; }
.doc-card table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 6px 0 10px; }
.doc-card th, .doc-card td { text-align: left; vertical-align: top; padding: 8px; border-top: 1px solid var(--border); }
.doc-card th { font-weight: 600; }
.doc-platforms { display: flex; flex-direction: column; gap: 16px; }
.doc-platform-title { display: flex; align-items: center; gap: 10px; }
.doc-platform-title .install-step-icon { width: 36px; height: 36px; }
@media (min-width: 900px) {
  .doc-card table { table-layout: auto; }
}
@media (max-width: 560px) {
  .doc-card table, .doc-card thead, .doc-card tbody, .doc-card tr, .doc-card th, .doc-card td { display: block; }
  .doc-card thead { display: none; }
  .doc-card td { border-top: none; padding: 2px 0; }
  .doc-card tr { border-top: 1px solid var(--border); padding: 8px 0; }
  .doc-card td:first-child { font-weight: 600; }
}

/* Utilitaires remplaçant d'anciens styles inline (CSP : pas de style= inline) */
.planning-check { margin: 0; }
.sheet-section-title.is-spaced { margin-top: 18px; }
.btn.is-spaced { margin-top: 14px; }

/* Installation — rendu dynamique (install.js / installer.js) */
.install-device { font-weight: 700; color: var(--text); margin: 0 0 10px; }
.install-note { font-size: 13px; margin-top: 8px; }
.install-actions { margin-top: 12px; }
#install-help-all { margin-top: 14px; }
.install-others-toggle > summary,
.install-other > summary {
  cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--text);
  list-style: none;
}
.install-others-toggle > summary::-webkit-details-marker,
.install-other > summary::-webkit-details-marker { display: none; }
.install-others-toggle > summary::before,
.install-other > summary::before { content: "▸ "; color: var(--c-orange); }
.install-others-toggle[open] > summary::before,
.install-other[open] > summary::before { content: "▾ "; }
.install-other { border-top: 1px solid var(--border); padding: 4px 0; }
.install-others-toggle { border-top: 1px solid var(--border); padding-top: 8px; }
.installer-current { margin: 16px 0 8px; padding: 16px; background: var(--bg); border-radius: var(--radius); }
.installer-all-title { margin-top: 28px; }
.install-done { background: var(--status-ok-bg); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.installer-native-btn, #installer-native-btn { margin-bottom: 12px; }
