:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --card: #243247;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-dim: #d97706;
  --ok: #10b981;
  --border: #334155;
  --danger: #f87171;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* --- Thème clair --- */
html[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --card: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #d97706;
  --accent-dim: #b45309;
  --ok: #059669;
  --border: #cbd5e1;
  --danger: #dc2626;
}

html[data-theme="light"] .log-pre {
  background: #e2e8f0;
  color: #1e293b;
}

html[data-theme="light"] .bp-numero {
  color: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Liens : jamais le bleu/mauve par défaut du navigateur (illisible sur fond
   sombre). Règle de base à faible spécificité — les composants qui définissent
   leur propre couleur (boutons, tuiles, nav…) la surchargent naturellement. */
a,
a:visited {
  color: var(--accent);
}

a:hover {
  color: var(--accent-dim);
}

/* Dans les tableaux, les liens (noms de chantiers, n° de bons…) restent
   couleur texte pour ne pas surcharger, avec l'accent au survol. */
.table a,
.table a:visited {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(148, 163, 184, 0.55);
  text-underline-offset: 2px;
}

.table a:hover {
  color: var(--accent);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* --- Barre une ligne + menu hamburger (téléphone / petite largeur) --- */
.nav-drawer-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-drawer-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(15, 23, 42, 0.55);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

html[data-theme="light"] .nav-drawer-backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.nav-drawer-head {
  display: none;
  padding-bottom: 0.5rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.nav-drawer-user {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.nav-drawer-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.nav-drawer-user-meta {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

@media (min-width: 901px) {
  .nav-drawer-panel {
    display: contents;
  }

  .nav-drawer-head {
    display: none !important;
  }

  .nav-drawer-btn {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.45rem;
  }

  .topbar-left {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    align-items: center;
    gap: 0.3rem;
  }

  .idea-bulb-btn .idea-bulb-label {
    display: none;
  }

  .idea-bulb-btn {
    padding: 0.05rem;
  }

  .idea-bulb-svg {
    width: 26px;
    height: 26px;
  }

  .brand {
    font-size: 0.74rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
  }

  .topbar-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    width: auto;
  }

  .topbar-toolbar .topbar-user {
    display: none;
  }

  .topbar-right .topbar-user,
  .topbar-right .nav-in-drawer,
  .topbar-right .topbar-toolbar-icons {
    order: unset;
  }

  .nav-drawer-btn {
    display: inline-flex;
  }

  .nav-drawer-panel {
    display: none;
  }

  .nav-drawer-panel.is-open {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 95;
    margin-top: calc(2.85rem + env(safe-area-inset-top, 0px));
    max-height: min(72vh, calc(100vh - 3.5rem - env(safe-area-inset-bottom, 0px)));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.55rem 0.65rem 0.85rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  }

  .nav-drawer-head {
    display: block;
  }

  .nav-drawer-panel .nav-in-drawer {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0.2rem;
    overflow: visible;
  }

  .nav-drawer-panel .nav-in-drawer a {
    flex-shrink: 0;
    text-align: left;
    padding: 0.5rem 0.55rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  .nav-drawer-panel .nav-in-drawer .btn-nav {
    text-align: center;
  }

  .notif-btn,
  .settings-btn {
    width: 32px;
    height: 32px;
  }

  .main {
    padding: 0.5rem 0.55rem 2.5rem;
  }

  h1 {
    font-size: 1.2rem;
    margin-bottom: 0.45rem;
  }

  body.nav-drawer-open {
    overflow: hidden;
  }

  html.topbar-minimal-pref-on .topbar-collapse-btn {
    display: inline-flex;
  }

  html.topbar-mobile-collapsed .topbar-collapse-btn {
    display: none !important;
  }

  html.topbar-mobile-collapsed .topbar {
    display: none !important;
  }

  html.topbar-mobile-collapsed .nav-drawer-backdrop {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
  }

  html.topbar-mobile-collapsed .nav-drawer-panel.is-open {
    display: none !important;
  }

  html.topbar-mobile-collapsed body.nav-drawer-open {
    overflow: visible;
  }

  html.topbar-mobile-collapsed .topbar-minimal-fab {
    display: inline-flex !important;
  }
}

.topbar-collapse-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.topbar-collapse-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.topbar-minimal-fab {
  display: none;
  position: fixed;
  top: max(0.35rem, env(safe-area-inset-top, 0px));
  right: max(0.4rem, env(safe-area-inset-right, 0px));
  z-index: 110;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  transition: color 0.15s, border-color 0.15s;
}

.topbar-minimal-fab:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (min-width: 901px) {
  .topbar-collapse-btn,
  .topbar-minimal-fab {
    display: none !important;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 0;
}

/* Ampoule « idée » — admins, en haut à gauche */
.idea-bulb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem 0.35rem 0.05rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.2) 0%, transparent 100%);
  cursor: pointer;
  flex-shrink: 0;
  animation: idea-bulb-pulse 2.8s ease-in-out infinite;
}
.idea-bulb-btn:hover {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.45) 0%, rgba(250, 204, 21, 0.08) 100%);
  transform: scale(1.05);
}
.idea-bulb-btn:active {
  transform: scale(0.98);
}
.idea-bulb-svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.idea-bulb-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #facc15;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
@keyframes idea-bulb-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
html[data-theme="light"] .idea-bulb-label {
  color: #ca8a04;
  text-shadow: none;
}
html[data-theme="light"] .idea-bulb-btn {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.35) 0%, transparent 100%);
}

.brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem 1rem;
  min-width: 0;
  flex: 1;
}

/* Regroupe user + icônes (mobile : une ligne) ; desktop : contents pour ordre user → nav → icônes */
.topbar-toolbar {
  display: contents;
}

.topbar-toolbar-icons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.topbar-right .topbar-user {
  order: 1;
}

.topbar-right .nav-in-drawer {
  order: 2;
}

.topbar-right .topbar-toolbar-icons {
  order: 3;
}

.topbar-user {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  max-width: min(220px, 42vw);
  text-align: right;
}

