/* ThermiPro — Direction B « Premium »
   Remplace static/css/thermipro.css. Les noms de variables et de classes existants
   sont conservés pour que les templates actuels (et leurs var() inline) basculent
   sans réécriture. Les nouveaux tokens sont préfixés --b-. */


:root {
  /* Neutres */
  --b-bg:            #F6F3EE;
  --b-surface:       #FFFDF9;
  --b-surface-hover: #FAF7F2;
  --b-border:        #E7E1D6;
  --b-border-soft:   #EFEAE2;
  --b-border-strong: #D5CDBF;
  --b-text:          #1D1B18;
  --b-text-2:        #57524A;
  --b-text-3:        #736D63;
  --b-text-disabled: #A8A196;
  --b-sep:           #C4BCAE;
  /* Navigation */
  --b-sidebar:        #1B2330;
  --b-sidebar-text:   #C9C3B8;
  --b-sidebar-label:  #8C94A1;
  --b-sidebar-active: rgba(255,255,255,.09);
  --b-sidebar-icon-active: #E08A5C;
  /* Accent cuivre (flamme du logo) */
  --b-accent:        #B4532A;
  --b-accent-hover:  #96431F;
  --b-accent-soft:   #F6E7DD;
  --b-accent-muted:  #E8D3C4;
  --b-accent-disabled: #DDB39E;
  --b-focus:         #EFD6C7;
  /* Fonctionnelles : texte / fond */
  --b-success: #2F6B3F; --b-success-bg: #E6EFE3;
  --b-warning: #8A5A12; --b-warning-bg: #F5EAD3; --b-warning-dot: #A8741F;
  --b-error:   #A3342A; --b-error-bg:   #F6E2DE; --b-error-border: #E9C3BB;
  --b-info:    #2D5779; --b-info-bg:    #E3ECF2;
  --b-neutral: #57524A; --b-neutral-bg: #EEEAE3;
  /* Rayons, ombres */
  --b-r-xs: 4px; --b-r-sm: 6px; --b-r-md: 8px; --b-r: 10px; --b-r-card: 14px; --b-r-full: 999px;
  --b-shadow-card:  0 1px 2px rgba(29,27,24,.04), 0 12px 32px -20px rgba(29,27,24,.22);
  --b-shadow-xs:    0 1px 2px rgba(29,27,24,.06);
  --b-shadow-menu:  0 8px 24px rgba(29,27,24,.10);
  --b-shadow-modal: 0 16px 48px rgba(29,27,24,.18);
  --b-ring: 0 0 0 3px var(--b-focus);

  /* ── Alias rétro-compatibles (utilisés partout en inline dans les templates) ── */
  --orange:       var(--b-accent);
  --orange-light: var(--b-accent-hover);
  --orange-dim:   var(--b-accent-soft);
  --orange-glow:  var(--b-focus);
  --navy:         var(--b-sidebar);
  --navy-mid:     #222B3A;
  --navy-light:   #2B3546;
  --navy-border:  rgba(255,255,255,.08);
  --bg:           var(--b-bg);
  --surface:      var(--b-surface);
  --surface-2:    var(--b-bg);
  --text-primary:   var(--b-text);
  --text-secondary: var(--b-text-2);
  --text-muted:     var(--b-text-3);
  --green:  var(--b-success);
  --red:    var(--b-error);
  --yellow: var(--b-warning);
  --blue:   var(--b-info);
  --sidebar-w:      240px;
  --sidebar-w-mini: 64px;
  --topbar-h:       56px;
  --radius:         var(--b-r);
  --radius-lg:      var(--b-r-card);
  --shadow:         var(--b-shadow-card);
  --shadow-lg:      var(--b-shadow-modal);
  --font-display: 'Newsreader', Georgia, serif;
  --font-body:    'Hanken Grotesk', system-ui, sans-serif;
  --transition:   .16s ease;
  --sidebar-text-muted: var(--b-sidebar-label);
}

[data-theme="dark"] {
  --b-bg: #15181E; --b-surface: #1D222B; --b-surface-hover: #232935;
  --b-border: #2E3542; --b-border-soft: #262C37; --b-border-strong: #3A4352;
  --b-text: #F3EFE8; --b-text-2: #C9C3B8; --b-text-3: #A39D93; --b-text-disabled: #6F6A62;
  --b-sidebar: #10141A; --b-accent: #D06A3C; --b-accent-hover: #E08A5C;
  --b-accent-soft: #3A2A22; --b-accent-muted: #5A3A2B; --b-focus: #5A3A2B;
  --b-success-bg: #1E3024; --b-success: #8CC39A; --b-warning-bg: #3A2F1A; --b-warning: #E0B46A;
  --b-error-bg: #3A2220; --b-error: #EE9A8F; --b-info-bg: #1C2B38; --b-info: #9CC0DE;
  --b-neutral-bg: #2A2F38; --b-neutral: #C9C3B8;
  --b-shadow-card: 0 1px 2px rgba(0,0,0,.3);
}

/* ════════════════════════════════════════════════════════════════════
   1. RÈGLES HISTORIQUES DE L'APPLICATION (couleurs converties en tokens)
   ════════════════════════════════════════════════════════════════════ */
/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: width var(--transition);
}

/* Header logo */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--navy-border);
  position: relative;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}
.logo-flame {
  width: 32px;
  height: 40px;
  flex-shrink: 0;
}
.logo-flame svg { width: 100%; height: 100%; }
.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}
.logo-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--sidebar-text);
  letter-spacing: 0.08em;
  line-height: 1.1;
}
.logo-sub {
  font-size: 0.7rem;
  color: var(--orange);
  font-weight: 500;
  letter-spacing: 0.05em;
}
.logo-image {
  height: var(--logo-h, 40px);
  max-height: 80px;
  max-width: 160px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.sidebar-toggle {
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
  margin-left: auto;
}
.sidebar-toggle svg { width: 16px; height: 16px; }
.sidebar-toggle:hover { color: var(--sidebar-text); background: var(--navy-light); }

/* ═══════════════════════════════════════════════════════
   AUTOCOMPLETE — Recherche clients AJAX
═══════════════════════════════════════════════════════ */

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  list-style: none;
  margin: 4px 0 0 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--b-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--b-border-soft);
  transition: background var(--transition);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: var(--orange-dim);
  color: var(--text-primary);
}

.autocomplete-display {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.autocomplete-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.autocomplete-empty {
  padding: 12px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-light) transparent;
}
.nav-section {
  margin-bottom: 6px;
}
.nav-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text-subtle);
  padding: 12px 20px 4px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text-dim);
  font-size: 0.88rem;
  font-weight: 400;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  color: var(--sidebar-text);
  background: rgba(255,255,255,0.05);
}
.nav-item.active {
  color: var(--sidebar-text);
  background: var(--orange-dim);
  border-left-color: var(--orange);
  font-weight: 500;
}
.nav-item-sub {
  padding-left: 48px;
  font-size: 0.82rem;
  color: var(--sidebar-text-muted);
}
.nav-item-sub .nav-icon svg { width: 14px; height: 14px; }
.nav-item-sub:hover { color: var(--sidebar-text-dim); }

/* ── Select statut inline (devis + factures) ── */
.select-statut {
  appearance: none; -webkit-appearance: none;
  border: none; border-radius: 999px;
  padding: 3px 22px 3px 10px;
  font-size: .75rem; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23fff' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
  transition: opacity .15s;
}
.select-statut:hover { opacity: .85; }
/* Devis */
.select-statut[data-statut="brouillon"] { background-color:#94A3B8; color:#fff; }
.select-statut[data-statut="envoye"]    { background-color:var(--b-info); color:#fff; }
.select-statut[data-statut="accepte"]   { background-color:var(--b-success); color:#fff; }
.select-statut[data-statut="refuse"]    { background-color:var(--b-error); color:#fff; }
/* Factures */
.select-statut[data-statut="envoyee"]   { background-color:var(--b-info); color:#fff; }
.select-statut[data-statut="payee"]     { background-color:var(--b-success); color:#fff; }
.select-statut[data-statut="impayee"]   { background-color:var(--b-error); color:#fff; }

.nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg { width: 18px; height: 18px; }
.nav-text { overflow: hidden; transition: opacity var(--transition); }
.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Footer user */
.sidebar-footer {
  border-top: 1px solid var(--navy-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--orange);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.user-info { overflow: hidden; white-space: nowrap; }
.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sidebar-text);
  line-height: 1.2;
}
.user-role { font-size: 0.72rem; color: var(--sidebar-text-muted); }
.logout-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: var(--red); background: var(--b-error-bg); }

/* ── Nav picker GPS (Google Maps / Waze / etc.) ─────────── */
.nav-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: .82rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background .1s;
  border-bottom: 1px solid var(--b-border-soft);
}
.nav-picker-item:last-child { border-bottom: none; }
.nav-picker-item:hover { background: var(--surface-2); }

/* ── Sidebar mini (collapsed) ─────────────────────────── */
.sidebar-mini .sidebar { width: var(--sidebar-w-mini); }
.sidebar-mini .logo-text,
.sidebar-mini .nav-label,
.sidebar-mini .nav-text,
.sidebar-mini .nav-badge,
.sidebar-mini .user-info { opacity: 0; pointer-events: none; }
.sidebar-mini .sidebar-header { padding: 20px 12px 16px; justify-content: center; }
.sidebar-mini .sidebar-toggle { display: flex; }
.sidebar-mini .nav-item { padding: 10px; justify-content: center; gap: 0; border-left: none; border-radius: 8px; margin: 2px 8px; }
.sidebar-mini .nav-item.active { background: var(--orange-dim); }
.sidebar-mini .sidebar-footer { flex-direction: column; padding: 14px 12px; }
.sidebar-mini .user-chip { justify-content: center; }
.sidebar-mini .main-content { margin-left: var(--sidebar-w-mini); }

/* ═══════════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--b-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(29,27,24,0.06);
}
.topbar-toggle {
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  display: none;
}
.topbar-toggle svg { width: 18px; height: 18px; }
.topbar-toggle:hover { background: var(--surface-2); }

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.bc-home {
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color .15s;
}
.bc-home:hover { color: var(--orange); text-decoration: none; }
.bc-sep { color: var(--text-muted); }
.bc-current { color: var(--text-primary); font-weight: 500; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--surface-2);
  padding: 5px 10px;
  border-radius: 20px;
}

/* Page body */
.page-body { padding: 28px 28px; flex: 1; }

/* ═══════════════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════════════ */
.flash-container { padding: 0 28px; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.flash-success { background: var(--b-success-bg); color: var(--b-success); border: 1px solid var(--b-success-bg); }
.flash-error   { background: var(--b-error-bg);  color: var(--b-error); border: 1px solid var(--b-error-bg); }
.flash-warning { background: var(--b-warning-bg); color: var(--b-warning); border: 1px solid var(--b-warning-bg); }
.flash-info    { background: var(--b-info-bg); color: var(--b-info); border: 1px solid var(--b-info-bg); }
.flash button  { color: inherit; opacity: 0.6; font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.flash button:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════
   PAGE HEADERS
═══════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-header-left h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.page-header-left p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 4px;
}
.page-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════
   BOUTONS
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 2px 8px var(--orange-glow);
}
.btn-primary:hover { background: var(--orange-light); box-shadow: 0 4px 16px var(--orange-glow); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--b-border-strong);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--b-border-strong); }

.btn-danger {
  background: var(--b-error-bg);
  color: var(--b-error);
  border: 1px solid var(--b-error-bg);
}
.btn-danger:hover { background: var(--b-error-bg); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--b-border);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.btn-icon svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--b-border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 18px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.card-body { padding: 18px 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--b-border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stat cards */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--b-border);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-orange { background: var(--orange-dim); color: var(--orange); }
.stat-icon-green  { background: var(--b-success-bg); color: var(--green); }
.stat-icon-blue   { background: var(--b-info-bg); color: var(--blue); }
.stat-icon-yellow { background: var(--b-warning-bg); color: var(--yellow); }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.stat-delta { font-size: 0.75rem; margin-top: 6px; font-weight: 500; }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ═══════════════════════════════════════════════════════
   TABLEAUX
═══════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--b-border);
  box-shadow: var(--shadow);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; }
thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--b-border);
}
th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
th.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
th.th-sortable:hover { color: var(--orange); }
th.th-sortable.sort-asc,
th.th-sortable.sort-desc { color: var(--orange); }
.sort-indicator {
  display: inline-block;
  margin-left: 5px;
  font-size: .65rem;
  opacity: .5;
  vertical-align: middle;
  transition: opacity .15s;
}
th.th-sortable:hover .sort-indicator { opacity: 1; }
th.sort-asc .sort-indicator,
th.sort-desc .sort-indicator { opacity: 1; }
td {
  padding: 13px 16px;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--b-border-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--b-surface-hover); }
.table-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════
   FORMULAIRES
