/* ============================================================
   app.css — Styles globaux de l'application Popey
   Extrait de index.html lors du nettoyage Phase 2
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

  :root {
    --bg: #f4f5f5;
    --bg2: #f4f5f5;
    --surface: #ffffff;
    --surface2: #f8f9fb;
    --border: #e5e7eb;
    --border2: #d1d5db;
    --sidebar-bg: linear-gradient(180deg, #1a5c42 0%, #0e3d2f 35%, #0a2e23 100%);
    --sidebar-bg2: #0a2e23;
    --sidebar-text: rgba(255,255,255,0.72);
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #16a34a;
    --sidebar-hover-bg: rgba(255,255,255,0.08);
    --sidebar-border: rgba(255,255,255,0.1);
    --accent: #16a34a;
    --accent-light: #dcfce7;
    --accent-hover: #15803d;
    --accent2: #0284c7;
    --accent2-light: #e0f2fe;
    --accent3: #d97706;
    --accent3-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --text: #111827;
    --text2: #6b7280;
    --text3: #9ca3af;
    --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
  }

  /* SIDEBAR */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    background: linear-gradient(180deg, #1a5c42 0%, #0e3d2f 35%, #0a2e23 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 0;
  }

  .logo {
    padding: 0px 12px 0px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 0px;
  }

  .logo-bertholon {
    display: flex;
    flex-direction: column;
    gap: 0px;
    align-items: center;
  }

  .logo-svg-wrap {
    display: flex;
    align-items: center;
    gap: 0;
  }

  .logo-sub {
    font-size: 9px;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.3px;
    font-weight: 400;
    line-height: 1.3;
    padding-left: 1px;
  }

  .nav-section {
    padding: 0 10px;
    margin-bottom: 2px;
  }

  .nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    padding: 10px 8px 4px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.12s;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--sidebar-text);
  }

  .nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
  }

  .nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
  }

  .nav-icon { font-size: 15px; width: 20px; text-align: center; }

  .badge {
    margin-left: auto;
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
  }

  .badge-soon {
    margin-left: auto;
    background: rgba(245,158,11,0.25);
    color: rgba(255,220,150,0.95);
    font-size: 9px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
  }

  .nav-item.active .badge {
    background: rgba(255,255,255,0.25);
    color: white;
  }

  .sidebar-nav-scroll {
    flex: 1;
    overflow-y: auto;
  }

  .sidebar-footer {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--sidebar-border);
  }

  .user-info { display: flex; align-items: center; gap: 10px; }

  .user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #4a9bc8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
  }

  .user-name { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.9); }
  .user-role { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 1px; }

  /* MAIN LAYOUT */
  .main {
    margin-left: 240px;
    min-height: 100vh;
  }

  /* TOPBAR */
  .topbar {
    height: 56px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 12px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  /* Bouton hamburger : cache sur desktop, affiche en media query sous 1024px */
  .menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border2);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 18px;
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Voile de fond derriere le menu mobile ouvert — ferme le menu au clic */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }
  .sidebar-backdrop.show { display: block; }

  .topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
  }

  .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* BUTTONS */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 7px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    border: none;
    white-space: nowrap;
  }

  .btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 2px rgba(22,163,74,0.3);
  }

  .btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 6px rgba(22,163,74,0.35); }

  .btn-ghost {
    background: var(--surface);
    color: var(--text2);
    border: 1px solid var(--border2);
  }

  .btn-ghost:hover { background: var(--bg); color: var(--text); border-color: var(--border2); }

  .btn-success {
    background: var(--accent2-light);
    color: var(--accent2);
    border: 1px solid #a7f3d0;
  }

  .btn-success:hover { background: #d1fae5; }

  .btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
  }

  .btn-danger:hover { background: #fee2e2; }

  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* PAGE */
  .page { display: none; padding: 28px 32px; }

  /* PREVISIONS — zone KPIs + synthese mensuelle fixee sous la topbar */
  .prev-fixed-header {
    display: none; /* masquee quand la page n'est pas active */
    position: fixed;
    top: 56px; /* hauteur de la topbar */
    left: 240px; /* largeur du sidebar */
    right: 0;
    z-index: 100;
    background: var(--bg);
    padding: 10px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
  }
  .page.active { display: block; }

  /* STATS ROW */
  .stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
  }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: var(--shadow);
  }

  .stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text3);
    margin-bottom: 10px;
  }

  .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
  }

  .stat-sub {
    font-size: 11.5px;
    color: var(--text3);
    margin-top: 5px;
  }

  /* SECTION TITLE */
  .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  /* DROP ZONE */
  .drop-zone-container { margin-bottom: 28px; }

  .drop-zone {
    border: 2px dashed var(--border2);
    border-radius: 12px;
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  #rapp-dropzone:hover, #rapp-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  #rapp-dropzone.drag-over { box-shadow: 0 0 0 4px rgba(5,150,105,0.12); }
  #edit-completer-doc-dropzone:hover, #edit-completer-doc-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  .rapp-card { background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:12px; }
  .rapp-card h3 { font-size:13px;font-weight:700;color:var(--text1);margin:0 0 12px 0; }
  .rapp-row { display:flex;justify-content:space-between;align-items:baseline;padding:4px 0;border-bottom:1px solid var(--border);font-size:12px; }
  .rapp-row:last-child { border-bottom:none; }
  .rapp-label { color:var(--text3); }
  .rapp-value { font-weight:500;color:var(--text1);text-align:right;max-width:60%; }
  .rapp-ecart-ok { color:#16a34a;font-weight:700; }


  .rapp-ecart-ko { color:#dc2626;font-weight:700; }

  .drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
  }

  .drop-zone.drag-over {
    border-color: var(--accent2);
    background: var(--accent2-light);
    box-shadow: 0 0 0 4px rgba(5,150,105,0.1);
  }

  .drop-icon {
    font-size: 44px;
    margin-bottom: 12px;
    display: block;
    transition: transform 0.2s;
  }

  .drop-zone:hover .drop-icon { transform: translateY(-4px); }
  .drop-zone.drag-over .drop-icon { transform: translateY(-6px) scale(1.1); }

  .drop-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
  .drop-sub { font-size: 13px; color: var(--text2); }
  .drop-or { font-size: 12px; color: var(--text3); margin: 14px 0; }

  /* PROCESSING OVERLAY */
  .processing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
  }

  .processing-overlay.show { display: flex; }

  .processing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 48px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: var(--shadow-lg);
  }

  .processing-spinner {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .processing-spinner img {
    max-width: 100%;
    max-height: 100%;
    animation: pulse-logo 1.4s ease-in-out infinite;
  }

  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse-logo { 0%, 100% { opacity: 0.55; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.04); } }

  .processing-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }

  .processing-steps {
    font-size: 12px;
    color: var(--text2);
    line-height: 2;
  }

  .step-done { color: var(--accent2); }
  .step-active { color: var(--accent); font-weight: 500; }

  .progress-bar {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 999px;
    margin-top: 18px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #818cf8);
    border-radius: 999px;
    transition: width 0.4s ease;
    width: 0%;
  }

  /* MODALS */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.4);
    backdrop-filter: blur(4px);
    z-index: 900;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
  }

  .modal-overlay.show { display: flex; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 820px;
    margin: auto;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease-out;
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface2);
  }

  .modal-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--accent2-light);
    border: 1px solid #a7f3d0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  .modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
  .modal-subtitle { font-size: 12px; color: var(--text3); margin-top: 1px; }

  .modal-close {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.12s;
    line-height: 1;
  }

  .modal-close:hover { background: var(--bg); color: var(--text); }

  .modal-body { padding: 24px; }
  .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--surface2);
  }

  /* AI BADGE */
  .ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-light);
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 18px;
  }

  /* FORMS */
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
  }

  .form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
  }

  .form-group { display: flex; flex-direction: column; gap: 5px; }
  .form-group.full { grid-column: 1 / -1; }

  .form-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .projet-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
  }
  .projet-suggestion-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  .projet-suggestion-item:last-child { border-bottom: none; }
  .projet-suggestion-item:hover { background: var(--surface2); }
  .projet-suggestion-item .num { font-weight: 700; color: var(--accent); margin-right: 4px; }

  .doc-preview-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35);
    z-index: 9000; display: none;
  }
  .doc-preview-backdrop.show { display: block; }
  .doc-preview-panel {
    position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 92vw;
    background: var(--surface); box-shadow: -8px 0 30px rgba(0,0,0,0.25);
    z-index: 9001; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform 0.2s ease-out;
  }
  .doc-preview-panel.show { transform: translateX(0); }
  .doc-preview-panel.fullscreen { width: 100vw !important; max-width: 100vw !important; }
  .doc-preview-header {
    display: flex; align-items: center; gap: 8px; padding: 12px 14px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
  }

  .btn-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: 8px 4px; font-size: 13px; font-weight: 600; color: var(--text3);
    cursor: pointer; margin-bottom: -1px;
  }
  .btn-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  .doublon-groupe {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 18px; margin-bottom: 10px;
  }
  .doublon-fiche {
    display: flex; align-items: center; gap: 10px; padding: 6px 0;
  }

  .arbo-folder-drop.drag-over { background: rgba(22,163,74,0.12); outline: 2px dashed var(--accent); }

  .calque-bande { position: relative; line-height: 0; }
  .calque-bande img { display: block; width: 100%; }
  .calque-valeur {
    position: absolute;
    display: flex; align-items: center; gap: 2px;
    background: rgba(255,255,255,0.92);
    border: 2px solid #16a34a;
    border-radius: 4px;
    padding: 1px;
    font-size: 11px;
  }
  .calque-valeur.desaccord { border-color: #dc2626; }
  .calque-valeur input { width: 28px; border: none; background: transparent; font-size: 11px; text-align: center; padding: 0; }
  .calque-valeur select { border: none; background: transparent; font-size: 10px; padding: 0; max-width: 70px; }
  .arbo-fichier-item:hover span { text-decoration: underline; }

  .zone-doc-drop:hover, .zone-doc-drop.drag-over {
    background: var(--accent-light) !important;
  }

  .arbo-drop-zone {
    border: 2px dashed var(--border2);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .arbo-drop-zone:hover, .arbo-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(22,163,74,0.06);
  }

  .sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
  .sortable-th:hover { color: var(--accent); }
  .sort-arrow { font-size: 10px; opacity: 0.5; display: inline-block; min-width: 10px; }
  .sort-arrow.active { opacity: 1; color: var(--accent); }

  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
  }
  .kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .kpi-card-title { font-size: 12px; color: var(--text2); font-weight: 600; margin-bottom: 4px; }
  .kpi-card-value { font-size: 22px; font-weight: 700; }
  .kpi-card-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

  .placeholder-module {
    max-width: 520px;
    margin: 60px auto 0;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 28px;
    box-shadow: var(--shadow);
  }
  .placeholder-module-icon { font-size: 40px; margin-bottom: 12px; }
  .placeholder-module-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
  .placeholder-module-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

  .ai-filled {
    background: var(--accent2-light);
    color: var(--accent2);
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
  }

  .form-input, .form-select, .form-textarea {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 7px;
    padding: 8px 12px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    transition: all 0.12s;
    width: 100%;
  }

  .form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.1);
  }

  .form-input.ai-auto {
    border-color: #a7f3d0;
    background: var(--accent2-light);
  }

  .form-textarea { resize: vertical; min-height: 72px; }
  .form-select { cursor: pointer; }
  .form-select option { background: white; }

  /* TABLE */
  .items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }

  .items-table th {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text3);
    padding: 9px 12px;
    text-align: left;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
  }

  .items-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
  }

  .items-table tr:last-child td { border-bottom: none; }
  .items-table tbody tr:hover td { background: var(--bg); }

  .items-table td input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    width: 100%;
    transition: all 0.12s;
  }

  .items-table td input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--accent-light);
  }

  .del-row {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.12s;
  }
  .del-row:hover { color: var(--danger); background: var(--danger-light); }

  .split-row {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.12s;
    display: inline-block;
  }
  .split-row:hover { color: var(--accent); background: var(--accent-light); }

  .drag-handle {
    cursor: grab;
    color: var(--text3);
    font-size: 14px;
    padding: 0 4px 0 0;
    display: inline-block;
    vertical-align: middle;
    user-select: none;
  }
  .drag-handle:active { cursor: grabbing; }

  .no-items-table tr.drag-over > td:first-child {
    border-left: 3px solid var(--accent);
  }
  .no-items-table tr.dragging { opacity: 0.4; }

  .add-row-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px dashed #bbf7d0;
    border-radius: 7px;
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.12s;
    font-family: 'Inter', sans-serif;
  }

  .add-row-btn:hover { background: #bbf7d0; border-style: solid; }

  .total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    padding: 14px 0 4px;
    border-top: 1px solid var(--border);
  }

  .total-label { font-size: 12px; color: var(--text2); font-weight: 500; }

  .total-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
  }

  /* NEW ORDER 2-COL LAYOUT */
  .new-order-layout {
    display: flex;
    gap: 0;
    align-items: flex-start;
  }
  .new-order-left {
    flex: none;
    width: var(--no-left-w, 44%);
    min-width: 280px;
    max-width: calc(100% - 280px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
  }
  .new-order-resize-handle {
    width: 12px;
    flex-shrink: 0;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    display: flex;
    align-self: stretch;
    align-items: flex-start;
    justify-content: center;
    margin: 0 4px;
  }
  .new-order-resize-handle::after {
    content: '';
    display: block;
    width: 4px;
    border-radius: 4px;
    background: var(--border);
    transition: background .15s, width .15s;
    position: sticky;
    top: 120px;
    height: calc(100vh - 200px);
  }
  .new-order-resize-handle:hover::after, .new-order-resize-handle.dragging::after {
    background: var(--accent);
    width: 6px;
  }
  .new-order-right {
    flex: 1;
    min-width: 280px;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    box-sizing: border-box;
  }
  .no-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
  }
  .card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
  }
  .no-section-title, .section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    margin-bottom: 12px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
  }
  .no-drop-zone {
    border: 2px dashed var(--border2);
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface2);
  }
  .no-drop-zone:hover, .no-drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  .no-pdf-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .no-pdf-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .no-pdf-item button {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
  }
  .no-pdf-item button:hover { background: var(--danger-light); }
  .no-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .no-items-table th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text3);
    padding: 7px 4px;
    text-align: left;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  .no-items-table td {
    padding: 4px 3px;
    border-bottom: 1px solid var(--border);
  }
  .no-items-table td input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 4px 5px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    width: 100%;
    transition: all 0.12s;
  }
  .no-items-table td input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--accent-light);
  }
  .no-items-table td input[readonly] {
    color: var(--accent2);
    font-weight: 600;
  }
  .item-desc-editor {
    font-size: 10.5px;
    color: var(--text2);
    line-height: 1.45;
    padding: 2px 4px;
    border: 1px dashed transparent;
    border-radius: 3px;
    outline: none;
    cursor: text;
    min-height: 0;
    transition: border-color 0.15s;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .item-desc-editor:focus {
    border-color: var(--border2);
    background: #fafbfc;
    min-height: 20px;
  }
  .item-desc-editor:not(:empty) {
    border-color: var(--border);
    min-height: 16px;
  }
  .item-desc-editor:empty::before {
    content: attr(data-ph);
    color: var(--text3);
    font-style: italic;
    pointer-events: none;
  }
  .no-totals-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 16px;
    align-items: center;
    font-size: 13px;
  }
  .no-totals-grid .lbl { color: var(--text2); text-align: right; }
  .no-totals-grid .val { font-weight: 600; text-align: right; min-width: 100px; }
  .no-totals-grid .val.big { font-size: 16px; color: var(--text); }
  .no-project-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--accent2-light);
    border: 1px solid #bae6fd;
    border-radius: 7px;
    font-size: 12px;
    color: var(--accent2);
    display: none;
  }
  /* Live PO preview */
  .po-live-preview-wrap {
    overflow: hidden;
  }
  .po-live-preview {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 8px;
    font-size: 10px;
    line-height: 1.35;
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
    box-shadow: var(--shadow);
    transform-origin: top left;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .po-live-preview .po-live-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #1e293b;
  }
  .po-live-preview .po-live-company { font-weight: 800; font-size: 16px; }
  .po-live-preview .po-live-company-info { font-size: 9.5px; color: #64748b; line-height: 1.6; margin-top: 4px; }
  .po-live-preview .po-live-bc-num { font-size: 12px; font-weight: 700; text-align: right; }
  .po-live-preview .po-live-bc-date { font-size: 10px; color: #64748b; text-align: right; }
  .po-live-preview .po-live-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
  }
  .po-live-preview .po-live-box {
    background: #f8fafc;
    border-radius: 6px;
    padding: 10px;
  }
  .po-live-preview .po-live-box-title {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-bottom: 4px;
  }
  .po-live-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
  }
  .po-live-preview table th,
  .po-live-preview table td {
    /* reset — les styles inline du bon de commande priment */
  }
  .po-live-preview .po-live-totals {
    text-align: right;
    margin-bottom: 12px;
    font-size: 10.5px;
  }
  .po-live-preview .po-live-totals .big {
    font-size: 13px;
    font-weight: 700;
  }
  .po-live-preview .po-live-footer {
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
    font-size: 9px;
    color: #94a3b8;
    line-height: 1.6;
  }
  .no-project-picker-popup {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
    display: none;
  }
  .no-project-picker-popup.show { display: block; }
  .no-project-picker-popup .pp-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
  }
  .no-project-picker-popup .pp-item:hover { background: var(--accent-light); }
  .no-project-picker-popup .pp-item .pp-num { font-weight: 600; color: var(--accent); }
  .no-project-picker-popup .pp-item .pp-name { color: var(--text2); margin-left: 8px; }

  /* ORDERS */
  .orders-grid { display: grid; gap: 8px; }

  .order-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 20px;
    display: grid;
    grid-template-columns: auto 1fr auto auto auto auto auto;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.12s;
    box-shadow: var(--shadow);
  }
  .order-card.with-fact {
    grid-template-columns: auto 1fr auto auto auto auto auto auto auto;
  }

  .order-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.08), var(--shadow);
  }

  .order-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Inter', monospace;
    background: var(--accent-light);
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
  }

  .order-main h3 { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
  .order-meta { font-size: 11.5px; color: var(--text3); }

  .order-amount { font-size: 14px; font-weight: 700; color: var(--text); text-align: right; }
  .order-date { font-size: 11px; color: var(--text3); text-align: right; margin-top: 2px; }

  .status-badge {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
  }

  .status-pending    { background: var(--accent3-light); color: var(--accent3); }
  .status-sent       { background: var(--accent-light);  color: var(--accent);  }
  .status-received   { background: var(--accent2-light); color: var(--accent2); }
  .status-cancelled  { background: var(--danger-light);  color: var(--danger);  }
  .status-accepted   { background: var(--accent-light);  color: var(--accent);  }
  .status-refused    { background: var(--danger-light);  color: var(--danger);  }
  .status-expired    { background: #f3f4f6;              color: var(--text3);   }
  .status-active     { background: var(--accent-light);  color: var(--accent);  }
  .status-completed  { background: var(--accent2-light); color: var(--accent2); }
  .status-onhold     { background: var(--accent3-light); color: var(--accent3); }
  /* Nouveaux statuts commandes */
  .status-draft        { background: #f3f4f6;  color: #6b7280; }
  .status-ar           { background: #fef3c7;  color: #d97706; }
  .status-partial      { background: #fff7ed;  color: #c2410c; }
  .status-partial-done { background: #ecfdf5;  color: #065f46; }
  .order-fact-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 6px 12px;
    margin-top: 4px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
  }
  .status-late       { background: #fee2e2;              color: #dc2626; animation: pulse-late 2s infinite; }
  @keyframes pulse-late { 0%,100%{opacity:1} 50%{opacity:0.7} }
  tr.cmd-late td { background: rgba(254,226,226,0.3) !important; }
  .statut-select { font-size:11px; border:1px solid var(--border); border-radius:12px; padding:2px 6px; background:transparent; cursor:pointer; font-weight:500; }

  /* Poignées de redimensionnement */
  .resize-handle {
    width: 5px;
    flex-shrink: 0;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.15s;
    position: relative;
    z-index: 10;
  }
  .resize-handle:hover, .resize-handle.dragging {
    background: var(--accent);
  }
  .resize-handle::after {
    content: '';
    position: absolute;
    inset: 0 -4px;
  }
  /* Empêcher la sélection de texte pendant le drag */
  body.resizing * { user-select: none !important; cursor: col-resize !important; }

  .order-actions { display: flex; gap: 4px; }

  .icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.12s;
  }

  .icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border2); }

  /* Variantes colorées des icones d'action (commandes) : fond teinte + icone de la
     meme couleur, pour etre identifiables au premier coup d'oeil plutot que des
     emojis gris peu contrastes. */
  .icon-btn-email     { background: #e0f2fe; border-color: #bae6fd; color: #0284c7; }
  .icon-btn-email:hover     { background: #bae6fd; color: #0369a1; }
  .icon-btn-edit       { background: #fff7ed; border-color: #fed7aa; color: #d97706; }
  .icon-btn-edit:hover       { background: #fed7aa; color: #b45309; }
  .icon-btn-historique { background: #f3e8ff; border-color: #e9d5ff; color: #9333ea; }
  .icon-btn-historique:hover { background: #e9d5ff; color: #7e22ce; }
  .icon-btn-delete     { background: #fee2e2; border-color: #fecaca; color: #dc2626; }
  .icon-btn-delete:hover     { background: #fecaca; color: #b91c1c; }

  /* FILTERS */
  .filters-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 56px;
    z-index: 40;
    background: var(--bg);
    padding: 12px 0;
    margin-top: -12px;
  }

  .search-wrapper { position: relative; flex: 1; min-width: 200px; }

  .search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 8px 14px 8px 36px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    transition: all 0.12s;
  }

  .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 13px;
    pointer-events: none;
  }

  .search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.08);
  }

  .search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 50%;
    display: none;
    transition: color 0.1s, background 0.1s;
  }
  .search-clear:hover { color: var(--text); background: var(--border); }
  .search-input.has-clear { padding-right: 30px; }

  /* TOAST */
  .toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 340px;
  }

  .toast.show { transform: translateY(0); opacity: 1; }
  .toast-icon { font-size: 18px; }
  .toast-title { font-size: 13px; font-weight: 600; }
  .toast-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }

  /* SUPPLIERS / CARDS GRID */
  .cards-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .cards-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .supplier-card, .entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow);
  }

  .supplier-card:hover, .entity-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.08), var(--shadow-md);
    transform: translateY(-1px);
  }

  .supplier-logo, .entity-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
    border: 1px solid #bbf7d0;
  }

  .supplier-name, .entity-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }

  .supplier-meta, .entity-meta {
    font-size: 11.5px;
    color: var(--text2);
    line-height: 1.7;
  }

  .supplier-stats {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .supplier-stat .label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text3);
  }

  .supplier-stat .value { font-size: 14px; font-weight: 700; margin-top: 2px; color: var(--text); }

  /* DATA TABLE (generic) */
  .data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
  .data-table th {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text3);
    padding: 12px 14px;
    text-align: left;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
  }
  .data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .data-table tbody tr:hover td { background: var(--bg); }
  .data-table tbody tr:last-child td { border-bottom: none; }

  /* PROGRESS BAR (projects) */
  .progress-track {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
  }
  .progress-thumb {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.3s;
  }

  /* EMPTY STATE */
  .empty-state { text-align: center; padding: 60px 20px; }
  .empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.25; }
  .empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
  .empty-state p { font-size: 12px; color: var(--text3); }

  /* SCROLLBAR */
  ::-webkit-scrollbar { width: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 999px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* PDF PREVIEW */
  .pdf-preview-area {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-family: 'Inter', monospace;
    font-size: 11px;
    color: var(--text2);
    max-height: 100px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
  }

  .separator { height: 1px; background: var(--border); margin: 16px 0; }

  .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text2);
  }

  /* PURCHASE ORDER PREVIEW */
  .purchase-order-preview {
    background: white;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #111;
    overflow-x: auto;
  }

  .po-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
  .po-company-name { font-size: 20px; font-weight: 800; color: #1e293b; letter-spacing: 0.5px; }
  .po-company-info { font-size: 11px; color: #64748b; margin-top: 4px; line-height: 1.6; }
  .po-badge { background: var(--accent); color: white; padding: 6px 14px; border-radius: 7px; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; }
  .po-number { font-size: 11px; color: #64748b; text-align: right; margin-top: 4px; }

  .po-section { margin-bottom: 22px; }
  .po-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; margin-bottom: 8px; }

  .po-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
  .po-info-box { background: #f8fafc; border-radius: 8px; padding: 14px; border: 1px solid #e5e7eb; }
  .po-info-label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; font-weight: 600; }
  .po-info-value { font-size: 13px; font-weight: 500; color: #1e293b; line-height: 1.5; }

  .po-table { width: 100%; border-collapse: collapse; }
  .po-table th { background: #1e293b; color: white; padding: 10px 14px; font-size: 11px; text-align: left; font-weight: 600; letter-spacing: 0.3px; }
  .po-table td { padding: 10px 14px; border-bottom: 1px solid #e2e8f0; font-size: 13px; }
  .po-table tr:last-child td { border-bottom: none; }
  .po-total-row td { font-weight: 700; background: #f8fafc; font-size: 14px; }

  .po-footer { margin-top: 28px; padding-top: 16px; border-top: 2px solid #e2e8f0; display: flex; justify-content: space-between; align-items: flex-end; }
  .po-signature { text-align: center; }
  .po-signature-line { width: 160px; height: 1px; background: #94a3b8; margin: 40px auto 6px; }
  .po-signature-name { font-size: 11px; color: #64748b; }
  .po-conditions { font-size: 10px; color: #94a3b8; max-width: 260px; line-height: 1.6; }

  /* ===================== BON DE COMMANDE STYLE PDF ===================== */
  .po-xl-wrap { font-family: Arial, Helvetica, sans-serif; font-size: 10.5px; color: #1a1a2e; background: white; line-height: 1.3; }

  /* Entête 3 colonnes */
  .po-xl-top-table { width: 100%; border-collapse: collapse; border: 1px solid #ccc; margin-bottom: 0; }
  .po-xl-top-table td { padding: 8px 10px; vertical-align: top; border: none; }
  .po-xl-logo-cell { width: 30%; border-right: 1px solid #ccc; background: white; }
  .po-xl-logo { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; color: #1e293b; font-family: Arial Black, Arial, sans-serif; line-height: 1; }
  .po-xl-logo-sub { font-size: 9px; color: #555; margin-top: 2px; font-style: italic; }
  .po-xl-logo-addr { font-size: 9px; color: #555; margin-top: 6px; line-height: 1.5; }
  .po-xl-contact-cell { width: 35%; border-right: 1px solid #ccc; font-size: 10px; color: #333; }
  .po-xl-refdate-cell { width: 35%; vertical-align: middle; padding: 0; }
  .po-xl-ref-tbl { width: 100%; border-collapse: collapse; height: 100%; }
  .po-xl-ref-tbl td { padding: 8px 10px; vertical-align: middle; }
  .po-xl-ref-lbl { font-size: 9px; color: #333; border-right: 1px solid #ccc; border-bottom: 1px solid #ccc; text-align: right; background: #f5f5f5; width: 60%; }
  .po-xl-ref-lbl em { font-size: 8px; color: #888; }
  .po-xl-ref-val { font-size: 14px; font-weight: 900; color: #1e293b; border-bottom: 1px solid #ccc; text-align: right; }

  /* Section fournisseur/livraison */
  .po-xl-addr-outer { width: 100%; border-collapse: collapse; border: 1px solid #ccc; border-top: none; margin-bottom: 0; }
  .po-xl-addr-outer th, .po-xl-addr-outer td { border: 1px solid #ccc; padding: 3px 6px; font-size: 10px; vertical-align: top; }
  .po-xl-sec-hdr { background: #1e293b; color: white; font-size: 10px; font-weight: 700; text-align: left; padding: 5px 8px !important; }
  .po-xl-sec-hdr em { font-size: 8.5px; font-weight: 400; color: #aaa; }
  .po-xl-fl { font-size: 9px; font-weight: 700; color: #444; white-space: nowrap; background: #f8f8f8; width: 12%; }
  .po-xl-fl em, .po-xl-fl-sm em { font-size: 8px; font-weight: 400; color: #888; font-style: italic; }
  .po-xl-fv { font-size: 10px; color: #1e293b; width: 26%; }
  .po-xl-fl-sm { font-size: 9px; font-weight: 700; color: #444; white-space: nowrap; background: #f8f8f8; width: 8%; }
  .po-xl-fv-sm { font-size: 10px; color: #1e293b; width: 12%; }
  .po-bold { font-weight: 700; }

  /* Titre BON DE COMMANDE */
  .po-xl-bc-title { background: #1e293b; color: white; font-size: 11px; font-weight: 700; text-align: center; padding: 6px; letter-spacing: 0.5px; }

  /* Tableau articles */
  .po-xl-wrap .po-xl-items { width: 100%; border-collapse: collapse; font-size: 10px; }
  .po-xl-wrap .po-xl-items th { background: #e8e8e8 !important; color: #1e293b !important; font-size: 9px !important; font-weight: 700 !important; padding: 4px 6px !important; border: 1px solid #ccc !important; text-align: center !important; line-height: 1.3; }
  .po-xl-ts { display: block; font-size: 8px !important; font-style: italic; font-weight: 400; color: #777; }
  .po-xl-wrap .po-xl-items td { padding: 3px 6px !important; border: 1px solid #ddd !important; font-size: 10px !important; vertical-align: top !important; }

  /* Conditions */
  .po-xl-cond-wrap { border: 1px solid #ccc; border-top: none; }
  .po-xl-cond-hdr { background: #1e293b; color: white; font-size: 10px; font-weight: 700; text-align: center; padding: 5px; }
  .po-xl-cond-body { padding: 6px 10px; font-size: 9px; color: #333; line-height: 1.5; }

  /* Footer 3 colonnes */
  .po-xl-footer-tbl { width: 100%; border-collapse: collapse; border: 1px solid #ccc; border-top: none; }
  .po-xl-footer-tbl td { border: 1px solid #ccc; vertical-align: top; }
  .po-xl-ft-col { vertical-align: top; }
  .po-xl-ft-hdr { background: #1e293b; color: white; font-size: 9.5px; font-weight: 700; text-align: center; padding: 4px 6px; }
  .po-xl-ft-hdr em { font-size: 8px; font-weight: 400; color: #aaa; }
  .po-xl-ft-body { padding: 6px 8px; font-size: 9.5px; color: #1e293b; line-height: 1.6; }
  .po-xl-ft-totals { vertical-align: top; padding: 0 !important; }
  .po-xl-tot-tbl { width: 100%; border-collapse: collapse; }
  .po-xl-tot-tbl td { padding: 4px 8px; font-size: 10px; border-bottom: 1px solid #e0e0e0; }
  .po-xl-tot-lbl { color: #444; font-size: 9.5px; }
  .po-xl-tot-lbl em { font-size: 8px; color: #888; }
  .po-xl-tot-val { text-align: right; font-size: 10.5px; white-space: nowrap; }
  .po-xl-subtotal td { background: #f0f0f0; }
  .po-xl-grandtotal .po-xl-gt-lbl { background: #1e293b; color: white; font-size: 9.5px; font-weight: 700; padding: 6px 8px; }
  .po-xl-grandtotal .po-xl-gt-lbl em { color: #aaa; font-weight: 400; font-size: 8px; }
  .po-xl-grandtotal .po-xl-gt-val { background: #1e293b; color: white; font-size: 14px; font-weight: 900; text-align: right; padding: 6px 8px; white-space: nowrap; }

  /* ACTIVITY LOG */
  .activity-list { display: flex; flex-direction: column; gap: 8px; }
  .activity-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
  }
  .activity-icon { font-size: 16px; }
  .activity-text { flex: 1; color: var(--text2); }
  .activity-time { font-size: 11px; color: var(--text3); }

  /* CONFIRM MODAL */
  .confirm-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(17,24,39,0.5);
    z-index: 1100;
    align-items: center;
    justify-content: center;
  }
  .confirm-overlay.show { display: flex; }
  .confirm-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
  }
  .confirm-box h3 { font-size: 15px; margin-bottom: 8px; }
  .confirm-box p { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
  .confirm-actions { display: flex; gap: 8px; justify-content: center; }

  /* PLACEHOLDER PAGE */
  .placeholder-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
  }
  .placeholder-page .big-icon { font-size: 64px; margin-bottom: 20px; opacity: 0.3; }
  .placeholder-page h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
  .placeholder-page p { font-size: 14px; color: var(--text2); max-width: 400px; line-height: 1.7; }
  .placeholder-features {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin-top: 28px; text-align: left;
  }
  .placeholder-feat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 12px;
    color: var(--text2);
  }
  .placeholder-feat strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 13px; }

  /* MOBILE / TABLETTE (<=1024px) : menu en tiroir coulissant au lieu de disparaitre.
     Le sidebar reste dans le DOM (transform le sort de l'ecran), le bouton
     hamburger l'ouvre, le voile de fond + un clic sur un lien le referment
     (voir ouvrirMenuMobile/fermerMenuMobile et navigate() cote JS). */
  @media (max-width: 1024px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .topbar { padding: 0 14px; }
    .main { margin-left: 0; }
    .sidebar {
      transform: translateX(-100%);
      transition: transform 0.22s ease;
      z-index: 200;
      box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .cards-grid-3 { grid-template-columns: 1fr; }
    .cards-grid-2 { grid-template-columns: 1fr; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    /* !important + selecteur explicite .with-fact : la variante avec facturation
       a 2 classes (specificite plus elevee) et gagnait sur cette regle malgre
       la media query, laissant le contenu deborder sur mobile. */
    .order-card, .order-card.with-fact { grid-template-columns: 1fr 1fr !important; }

    /* Filet de securite pour les tableaux larges (utilisateurs, projets, etc.) :
       beaucoup de <table class="data-table"> n'ont pas de conteneur a defilement
       dedie dans leur page — on le rend possible au niveau de la page elle-meme
       pour ne jamais couper le contenu, plutot que de retoucher chaque tableau. */
    .page { overflow-x: auto; }
    .prev-fixed-header { left: 0; }
  }

  /* SMARTPHONE (<=600px) : resserre encore les marges et empile les barres d'action */
  @media (max-width: 600px) {
    .topbar-title { font-size: 13px; }
    .page { padding: 12px !important; }
    .filters-bar { flex-direction: column; align-items: stretch !important; }
    .filters-bar .search-wrapper { width: 100%; }
    .order-card, .order-card.with-fact { grid-template-columns: 1fr !important; }
    .modal { width: 94vw !important; max-width: 94vw !important; margin: 0 3vw; }
  }

  /* PROJETS - Layout 3 colonnes */
  .projets-tab {
    background: none; border: none; padding: 4px 10px; border-radius: 6px;
    font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
    color: var(--text2); cursor: pointer; transition: all 0.12s;
    display: inline-flex; align-items: center; gap: 5px;
  }
  .projets-tab:hover { background: var(--bg); color: var(--text); }
  .projets-tab.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
  .projets-tab-count {
    background: var(--bg); padding: 0 5px; border-radius: 4px; font-size: 10px; font-weight: 600;
  }
  .projets-tab.active .projets-tab-count { background: rgba(22,163,74,0.15); color: var(--accent); }

  .projet-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background 0.1s; display: flex; gap: 12px; align-items: flex-start;
  }
  .projet-item:hover { background: var(--bg); }
  .projet-item.selected { background: var(--accent-light); border-right: 3px solid var(--accent); }
  .projet-item-num {
    background: var(--accent-light); color: var(--accent); font-weight: 700; font-size: 11px;
    padding: 3px 8px; border-radius: 5px; white-space: nowrap; flex-shrink: 0; margin-top: 2px;
  }
  .projet-item-body { flex: 1; min-width: 0; }
  .projet-item-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .projet-item-client { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .projet-item-right { text-align: right; flex-shrink: 0; }
  .projet-item-amount { font-size: 13px; font-weight: 700; color: var(--text); }
  .projet-item-date { font-size: 11px; color: var(--text3); margin-top: 2px; }

  /* Détails projet - onglets */
  .projet-detail-tabs {
    display: flex; border-bottom: 2px solid var(--border); padding: 0 16px;
  }
  .projet-detail-tab {
    background: none; border: none; padding: 10px 14px; font-family: 'Inter', sans-serif;
    font-size: 12.5px; font-weight: 500; color: var(--text2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.12s;
  }
  .projet-detail-tab:hover { color: var(--text); }
  .projet-detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

  .projet-detail-section { padding: 16px; }
  .projet-info-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .projet-info-label { width: 140px; color: var(--text3); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; padding-top: 2px; }

  /* FOURNISSEURS 2-col layout */
  .fourn-item {
    padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
    display: flex; align-items: center; gap: 10px; transition: background 0.1s;
  }
  .fourn-item:hover { background: var(--bg); }
  .fourn-item.selected { background: var(--accent-light); border-right: 3px solid var(--accent); }
  .fourn-item-icon { font-size: 18px; flex-shrink: 0; }
  .fourn-item-body { flex: 1; min-width: 0; }
  .fourn-item-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fourn-item-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
  .fourn-detail-tabs-bar {
    display: flex; border-bottom: 2px solid var(--border); padding: 0 16px;
  }
  .fourn-detail-tab {
    background: none; border: none; padding: 10px 14px; font-family: 'Inter', sans-serif;
    font-size: 12.5px; font-weight: 500; color: var(--text2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.12s;
  }
  .fourn-detail-tab:hover { color: var(--text); }
  .fourn-detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
  .projet-info-value { flex: 1; color: var(--text); font-weight: 500; }

  .projet-cmd-item {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; margin-bottom: 8px; cursor: pointer; transition: all 0.12s;
  }
  .projet-cmd-item:hover { border-color: var(--accent); background: var(--accent-light); }
  .projet-cmd-item.selected-cmd { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(22,163,74,0.15); }

  /* Export cards */
  .export-card {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
    cursor: pointer; transition: all 0.12s;
  }
  .export-card:hover { border-color: var(--accent); background: var(--accent-light); }
  .export-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
  .export-info { flex: 1; min-width: 0; }
  .export-name { font-size: 13px; font-weight: 600; color: var(--text); }
  .export-count { font-size: 11px; color: var(--text3); margin-top: 1px; }
  .export-btn { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-light); padding: 4px 10px; border-radius: 5px; flex-shrink: 0; }

/* ── Conformités machines ─────────────────────────────── */
#page-conformites .conf-table-wrap {
  overflow: auto;
  flex: 1;
  padding: 0 20px 20px;
}
#page-conformites table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}
#page-conformites thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  z-index: 2;
  padding: 9px 10px;
  text-align: left;
  font-weight: 700;
  color: var(--text2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
#page-conformites tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
#page-conformites tbody tr:nth-child(even) { background: var(--surface2); }
#page-conformites tbody tr:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
#page-conformites tbody td {
  padding: 7px 10px;
  vertical-align: middle;
  color: var(--text1);
}
#page-conformites .conf-num {
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  font-family: monospace;
  letter-spacing: 0.5px;
}
#page-conformites .conf-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
#page-conformites .conf-link:hover { text-decoration: underline; }
#page-conformites .conf-obs {
  font-size: 11px;
  color: var(--text2);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