.topbar-user-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.topbar-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-email {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.nav a:hover {
  color: var(--text);
  background: var(--card);
}

.btn-nav {
  background: var(--accent);
  color: var(--bg) !important;
  font-weight: 600;
}

.logout {
  color: var(--danger) !important;
}

.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.paper-hint {
  margin-bottom: 0.75rem;
}

.subcard {
  background: var(--surface);
  margin-bottom: 1.25rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.h2-inline {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.bon-chantier {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.bon-materiel {
  display: block;
  font-size: 0.8rem;
  color: var(--text, inherit);
  margin-top: 0.2rem;
  line-height: 1.35;
}

.bon-materiel-label {
  color: var(--muted);
  font-weight: 500;
  margin-right: 0.35rem;
}

.materiel-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.35rem 0 0.65rem;
}

.materiel-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.materiel-row input[name="materiel_items"] {
  flex: 1;
  min-width: 0;
}

.materiel-qty {
  width: 5rem;
  max-width: 5rem;
  flex: 0 0 5rem;
  text-align: center;
}

.btn-mat-remove {
  flex-shrink: 0;
  padding: 0.4rem 0.55rem;
  min-width: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--danger);
}

.btn-mat-remove:hover {
  border-color: var(--danger);
}

.materiel-list-read {
  margin: 0;
  padding-left: 1.1rem;
}

.materiel-block .materiel-add-btn {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card.narrow,
.login-card {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.card.mini {
  margin-bottom: 0.5rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.empty {
  padding: 2rem;
  text-align: center;
}

.form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.form input,
.form textarea,
.form select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .row-3 {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.wide {
  width: 100%;
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.alert-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.badge-warn {
  display: inline-block;
  background: rgba(245, 158, 11, 0.18);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.15em 0.55em;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.role-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.role-box h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.role-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.section-title {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.35rem;
}

.user-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.user-editor-head h3 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  min-width: 12rem;
}

.form-compact label {
  margin-bottom: 0.5rem;
}

/* Combobox + bouton « + » inline */
.inline-select-add {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.inline-select-add select {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.btn-inline-add {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
  padding: 0;
}

.btn-inline-add:hover,
.btn-inline-add.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.inline-add-panel {
  margin: -0.35rem 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.inline-add-panel-title {
  font-weight: 600;
  font-size: 0.88rem;
  display: block;
  margin-bottom: 0.3rem;
  color: var(--accent);
}

.inline-add-fields {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.inline-add-fields input[type="text"] {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
}

.inline-add-fields input[type="text"]:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.inline-add-fields .btn {
  align-self: flex-start;
  margin-top: 0.15rem;
}

.pass-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}

.badge-draft {
  background: #92400e;
  border-color: #f59e0b;
  color: #fbbf24;
  text-decoration: none;
  font-size: 0.72rem;
}
.badge-draft:hover { background: #78350f; }

.chantier-bon-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-draft {
  border-color: var(--muted);
  color: var(--muted);
}

.status-submitted {
  border-color: var(--accent);
  color: var(--accent);
}

.status-validated {
  border-color: var(--ok);
  color: var(--ok);
}

.status-signed {
  border-color: #6366f1;
  color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
}

.status-falko {
  border-color: #8b5cf6;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}

.bon-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bon-list li {
  margin-bottom: 0.5rem;
}

.bon-card {
  display: block;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.bon-card:hover {
  border-color: var(--accent);
}

.bon-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.bon-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.bon-date {
  font-weight: 600;
}

.bon-numero {
  color: var(--accent);
  font-family: "Consolas", "Monaco", monospace;
  letter-spacing: 0.03em;
}

.bp-numero {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.bon-worker {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.bon-vehicle {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.bon-client {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
}

.bon-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.bon-photos {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}
.bon-photos-icon {
  flex-shrink: 0;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.kv dt {
  margin: 0;
  color: var(--muted);
  font-weight: normal;
}

.kv dd {
  margin: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.photo-grid figure {
  margin: 0;
}

.photo-grid img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-grid figcaption {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.upload-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.inline-form {
  display: inline-block;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.tile {
  display: block;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  text-align: center;
}

.tile:hover {
  border-color: var(--accent);
}

.tile strong {
  display: block;
  font-size: 1.5rem;
  color: var(--accent);
}

.tile span {
  font-size: 0.85rem;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table code {
  font-size: 0.8rem;
  color: var(--accent);
}

.client-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.client-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.client-bon-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

code {
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.log-pre {
  margin: 0.75rem 0 0;
  padding: 1rem;
  max-height: 70vh;
  overflow: auto;
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Responsive tables --- */
.row-inactive {
  opacity: 0.5;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 520px) {
  .row-2 {
    grid-template-columns: 1fr;
  }
}

/* --- Boutons petits et danger --- */
.btn-sm {
  font-size: 0.82rem;
  padding: 0.3rem 0.65rem;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.3);
}

.btn-signer {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-weight: 600;
}

.btn-signer:hover {
  background: rgba(99, 102, 241, 0.25);
}

.btn-email {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-email:hover {
  background: rgba(59, 130, 246, 0.3);
}

.btn-falko {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.4);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.btn-falko:hover {
  background: rgba(139, 92, 246, 0.3);
}

/* --- Filtre recherche rapide --- */
.quick-filter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.quick-filter input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.quick-filter input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.quick-filter-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Filtres bons --- */

.bon-filters {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bon-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bon-filter-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.2rem;
}

.bon-filter-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.bon-filter-btn:hover {
  opacity: 0.85;
}

.bon-filter-btn[data-statut="all"] { border-color: var(--muted); color: var(--muted); }
.bon-filter-btn[data-statut="all"]:hover { border-color: var(--text); color: var(--text); }
.bon-filter-btn[data-statut="all"].active { background: var(--text); border-color: var(--text); color: var(--bg); }

.bon-filter-btn[data-statut="draft"] { border-color: var(--muted); color: var(--muted); }
.bon-filter-btn[data-statut="draft"].active { background: var(--muted); border-color: var(--muted); color: #fff; }

.bon-filter-btn[data-statut="submitted"] { border-color: #f59e0b; color: #f59e0b; }
.bon-filter-btn[data-statut="submitted"].active { background: #f59e0b; border-color: #f59e0b; color: #fff; }

.bon-filter-btn[data-statut="validated"] { border-color: #10b981; color: #10b981; }
.bon-filter-btn[data-statut="validated"].active { background: #10b981; border-color: #10b981; color: #fff; }

.bon-filter-btn[data-statut="signed"] { border-color: #6366f1; color: #6366f1; }
.bon-filter-btn[data-statut="signed"].active { background: #6366f1; border-color: #6366f1; color: #fff; }

.bon-filter-btn[data-statut="falko"] { border-color: #8b5cf6; color: #8b5cf6; }
.bon-filter-btn[data-statut="falko"].active { background: #8b5cf6; border-color: #8b5cf6; color: #fff; }

.bon-filter-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.bon-filter-toggle input {
  accent-color: #8b5cf6;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* --- Facturation --- */

.factu-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.factu-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.factu-tab:hover {
  background: var(--card);
  color: var(--text);
}

.factu-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.factu-tab-count {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.1rem 0.45rem;
  border-radius: 0.3rem;
  font-size: 0.8rem;
}

.factu-client-card {
  margin-bottom: 1rem;
}

.factu-client-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.factu-client-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.factu-table td {
  vertical-align: middle;
}

.factu-table a,
.factu-table a:link,
.factu-table a:visited {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

.factu-table a:hover {
  color: var(--accent);
}

.falko-ref {
  font-size: 0.85rem;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.3);
}

.chantier-closed {
  opacity: 0.7;
}

/* --- Édition inline articles / chantiers --- */
.edit-row td {
  background: var(--surface);
  padding: 0.75rem;
}

.form-inline-edit label {
  margin-bottom: 0.45rem;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.td-actions {
  white-space: nowrap;
}

.th-actions {
  width: 1%;
  white-space: nowrap;
}

/* --- Lignes véhicules (bon) --- */
.vehicle-lines-fieldset {
  border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin: 0 0 0.75rem;
}
.vehicle-lines-fieldset legend { font-weight: 700; font-size: 0.92rem; padding: 0 0.35rem; }
.vehicle-line {
  display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-light, #eee);
}
.vehicle-line:last-child { border-bottom: none; padding-bottom: 0; }
.veh-line-top {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: nowrap;
}
.veh-line-top select { flex: 1; min-width: 120px; }
.veh-line-bottom {
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
}
.veh-dur-h, .veh-dur-m { width: 52px; text-align: center; flex-shrink: 0; }
.veh-dur-sep { font-size: 0.82rem; color: var(--muted); }
.btn-inline-remove {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.1rem; padding: 0.2em; line-height: 1; border-radius: 4px;
}
.btn-inline-remove:hover { color: #c0392b; background: rgba(192,57,43,0.08); }
.service-line {
  display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; flex-wrap: wrap;
}
.service-line select { flex: 1; min-width: 140px; }

/* --- Chantiers admin --- */
.chantier-editor {
  margin-bottom: 0.75rem;
}

.chantier-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.chantier-workers {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--text);
}

.client-counts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chantier-bon-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.badge-chantier-count {
  background: rgba(100, 116, 139, 0.1);
  color: var(--muted);
  border: 1px solid rgba(100, 116, 139, 0.25);
  font-weight: 500;
  text-decoration: none;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.chantier-name-link {
  text-decoration: none;
  color: var(--text);
  transition: color 0.15s;
}

.chantier-name-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.chantier-name-link.muted {
  color: var(--muted);
}

.chantier-name-link.muted:hover {
  color: var(--accent);
}

.chantier-detail-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chantier-photo-fig {
  position: relative;
}

.photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  gap: 0.5rem;
}

.chantier-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chantier-edit-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* --- Validation bureau --- */
.validation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Édition bon inline --- */
.edit-mode-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.edit-mode-header h2 {
  margin: 0;
}

.edit-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dd-pre {
  white-space: pre-wrap;
}

/* --- Statuts par client --- */
.client-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

/* --- Vue mobile admin (sans barre du haut) --- */
body.page-hide-topbar .main {
  padding-top: 0.65rem;
  max-width: 520px;
}

.admin-vue-mobile {
  padding-bottom: 2rem;
}

.admin-vue-mobile h1 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.admin-vue-mobile-lead {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.admin-vue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 380px) {
  .admin-vue-grid {
    grid-template-columns: 1fr;
  }

  .admin-vue-tile-span2 {
    grid-column: 1;
  }
}

.admin-vue-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: 0.65rem 0.75rem;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}

.admin-vue-tile:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.admin-vue-tile-accent {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent-dim);
}

.admin-vue-tile-accent:hover {
  opacity: 0.93;
  color: var(--bg);
  border-color: var(--accent);
}

.admin-vue-tile-span2 {
  grid-column: 1 / -1;
}

.admin-vue-exit {
  margin: 0;
  text-align: center;
  font-size: 0.88rem;
}

.admin-vue-exit a {
  font-weight: 600;
  text-decoration: none;
}

.admin-vue-exit a:first-of-type {
  color: var(--accent);
}

.admin-vue-exit a:first-of-type:hover {
  text-decoration: underline;
}

.admin-vue-exit-sep {
  margin: 0 0.35rem;
  color: var(--muted);
}

.admin-vue-logout {
  color: var(--danger);
}

.admin-vue-logout:hover {
  text-decoration: underline;
}

/* --- Plan du site --- */
.sitemap-section {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

.sitemap-section .muted {
  font-weight: 400;
}

.sitemap {
  margin: 0 0 0.75rem;
  padding: 0;
}

.sitemap dt {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.65rem;
}

.sitemap dt a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
}

/* Raccourcis chantiers récents — nouveau bon */
.bon-recent-chantiers {
  margin-bottom: 1rem;
}
.bon-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}
.bon-recent-tile {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.bon-recent-tile:hover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.bon-recent-tile-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--accent);
}
.bon-recent-tile-client {
  font-size: 0.8rem;
  color: var(--text);
}

.sitemap dt a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sitemap dd {
  margin: 0.15rem 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* --- Filter banner --- */
.filter-banner {
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* --- Bon count link (admin chantiers/clients) --- */
.chantier-bon-link {
  text-decoration: none;
  color: var(--bg);
  background: var(--accent);
  padding: 0.15em 0.55em;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  transition: opacity 0.15s;
}

.chantier-bon-link:hover {
  opacity: 0.8;
}

/* --- Admin sub-navigation --- */
.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-subnav-item {
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.admin-subnav-item:hover {
  background: var(--card);
  color: var(--text);
}

.admin-subnav-item.active {
  background: var(--accent);
  color: var(--bg);
}

.admin-subnav-item.admin-subnav-bon-plus {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.admin-subnav-item.admin-subnav-bon-plus:hover {
  opacity: 0.92;
  color: var(--bg);
}

.admin-subnav-item.admin-subnav-bon-plus.active {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.admin-subnav-item.admin-subnav-bon-plus {
  margin-left: auto;
}

@media (max-width: 900px) {
  .admin-subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 0.2rem;
    padding: 0.2rem 0.3rem;
    margin-bottom: 0.55rem;
    scrollbar-width: thin;
  }
  .admin-subnav-item {
    flex-shrink: 0;
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
    white-space: nowrap;
  }
}

/* --- Photo source & camera --- */
.photo-source-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.photo-source-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.photo-file-name {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.camera-thumb {
  margin-bottom: 0.5rem;
}

.camera-thumb img {
  max-width: 180px;
  max-height: 120px;
  border-radius: 8px;
  border: 2px solid var(--accent);
}

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.camera-modal-inner {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.camera-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.camera-modal-inner video {
  width: 100%;
  max-height: 60vh;
  object-fit: cover;
  background: #000;
  flex: 1;
  min-height: 200px;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

@media (max-width: 500px) {
  .camera-modal-inner {
    max-width: 100%;
    border-radius: 0;
    height: 100%;
  }
  .camera-modal-inner video {
    max-height: calc(100vh - 120px);
  }
}

/* --- Signature pad --- */
.signature-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.signature-modal-inner {
  background: var(--card);
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  padding: 1rem 1.25rem 1.25rem;
}

.signature-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.signature-canvas-wrap {
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.signature-canvas-wrap canvas {
  display: block;
  width: 100%;
}

.signature-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.signature-card {
  border-left: 4px solid #6366f1;
}

.signature-display {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
  max-width: 400px;
}

.signature-img {
  max-width: 100%;
  height: auto;
  max-height: 180px;
}

.signature-signer {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

@media (max-width: 500px) {
  .signature-modal-inner {
    max-width: 100%;
    border-radius: 10px;
  }
}

/* --- Dashboard bons --- */
.dashboard-card {
  margin-bottom: 1.5rem;
}

.dashboard-card h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.dashboard-card h3 {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.dash-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.5rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none !important;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

a.dash-stat,
a.dash-stat:link,
a.dash-stat:visited,
a.dash-stat:hover,
a.dash-stat:active,
a.dash-stat *{
  text-decoration: none !important;
  color: inherit;
}

.dash-stat:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
  background: var(--card);
}

.dash-stat:active {
  transform: translateY(0);
  box-shadow: none;
  background: var(--surface);
}

.dash-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.dash-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.dash-total .dash-number { color: var(--text); }
.dash-draft .dash-number { color: var(--muted); }
.dash-submitted .dash-number { color: var(--accent); }
.dash-validated .dash-number { color: var(--ok); }
.dash-signed .dash-number { color: #6366f1; }
.dash-falko .dash-number { color: #8b5cf6; }

.dash-progress {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 1rem;
  background: var(--surface);
}

.dash-bar {
  height: 100%;
  min-width: 2px;
  transition: width 0.4s ease;
}

.dash-bar-validated { background: var(--ok); }
.dash-bar-submitted { background: var(--accent); }
.dash-bar-signed { background: #6366f1; }
.dash-bar-falko { background: #8b5cf6; }
.dash-bar-draft { background: var(--muted); }

.dash-activity {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.dash-activity strong {
  color: var(--text);
}

.dash-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.dash-recent-header h3 {
  margin: 0;
}

.dash-recent {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dash-recent-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.75rem;
  padding-right: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.dash-recent-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  background: #fff;
}

.dash-recent-item:active {
  background: rgba(234, 135, 28, 0.06);
}

.dash-recent-arrow {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--muted);
  font-weight: 300;
  transition: color 0.15s, right 0.15s;
}

.dash-recent-item:hover .dash-recent-arrow {
  color: var(--accent);
  right: 0.45rem;
}

.dash-recent-row1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-recent-row2 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.8rem;
  padding-left: 0.15rem;
}

.badge-sm {
  font-size: 0.72rem;
  padding: 0.15em 0.55em;
}

.dash-recent-num {
  font-weight: 600;
  min-width: 5.5em;
}

.dash-recent-worker {
  color: var(--muted);
  font-size: 0.82rem;
}

.dash-recent-date {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: auto;
}

.dash-recent-client {
  color: var(--text);
  font-weight: 500;
}

.dash-recent-chantier {
  color: var(--accent);
}

.dash-recent-active {
  color: var(--ok);
  font-weight: 600;
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.12);
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
}

@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-activity {
    flex-direction: column;
    gap: 0.35rem;
  }
}

/* --- Sauvegardes --- */
.backup-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0.65rem 0 1rem;
  font-size: 0.9rem;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.backup-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.backup-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.backup-info strong {
  word-break: break-all;
  font-size: 0.88rem;
}

.backup-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* --- Notification bulle suggestions --- */
.notif-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.notif-btn:hover { color: var(--accent); background: var(--surface); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 99px;
  padding: 0 4px;
  pointer-events: none;
}

/* --- Paramètres (roue dentée) --- */
.settings-wrap {
  position: relative;
  flex-shrink: 0;
}

.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.settings-btn:hover,
.settings-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.settings-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  margin-bottom: 0.65rem;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.settings-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  color: var(--text);
}

.settings-check-row input {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.settings-check-hint {
  margin: 0.35rem 0 0;
  padding-left: 0.1rem;
  line-height: 1.35;
}

.theme-options {
  display: flex;
  gap: 0.4rem;
}

.theme-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.25rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  transition: border-color 0.15s;
}

.theme-option:hover {
  border-color: var(--muted);
}

.theme-option.active {
  border-color: var(--accent);
}

.theme-preview {
  display: block;
  width: 28px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

.theme-preview-dark {
  background: linear-gradient(135deg, #0f172a 50%, #1e293b 50%);
}

.theme-preview-light {
  background: linear-gradient(135deg, #f1f5f9 50%, #ffffff 50%);
  border-color: rgba(0,0,0,0.15);
}

.theme-preview-custom {
  background: linear-gradient(135deg, #0f172a 40%, var(--accent) 100%);
}

.accent-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.accent-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.accent-dot:hover {
  transform: scale(1.15);
}

.accent-dot.active {
  border-color: var(--text);
}

@media (max-width: 500px) {
  .settings-panel {
    width: calc(100vw - 2rem);
    right: -0.5rem;
  }
}

/* --- Bouton suggestion dans paramètres --- */
.settings-suggest-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.settings-suggest-btn:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.settings-link-btn {
  text-decoration: none;
  box-sizing: border-box;
}

.settings-admin-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* --- Server health dashboard --- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.health-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.health-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.health-row:last-child { border-bottom: none; }
.health-row-wrap { align-items: flex-start; }
.health-ssl-line {
  max-width: 65%;
  text-align: right;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.35;
}
.health-status { font-weight: 700; text-transform: uppercase; font-size: 0.78rem; }
.health-ok { color: #22c55e; }
.health-warn { color: #f59e0b; }
.health-err { color: #ef4444; }
.health-bar-wrap {
  height: 10px;
  background: var(--surface);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}
.health-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.3s;
}
.health-bar-warn { background: #ef4444; }
.health-bar-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.health-pre {
  background: var(--surface);
  padding: 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text);
  margin: 0;
}

/* --- Admin suggestions list --- */
.suggestion-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-unread {
  border-left: 3px solid var(--accent);
  background: rgba(245, 158, 11, 0.05);
}
.suggestion-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.suggestion-item-body {
  margin: 0.4rem 0 0.5rem;
  white-space: pre-wrap;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}
.suggestion-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.suggestion-readers, .suggestion-approvers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.suggestion-meta-icon {
  font-weight: 600;
  color: var(--muted);
}
.suggestion-meta-full {
  color: #22c55e;
}
.suggestion-reader-name, .suggestion-approver-name {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.72rem;
  color: var(--text);
}
.suggestion-approver-name {
  border-color: var(--accent);
  color: var(--accent);
}
.suggestion-item-actions {
  display: flex;
  gap: 0.5rem;
}

.suggestion-done {
  opacity: 0.65;
  border-left: 3px solid var(--ok);
  background: rgba(16, 185, 129, 0.04);
}

.suggestion-done-banner {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ok);
  margin-bottom: 0.4rem;
  padding: 0.3rem 0.5rem;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 0.3rem;
  display: inline-block;
}

.btn-done {
  background: rgba(16, 185, 129, 0.12);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 600;
}

.btn-done:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-done-active {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* --- Modale suggestion --- */
.suggestion-overlay[hidden] { display: none; }
.suggestion-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.suggestion-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.suggestion-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.suggestion-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}

.suggestion-close:hover {
  color: var(--danger);
}

.suggestion-form {
  padding: 1rem;
}

.suggestion-form label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.suggestion-form input,
.suggestion-form textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.suggestion-form input:focus,
.suggestion-form textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.suggestion-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.veh-obu { width: 80px; text-align: right; flex-shrink: 0; }

.veh-time-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.veh-time {
  width: 7.5rem;
  font-size: 0.9rem;
  padding: 0.3rem 0.4rem;
}
.veh-dur-calc {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.svc-note {
  flex: 1;
  min-width: 120px;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.veh-trailer-chk {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}
.veh-trailer-chk input[type="hidden"] { display: none; }

.factu-total-row td {
  background: var(--bg-alt, #f0f4f8);
  border-top: 2px solid var(--primary);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.badge-devis {
  background: #eef4ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.badge-devis:hover { background: #dbeafe; }

.plage2-toggle-row { margin: 0.15rem 0 0.5rem; }

.pause-field { margin-bottom: 0.5rem; }
.pause-label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
.pause-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.pause-btn {
  padding: 0.35rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.pause-btn:hover { border-color: var(--primary); color: var(--primary); }
.pause-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pause-custom {
  width: 72px;
  text-align: center;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  padding: 0.35rem 0.4rem;
}

.sug-dictee-zone {
  margin-bottom: 0.6rem;
}
.sug-dictee-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.sug-dictee-mic {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(245, 158, 11, 0.08);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.sug-dictee-mic:hover {
  background: rgba(245, 158, 11, 0.18);
}
.sug-dictee-mic.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: sug-pulse 1.2s ease-in-out infinite;
}
@keyframes sug-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.sug-dictee-status {
  font-size: 0.8rem;
  color: var(--muted);
}
.sug-dictee-status.recording { color: var(--danger); font-weight: 600; }
.sug-dictee-status.loading { color: var(--accent); }
.sug-dictee-status.success { color: var(--ok); }
.sug-dictee-status.error { color: var(--danger); }

/* --- Toast confirmation --- */
.suggestion-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  background: var(--ok);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease, toastOut 0.4s ease 4s forwards;
}

.suggestion-toast-err {
  background: var(--danger);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* ============================
   Admin — Appareils connectés
   ============================ */
.device-list-card { padding: 0; overflow: hidden; }
.device-table-wrap { overflow-x: auto; }

.device-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.device-table thead {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.device-table th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.device-table td {
  padding: 0.55rem 0.75rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.device-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.device-date { white-space: nowrap; }
.device-user-name { font-weight: 600; display: block; }
.device-user-email { font-size: 0.8rem; display: block; }
.device-label { max-width: 220px; }
.device-ip code { font-size: 0.82rem; background: var(--surface); padding: 0.1em 0.35em; border-radius: 4px; }
.device-isp { font-size: 0.78rem; }

.device-last-seen { font-size: 0.78rem; display: block; }
.device-pages { text-align: center; }

.badge-page-count {
  display: inline-block;
  min-width: 28px;
  padding: 0.15em 0.5em;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

.btn-map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-map:hover { transform: scale(1.1); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

@media (max-width: 900px) {
  .device-table { font-size: 0.82rem; }
  .device-table th,
  .device-table td { padding: 0.45rem 0.5rem; }
  .device-label { max-width: 150px; word-break: break-word; }
}

.back-arrow {
  text-decoration: none;
  color: var(--muted);
  margin-right: 0.4rem;
  font-size: 1.3em;
  transition: color 0.15s;
}
.back-arrow:hover { color: var(--accent); }

.fab-save {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab-save:hover { transform: scale(1.1); box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
.fab-save:active { transform: scale(0.95); }

/* --- Dictée vocale IA --- */
.dictee-card {
  border: 2px dashed var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.dictee-card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.dictee-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.dictee-mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.dictee-mic-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dictee-mic-btn.recording {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  animation: dictee-pulse 1.2s ease-in-out infinite;
}

@keyframes dictee-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.dictee-or {
  font-size: 0.8rem;
  color: var(--muted);
}

.dictee-textarea {
  width: 100%;
  min-height: 60px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  resize: vertical;
  transition: border-color 0.2s;
}

.dictee-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.dictee-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.dictee-analyse-btn {
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
}

.dictee-status {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.2s;
}

.dictee-status.recording { color: #ef4444; font-weight: 600; }
.dictee-status.loading { color: var(--accent); }
.dictee-status.success { color: #10b981; font-weight: 600; }
.dictee-status.error { color: #ef4444; }

.dictee-filled {
  animation: dictee-highlight 2s ease-out;
}

@keyframes dictee-highlight {
  0% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.5); }
  100% { box-shadow: none; }
}

/* --- Bouton micro topbar (haut gauche) --- */
.topbar-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.topbar-mic-btn:hover {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 900px) {
  .topbar-mic-btn {
    width: 30px;
    height: 30px;
  }
  .topbar-mic-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* --- Bouton micro dans la nav --- */
.btn-nav-mic {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-nav-mic:hover {
  background: var(--accent);
  color: #fff;
}

.admin-subnav-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.admin-subnav-mic:hover {
  background: var(--accent);
  color: #fff;
}

/* --- Overlay dictée rapide --- */
.quick-dictee-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.quick-dictee-overlay[hidden] {
  display: none !important;
}

body.quick-dictee-open { overflow: hidden; }

.quick-dictee-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.quick-dictee-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: color 0.15s;
}

.quick-dictee-close:hover { color: var(--text); }

.quick-dictee-mic-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--border);
  color: var(--muted);
  margin: 0 auto 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.quick-dictee-mic-ring.recording {
  border-color: #ef4444;
  color: #ef4444;
  animation: quick-dictee-pulse 1.5s ease-in-out infinite;
}

.quick-dictee-mic-ring.loading {
  border-color: var(--accent);
  color: var(--accent);
  animation: quick-dictee-spin 1.2s linear infinite;
}

@keyframes quick-dictee-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
}

@keyframes quick-dictee-spin {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
}

.quick-dictee-status {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.quick-dictee-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
  text-align: left;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

.qd-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: background 0.3s;
}

.qd-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}

.qd-label {
  font-weight: 600;
  color: var(--muted);
  min-width: 65px;
  flex-shrink: 0;
  transition: color 0.3s;
}

.qd-val {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qd-check.qd-green .qd-dot { background: #10b981; }
.qd-check.qd-green .qd-label { color: #10b981; }
.qd-check.qd-green .qd-val { color: var(--text); }
.qd-check.qd-green { background: rgba(16, 185, 129, 0.08); }

.qd-check.qd-orange .qd-dot { background: #f59e0b; }
.qd-check.qd-orange .qd-label { color: #f59e0b; }
.qd-check.qd-orange .qd-val { color: #f59e0b; }
.qd-check.qd-orange { background: rgba(245, 158, 11, 0.08); }

.quick-dictee-mic-ring.done {
  border-color: #10b981;
  color: #10b981;
}

/* --- Bannière installation PWA --- */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--card);
  border-top: 2px solid var(--accent);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* --- Toggle row dans paramètres --- */
.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 0.5rem;
  color: var(--text);
}

.settings-toggle-row:hover {
  background: var(--hover);
}

.settings-toggle-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.pwa-install-banner[hidden] { display: none !important; }

.pwa-install-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.pwa-install-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.quick-dictee-text {
  font-size: 0.9rem;
  color: var(--text);
  width: 100%;
  min-height: 4rem;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  margin-bottom: 1rem;
  line-height: 1.5;
  padding: 0.5rem;
  font-family: inherit;
}

.quick-dictee-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Calendrier Exchange — bouton + panneau split ────────── */
.cal-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.cal-toggle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.cal-toggle-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--card);
}

.app-layout {
  display: flex;
  min-height: 0;
}

.app-layout .main {
  flex: 1 1 0;
  min-width: 0;
  transition: max-width 0.25s ease;
}

.app-layout.cal-open .main {
  max-width: calc(100% - 360px);
}

.cal-panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  overflow: hidden;
}

.cal-panel[hidden],
.map-panel[hidden] {
  display: none !important;
}

.cal-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

.cal-panel-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.cal-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.cal-nav-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cal-nav-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 130px;
  text-align: center;
}

.cal-panel-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.25rem;
  margin-left: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

.cal-panel-close:hover {
  color: var(--danger);
}

.cal-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem;
}

.cal-loading,
.cal-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 0;
}

.cal-error {
  text-align: center;
  color: var(--danger);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

.cal-day-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.04em;
  padding: 0.6rem 0 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}

.cal-event {
  background: var(--card);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
  border-left: 3px solid var(--accent);
}

.cal-event-allday {
  border-left-color: var(--ok);
}

.cal-event-chantier {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.cal-event-planning {
  background: rgba(59, 130, 246, 0.08);
}

.cal-event-time {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.cal-event-subject {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.cal-event-location {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ── Carte des chantiers — panneau ────────────────────────── */
.map-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  overflow: hidden;
}

.map-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.map-panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

.map-geocode-btn {
  margin-left: auto;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.map-geocode-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.map-geocode-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.map-panel-body {
  flex: 1;
  min-height: 0;
}

.map-panel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.map-marker-icon {
  background: transparent !important;
  border: none !important;
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: 8px !important;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
}

.leaflet-popup-content a {
  color: var(--accent) !important;
}

.cal-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .cal-panel,
  .map-panel {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    z-index: 1001;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  }

  .cal-panel {
    width: min(320px, 85vw);
  }

  .map-panel {
    width: 100%;
    max-width: 400px;
  }

  .app-layout.cal-open .main {
    max-width: 100%;
  }

  .cal-toggle-btn {
    width: 30px;
    height: 30px;
  }

  .cal-toggle-btn svg {
    width: 16px;
    height: 16px;
  }

  .cal-panel-head {
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem 0.55rem;
  }

  .cal-panel-close {
    font-size: 1.6rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
  }

  .cal-backdrop[hidden] {
    display: none !important;
  }

  .cal-backdrop:not([hidden]) {
    display: block;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BON EDIT PANEL (facturation aperçu)
   ═══════════════════════════════════════════════════════════════ */
.bon-edit-panel {
  position: fixed;
  right: 0;
  top: 60px;
  width: 600px;
  height: calc(100vh - 60px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease;
}

.bon-edit-panel[hidden] {
  display: none !important;
}

.app-layout.bon-panel-open .main {
  margin-right: 600px;
  transition: margin-right 0.25s ease;
}

.bon-edit-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bon-edit-panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bon-edit-panel-body {
  flex: 1;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .bon-edit-panel {
    width: 500px;
  }
  .app-layout.bon-panel-open .main {
    margin-right: 500px;
  }
}

@media (max-width: 900px) {
  .bon-edit-panel {
    top: 0;
    height: 100vh;
    width: min(500px, 92vw);
  }
  .app-layout.bon-panel-open .main {
    margin-right: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PLANNING
   ═══════════════════════════════════════════════════════════════ */
.planning-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 60px);
  margin: -1rem -1rem 0;
}

.planning-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
  overflow: hidden;
}
.planning-sidebar.collapsed { width: 0; min-width: 0; padding: 0; border-right: none; }
.ps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.ps-header h2 { margin: 0; font-size: 1rem; }
.ps-search {
  margin: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
}
.ps-tabs { display: flex; gap: 0; padding: 0 0.5rem; margin-bottom: 0.5rem; }
.ps-tab {
  flex: 1;
  padding: 0.3rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.ps-tab:first-child { border-radius: 6px 0 0 6px; }
.ps-tab:last-child { border-radius: 0 6px 6px 0; }
.ps-tab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.ps-list { flex: 1; overflow-y: auto; padding: 0 0.5rem 0.5rem; }
.ps-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  user-select: none;
}
.ps-item:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.ps-item.dragging { opacity: 0.4; transform: scale(0.95); }
.ps-item-color { width: 6px; height: 32px; border-radius: 3px; flex-shrink: 0; }
.ps-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ps-item-name { font-weight: 600; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-item-client { font-size: 0.72rem; color: var(--muted); }
.ps-item-statut { font-size: 0.65rem; flex-shrink: 0; }

.planning-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.pm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pm-nav { display: flex; align-items: center; gap: 0.4rem; }
.pm-period-label { margin: 0 0 0 0.5rem; font-size: 1rem; font-weight: 600; white-space: nowrap; }
.pm-views { display: flex; gap: 0; }
.pm-view-btn {
  padding: 0.35rem 0.7rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pm-view-btn:first-child { border-radius: 6px 0 0 6px; }
.pm-view-btn:last-child { border-radius: 0 6px 6px 0; }
.pm-view-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.pm-grid-wrapper { flex: 1; overflow: auto; padding: 0.5rem; }

/* Week */
.pm-week { display: flex; flex-direction: column; height: 100%; }
.pm-week-header, .pm-month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 2px;
}
.pm-col-head {
  text-align: center;
  padding: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border-radius: 6px 6px 0 0;
}
.pm-col-head.today { color: var(--accent); }
.pm-col-date { display: block; font-size: 1.1rem; color: var(--text); }
.pm-col-head.today .pm-col-date {
  background: var(--accent);
  color: var(--bg);
  width: 28px; height: 28px; line-height: 28px;
  border-radius: 50%;
  margin: 0.15rem auto 0;
  display: inline-block;
}
.pm-week-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  flex: 1;
  min-height: 300px;
}
.pm-day-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 120px;
  transition: background 0.15s;
}
.pm-day-col.today { border-color: var(--accent); }
.pm-day-col.drag-over, .pm-month-cell.drag-over {
  background: rgba(245,158,11,0.08);
  border-color: var(--accent);
}
.pm-day-add {
  text-align: center;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  margin-top: auto;
}
.pm-day-add:hover { background: var(--surface); color: var(--accent); }

/* Month */
.pm-month-body { display: flex; flex-direction: column; gap: 1px; }
.pm-month-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.pm-month-cell {
  min-height: 80px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.pm-month-cell.outside { background: var(--bg); cursor: default; opacity: 0.3; }
.pm-month-cell.today { border-color: var(--accent); }
.pm-cell-num { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.pm-month-cell.today .pm-cell-num { color: var(--accent); }
.pm-more { font-size: 0.65rem; color: var(--accent); font-weight: 600; }

/* Day */
.pm-day { padding: 0.5rem; }
.pm-day-events { display: flex; flex-direction: column; gap: 0.5rem; }
.pm-day-event {
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pm-day-event:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
.pm-day-ev-head { display: flex; align-items: center; gap: 0.5rem; }
.pm-ev-resources { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.pm-day-add-big {
  text-align: center;
  padding: 1rem;
  margin-top: 0.5rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.pm-day-add-big:hover { border-color: var(--accent); color: var(--accent); background: rgba(245,158,11,0.05); }

/* Chips */
.pm-chip {
  padding: 0.25rem 0.4rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: transform 0.12s, box-shadow 0.12s;
  overflow: hidden;
}
.pm-chip:hover { transform: scale(1.03); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.pm-chip.compact { font-size: 0.65rem; padding: 0.15rem 0.3rem; }
.pm-chip-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.pm-chip-res { font-size: 0.65rem; opacity: 0.8; flex-shrink: 0; }

@keyframes dropIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.drop-anim { animation: dropIn 0.35s cubic-bezier(0.34,1.56,0.64,1); }

/* Modal */
.planning-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: planFadeIn 0.15s ease;
}
@keyframes planFadeIn { from { opacity: 0; } to { opacity: 1; } }
.planning-modal-inner {
  background: var(--card);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: planSlideUp 0.2s ease;
}
@keyframes planSlideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.planning-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.planning-modal-body {
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.planning-modal-body label { font-size: 0.85rem; font-weight: 500; }
.planning-modal-body select[multiple] { min-height: 80px; }
.planning-modal-foot {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

.color-picker { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.25rem; }
.color-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: var(--text); transform: scale(1.15); }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; cursor: pointer; }

@media (max-width: 768px) {
  .planning-layout { flex-direction: column; margin: -0.5rem -0.5rem 0; }
  .planning-sidebar {
    width: 100% !important; min-width: 0 !important;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .planning-sidebar.collapsed { max-height: 0; }
  .pm-week-body { min-height: 200px; }
  .pm-day-col { min-height: 80px; }
  .pm-month-cell { min-height: 55px; }
  .pm-toolbar { padding: 0.35rem 0.5rem; }
  .pm-period-label { font-size: 0.85rem; }
}

/* ── Galerie photos ─────────────────────────────── */
.photos-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}
.photos-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.photos-filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.photos-filter-chip.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.photos-filter-count {
  font-size: 0.75rem;
  background: rgba(255,255,255,0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
}
.photos-filter-chip.active .photos-filter-count {
  background: rgba(0,0,0,0.2);
}

.photos-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

@media (max-width: 600px) {
  .photos-gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.6rem;
  }
}

.photos-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.12s;
}
.photos-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.photos-card-img {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface, #0f172a);
}
.photos-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.photos-card-img:hover img {
  transform: scale(1.05);
}

.photos-card-info {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.photos-card-chantier {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}
.photos-card-bon {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}
.photos-card-bon:hover {
  color: var(--accent);
  text-decoration: underline;
}
.photos-card-client {
  font-size: 0.75rem;
  color: var(--muted);
}
.photos-card-caption {
  font-size: 0.75rem;
  color: var(--text);
  font-style: italic;
  margin-top: 0.1rem;
}

/* ── Lightbox photos ── */
.photos-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photos-lightbox[hidden] { display: none; }

.photos-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}
.photos-lightbox-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 2rem;
}
.photos-lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  z-index: 1;
}
.photos-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 2;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.photos-lightbox-close:hover { opacity: 1; }

.photos-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 2;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
.photos-lightbox-nav:hover { opacity: 1; background: rgba(0, 0, 0, 0.7); }
.photos-lightbox-prev { left: 1rem; }
.photos-lightbox-next { right: 1rem; }

.photos-lightbox-caption {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  z-index: 2;
  max-width: 80%;
  text-align: center;
}
.photos-lightbox-caption:empty { display: none; }

/* ── Weather badge ── */
.weather-badge {
  display: inline-block;
  background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  color: #0c4a6e;
}

/* ── Formulaire bon : sections colorées ── */
.bf-section {
  border-left: 4px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
}
.bf-section > legend {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.12rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.92rem;
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
}
.bf-section-icon { font-size: 1.05rem; line-height: 1; }
.bf-section-header { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.06); }
.bf-section-header > legend { background: rgba(239, 68, 68, 0.18); color: #b91c1c; }
.bf-section-vehicles { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.06); }
.bf-section-vehicles > legend { background: rgba(59, 130, 246, 0.18); color: #2563eb; }
.bf-section-services { border-left-color: #10b981; background: rgba(16, 185, 129, 0.06); }
.bf-section-services > legend { background: rgba(16, 185, 129, 0.18); color: #047857; }
.bf-section-materiel { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.07); }
.bf-section-materiel > legend { background: rgba(245, 158, 11, 0.20); color: #b45309; }
.bf-section-place { border-left-color: #ec4899; background: rgba(236, 72, 153, 0.06); }
.bf-section-place > legend { background: rgba(236, 72, 153, 0.18); color: #be185d; }
.bf-section-time { border-left-color: #8b5cf6; background: rgba(139, 92, 246, 0.06); }
.bf-section-time > legend { background: rgba(139, 92, 246, 0.18); color: #6d28d9; }
.bf-section-notes { border-left-color: #0ea5e9; background: rgba(14, 165, 233, 0.05); }
.bf-section-notes > legend { background: rgba(14, 165, 233, 0.18); color: #0369a1; }

html:not([data-theme="light"]) .bf-section { background: rgba(148, 163, 184, 0.08); }
html:not([data-theme="light"]) .bf-section > legend { color: #ffffff; }
html:not([data-theme="light"]) .bf-section-header { background: rgba(239, 68, 68, 0.10); }
html:not([data-theme="light"]) .bf-section-header > legend { background: rgba(239, 68, 68, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-vehicles { background: rgba(59, 130, 246, 0.10); }
html:not([data-theme="light"]) .bf-section-vehicles > legend { background: rgba(59, 130, 246, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-services { background: rgba(16, 185, 129, 0.10); }
html:not([data-theme="light"]) .bf-section-services > legend { background: rgba(16, 185, 129, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-materiel { background: rgba(245, 158, 11, 0.12); }
html:not([data-theme="light"]) .bf-section-materiel > legend { background: rgba(245, 158, 11, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-place { background: rgba(236, 72, 153, 0.10); }
html:not([data-theme="light"]) .bf-section-place > legend { background: rgba(236, 72, 153, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-time { background: rgba(139, 92, 246, 0.12); }
html:not([data-theme="light"]) .bf-section-time > legend { background: rgba(139, 92, 246, 0.55); color: #ffffff; }
html:not([data-theme="light"]) .bf-section-notes { background: rgba(14, 165, 233, 0.10); }
html:not([data-theme="light"]) .bf-section-notes > legend { background: rgba(14, 165, 233, 0.55); color: #ffffff; }

/* ── Note IA (carte read-only sur la page d'un bon) ── */
.ai-note-card { border-left: 4px solid #6366f1; }
.ai-note-card.ai-sev-warning { border-left-color: #f59e0b; }
.ai-note-card.ai-sev-alert { border-left-color: #ef4444; background: rgba(239,68,68,0.04); }
.ai-note-card.ai-sev-ok { border-left-color: #10b981; }
.ai-note-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.ai-note-icon { font-size: 1.1rem; }
.ai-note-body { margin: 0.2rem 0 0.4rem; line-height: 1.45; white-space: pre-wrap; }
.ai-note-foot { margin: 0; }
.badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; padding: 0.1em 0.55em; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.badge-warning { background: rgba(245,158,11,0.18); color: #d97706; padding: 0.1em 0.55em; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.badge-ok { background: rgba(16,185,129,0.18); color: #10b981; padding: 0.1em 0.55em; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