═══════════════════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.form-label .required { color: var(--orange); margin-left: 2px; }
.form-control {
  padding: 10px 14px;
  border: 1.5px solid var(--b-border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6B7E' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); }
.form-error { font-size: 0.75rem; color: var(--red); }
.form-control.is-invalid { border-color: var(--red); }
.form-section {
  padding: 22px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--b-border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.form-section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--b-border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   BADGES / STATUTS
═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-actif    { background: var(--b-success-bg);  color: var(--b-success); }
.badge-expire   { background: var(--b-error-bg);  color: var(--b-error); }
.badge-resilie  { background: var(--b-neutral-bg); color: var(--b-neutral); }
.badge-prospect { background: var(--b-warning-bg); color: var(--b-warning); }
.badge-client   { background: var(--b-info-bg); color: var(--b-info); }
.badge-brouillon { background: var(--b-neutral-bg); color: var(--b-neutral); }
.badge-envoye   { background: var(--b-info-bg); color: var(--b-info); }
.badge-accepte  { background: var(--b-success-bg);  color: var(--b-success); }
.badge-refuse   { background: var(--b-error-bg);  color: var(--b-error); }
.badge-payee    { background: var(--b-success-bg);  color: var(--b-success); }
.badge-impayee  { background: var(--b-error-bg);  color: var(--b-error); }

/* ═══════════════════════════════════════════════════════
   FILTRES / TOOLBAR
═══════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; }
.search-input-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  padding: 9px 14px 9px 33px;
  border: 1.5px solid var(--b-border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--text-primary);
  width: 240px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-dim); }
.filter-select {
  padding: 9px 34px 9px 12px;
  border: 1.5px solid var(--b-border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--text-primary);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6B7E' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 15px;
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--orange); }
.toolbar-spacer { flex: 1; }
.toolbar-count { font-size: 0.8rem; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════
   SIGNATURE PAD
═══════════════════════════════════════════════════════ */
.signature-wrap {
  border: 1.5px solid var(--b-border-strong);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  position: relative;
}
.signature-wrap canvas {
  display: block;
  width: 100% !important;
  touch-action: none;
}
.signature-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--b-border);
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.signature-toolbar button {
  font-size: 0.78rem;
  color: var(--orange);
  font-weight: 500;
}
.signature-toolbar button:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state svg {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  opacity: 0.5;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.empty-state p { font-size: 0.85rem; max-width: 320px; margin: 0 auto 20px; }

/* ═══════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(29,27,24,0.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}
.modal-close {
  color: var(--text-muted);
  padding: 4px;
  font-size: 1.3rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ═══════════════════════════════════════════════════════
   MOBILE BOTTOM NAV
═══════════════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--b-border);
  box-shadow: 0 -4px 20px rgba(29,27,24,.08);
  z-index: 300;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-inner {
  display: flex;
  height: 58px;
  align-items: stretch;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 2px;
  min-height: 44px;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.mobile-nav-item:hover,
.mobile-nav-item.active { color: var(--orange); }
.mobile-nav-icon {
  width: 38px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: background .15s;
}
.mobile-nav-item.active .mobile-nav-icon { background: var(--orange-dim); }

/* ── FAB (Floating Action Button) ───────────────────── */
.fab {
  display: none;
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  right: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--orange-glow), 0 2px 8px rgba(0,0,0,.18);
  z-index: 290;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.94); box-shadow: 0 2px 8px var(--orange-glow); }
.fab svg { width: 26px; height: 26px; }

/* ── Mobile card list (replaces table on phones) ─────── */
.mobile-card-list { display: none; }
.m-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  border: 1.5px solid transparent;
  transition: border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.m-card:active { border-color: var(--orange); }
.m-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m-card-title { font-weight: 600; font-size: .93rem; color: var(--text-primary); }
.m-card-sub { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.m-card-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.m-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.m-card-actions .btn-icon { width: 38px; height: 38px; border-radius: 10px; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — TABLETTE (≤ 900px)
═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open {
    transform: translateX(0);
    z-index: 400; /* au-dessus de la bottom nav (z:300) */
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(29,27,24,0.5);
    z-index: 199;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
  .sidebar-mini .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-body { padding: 20px 16px; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Empêcher le défilement horizontal ──────────────── */
  html, body { overflow-x: hidden; max-width: 100%; }
  .main-content {
    max-width: 100vw;
    overflow-x: hidden;
    padding-bottom: calc(58px + env(safe-area-inset-bottom));
  }
  .page-body { max-width: 100%; overflow-x: hidden; }

  /* ── Bottom nav ─────────────────────────────────────── */
  .mobile-nav { display: block; }

  /* ── FAB ────────────────────────────────────────────── */
  .fab { display: flex; }

  /* ── Mobile cards : afficher, masquer table ─────────── */
  .mobile-card-list { display: block; }
  .desktop-table-wrap { display: none; }

  /* ── Toast au-dessus de la bottom nav ──────────────── */
  #toastContainer { bottom: calc(74px + env(safe-area-inset-bottom)) !important; right: 12px !important; }

  /* ── Inputs plus grands (zone tactile) ──────────────── */
  .form-control { min-height: 46px; font-size: 1rem; }
  select.form-control { min-height: 46px; }
  textarea.form-control { min-height: 80px; }

  /* ── Boutons pleine largeur dans les formulaires ────── */
  .form-submit-row { flex-direction: column-reverse; gap: 10px; }
  .form-submit-row .btn { width: 100%; justify-content: center; min-height: 48px; font-size: 1rem; }

  /* ── File input mobile ──────────────────────────────── */
  .file-input-mobile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px dashed var(--b-border-strong); border-radius: 12px;
    padding: 24px 16px; cursor: pointer; text-align: center; gap: 8px;
    background: var(--surface-2); color: var(--text-secondary);
  }
  .file-input-mobile input[type=file] { display: none; }
  .file-input-mobile svg { color: var(--orange); }

  /* ── Topbar simplifié ───────────────────────────────── */
  .topbar-date { display: none; }
  .topbar { padding: 0 10px; gap: 6px; }
  /* Breadcrumb : tronquer plutôt que pousser les actions */
  .topbar-breadcrumb { min-width: 0; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Actions : ne pas rétrécir, limiter la largeur max */
  .topbar-actions { gap: 6px; flex-wrap: nowrap; min-width: 0; flex-shrink: 0; max-width: 70vw; }
  /* Boutons texte courts sur mobile */
  .topbar-actions .btn-sm { padding: 5px 8px; font-size: .72rem; white-space: nowrap; }
  #globalSearch { width: 110px; font-size: .8rem; }

  /* ── Page body ──────────────────────────────────────── */
  .page-body { padding: 14px 12px; }

  /* ── Page header ────────────────────────────────────── */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header h1 { font-size: 1.2rem; }
  .page-header-left { width: 100%; }

  /* ── Toolbar wrap ───────────────────────────────────── */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar-spacer { display: none; }
  .search-input-wrap { flex: 1 1 150px; min-width: 0; }
  .search-input { width: 100%; }
  .filter-select { flex: 1 1 120px; }

  /* ── Tables → scroll horizontal interne ─────────────── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    width: 100%;
  }
  /* Reset table-layout fixe sur mobile pour scroll correct */
  .table-wrap table { width: max-content; min-width: 100%; }

  /* ── Cards ──────────────────────────────────────────── */
  .card { overflow: hidden; }
  .card-body { padding: 12px; }
  .card-header { padding: 12px 14px; }

  /* ── KPI chips : 2 par ligne ────────────────────────── */
  .kpi-grid { gap: 8px; }
  .kpi-chip { min-width: 0; flex: 1 1 calc(50% - 4px); padding: 10px 12px; }

  /* ── Tab bar : scroll horizontal ───────────────────── */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; padding: 9px 14px; }

  /* ── Fiche client : sidebar en-dessous ──────────────── */
  .fiche-grid { grid-template-columns: 1fr !important; }

  /* ── Écraser les grilles inline → 1 colonne ────────── */
  /* Cible les style="" inline avec 2 colonnes asymétriques */
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 3fr 1fr"],
  [style*="grid-template-columns:3fr 1fr"],
  [style*="grid-template-columns: 3fr 2fr"],
  [style*="grid-template-columns:3fr 2fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 260px"],
  [style*="grid-template-columns:1fr 260px"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(3,"],
  [style*="grid-template-columns:repeat(3,"],
  [style*="grid-template-columns: repeat(4,"],
  [style*="grid-template-columns:repeat(4,"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Boutons : taille tactile minimale ──────────────── */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
  .btn-icon { width: 34px; height: 34px; }

  /* ── Grille stats ───────────────────────────────────── */
  .stats-grid { grid-template-columns: 1fr 1fr !important; }

  /* ── Éléments larges à contraindre ─────────────────── */
  img, video, iframe, table { max-width: 100%; }
  pre, code { white-space: pre-wrap; word-break: break-all; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — PETIT TÉLÉPHONE (≤ 480px)
═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .form-grid-3 { grid-template-columns: minmax(0, 1fr); }

  /* Recherche globale cachée */
  #globalSearch { display: none; }

  /* Topbar */
  .topbar { padding: 0 8px; }
  .topbar-breadcrumb { font-size: .77rem; }

  /* Page body */
  .page-body { padding: 10px; }

  /* Toolbar vertical */
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-select, .col-picker-wrap { width: 100%; }
  .col-picker-dropdown { right: 0; left: 0; }
  .toolbar-count { display: none; }

  /* KPI : réduire padding */
  .kpi-chip { padding: 8px 10px; }
  .kpi-chip .kpi-val { font-size: 1.15rem; }

  /* Cards */
  .card-body { padding: 10px; }
  .modal { padding: 16px; }

  /* Grilles attestations */
  .check-grid { grid-template-columns: 1fr !important; }
  .mesure-grid { grid-template-columns: 1fr 1fr !important; }
  .conformite-table th, .conformite-table td { padding: 6px 8px; font-size: .75rem; }
}

/* ═══════════════════════════════════════════════════════
   AMÉLIORATIONS MOBILE — v2
═══════════════════════════════════════════════════════ */

/* ── 1. Modaux → bottom-sheet (classe ajoutée par JS) ── */
@keyframes slideUpModal {
  from { transform: translateY(52px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@media (max-width: 768px) {
  [id^="modal-"].modal-active {
    align-items: flex-end !important;
  }
  [id^="modal-"].modal-active > div {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
    animation: slideUpModal .28s cubic-bezier(.4,0,.2,1);
  }
  /* Poignée visuelle en haut du sheet */
  [id^="modal-"].modal-active > div::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--b-border-strong);
    border-radius: 2px;
    margin: 0 auto 14px;
    flex-shrink: 0;
  }
}

/* ── 2. Settings nav → scroll horizontal ─────────────── */
@media (max-width: 768px) {
  .settings-nav {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    width: 100%;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav a { white-space: nowrap; flex-shrink: 0; font-size: .75rem; padding: 6px 12px; }
}

/* ── 3. Table-wrap → indicateur de scroll ────────────── */
@media (max-width: 768px) {
  .table-wrap { position: relative; }
  .table-wrap::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, rgba(244,246,250,.92));
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    z-index: 1;
  }
}

/* ── 4. Table-actions → touch-friendly ───────────────── */
@media (max-width: 768px) {
  .table-actions { flex-wrap: wrap; gap: 4px; }
  .table-actions .btn-icon { width: 38px !important; height: 38px !important; }
  .select-statut { font-size: .72rem; padding: 3px 22px 3px 7px; max-width: 118px; }
}

/* ── 5. Page header → actions full-width sous le titre── */
@media (max-width: 600px) {
  .page-header { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .page-header-actions { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .page-header-actions .btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }
}

/* ── 6. Topbar breadcrumb → tronqué ─────────────────── */
@media (max-width: 480px) {
  .topbar-breadcrumb {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: min(140px, 35vw);
    font-size: .75rem;
  }
  .bc-home { display: none; } /* cache "ThermiPro" pour gagner de la place */
  .bc-sep:first-of-type { display: none; }
}

/* ── 7. Topbar actions : bouton compact ──────────────── */
@media (max-width: 480px) {
  .topbar-actions .btn-sm { padding: 6px 8px; font-size: .73rem; }
  .topbar-actions .btn-sm svg { flex-shrink: 0; }
}

/* ── 7b. Dropdown recherche globale → ne pas dépasser l'écran ─ */
@media (max-width: 768px) {
  #globalSearchResults {
    min-width: 0 !important;
    width: calc(100vw - 24px) !important;
    left: 0 !important;
    right: auto !important;
  }
}

/* ── 8. Grilles inline supplémentaires → 1 col ───────── */
@media (max-width: 768px) {
  [style*="grid-template-columns: 2fr 1fr 1fr"],
  [style*="grid-template-columns:2fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(2, 1fr)"],
  [style*="grid-template-columns:repeat(2, 1fr)"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns:1fr 2fr"],
  [style*="grid-template-columns: 200px 1fr"],
  [style*="grid-template-columns:200px 1fr"],
  /* fiches devis / facture / sidebar 300px */
  [style*="grid-template-columns: 1fr 300px"],
  [style*="grid-template-columns:1fr 300px"],
  /* dashboard graph + échéances */
  [style*="grid-template-columns: 1fr 380px"],
  [style*="grid-template-columns:1fr 380px"],
  /* export preview */
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns:280px 1fr"],
  /* toute colonne fixe ≥ 240px + 1fr */
  [style*="grid-template-columns: 1fr 240px"],
  [style*="grid-template-columns:1fr 240px"],
  [style*="grid-template-columns: 240px 1fr"],
  [style*="grid-template-columns:240px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Grille de stats 4 colonnes → 2 colonnes */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── 9. Boutons de formulaire → hauteur tactile ──────── */
@media (max-width: 768px) {
  [style*="justify-content:flex-end"] > .btn,
  [style*="justify-content: flex-end"] > .btn { min-height: 44px; }
  .form-section { padding: 16px 14px; margin-bottom: 12px; }
}

/* ── 10. Sidebar → ombre quand ouverte mobile ────────── */
@media (max-width: 900px) {
  .sidebar { transition: transform var(--transition), box-shadow var(--transition); }
  .sidebar.open { box-shadow: 6px 0 40px rgba(0,0,0,.28); }
}

/* ── 11. KPI mini → wrap en 2 colonnes ──────────────── */
@media (max-width: 600px) {
  .kpi-mini { flex: 1 1 calc(50% - 8px) !important; min-width: 120px; }
}

/* ── 12. Toast → pleine largeur sur petit mobile ─────── */
@media (max-width: 480px) {
  #toastContainer {
    left: 12px !important;
    right: 12px !important;
  }
  #toastContainer .toast-msg {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}

/* ── 13. Signature pad ───────────────────────────────── */
@media (max-width: 768px) {
  .signature-wrap { height: 130px !important; }
  .signature-wrap #sigCanvas { height: 130px !important; }
}

/* ── 14. Protections générales débordement ───────────── */
@media (max-width: 768px) {
  /* Empêcher les flex-items textuels de sortir de leur conteneur */
  .card, .card-body, .form-section {
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  /* Ligne récap totaux factures/devis (montant HT / TVA / TTC) */
  .totaux-row { flex-direction: column !important; gap: 6px !important; }
  /* Boutons dans les cards → wrap */
  .card-actions, .detail-actions { flex-wrap: wrap; gap: 8px; }
  /* Valeurs min-width fixes → ne pas forcer le débordement hors conteneur */
  [style*="min-width:200px"],
  [style*="min-width: 200px"],
  [style*="min-width:240px"],
  [style*="min-width: 240px"],
  [style*="min-width:260px"],
  [style*="min-width: 260px"] { min-width: 0 !important; }
}

/* ── 15. Très petit écran ≤ 380px ────────────────────── */
@media (max-width: 380px) {
  .page-body { padding: 8px; }
  .card-body { padding: 8px; }
}

/* ═══════════════════════════════════════════════════════
   MOBILE — AMÉLIORATIONS SIGNIFICATIVES
═══════════════════════════════════════════════════════ */

/* ── Utilitaires visibilité ──────────────────────────── */
.mobile-only  { display: none !important; }
.desktop-only { display: block !important; }
@media (max-width: 768px) {
  .mobile-only  { display: block !important; }
  .desktop-only { display: none !important; }
  .mobile-only-flex { display: flex !important; }
}

/* ── Fiche pages : side-panel → pleine largeur ────────── */
@media (max-width: 768px) {
  /* Tous les layouts "contenu + sidebar droite" */
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns: 1fr 300px"],
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 280px"],
  [style*="grid-template-columns: 1fr 280px"],
  [style*="grid-template-columns:1fr 260px"],
  [style*="grid-template-columns: 1fr 260px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── KPI stat-cards → 2 cols sur mobile ─────────────── */
@media (max-width: 768px) {
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 380px) {
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Stat card touch-friendly ────────────────────────── */
@media (max-width: 768px) {
  .stat-card {
    padding: 14px 12px !important;
    gap: 10px !important;
  }
  .stat-value { font-size: 1.4rem !important; }
  .stat-label { font-size: .7rem !important; }
  .stat-icon  { width: 36px !important; height: 36px !important; flex-shrink: 0; }
}

/* ── Topbar search → escamotable sur petit écran ─────── */
@media (max-width: 768px) {
  .topbar-search-wrap { order: 10; }
  #globalSearch { width: 100px; }
}
@media (max-width: 480px) {
  .topbar { gap: 4px; }
  /* Masquer le texte des boutons topbar, garder icônes */
  .topbar-actions .btn-sm .btn-label { display: none; }
}

/* ── Toolbar mobile : search + bouton "Filtres" toggle ── */
@media (max-width: 768px) {

  /* Row 1 : search + toggle bouton */
  .toolbar {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    gap: 0 !important;
    padding: 0 !important;
    align-items: stretch;
  }

  /* Barre de recherche prend toute la largeur */
  .toolbar .search-input-wrap {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    order: -10;
  }
  .toolbar .search-input {
    width: 100% !important;
    font-size: .95rem !important;
    min-height: 46px !important;
    border-radius: 10px 0 0 10px !important;
    padding-left: 38px !important;
    border-right: none !important;
  }
  .toolbar .search-input-wrap svg {
    width: 16px; height: 16px;
  }

  /* Bouton toggle filtres — accolé à droite de la recherche */
  .toolbar-filter-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 12px;
    min-height: 46px;
    background: var(--surface);
    border: 1px solid var(--b-border-strong);
    border-left: none;
    border-radius: 0 10px 10px 0;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    order: -9;
  }
  .toolbar-filter-toggle.has-filters {
    color: var(--orange);
    border-color: var(--orange);
  }
  .toolbar-filter-toggle .filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    background: var(--orange);
    color: #fff;
    border-radius: 50%;
    font-size: .65rem;
    font-weight: 700;
  }

  /* Panneau filtres — caché par défaut, pleine largeur sous la search */
  .toolbar-filters-panel {
    display: none;
    flex: 0 0 100% !important;
    width: 100% !important;
    order: -5;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0 4px;
    border-top: 1px solid var(--b-border-soft);
    margin-top: 6px;
  }
  .toolbar-filters-panel.open {
    display: flex !important;
  }
  .toolbar-filters-panel .filter-select,
  .toolbar-filters-panel select {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    max-width: 100%;
    font-size: .82rem !important;
    min-height: 40px !important;
    border-radius: 8px !important;
    padding: 6px 24px 6px 10px !important;
  }
  .toolbar-filters-panel .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
    font-size: .82rem;
    border-radius: 8px;
    justify-content: center;
  }

  /* Compteur résultats → fin de ligne 1 */
  .toolbar .toolbar-count {
    flex-shrink: 0;
    font-size: .78rem;
    order: -8;
    padding: 0 6px;
    align-self: center;
  }

  /* Spacer + boutons desktop → cachés sur mobile */
  .toolbar .toolbar-spacer { display: none; }
  .toolbar-desktop-only    { display: none !important; }

  /* Formulaires display:contents → comportement normal dans le panel */
  .toolbar-filters-panel > form {
    display: contents;
  }
}

/* ── m-card amélioré ─────────────────────────────────── */
.m-card-badge-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.m-card-amount {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--orange);
}
.m-card-tel {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--orange-dim); color: var(--orange);
  border-radius: 8px; padding: 4px 10px;
  font-size: .82rem; font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.m-card-tel:active { background: var(--orange-glow); }
.m-card-pill {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 6px; padding: 2px 8px;
  font-size: .74rem; color: var(--text-secondary);
}

/* ── Boutons d'action sur mobile : taille tactile ─────── */
@media (max-width: 768px) {
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { width: 40px !important; height: 40px !important; border-radius: 10px !important; }
  .form-control, .form-select, select.form-control {
    min-height: 44px;
    font-size: 1rem !important;
  }
  textarea.form-control { min-height: unset; }
  input[type="date"].form-control,
  input[type="number"].form-control {
    min-height: 44px;
    font-size: 1rem !important;
  }
}

/* ── Pagination / pied de liste mobile ───────────────── */
@media (max-width: 768px) {
  tfoot td { font-size: .78rem !important; padding: 8px 12px !important; }
}

/* ── Section formulaire → full page mobile ───────────── */
@media (max-width: 768px) {
  .form-section { border-radius: 10px; }
  .form-group label.form-label { font-size: .82rem; margin-bottom: 4px; }
  /* hint plus petit */
  .form-hint { font-size: .74rem; }
}

/* ── Tabs (fiche client) → scroll horizontal ─────────── */
@media (max-width: 768px) {
  .tab-list {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tab-list::-webkit-scrollbar { display: none; }
  .tab-item { white-space: nowrap; flex-shrink: 0; }
}

/* ── Cartes info ligne lignes devis/facture ──────────── */
@media (max-width: 768px) {
  .ligne-unite { width: 56px !important; min-width: 40px; }
  .td-qty      { width: 70px !important; }
  .td-pu       { width: 90px !important; }
}

/* ── Page-body padding bottom pour la bottom-nav ─────── */
@media (max-width: 768px) {
  .page-body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
}

/* ── Cards + ombres sur mobile ───────────────────────── */
@media (max-width: 768px) {
  .card {
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(29,27,24,.07) !important;
  }
  .card + .card { margin-top: 12px; }
}

/* ── Topbar : actions débordement → masquer items low-prio */
@media (max-width: 600px) {
  .topbar-action-secondary { display: none !important; }
}

/* ── Desktop table wrap (alias pour classes manquantes) ── */
@media (max-width: 768px) {
  .desktop-table-wrap { display: none !important; }
  .mobile-card-list   { display: block !important; }
}

/* ═══════════════════════════════════════════════════════
   PDF PRINT
═══════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .flash-container, .toolbar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
}

/* ═══════════════════════════════════════════════════════
   MOBILE v3 — finitions (audit 375 px)
═══════════════════════════════════════════════════════ */

.stat-icon-red { background: var(--b-error-bg); color: var(--red); }

/* Bouton loupe de la barre du haut : caché sur ordinateur */
.gs-open-btn { display: none; }
.topbar-icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-secondary);
  border-radius: 10px; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {

  /* ── Champs ≥ 16 px : sinon iOS zoome à chaque saisie ── */
  html:root body input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]),
  html:root body select, html:root body textarea,
  html:root body .form-control, html:root body .filter-select, html:root body .search-input {
    font-size: 16px !important;
  }

  /* ── Anti-débordement : un champ/texte long ne doit jamais élargir la page ── */
  .form-grid > *, .form-group, .form-section, .card-body,
  [style*="display:grid"] > *, [style*="display: grid"] > *,
  [style*="display:flex"] > *, [style*="display: flex"] > * { min-width: 0; }
  .page-body select, .page-body input, .page-body textarea { max-width: 100%; }
  .page-body select { text-overflow: ellipsis; }
  /* Mises en page « contenu + colonne latérale fixe » (1fr 360px, 1fr 2xxpx…) → 1 colonne */
  [style*="grid-template-columns:1fr 2"], [style*="grid-template-columns: 1fr 2"],
  [style*="grid-template-columns:1fr 3"], [style*="grid-template-columns: 1fr 3"],
  [style*="grid-template-columns:1fr 4"], [style*="grid-template-columns: 1fr 4"],
  [style*="grid-template-columns:2"][style*="px 1fr"], [style*="grid-template-columns: 2"][style*="px 1fr"],
  [style*="grid-template-columns:3"][style*="px 1fr"], [style*="grid-template-columns: 3"][style*="px 1fr"],
  [style*="grid-template-columns:1"][style*="px 1fr"], [style*="grid-template-columns: 1"][style*="px 1fr"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* Lignes « titre … boutons » : passer à la ligne plutôt que déborder */
  .page-body [style*="justify-content:space-between"],
  .page-body [style*="justify-content: space-between"] { flex-wrap: wrap; row-gap: 8px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .page-body [style*="flex-wrap:wrap"] > div { max-width: 100%; flex-wrap: wrap; }
  /* Barres d'outils des lignes devis/facture : recherche pleine largeur */
  #articleSearch { width: 100% !important; }
  #articleSearch:not(.x) { flex: 1 1 100%; }
  .form-section-title > div:has(#articleSearch),
  div:has(> #articleSearch) { flex: 1 1 100%; flex-wrap: wrap; }

  /* Fil d'Ariane : seulement la page courante (évite « › › Rapport ») */
  .topbar-breadcrumb > *:not(:last-child) { display: none !important; }

  /* ── Barre du haut ──────────────────────────────────── */
  .topbar-icon-btn, .topbar-actions > a.topbar-icon-btn {
    display: flex !important; width: 40px !important; height: 40px !important; flex-shrink: 0;
  }
  .gs-open-btn { display: flex; }
  #globalSearchWrap { margin-right: 0 !important; }
  #globalSearchWrap .gs-field { display: none; }
  .topbar.search-open #globalSearchWrap {
    position: absolute !important; left: 8px; right: 8px; top: 50%; transform: translateY(-50%);
    z-index: 260; margin: 0 !important;
  }
  .topbar.search-open #globalSearchWrap .gs-field { display: block; }
  .topbar.search-open .gs-open-btn { display: none !important; }
  .topbar.search-open #globalSearch {
    display: block !important; width: 100% !important; height: 44px;
    border-radius: 12px !important; box-shadow: 0 4px 18px rgba(29,27,24,.12);
    background: var(--surface) !important;
  }
  #globalSearchResults { width: 100% !important; max-height: 70vh; overflow-y: auto !important; }
  /* Boutons secondaires de la barre du haut : icône seule */
  .topbar-actions .btn-secondary.btn-sm:has(svg) {
    font-size: 0 !important; padding: 0 !important; width: 40px; min-height: 40px !important;
    justify-content: center; gap: 0 !important;
  }
  .topbar-actions .btn-secondary.btn-sm svg { width: 17px; height: 17px; }
  .topbar-actions .btn-primary.btn-sm { min-height: 38px; padding: 0 12px !important; }

  /* ── Barre de recherche + bouton Filtres sur une seule ligne ── */
  .toolbar { flex-direction: row !important; }
  .toolbar .search-input-wrap { flex: 1 1 0 !important; }
  .toolbar-filters-panel > div {
    flex: 1 1 100%; display: flex !important; align-items: center; gap: 8px; flex-wrap: nowrap;
  }
  .toolbar-filters-panel > div input[type=date] { flex: 1 1 0; min-width: 0; }

  /* ── Petits boutons → taille doigt (≥ 36 px) ── */
  .section-collapse-btn { min-width: 38px; min-height: 34px; }
  .modal-close { min-width: 40px; min-height: 40px; font-size: 1.4rem !important; }
  #rapportForm [onclick^="supprimerPhoto"] { width: 32px !important; height: 32px !important; }

  /* ── Indicateurs des fiches (client…) : 2 par ligne ── */
  .kpi-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
  .kpi-grid .kpi-chip { min-width: 0 !important; width: auto !important; }

  /* ── Planning (FullCalendar) ── */
  .fc .fc-toolbar { gap: 8px; }
  .fc .fc-toolbar-title { font-size: 1.05rem !important; text-align: center; }
  .fc .fc-button { min-height: 38px; padding: 6px 12px !important; font-size: .85rem !important; }
  .fc .fc-list-event td { padding: 10px 12px !important; font-size: .9rem; }
  .fc .fc-daygrid-event { font-size: .7rem; }
  #calendar { padding: 10px !important; }
  /* Détail d'une intervention : panneau en bas d'écran plutôt qu'au point cliqué */
  #eventPopup {
    left: 10px !important; right: 10px !important; width: auto !important;
    top: auto !important; bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
  #eventPopup .btn { min-height: 44px; }

  /* ── Boutons de statut (listes interventions) : taille doigt ── */
  .statut-btn { width: 40px !important; height: 40px !important; font-size: 1rem !important; border-radius: 10px !important; }

  /* ── Tableau de bord : accès rapide en grille 3 × 2 ── */
  .dash-quick { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px !important; }
  .dash-quick .btn {
    flex-direction: column; justify-content: center; text-align: center;
    min-height: 64px; padding: 8px 4px; gap: 5px !important;
    font-size: .76rem; line-height: 1.15; white-space: normal; border-radius: 12px;
  }
  .dash-quick .btn svg { width: 18px; height: 18px; }

  /* ── Tableau de bord : indicateurs 2 par ligne, compacts ── */
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .dash-kpis > * { min-width: 0; }
  .dash-stack { grid-template-columns: minmax(0, 1fr) !important; gap: 14px !important; }
  .dash-stack > * { min-width: 0; }
  /* « .card + .card { margin-top } » est prévu pour des cartes empilées :
     dans une grille, il décale les cartes les unes par rapport aux autres */
  [style*="display:grid"] > .card, [style*="display: grid"] > .card, .dash-kpis > .card { margin-top: 0 !important; }
  .dash-kpis > .kpi-wide { grid-column: 1 / -1; }
  .dash-kpis > .stat-card,
  .dash-kpis > .card:not(.kpi-wide) {
    flex-direction: column; align-items: flex-start !important;
    gap: 8px !important; padding: 12px !important;
  }
  .dash-kpis > .card:not(.kpi-wide) > div:first-child { width: 34px !important; height: 34px !important; }
  .dash-kpis > .card:not(.kpi-wide) > div:first-child svg { width: 18px; height: 18px; }
  .dash-kpis [style*="font-size:1.5rem"] { font-size: 1.2rem !important; }
  .dash-kpis .stat-value { font-size: 1.35rem !important; }

  /* ── Lignes de devis / facture : une carte par ligne ── */
  .lignes-table, .lignes-table tbody { display: block; width: 100%; }
  .lignes-table thead { display: none; }
  .lignes-table tr.ligne-row {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px; padding: 12px 12px 14px; position: relative;
    border-bottom: 1px solid var(--b-border);
  }
  .lignes-table tr.ligne-row:last-child { border-bottom: none; }
  .lignes-table tr.ligne-row > td {
    display: block; padding: 0 !important; border: none !important;
    width: auto !important; min-width: 0; text-align: left !important;
  }
  .lignes-table tr.ligne-row > td.d-none { display: none !important; }
  .lignes-table td .form-control { width: 100% !important; }
  .lignes-table .ligne-unite { width: 100% !important; margin-top: 6px; }
  .lignes-table textarea.ligne-desig { min-height: 64px !important; }
  /* Facture : 1 type · 2 désignation · 3 qté · 4 PU · 5 TVA · 6 remise · 7 total · 8 suppr.
     Devis   : 1 désignation · 2 qté · 3 PU · 4 TVA · 5 remise · 6 total · 7 suppr. */
  .lignes-facture tr.ligne-row > td:nth-child(2) { grid-column: 1 / -1; padding-right: 48px !important; }
  .lignes-facture tr.ligne-row > td:nth-child(3) { grid-column: 1 / -1; }
  .lignes-devis   tr.ligne-row > td:nth-child(2) { grid-column: 1 / -1; padding-right: 48px !important; }
  .lignes-facture tr.ligne-row > td:nth-child(4)::before,
  .lignes-devis   tr.ligne-row > td:nth-child(3)::before { content: 'Quantité'; }
  .lignes-facture tr.ligne-row > td:nth-child(5)::before,
  .lignes-devis   tr.ligne-row > td:nth-child(4)::before { content: 'P.U. HT'; }
  .lignes-facture tr.ligne-row > td:nth-child(6)::before,
  .lignes-devis   tr.ligne-row > td:nth-child(5)::before { content: 'TVA'; }
  .lignes-facture tr.ligne-row > td:nth-child(7)::before,
  .lignes-devis   tr.ligne-row > td:nth-child(6)::before { content: 'Remise'; }
  .lignes-facture tr.ligne-row > td:nth-child(8)::before,
  .lignes-devis   tr.ligne-row > td:nth-child(7)::before { content: 'Total HT'; }
  .lignes-facture tr.ligne-row > td:is(:nth-child(4), :nth-child(5), :nth-child(6), :nth-child(7), :nth-child(8))::before,
  .lignes-devis   tr.ligne-row > td:is(:nth-child(3), :nth-child(4), :nth-child(5), :nth-child(6), :nth-child(7))::before {
    display: block; font-size: .66rem; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
  }
  /* remise sur 2 colonnes, total à droite */
  .lignes-facture tr.ligne-row > td:nth-child(7),
  .lignes-devis   tr.ligne-row > td:nth-child(6) { grid-column: 1 / 3; }
  .lignes-table .td-remise > div { flex-direction: row !important; gap: 12px !important; }
  .lignes-table td .ligne-remise-pct, .lignes-table td .ligne-remise-eur { width: 92px !important; flex: 0 0 auto; }
  .lignes-facture tr.ligne-row > td:nth-child(8),
  .lignes-devis   tr.ligne-row > td:nth-child(7) { grid-column: 3; text-align: right !important; align-self: end; }
  .lignes-table .ligne-total { font-size: 1rem !important; }
  /* bouton supprimer en haut à droite de la carte */
  .lignes-facture tr.ligne-row > td:nth-child(9),
  .lignes-devis   tr.ligne-row > td:nth-child(8) { position: absolute; top: 8px; right: 8px; }
  .lignes-table .btn-remove-ligne { width: 38px !important; height: 38px !important; color: #9AA5B8 !important; }

  /* Totaux du document : pleine largeur */
  .totaux-box { min-width: 0 !important; width: 100%; }

  /* ── Tableaux empilés (classe .m-stack posée par base.html) ── */
  table.m-stack { width: 100% !important; min-width: 0 !important; border-collapse: collapse; }
  table.m-stack thead { display: none; }
  table.m-stack, table.m-stack tbody, table.m-stack tfoot { display: block; }
  table.m-stack tr {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px;
    padding: 12px 14px; border-bottom: 1px solid var(--b-border-soft);
  }
  table.m-stack tr:last-child { border-bottom: none; }
  table.m-stack td {
    display: block; border: none !important; padding: 0 !important;
    text-align: left !important; white-space: normal !important;
    min-width: 0; max-width: 100%; width: auto !important;
    flex: 0 1 auto; word-break: normal !important; overflow-wrap: anywhere;
  }
  table.m-stack td:empty { display: none; }
  /* 1re cellule = titre de la fiche, sur toute la largeur */
  table.m-stack td:first-child { flex: 1 1 100%; font-weight: 600; }
  table.m-stack td[data-label]:not(:first-child)::before {
    content: attr(data-label); display: block;
    font-size: .64rem; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px;
  }
  /* cellules d'actions (boutons) : alignées à droite, sur leur propre ligne */
  table.m-stack td:has(> .btn, > form, > a.btn-icon, > .table-actions) {
    flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
  }
  table.m-stack td:has(> .btn, > form, > a.btn-icon, > .table-actions)::before { display: none; }
  .table-wrap:has(> table.m-stack)::after { display: none; }
  .table-wrap:has(> table.m-stack) { overflow-x: visible; }
}

/* ═══════════════════════════════════════════════════════
   FINITIONS PRO (v4) — typo Inter, chiffres alignés, débordements
═══════════════════════════════════════════════════════ */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.005em; }
.main-content { min-width: 0; }
table, .stat-value, .num, td, .dash-kpis { font-variant-numeric: tabular-nums; }
h1, h2, h3, .card-title, .modal-title, .form-section-title, .page-header-left h1 { letter-spacing: -0.015em; }
.page-header-left h1 { font-size: 1.45rem; font-weight: 700; }
.stat-value { font-size: 1.55rem; letter-spacing: -0.02em; }
th { font-size: 0.7rem; letter-spacing: 0.04em; }
.form-label { text-transform: none; letter-spacing: 0; font-size: 0.82rem; color: var(--text-primary); font-weight: 500; }
.btn-primary:hover { transform: none; }
.btn:focus-visible, .btn-icon:focus-visible, a:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 2px;
}

/* ── Utilitaires ── */
.muted { color: var(--text-secondary); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.r { text-align: right !important; }
.txt-red { color: var(--b-error) !important; }
.txt-green { color: #16A34A !important; }
.txt-orange { color: var(--b-warning) !important; }

/* ── Pastilles de statut (plus sobres que les badges) ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 500; letter-spacing: 0; white-space: nowrap;
  vertical-align: middle; line-height: 1.5;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-gray   { background: var(--b-neutral-bg); color: #5A6472; }
.pill-blue   { background: #EAF1FF; color: #2459C7; }
.pill-green  { background: #E7F7EE; color: #15803D; }
.pill-orange { background: #FFF3E0; color: var(--b-warning); }
.pill-red    { background: #FDECEC; color: var(--b-error); }

/* ── Fiches devis / facture ── */
.doc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.doc-kind { font-size: .78rem; color: var(--text-secondary); margin-bottom: 2px; }
.doc-head h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-client { display: inline-block; margin-top: 4px; font-size: .92rem; color: var(--text-secondary); }
.doc-client:hover { color: var(--orange); }
.doc-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-actions form { margin: 0; }
.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.doc-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.doc-side { position: sticky; top: calc(var(--topbar-h) + 20px); }

.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px 24px; padding: 18px 22px; }
.doc-meta > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.doc-meta > div:first-child { grid-column: span 2; }
.doc-meta span { font-size: .75rem; color: var(--text-muted); }
.doc-meta strong { font-size: .92rem; font-weight: 600; }
.doc-meta a strong { color: var(--text-primary); }
.doc-meta a:hover strong { color: var(--orange); }
.doc-meta small { font-size: .82rem; color: var(--text-secondary); overflow-wrap: anywhere; }

.doc-lignes { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.doc-table th { background: transparent; padding: 12px 16px; border-bottom: 1px solid var(--b-border); }
.doc-table td { padding: 11px 16px; font-size: .88rem; border-bottom: 1px solid var(--b-border-soft); vertical-align: top; }
.doc-table tbody tr:hover td { background: transparent; }
.doc-table .l-titre td { font-weight: 600; padding-top: 18px; color: var(--text-primary); border-bottom-color: var(--b-border); }
.doc-table .l-comm td { color: var(--text-secondary); font-style: italic; font-size: .84rem; }
.doc-table .l-ref { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.doc-table .muted { color: var(--text-secondary); }
.doc-totaux { display: flex; justify-content: flex-end; padding: 16px 22px 20px; }
.doc-totaux dl { min-width: 260px; margin: 0; }
.doc-totaux dl > div { display: flex; justify-content: space-between; gap: 24px; padding: 4px 0; font-size: .88rem; }
.doc-totaux dl > div.muted { color: var(--text-secondary); font-size: .84rem; }
.doc-totaux dd { margin: 0; font-variant-numeric: tabular-nums; }
.doc-totaux .ttc { border-top: 1px solid var(--b-border); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 1rem; }

.doc-notes { padding: 18px 22px; }
.doc-notes p { font-size: .88rem; color: var(--text-secondary); line-height: 1.6; white-space: pre-line; margin: 0; }
.doc-section-title { font-size: .8rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }

.doc-summary { padding: 20px; }
.doc-summary-label { font-size: .8rem; color: var(--text-secondary); }
.doc-summary-amount { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.doc-summary > small { font-size: .82rem; color: var(--text-secondary); }
.progress { height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--green); border-radius: 99px; }
.reg-list { list-style: none; margin: 0; padding: 0; }
.reg-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--b-border-soft); font-size: .86rem; }
.reg-list li:first-child { border-top: 0; }
.reg-list small { display: block; font-size: .76rem; color: var(--text-secondary); }
.reg-list time { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.reg-list a:hover strong { color: var(--orange); }
.acompte-box { margin-top: 14px; border-top: 1px solid var(--b-border-soft); padding-top: 12px; }
.acompte-box summary { cursor: pointer; font-size: .86rem; color: var(--text-secondary); list-style: none; }
.acompte-box summary::before { content: '+ '; }
.acompte-box[open] summary { margin-bottom: 10px; }

/* Menu « … » (plus d'actions) */
.menu-more { position: relative; }
.menu-more > summary { list-style: none; padding-left: 11px; padding-right: 11px; }
.menu-more > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 250px;
  background: var(--surface); border: 1px solid var(--b-border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(29,27,24,.14); padding: 6px;
}
[hidden] { display: none !important; }
.menu-pop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; color: var(--b-text); font-size: .82rem;
  border-bottom: 1px solid var(--b-border-soft); margin-bottom: 4px;
}
.menu-pop .menu-pop-close {
  display: none; width: 36px; min-height: 36px; padding: 0; flex: 0 0 36px;
  align-items: center; justify-content: center; color: var(--b-text-2);
  font-size: 1.5rem; line-height: 1;
}
.menu-pop form { margin: 0; }
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  font-size: .86rem; color: var(--text-primary); background: none; border: 0; cursor: pointer; font-family: inherit;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--b-error); }
.menu-pop hr { border: 0; border-top: 1px solid var(--b-border-soft); margin: 5px 0; }

@media (max-width: 1100px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; order: -1; }
}
@media (max-width: 768px) {
  .doc-head { align-items: stretch; }
  .doc-actions > .btn-primary, .doc-actions > form { flex: 1 1 100%; }
  .doc-actions > form .btn { width: 100%; justify-content: center; }
  .doc-actions > .btn-primary { justify-content: center; }
  .doc-meta > div:first-child { grid-column: 1 / -1; }
  .doc-table .c-opt { display: none; }
  .doc-table td, .doc-table th { padding-left: 12px; padding-right: 12px; }
  .menu-more[open]::before {
    content: ''; position: fixed; inset: 0; z-index: 890;
    background: rgba(29, 27, 24, .28); backdrop-filter: blur(1px);
  }
  .menu-pop {
    position: fixed; z-index: 900; left: 12px; right: 12px;
    top: auto; bottom: calc(78px + env(safe-area-inset-bottom));
    width: auto; min-width: 0; max-height: min(62dvh, 520px); overflow-y: auto;
    padding: 8px; border-color: var(--b-border-strong); border-radius: 14px;
    box-shadow: 0 18px 55px rgba(29, 27, 24, .24);
  }
  .menu-pop-head { padding: 7px 8px 10px; font-size: .92rem; }
  .menu-pop .menu-pop-close { display: inline-flex; }
  .menu-pop a, .menu-pop button:not(.menu-pop-close) {
    display: flex; align-items: center; min-height: 46px; padding: 11px 12px;
    color: var(--b-text); font-size: .92rem; font-weight: 500;
  }
  .menu-pop hr { margin: 6px 4px; }
}
.form-group { min-width: 0; }
.form-control { min-width: 0; max-width: 100%; }
.doc-num { font-weight: 600; color: var(--text-primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-num:hover { color: var(--orange); text-decoration: underline; text-underline-offset: 3px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: rgba(29,27,24,0.025); }
[data-theme="dark"] tr.row-link:hover td { background: rgba(255,255,255,0.04); }

/* Barre d'enregistrement des formulaires : toujours visible en bas d'écran (ordinateur) */
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
@media (min-width: 769px) {
  .form-actions {
    position: sticky; bottom: 0; z-index: 40;
    margin-top: 8px; padding: 14px 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--b-border);
  }
  [data-theme="dark"] .form-actions { border-top-color: #374151; }
}

/* ── Paramètres : Google Agenda ── */
.g-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .88rem; }
.g-guide { margin-top: 18px; border-top: 1px solid var(--b-border-soft); padding-top: 14px; }
.g-guide > summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.g-steps { margin: 14px 0 18px 20px; display: flex; flex-direction: column; gap: 12px; font-size: .88rem; line-height: 1.55; color: var(--text-primary); }
.g-steps a { color: var(--orange); text-decoration: underline; text-underline-offset: 2px; }
.g-copy { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.g-copy span { font-size: .8rem; color: var(--text-secondary); min-width: 190px; }
.g-copy code { background: var(--surface-2); border: 1px solid var(--b-border); border-radius: 6px; padding: 5px 9px; font-size: .82rem; overflow-wrap: anywhere; }
.g-simple { border: 1px solid var(--b-border); border-radius: 12px; padding: 18px 20px; background: var(--surface); }
.g-simple-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: .95rem; }
.g-simple > p { font-size: .86rem; line-height: 1.55; }

/* ════════════════════════════════════════════════════════════════════
   2. COMPOSANTS DIRECTION B (prioritaires)
   ════════════════════════════════════════════════════════════════════ */
/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--b-bg); color: var(--b-text);
  font: 400 14px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--b-accent); text-decoration: none; }
a:hover { color: var(--b-accent-hover); }
input, select, textarea, button { font-family: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; color: var(--b-text); }
:focus-visible { outline: none; box-shadow: var(--b-ring); border-radius: var(--b-r-md); }

/* ── Sidebar ── */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 100;
  background: var(--b-sidebar); display: flex; flex-direction: column;
  transition: width var(--transition), transform var(--transition);
}
.sidebar-header { padding: 16px 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo-wrap { display: flex; align-items: center; height: 40px; padding: 0 6px; background: var(--b-bg); border-radius: 14px; overflow: hidden; }
.logo-image { height: calc(var(--logo-h, 40px) - 8px); max-height: 32px; width: auto; display: block; }
.sidebar-toggle { width: 28px; height: 28px; border: 0; background: none; border-radius: var(--b-r-md); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--b-sidebar-label); }
.sidebar-toggle svg { width: 16px; height: 16px; }
.sidebar-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 8px 12px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: #3A4556 transparent; }
.nav-section { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--b-sidebar-label); padding: 4px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px;
  border-radius: var(--b-r-md); font-size: 13.5px; color: var(--b-sidebar-text);
  white-space: nowrap; transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--b-sidebar-active); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { color: var(--b-sidebar-icon-active); }
.nav-item-sub { padding-left: 34px; font-size: 13px; }
.nav-item-sub .nav-icon { display: none; }
.nav-icon { display: flex; width: 16px; height: 16px; flex-shrink: 0; color: var(--b-sidebar-label); }
.nav-icon svg { width: 16px; height: 16px; }
.nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { font: 600 11px var(--font-body); color: var(--b-sidebar); background: var(--b-sidebar-icon-active); border-radius: var(--b-r-xs); padding: 1px 6px; }
.sidebar-footer { padding: 8px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--b-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
.user-name { font-size: 13px; font-weight: 500; color: #F3EFE8; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: #A9B0BC; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { width: 28px; height: 28px; border: 0; background: none; border-radius: var(--b-r-md); display: flex; align-items: center; justify-content: center; color: #A9B0BC; cursor: pointer; }
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-mini); }
body.sidebar-collapsed .nav-text, body.sidebar-collapsed .nav-label, body.sidebar-collapsed .user-info, body.sidebar-collapsed .nav-badge { display: none; }

/* ── Main + topbar ── */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; transition: margin-left var(--transition); }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-mini); }
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: var(--b-surface); border-bottom: 1px solid var(--b-border);
}
.topbar-toggle { display: none; width: 34px; height: 34px; border: 1px solid var(--b-border); background: var(--b-surface); border-radius: var(--b-r); align-items: center; justify-content: center; color: var(--b-text-2); cursor: pointer; }
.topbar-toggle svg { width: 16px; height: 16px; }
.topbar-breadcrumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--b-text-3); white-space: nowrap; overflow: hidden; }
.bc-home { color: var(--b-text-3); }
.bc-home:hover { color: var(--b-text); }
.bc-sep { color: var(--b-sep); }
.bc-current { color: var(--b-text); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-date { display: none; }
.page-body { padding: 28px; flex: 1; width: 100%; max-width: 1320px; display: flex; flex-direction: column; gap: 24px; }

/* ── Flash (conservé pour compatibilité) ── */
.flash-container { padding: 0 28px; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--b-r); font-size: 13.5px; border: 1px solid transparent; }
.flash-success { background: var(--b-success-bg); color: var(--b-success); }
.flash-error   { background: var(--b-error-bg);   color: var(--b-error); }
.flash-warning { background: var(--b-warning-bg); color: var(--b-warning); }
.flash-info    { background: var(--b-info-bg);    color: var(--b-info); }

/* ── En-tête de page ── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1, .page-title { font-family: var(--font-display); font-size: 34px; font-weight: 400; letter-spacing: -.01em; line-height: 1.15; }
.page-subtitle { font-size: 14px; color: var(--b-text-2); margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--b-r); border: 1px solid transparent;
  font-size: 13px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:disabled, .btn.disabled { cursor: not-allowed; }
.btn-primary { background: var(--b-accent); color: #fff; }
.btn-primary:hover { background: var(--b-accent-hover); color: #fff; }
.btn-primary:disabled { background: var(--b-accent-disabled); }
.btn-secondary { background: var(--b-surface); border-color: var(--b-border-strong); color: var(--b-text); }
.btn-secondary:hover { background: var(--b-bg); color: var(--b-text); }
.btn-secondary:disabled { border-color: var(--b-border); color: var(--b-text-disabled); background: var(--b-surface); }
.btn-ghost { background: none; color: var(--b-accent); }
.btn-ghost:hover { background: var(--b-accent-soft); color: var(--b-accent-hover); }
.btn-danger { background: var(--b-surface); border-color: var(--b-error-border); color: var(--b-error); }
.btn-danger:hover { background: var(--b-error); border-color: var(--b-error); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--b-r-md); }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }

/* ── Cartes ── */
.card { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-card); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--b-border); }
.card-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; line-height: 1.2; color: var(--b-text); }
.card-subtitle { font-size: 13px; color: var(--b-text-3); }
.card-body { padding: 16px 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--b-border-soft); display: flex; gap: 8px; justify-content: flex-end; }
.card-link { font-size: 13px; font-weight: 500; }

/* ── Bande KPI (nouveau) + stat-card (compat) ── */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-card); overflow: hidden; }
.kpi { padding: 22px 24px; display: flex; flex-direction: column; gap: 8px; border-right: 1px solid var(--b-border-soft); margin-right: -1px; color: inherit; }
a.kpi:hover { background: var(--b-surface-hover); color: inherit; }
.kpi-label { font-size: 13px; color: var(--b-text-2); }
.kpi-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-value { font-family: var(--font-display); font-size: 36px; font-weight: 400; letter-spacing: -.01em; line-height: 1.1; color: var(--b-text); }
.kpi-sub { font-size: 13px; color: var(--b-text-3); }
.kpi-delta { font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: var(--b-r-xs); background: var(--b-neutral-bg); color: var(--b-neutral); }
.kpi-delta.up   { background: var(--b-success-bg); color: var(--b-success); }
.kpi-delta.down { background: var(--b-error-bg);   color: var(--b-error); }
.kpi-delta.warn { background: var(--b-warning-bg); color: var(--b-warning); }
.kpi-bar { height: 4px; border-radius: 2px; background: var(--b-border-soft); overflow: hidden; }
.kpi-bar > span { display: block; height: 100%; background: var(--b-accent); border-radius: 2px; }
.stat-card { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-card); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; color: inherit; }
.stat-icon { display: none; }
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 400; letter-spacing: -.01em; line-height: 1.1; color: var(--b-text); }
.stat-label { font-size: 13px; color: var(--b-text-2); }
.stat-delta { font-size: 12px; font-weight: 500; }
.stat-delta.up { color: var(--b-success); }
.stat-delta.down { color: var(--b-error); }

/* ── Listes de lignes (dashboard) ── */
.row-list { display: flex; flex-direction: column; }
.row-item { display: grid; grid-template-columns: 56px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--b-border-soft); color: inherit; }
.row-item:last-child { border-bottom: 0; }
a.row-item:hover { background: var(--b-surface-hover); color: inherit; }
.row-time { display: flex; flex-direction: column; font-size: 13px; }
.row-time b { font-weight: 500; }
.row-time span { color: var(--b-text-3); }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; border-left: 2px solid var(--b-border-strong); padding-left: 12px; }
.row-main.is-done { border-left-color: var(--b-success); }
.row-main.is-current { border-left-color: var(--b-accent); }
.row-title { font-size: 14px; font-weight: 500; color: var(--b-text); }
.row-meta { font-size: 13px; color: var(--b-text-2); }
.row-meta-2 { font-size: 13px; color: var(--b-text-3); }
.todo-group-head { display: flex; align-items: center; gap: 8px; padding: 12px 18px 6px; font-size: 13px; }
.todo-group-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--b-accent); }
.todo-group-head .dot.error { background: var(--b-error); }
.todo-group-head .dot.warning { background: var(--b-warning-dot); }
.todo-group-head strong { font-weight: 600; }
.todo-group-head span { color: var(--b-text-3); }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 8px 18px; }
.todo-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.todo-item-title { font-size: 13.5px; font-weight: 500; color: var(--b-text); }
.todo-item-detail { font-size: 13px; color: var(--b-text-2); }
.todo-item-detail.error { color: var(--b-error); }
.todo-item-amount { font-size: 13px; }

/* ── Graphique barres CSS ── */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 10px; align-items: end; height: 180px; border-bottom: 1px solid var(--b-border); }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bar-val { font: 500 11px var(--font-body); color: var(--b-text-2); }
.bar-fill { width: 100%; max-width: 44px; border-radius: 4px 4px 0 0; background: var(--b-accent-muted); }
.bar.current .bar-fill { background: var(--b-accent); }
.bars-labels { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 10px; margin-top: 8px; }
.bars-labels span { text-align: center; font-size: 12px; color: var(--b-text-3); }

/* ── Tableaux ── */
.table-wrap { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-card); overflow-x: auto; }
.table-wrap table, table.table { width: 100%; border-collapse: collapse; }
.table-wrap th, table.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--b-text-3); padding: 10px 16px; border-bottom: 1px solid var(--b-border); background: var(--b-surface); white-space: nowrap; }
.table-wrap td, table.table td { padding: 12px 16px; border-bottom: 1px solid var(--b-border-soft); font-size: 14px; vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td { background: var(--b-surface-hover); }
.table-wrap th.sortable { cursor: pointer; }
.sort-indicator { color: var(--b-text-disabled); margin-left: 4px; }
th.sorted .sort-indicator { color: var(--b-accent); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Formulaires ── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--b-text); }
.form-label .req { color: var(--b-accent); }
.form-control, .filter-select, .search-input, select.form-control, textarea.form-control {
  height: 36px; padding: 0 10px; width: 100%;
  background: var(--b-surface); color: var(--b-text);
  border: 1px solid var(--b-border-strong); border-radius: var(--b-r);
  font-size: 14px; outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
textarea.form-control { height: auto; min-height: 88px; padding: 8px 10px; line-height: 1.45; resize: vertical; }
.form-control:focus, .filter-select:focus, .search-input:focus { border-color: var(--b-accent); box-shadow: var(--b-ring); }
.form-control.is-invalid { border-color: var(--b-error); }
.form-control:disabled { background: var(--b-bg); border-color: var(--b-border); color: var(--b-text-disabled); }
.form-hint { font-size: 12.5px; color: var(--b-text-3); }
.form-error { font-size: 12.5px; color: var(--b-error); }
.form-section { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-card); padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.form-section-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--b-accent); }

/* ── Badges de statut : pastille + point ── */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 2px 8px; border-radius: var(--b-r-full); white-space: nowrap; background: var(--b-neutral-bg); color: var(--b-neutral); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-actif, .badge-accepte, .badge-payee, .badge-realise, .badge-success { background: var(--b-success-bg); color: var(--b-success); }
.badge-envoye, .badge-client, .badge-planifie, .badge-info { background: var(--b-info-bg); color: var(--b-info); }
.badge-prospect, .badge-echeance, .badge-warning { background: var(--b-warning-bg); color: var(--b-warning); }
.badge-expire, .badge-refuse, .badge-impayee, .badge-annule, .badge-error { background: var(--b-error-bg); color: var(--b-error); }
.badge-brouillon, .badge-resilie, .badge-neutral { background: var(--b-neutral-bg); color: var(--b-neutral); }
.badge-encours { background: var(--b-accent-soft); color: var(--b-accent-hover); }
.count-chip { font: 500 12px var(--font-body); color: var(--b-text-2); }

/* ── Barre d'outils ── */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-input-wrap { position: relative; flex: 1 1 240px; max-width: 360px; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--b-text-3); pointer-events: none; }
.search-input { padding-left: 32px; }
.filter-select { width: auto; padding-right: 28px; }
.toolbar-spacer { flex: 1; }
.toolbar-count { font-size: 13px; color: var(--b-text-3); }

/* ── Signature ── */
.signature-wrap { border: 1px dashed var(--b-border-strong); border-radius: var(--b-r); background: var(--b-surface); }
.signature-toolbar { display: flex; gap: 8px; justify-content: flex-end; padding: 8px; }

/* ── État vide ── */
.empty-state { padding: 32px 18px; text-align: center; color: var(--b-text-3); font-size: 13.5px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state p { margin: 0; }

/* ── Modale / panneau ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(27,35,48,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--b-surface); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-modal); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-title { font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.modal-close { width: 32px; height: 32px; border: 0; background: none; border-radius: var(--b-r-md); cursor: pointer; color: var(--b-text-3); }
.modal-close:hover { background: var(--b-bg); color: var(--b-text); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.side-panel { position: fixed; top: 72px; right: 20px; width: 340px; max-height: calc(100vh - 92px); background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); box-shadow: var(--b-shadow-modal); z-index: 1001; display: flex; flex-direction: column; }

/* ── Toasts ── */
.toast-msg { background: var(--b-sidebar) !important; color: #F3EFE8; border: 0 !important; border-radius: var(--b-r) !important; box-shadow: var(--b-shadow-modal) !important; }
.toast-msg span { color: #F3EFE8 !important; }

/* ── Recherche globale / autocomplete ── */
.autocomplete-dropdown { position: absolute; z-index: 200; background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r); box-shadow: var(--b-shadow-menu); padding: 4px; max-height: 320px; overflow: auto; }
.autocomplete-item { padding: 8px; border-radius: var(--b-r-md); cursor: pointer; font-size: 13.5px; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--b-bg); }
.autocomplete-display { font-weight: 500; }
.autocomplete-detail { font-size: 12.5px; color: var(--b-text-3); }
.autocomplete-empty { padding: 10px 8px; font-size: 13px; color: var(--b-text-3); }

/* ── Mobile ── */
.mobile-nav { display: none; }
.fab { position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border-radius: 50%; background: var(--b-accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--b-shadow-modal); z-index: 90; }
.mobile-card-list { display: none; }
.m-card { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-card); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.m-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m-card-title { font-weight: 600; font-size: 15px; }
.m-card-sub { font-size: 13px; color: var(--b-text-3); }
.m-card-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.m-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.sidebar-overlay { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: none; }
  .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(27,35,48,.45); z-index: 99; }
  .main-content, body.sidebar-collapsed .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar-toggle { display: flex; }
  .page-body { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); gap: 20px; }
  .page-header h1, .page-title { font-size: 28px; }
  .form-grid, .form-grid-3 { grid-template-columns: minmax(0,1fr); }
  .mobile-nav { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; background: var(--b-surface); border-top: 1px solid var(--b-border); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav-inner { display: flex; height: 60px; }
  .mobile-nav-item { flex:1 1 0; min-width:0; padding:4px 1px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; font-size: 10px; font-weight: 500; color: var(--b-text-3); background: none; border: 0; cursor: pointer; }
  .mobile-nav-item.active { color: var(--b-accent); }
  .mobile-nav-icon { display: flex; }
  .btn { height: 40px; }
  .btn-sm { height: 32px; }
  .form-control, .filter-select, .search-input { height: 44px; font-size: 16px; }
}
@media (max-width: 600px) {
  .table-wrap.has-mobile-cards { display: none; }
  .mobile-card-list { display: flex; flex-direction: column; gap: 10px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi { padding: 16px; border-bottom: 1px solid var(--b-border-soft); }
  .kpi-value { font-size: 28px; }
  .row-item { grid-template-columns: 48px minmax(0,1fr); }
  .row-item > .badge { grid-column: 2; justify-self: start; }
}

/* ════════════════════════════════════════════════════════════════════
   3. RACCORDS DIRECTION B ↔ APPLICATION
   Mécanismes que la charte B ne couvre pas (ouverture des modales, listes
   mobiles…) et composants ajoutés à l'application, alignés sur les tokens B.
   Toute couleur passe par un token --b-*.
   ════════════════════════════════════════════════════════════════════ */

/* ── Base ── */
a { color: inherit; }
a:hover { color: inherit; }
.card-link, .link { color: var(--b-accent); font-weight: 500; }
.card-link:hover, .link:hover { color: var(--b-accent-hover); }
.page-body { display: block; }
.page-body > .page-header { margin-bottom: 24px; }
body, input, select, textarea, button { font-family: var(--font-body); }
h1, h2, h3, .card-title, .modal-title, .form-section-title { letter-spacing: -0.01em; }
.muted { color: var(--b-text-3); }
.txt-red { color: var(--b-error) !important; }
.txt-green { color: var(--b-success) !important; }
.txt-orange { color: var(--b-warning) !important; }
::selection { background: var(--b-accent-soft); }

/* ── En-têtes de tableaux : casse normale, 12/500 ── */
th { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; color: var(--b-text-3); }
td { border-bottom-color: var(--b-border-soft); }
tbody tr:hover td { background: var(--b-surface-hover); }
tr.row-link:hover td { background: var(--b-surface-hover); }

/* ── Champs : flèche des listes déroulantes ── */
select.form-control, .filter-select { padding-right: 32px; background-position: right 10px center; }
.form-section-title { margin: 0; padding: 0; border: 0; }
.form-section-title .dot { display: none; }
.form-section { margin-bottom: 20px; }
.form-label .required { color: var(--b-accent); }

/* ── Modales : fermées par défaut, ouvertes avec .open ── */
.modal-overlay { opacity: 0; pointer-events: none; transition: opacity var(--transition); backdrop-filter: none; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.6); }

/* ── Listes mobiles : cartes sous 768 px (les tableaux « desktop » sont masqués) ── */
@media (max-width: 768px) {
  .mobile-card-list { display: flex; flex-direction: column; gap: 10px; }
}

/* ── Barre du haut ── */
.topbar-search-wrap { position: relative; }
.gs-field { position: relative; }
.gs-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--b-text-3); pointer-events: none; }
.gs-input {
  height: 34px; width: 240px; padding: 0 12px 0 32px;
  background: var(--b-surface); color: var(--b-text);
  border: 1px solid var(--b-border); border-radius: var(--b-r);
  font-size: 13.5px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.gs-input::placeholder { color: var(--b-text-3); }
.gs-input:focus { border-color: var(--b-accent); box-shadow: var(--b-ring); }
.gs-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 300px; z-index: 200; overflow: hidden;
  background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r); box-shadow: var(--b-shadow-menu);
}
.topbar-icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--b-border); background: var(--b-surface);
  border-radius: var(--b-r); color: var(--b-text-2); transition: background var(--transition), border-color var(--transition);
}
.topbar-icon-btn:hover { background: var(--b-surface-hover); border-color: var(--b-border-strong); color: var(--b-text); }
.topbar-icon-btn svg { width: 16px; height: 16px; }
#globalSearchWrap { display: flex; align-items: center; }
.topbar-icon-btn.gs-open-btn { display: none; }
@media (max-width: 768px) {
  .topbar-icon-btn.gs-open-btn { display: inline-flex; }
  .topbar.search-open .topbar-icon-btn.gs-open-btn { display: none !important; }
}
.topbar-count {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--b-accent); color: #fff; border-radius: var(--b-r-xs);
  font: 600 11px/16px var(--font-body); text-align: center;
}
@media (max-width: 900px) {
  .topbar-primary span { display: none; }
  .topbar-primary { width: 40px; padding: 0; }
}

/* ── Toasts (messages de confirmation) ── */
#toastContainer { position: fixed; right: 24px; bottom: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-msg {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 400px; padding: 12px 14px;
  pointer-events: auto; animation: toastIn .16s ease;
}
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; color: #F3EFE8; }
.toast-error .toast-icon { color: #EE9A8F; }
.toast-success .toast-icon { color: #8CC39A; }
.toast-text { flex: 1; font-size: 13.5px; font-weight: 500; }
.toast-close { background: none; border: 0; color: #A9B0BC; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-close:hover { color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) { #toastContainer { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); } .toast-msg { max-width: none; } }

/* ── Pastilles de statut (fiches) = badges B ── */
.pill { border-radius: var(--b-r-full); font-size: 12.5px; font-weight: 500; padding: 2px 8px; }
.pill-gray   { background: var(--b-neutral-bg); color: var(--b-neutral); }
.pill-blue   { background: var(--b-info-bg);    color: var(--b-info); }
.pill-green  { background: var(--b-success-bg); color: var(--b-success); }
.pill-orange { background: var(--b-warning-bg); color: var(--b-warning); }
.pill-red    { background: var(--b-error-bg);   color: var(--b-error); }
.badge-encours, .pill-accent { background: var(--b-accent-soft); color: var(--b-accent-hover); }

/* ── Menus « … » et listes déroulantes ── */
.menu-pop { background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r); box-shadow: var(--b-shadow-menu); }
.menu-pop a, .menu-pop button { border-radius: var(--b-r-md); font-size: 13.5px; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--b-surface-hover); }
.menu-pop button.danger { color: var(--b-error); }
.menu-pop hr { border-top-color: var(--b-border-soft); }

/* ── Fiches devis / facture ── */
.doc-head h1 { font-family: var(--font-display); font-size: 34px; font-weight: 400; }
.doc-kind { color: var(--b-text-3); }
.doc-meta span { color: var(--b-text-3); }
.doc-summary-amount { font-family: var(--font-display); font-size: 36px; font-weight: 400; }
.doc-table th { font-size: 12px; }
.doc-totaux .ttc dd { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.progress > div { background: var(--b-success); }
.doc-num { color: var(--b-text); font-weight: 500; }
.doc-num:hover { color: var(--b-accent); }

/* ── Barre d'enregistrement des formulaires ── */
@media (min-width: 769px) {
  .form-actions { background: color-mix(in srgb, var(--b-bg) 90%, transparent); border-top-color: var(--b-border); }
}

/* ── Paramètres : Google Agenda ── */
.g-simple { border-color: var(--b-border); background: var(--b-surface); }
.g-copy code { background: var(--b-bg); border-color: var(--b-border); }
.g-steps a { color: var(--b-accent); }

/* ════════════════════════════════════════════════════════════════════
   4. TABLEAU DE BORD (Direction B)
   ════════════════════════════════════════════════════════════════════ */
.dash { display: flex; flex-direction: column; gap: 24px; }
.dash-banner { background: var(--b-accent-soft); color: var(--b-accent-hover); border-radius: var(--b-r); padding: 12px 16px; font-size: 14px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.kpi-strip.kpi-compact { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi-strip.kpi-large   { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kpi-strip .kpi-bar { margin-top: 2px; }
.kpi-strip .kpi { border-bottom: 1px solid var(--b-border-soft); margin-bottom: -1px; }
.card-header .card-subtitle { margin-top: 2px; }
.todo-group + .todo-group { border-top: 1px solid var(--b-border-soft); }
.todo-group-head { justify-content: flex-start; }
.todo-group-head .btn { margin-left: auto; }
.todo-group-foot { padding: 0 18px 10px; }
.todo-item-amount { white-space: nowrap; }
.todo-item form { margin: 0; }
.chart-total { font-family: var(--font-display); font-size: 30px; font-weight: 400; letter-spacing: -.01em; }
.chart-card { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.chart-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.share-bar { height: 4px; background: var(--b-border-soft); border-radius: 2px; overflow: hidden; }
.share-bar > span { display: block; height: 100%; background: var(--b-accent); border-radius: 2px; }
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.legend-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend-list i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }

/* Panneau « Personnaliser » */
.side-panel-overlay { position: fixed; inset: 0; background: rgba(27,35,48,.45); z-index: 1000; }
.side-panel-head { padding: 14px 18px; border-bottom: 1px solid var(--b-border); display: flex; align-items: center; justify-content: space-between; }
.side-panel-section { padding: 12px 18px; border-bottom: 1px solid var(--b-border-soft); }
.side-panel-foot { padding: 12px 18px; border-top: 1px solid var(--b-border); display: flex; gap: 8px; }
.side-panel-label { font-size: 12px; font-weight: 500; color: var(--b-text-3); margin-bottom: 8px; }
.segmented { display: flex; background: var(--b-neutral-bg); border-radius: var(--b-r-md); padding: 2px; gap: 2px; }
.segmented button { flex: 1; height: 28px; border: 0; background: none; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--b-text-2); cursor: pointer; }
.segmented button.active { background: var(--b-surface); color: var(--b-text); box-shadow: var(--b-shadow-xs); }
.widget-row {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin-bottom: 6px;
  border: 1px solid var(--b-border); border-radius: var(--b-r-md); background: var(--b-surface);
  cursor: grab; font-size: 13px; color: var(--b-text); user-select: none;
}
.widget-row.off { border-style: dashed; border-color: var(--b-border-strong); color: var(--b-text-disabled); }
.widget-row .grip { color: var(--b-text-disabled); display: flex; }

@media (max-width: 900px) {
  .page-header h1 { font-size: 28px; }
}
@media (max-width: 600px) {
  .todo-item { flex-wrap: wrap; }
  .chart-total { font-size: 24px; }
}

/* ── Correctifs de raccord (vérification écran par écran) ── */
.pill, .badge { font-family: var(--font-body); letter-spacing: 0; }
.btn-icon {
  flex-shrink: 0; min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r-md); color: var(--b-text-2);
}
.btn-icon:hover { background: var(--b-surface-hover); border-color: var(--b-border-strong); color: var(--b-text); }
.btn-icon.btn-sm { min-width: 28px; height: 28px; }
.fab { display: none; }
@media (max-width: 768px) { .fab { display: flex; } }

/* ── Barre latérale : Paramètres en bas ── */
.nav-section-bottom { margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.06); }

/* ── Listes (clients…) : carte avec barre d'outils intégrée ── */
.list-card { overflow: visible; }
.list-card > .table-wrap, .list-card > .desktop-table-wrap { border: 0; border-radius: 0 0 var(--b-r-card) var(--b-r-card); box-shadow: none; }
.list-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--b-border); }
.list-toolbar .search-input-wrap { flex: 0 1 300px; }
.list-filters { display: flex; gap: 8px; }
.segmented.seg-links a { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--b-text-2); }
.segmented.seg-links a:hover { color: var(--b-text); }
.segmented.seg-links a.active { background: var(--b-surface); color: var(--b-text); box-shadow: var(--b-shadow-xs); }
.segmented.seg-links { flex: 0 0 auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--b-neutral-bg); color: var(--b-text-2); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; background: var(--b-sidebar); color: #F3EFE8; }
.client-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-cell-text { display: flex; flex-direction: column; min-width: 0; }
.client-name { font-weight: 500; color: var(--b-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-sub { font-size: 12.5px; color: var(--b-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-quiet { background: none; border-color: transparent; color: var(--b-text-3); }
.btn-quiet:hover { background: var(--b-surface-hover); border-color: var(--b-border); color: var(--b-text); }
@media (max-width: 768px) {
  .list-card { background: none; border: 0; box-shadow: none; }
  .list-toolbar { padding: 0 0 12px; border: 0; }
  .list-toolbar .search-input-wrap { flex: 1 1 100%; max-width: none; }
  .list-filters { display: flex; flex-wrap: wrap; width: 100%; }
  .list-filters .filter-select { flex: 1 1 140px; min-width: 0; }
}
.client-line { display: flex; align-items: center; gap: 6px; min-width: 0; }

/* ── Fiches (client…) : en-tête ── */
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--b-text-3); margin-bottom: 10px; }
.back-link svg { width: 14px; height: 14px; }
.back-link:hover { color: var(--b-text); }
.fiche-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.fiche-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.fiche-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fiche-title h1 { margin-right: 4px; }
.fiche-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; font-size: 13.5px; color: var(--b-text-2); }
.fiche-meta > * { display: inline-flex; align-items: center; gap: 6px; }
.fiche-meta svg { width: 14px; height: 14px; color: var(--b-text-3); flex-shrink: 0; }
.fiche-meta a:hover { color: var(--b-accent); }
.kpi-value-sm { font-size: 24px; }
@media (max-width: 600px) { .kpi-value-sm { font-size: 20px; } .avatar-lg { width: 38px; height: 38px; } }

/* ── Paramètres : menu vertical + contenu ── */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 1px; }
.settings-nav a { display: block; padding: 7px 10px; border-radius: var(--b-r-md); font-size: 13.5px; color: var(--b-text-2); transition: background var(--transition), color var(--transition); }
.settings-nav a:hover { background: var(--b-surface-hover); color: var(--b-text); }
.settings-nav a.active { background: var(--b-surface); color: var(--b-text); font-weight: 500; box-shadow: var(--b-shadow-xs); }
.settings-main { min-width: 0; }
.settings-nav-mobile { display: none; }
.settings-main .settings-section { margin-top: 0 !important; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { display: none; }
  .settings-nav-mobile { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--b-text-2); }
}

/* ── Formulaire d'intervention (maquette « Nouvelle intervention ») ── */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.iform { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; max-width: 1100px; }
.iform-card { overflow: visible; }
.iform-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 20px 22px; border-bottom: 1px solid var(--b-border-soft); }
.iform-row:last-child { border-bottom: 0; }
.iform-desc h2 { font-family: var(--font-body); font-size: 14px; font-weight: 600; letter-spacing: 0; }
.iform-desc p { font-size: 13px; color: var(--b-text-3); margin-top: 4px; line-height: 1.45; }
.segmented.seg-inline { display: inline-flex; width: fit-content; }
.segmented.seg-inline button { flex: 0 0 auto; padding: 0 14px; }
.iform-recap { position: sticky; top: calc(var(--topbar-h) + 20px); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.iform-recap-title { font-size: 14px; font-weight: 600; }
.iform-recap dl { margin: 0 0 6px; display: flex; flex-direction: column; gap: 6px; }
.iform-recap dl > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.iform-recap dt { color: var(--b-text-3); }
.iform-recap dd { margin: 0; font-weight: 500; text-align: right; }
@media (max-width: 1000px) {
  .iform { grid-template-columns: minmax(0, 1fr); }
  .iform-recap { position: static; }
  .iform-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

/* ── Ajustements mobile (vérification 375 px) ── */
@media (max-width: 600px) {
  .kpi-strip.kpi-compact, .kpi-strip.kpi-large { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segmented.seg-inline { flex-wrap: wrap; width: 100%; }
  .segmented.seg-inline button { flex: 1 1 auto; }
  .fiche-id { align-items: flex-start; }
  .fiche-head .page-header-actions { width: 100%; }
  .fiche-head .page-header-actions .btn { flex: 1 1 auto; }
}

/* ════════════════════════════════════════════════════════════════════
   5. FIL DE VIE DU CHANTIER (devis → intervention → attestation → facture)
   ════════════════════════════════════════════════════════════════════ */
.chaine { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 20px; overflow: visible; }
.chaine-etapes { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; min-width: 0; }
.chaine-etape { display: flex; align-items: center; }
.chaine-etape + .chaine-etape::before { content: ''; width: 22px; height: 1px; background: var(--b-border-strong); margin: 0 6px; }
.chaine-etape a { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--b-r-md); transition: background var(--transition); }
.chaine-etape a:hover { background: var(--b-surface-hover); }
.chaine-point { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--b-border-strong); background: var(--b-surface); color: #fff; }
.chaine-point svg { width: 10px; height: 10px; }
.chaine-etape.is-fait .chaine-point { background: var(--b-success); border-color: var(--b-success); }
.chaine-etape.is-en_cours .chaine-point { border-color: var(--b-accent); box-shadow: inset 0 0 0 3px var(--b-surface), inset 0 0 0 9px var(--b-accent); }
.chaine-etape.is-bloque .chaine-point { background: var(--b-error); border-color: var(--b-error); }
.chaine-texte { display: flex; flex-direction: column; line-height: 1.25; }
.chaine-label { font-size: 13px; font-weight: 500; color: var(--b-text); white-space: nowrap; }
.chaine-sub { font-size: 12px; color: var(--b-text-3); }
.chaine-etape.is-courant a { background: var(--b-bg); }
.chaine-etape.is-courant .chaine-label { font-weight: 600; }
.chaine-suite { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chaine-suite form { margin: 0; }
.chaine-suite-label { font-size: 12.5px; color: var(--b-text-3); }
@media (max-width: 768px) {
  .chaine { flex-direction: column; align-items: stretch; }
  .chaine-etapes { flex-direction: column; align-items: stretch; }
  .chaine-etape + .chaine-etape::before { display: none; }
  .chaine-suite { justify-content: space-between; border-top: 1px solid var(--b-border-soft); padding-top: 10px; }
}

/* ════════════════════════════════════════════════════════════════════
   6. TABLEAU DE BORD MODULABLE (blocs S = 1/3, M = 1/2, L = pleine largeur)
   ════════════════════════════════════════════════════════════════════ */
.dash-blocs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; align-items: start; }
.bloc { min-width: 0; position: relative; }
.bloc > .card { height: 100%; }
.bloc-s { grid-column: span 2; }
.bloc-m { grid-column: span 3; }
.bloc-l { grid-column: span 6; }
.bloc-tools { display: none; }
.btn-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.raccourcis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.raccourcis .btn { width: 100%; }
.client-photo-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:10px; margin-top:18px; }
.client-photo-card { position:relative; display:block; aspect-ratio:4/3; overflow:hidden; border-radius:10px; background:var(--b-bg); border:1px solid var(--b-border); }
.client-photo-card img { width:100%; height:100%; object-fit:cover; display:block; }
.client-photo-card span { position:absolute; inset:auto 0 0; padding:18px 8px 7px; color:#fff; font-size:11px; background:linear-gradient(transparent,rgba(0,0,0,.72)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dossier-upload-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; }
.dossier-upload-actions .form-hint { margin:0; overflow-wrap:anywhere; }
.client-document-list { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 16px; margin-top:18px; font-size:13px; }
.client-document-list span { color:var(--b-text-3); text-align:right; }
.notice-direct-link { display:inline-flex; align-items:center; min-height:32px; padding:4px 8px; font-size:11px; font-weight:600; background:var(--b-accent-soft); color:var(--b-warning); border-radius:6px; border:1px solid var(--b-accent-muted); text-decoration:none; white-space:nowrap; }
.dash-edit-hint { display: none; }
.dash-edit .dash-edit-hint {
  display: flex; align-items: center; gap: 8px; margin: 12px 0 16px; padding: 10px 14px;
  border: 1px solid var(--b-accent-muted); border-radius: var(--b-r); background: var(--b-accent-soft);
  color: var(--b-warning); font-size: 13px;
}
.obj-form { display: flex; gap: 8px; margin-top: 4px; }
.obj-form .form-control { max-width: 160px; }
#dashNotes { min-height: 140px; }

/* Mode édition */
.dash-edit .bloc { outline: 1px dashed var(--b-border-strong); outline-offset: 4px; border-radius: var(--b-r-card); cursor: grab; }
.dash-edit .bloc > .card { pointer-events: none; opacity: .92; }
.dash-edit .bloc-tools {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 8px;
  background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r); box-shadow: var(--b-shadow-xs);
}
.bloc-grip { display: flex; align-items:center; justify-content:center; color: var(--b-text-3); cursor: grab; touch-action: none; min-width: 32px; min-height: 32px; border-radius:6px; }
.bloc-grip:focus-visible { outline: 2px solid var(--b-accent); outline-offset: 2px; }
.bloc-grip svg { width: 14px; height: 14px; }
.bloc-nom { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bloc-tailles { display: inline-flex; }
.bloc-tailles button { width: 28px; flex: 0 0 auto; }
.bloc-ajouter { display: none; }
.dash-edit .bloc.is-off { display: block; outline-color: var(--b-border); }
.dash-edit .bloc.is-off > .card { opacity: .38; }
.dash-edit .bloc.is-off .bloc-ajouter { display: inline-flex; }
.dash-edit .bloc.is-off .bloc-tailles, .dash-edit .bloc.is-off .bloc-retirer { display: none; }
.dash-edit .bloc.is-dragging { opacity: .4; }
.dash-edit .bloc.drop-avant { box-shadow: -4px 0 0 var(--b-accent); }
@media (max-width: 1100px) {
  .bloc-s { grid-column: span 3; }
}
@media (max-width: 900px) {
  .dash-blocs { grid-template-columns: minmax(0, 1fr); }
  .bloc-s, .bloc-m, .bloc-l { grid-column: 1 / -1; }
  .bloc-tailles { display: none; }
  .dash-edit .bloc-tools { position: sticky; top: 64px; z-index: 3; }
  .dash-edit .bloc-grip { min-width: 44px; min-height: 44px; }
}
@media (max-width: 600px) {
  .client-photo-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .client-document-list { grid-template-columns:minmax(0,1fr); gap:2px; }
  .client-document-list span { text-align:left; margin-bottom:8px; }
  .notice-direct-link { min-height:40px; }
  .client-appareil-row { align-items:flex-start !important; flex-direction:column; gap:8px; }
  .client-appareil-actions { width:100%; }
}
.obj-form[hidden] { display: none; }

/* ════════════════════════════════════════════════════════════════════
   7. HISTORIQUE UNIFIÉ + APERÇU AU SURVOL
   ════════════════════════════════════════════════════════════════════ */
.histo { list-style: none; margin: 0; padding: 8px 18px 16px; }
.histo-mois { font-size: 12px; font-weight: 500; color: var(--b-text-3); padding: 14px 0 6px; text-transform: capitalize; }
.histo-ev { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--b-border-soft); }
.histo-ev:last-child { border-bottom: 0; }
.histo-point { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--b-border-strong); }
.histo-point.ton-success { background: var(--b-success); }
.histo-point.ton-info { background: var(--b-info); }
.histo-point.ton-warning { background: var(--b-warning-dot); }
.histo-point.ton-error { background: var(--b-error); }
.histo-corps { display: flex; flex-direction: column; min-width: 0; }
.histo-corps:hover .histo-titre { color: var(--b-accent); }
.histo-titre { font-size: 13.5px; font-weight: 500; color: var(--b-text); }
.histo-detail { font-size: 13px; color: var(--b-text-3); }
.histo-date { font-size: 12.5px; color: var(--b-text-3); white-space: nowrap; }
#histoFiltres { flex-wrap: wrap; }
#histoFiltres button { flex: 0 0 auto; padding: 0 10px; }

.apercu-carte {
  position: fixed; z-index: 1500; width: 280px; padding: 12px 14px; pointer-events: auto;
  background: var(--b-surface); border: 1px solid var(--b-border); border-radius: var(--b-r); box-shadow: var(--b-shadow-menu);
  opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease;
}
.apercu-carte.visible { opacity: 1; transform: none; }
.apercu-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.apercu-titre { font-size: 14px; font-weight: 600; color: var(--b-text); line-height: 1.3; }
.apercu-carte dl { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.apercu-carte dl > div { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.apercu-carte dt { color: var(--b-text-3); }
.apercu-carte dd { margin: 0; text-align: right; font-weight: 500; color: var(--b-text); }
.apercu-lien { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 500; color: var(--b-accent); }
.histo-ev[hidden], .histo-mois[hidden] { display: none; }

/* ── Logements : principal / location + locataire ── */
.logement-type { margin-bottom: 4px; }
.locataire { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; padding: 6px 10px; border-radius: var(--b-r-md); background: var(--b-bg); font-size: 13px; }
.locataire-nom { font-weight: 500; color: var(--b-text); }
.locataire a { color: var(--b-accent); }

/* ── Factures : filtres par période + exports ── */
.fac-filtres { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; margin-bottom: 16px; overflow: visible; }
.fac-filtres-ligne { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fac-filtres .search-input-wrap { flex: 0 1 240px; }
.fac-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--b-text-2); }
.fac-date .form-control { width: 150px; }
.fac-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.fac-presets button { height: 26px; padding: 0 10px; border: 1px solid var(--b-border); border-radius: var(--b-r-full); background: var(--b-surface); font-size: 12.5px; color: var(--b-text-2); cursor: pointer; }
.fac-presets button:hover { border-color: var(--b-border-strong); color: var(--b-text); }
.btn.disabled { opacity: .55; pointer-events: none; }
@media (max-width: 768px) { .fac-date .form-control { width: 100%; } .fac-date { flex: 1 1 45%; } }

/* ── Rapport ventes & devis ── */
.legende-mois { display: flex; gap: 14px; font-size: 12.5px; color: var(--b-text-3); }
.legende-mois i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.lg-f { background: var(--b-accent); }
.lg-e { background: var(--b-success); }
.barre-mois { height: 5px; background: var(--b-border-soft); border-radius: 3px; overflow: hidden; margin: 2px 0; }
.barre-mois > span { display: block; height: 100%; border-radius: 3px; }
.barre-mois > .lg-f { opacity: .85; }
.devis-statuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--b-border); }
.devis-statuts > div { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border-right: 1px solid var(--b-border-soft); }
.devis-statuts > div:last-child { border-right: 0; }
.devis-statuts strong { font-family: var(--font-display); font-size: 26px; font-weight: 400; }
.devis-alerte { margin: 0; padding: 10px 18px; background: var(--b-warning-bg); color: var(--b-warning); font-size: 13px; }
@media (max-width: 600px) { .devis-statuts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Impression (rapports) ── */
@media print {
  .sidebar, .topbar, .mobile-nav, .fab, #toastContainer, .no-print, .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .card, .kpi-strip, .table-wrap { box-shadow: none !important; break-inside: avoid; }
  tr.row-link { cursor: default; }
}
.alerte-systeme { margin: 16px 28px 0; padding: 10px 14px; border-radius: var(--b-r); background: var(--b-error-bg); color: var(--b-error); font-size: 13.5px; }
@media (max-width: 900px) { .alerte-systeme { margin: 12px 16px 0; } }

/* Composants communs aux rubriques et saisie commerciale. */
:root { --b-sidebar-selected-text:#fff; --action-bg:#282622; --action-hover:#413D36; --action-text:#fff; }
[data-theme="dark"] { --action-bg:#E7E1D6; --action-hover:#FFFDF9; --action-text:#1D1B18; }
.sidebar .nav-item:hover, .sidebar .nav-item.active, .sidebar-mini .nav-item.active { background:var(--b-sidebar-active); color:var(--b-sidebar-selected-text); }
.sidebar .nav-item.active .nav-icon { color:inherit; }
.btn-primary, .fab { background:var(--action-bg); color:var(--action-text); box-shadow:none; }
.btn-primary:hover, .fab:hover { background:var(--action-hover); color:var(--action-text); box-shadow:none; transform:none; }
.btn-primary:disabled { background:var(--b-neutral-bg); color:var(--b-text-disabled); }
.quick-dialog { margin:auto; padding:24px; width:min(660px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); overflow:auto; background:var(--b-surface); color:var(--b-text); border:1px solid var(--b-border); border-radius:var(--b-r-card); }
.quick-dialog::backdrop { background:rgba(15,23,42,.45); }
.quick-dialog [role="alert"] { color:var(--b-error); margin-top:12px; }
.ligne-interne-label { display:block; font-size:11px; color:var(--b-text-2); margin-top:6px; }
.references-column { width:190px; min-width:160px; padding:8px; vertical-align:top; }
.suivi-devis { display:flex; justify-content:space-between; gap:12px; align-items:center; flex-wrap:wrap; padding:10px 0; border-bottom:1px solid var(--b-border-soft); }
@media(max-width:768px) {
  .lignes-table tr.ligne-row > td.references-column { grid-column:1 / -1; padding-right:48px !important; }
  .lignes-table tr.ligne-row > td.references-column::before { content:none; }
  .lignes-facture tr.ligne-row > td:first-child { grid-column:1 / -1; }
  .quick-dialog .form-grid { grid-template-columns:1fr; }
}
@media print { .reference-interne { display:none !important; } }

/* Shared workspace tools, usable with the same actions on desktop and phone. */
.workflow-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr)); gap:16px; margin-top:20px; }
.workflow-cards > *, .workflow-cards .form-grid > *, .document-tools { min-width:0; }
.workflow-cards h2 { font-size:18px; overflow-wrap:anywhere; }
.workflow-cards .page-header { margin:0 0 16px; gap:10px; text-align:left; align-items:flex-start; justify-content:space-between; }
.workflow-cards .page-header h2 { margin:0; }
.workflow-cards .form-section { margin:0; }
.workflow-actions { display:flex; gap:12px; flex-wrap:wrap; align-items:end; margin:12px 0; }
.workflow-actions > label { flex:1 1 180px; min-width:0; }
.workflow-choice { display:flex; align-items:start; gap:12px; padding:12px 0; border-bottom:1px solid var(--b-border); }
.workflow-choice input { margin-top:5px; }
.workflow-photos { display:grid; grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); gap:12px; }
.workflow-photos img { width:100%; height:120px; object-fit:cover; border-radius:var(--b-r); }
.workflow-photos a { display:flex; flex-direction:column; gap:6px; }
.document-tools details { margin-top:12px; }
.document-tools summary, #dossier-client summary { cursor:pointer; padding:10px 0; }
.document-tools [hidden] { display:none !important; }
#draftStatus { font-size:13px; color:var(--b-text-2); }
.document-view-choice { display:none; }
@media(max-width:768px) {
  .document-view-choice { display:block; margin:12px 0; }
  table.lignes-table.document-table-mode { display:table; min-width:950px; }
  table.lignes-table.document-table-mode thead { display:table-header-group; }
  table.lignes-table.document-table-mode tbody { display:table-row-group; }
  table.lignes-table.document-table-mode tr.ligne-row { display:table-row; }
  table.lignes-table.document-table-mode tr.ligne-row > td { display:table-cell; position:static; padding:8px !important; vertical-align:top; }
  table.lignes-table.document-table-mode tr.ligne-row > td::before { display:none; }
  table.lignes-table.document-table-mode tr.ligne-row > td:has(.ligne-desig) { min-width:260px; }
  table.lignes-table.document-table-mode tr.ligne-row > td:has(.ligne-qty),
  table.lignes-table.document-table-mode tr.ligne-row > td:has(.ligne-pu),
  table.lignes-table.document-table-mode tr.ligne-row > td:has(.ligne-tva) { min-width:90px; }
  table.lignes-table.document-table-mode:not([data-remise]) tr.ligne-row > td.td-remise { display:none; }
  .workflow-cards { grid-template-columns:minmax(0,1fr); }
  .workflow-actions .btn, .workflow-cards .btn, #dossier-client .btn { min-height:44px; height:auto; white-space:normal; }
  .document-tools .workflow-actions > * { max-width:100%; }
  .document-tools input, .document-tools select { width:100%; }
  .form-section-title { flex-wrap:wrap; gap:10px; }
  .form-section-title > div { flex-wrap:wrap; max-width:100%; }
  .form-section-title #articleSearch { width:100% !important; min-width:0; }
  .form-submit-row { position:sticky; bottom:calc(60px + env(safe-area-inset-bottom)); background:var(--b-surface); border-top:1px solid var(--b-border); z-index:20; padding:12px 0; }
  .form-submit-row .btn { min-height:44px; }
  .topbar-actions .topbar-action-secondary { display:inline-flex !important; }
  .topbar-actions { flex-wrap:wrap; }
  #dossier-client input[type=file] { height:auto; max-width:100%; }
  .dossier-upload-actions { align-items:stretch; flex-direction:column; }
  .dossier-save-btn { width:100%; min-height:50px !important; font-size:1rem; }
}
@media(max-width:768px) {
  .btn { min-height:44px; height:auto; }
  .btn-sm { min-width:40px; min-height:40px; height:auto; }
  .fac-presets button { min-height:36px; }
  .fc .fc-button { min-height:40px; }
  .fc .fc-prev-button, .fc .fc-next-button { min-width:40px; }
  .segmented.seg-inline { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
  .segmented.seg-inline button { min-height:44px; padding:0 8px; }
  .nav-picker > button { min-height:40px; padding:0 8px !important; margin-left:-8px; }
  .nav-picker-item { min-height:44px; display:flex; align-items:center; }
  .signature-toolbar button { min-width:64px; min-height:44px; }
  .modal-overlay { padding:12px; }
  .modal { max-height:calc(100dvh - 24px); padding:16px; }
  .modal-header { position:sticky; top:-16px; z-index:3; margin:-16px -16px 14px; padding:16px; background:var(--b-surface); border-bottom:1px solid var(--b-border-soft); }
  .modal-close { width:44px; height:44px; }
  .modal-footer { position:sticky; bottom:-16px; z-index:3; margin:14px -16px -16px; padding:12px 16px 16px; background:var(--b-surface); border-top:1px solid var(--b-border-soft); }
  .quick-dialog .page-header-actions, .client-dialog .page-header-actions { position:sticky; bottom:-24px; z-index:3; margin:16px -24px -24px !important; padding:12px 24px 24px; background:var(--b-surface); border-top:1px solid var(--b-border-soft); }
  .client-dialog .page-header-actions { bottom:-18px; margin:16px -18px -18px !important; padding:12px 18px 18px; }
  .menu-more > summary, .menu-pop .menu-pop-close { min-width:44px; min-height:44px; }
  .ligne-type-btn { min-height:36px; }
}
/* Sélection de commune après saisie du code postal */
.postal-city-dropdown { position:absolute; top:100%; left:0; right:0; z-index:70; max-height:220px; overflow:auto; margin-top:3px; padding:4px; background:var(--b-surface); border:1px solid var(--b-border-strong); border-radius:9px; box-shadow:var(--shadow-lg); }
.postal-city-option { display:block; width:100%; padding:9px 11px; border:0; border-radius:6px; background:transparent; color:var(--text-primary); text-align:left; cursor:pointer; }
.postal-city-option:hover,.postal-city-option:focus { background:var(--b-bg); outline:2px solid var(--b-accent-soft); }
/* Autocomplétion d'adresse issue de la Base Adresse Nationale */
.address-dropdown { position:absolute; top:100%; left:0; right:0; z-index:75; max-height:280px; overflow:auto; margin-top:3px; padding:4px; background:var(--b-surface); border:1px solid var(--b-border-strong); border-radius:9px; box-shadow:var(--shadow-lg); }
.address-option { display:block; width:100%; padding:9px 11px; border:0; border-radius:6px; background:transparent; color:var(--text-primary); text-align:left; cursor:pointer; }
.address-option:hover,.address-option:focus,.address-option.is-active { background:var(--b-bg); outline:2px solid var(--b-accent-soft); }
.address-option-main { display:block; font-weight:600; }
.address-option-detail { display:block; margin-top:2px; color:var(--text-muted); font-size:.85rem; }

/* Aperçu compact des principales marques d'appareils */
.brand-entry-row { display:flex; align-items:stretch; gap:8px; min-width:0; }
.brand-entry-row > .form-control { min-width:0; flex:1 1 auto; }
.brand-logo-preview { flex:0 0 142px; min-height:42px; padding:5px 9px; display:flex; align-items:center; justify-content:center; overflow:hidden; background:#fff; border:1px solid var(--b-border-strong); border-radius:8px; }
.brand-logo-preview[hidden] { display:none; }
.brand-logo-image { display:block; width:100%; max-width:122px; height:32px; object-fit:contain; }
.brand-logo-fallback { color:var(--text-primary); font-size:11px; font-weight:700; line-height:1.1; text-align:center; }
@media(max-width:480px) {
  .brand-logo-preview { flex-basis:118px; padding-inline:6px; }
  .brand-logo-image { max-width:104px; }
}
