:root {
    --primary: hsl(222, 89%, 60%);
    --primary-light: hsl(222, 89%, 95%);
    --primary-dark: hsl(222, 89%, 45%);
    --success: hsl(142, 71%, 45%);
    --success-light: hsl(142, 71%, 95%);
    --warning: hsl(38, 92%, 50%);
    --warning-light: hsl(38, 92%, 95%);
    --danger: hsl(350, 89%, 60%);
    --danger-light: hsl(350, 89%, 95%);
    
    --bg-main: hsl(210, 40%, 98%);
    --bg-card: hsl(0, 0%, 100%);
    --sidebar-bg: linear-gradient(180deg, hsl(222, 47%, 11%) 0%, hsl(222, 47%, 7%) 100%);
    
    --text-main: hsl(222, 47%, 15%);
    --text-muted: hsl(222, 15%, 50%);
    --text-white: hsl(0, 0%, 100%);
    
    --border-color: hsl(214, 32%, 91%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 20px rgba(18, 28, 53, 0.05);
    --shadow-lg: 0 10px 30px rgba(18, 28, 53, 0.08);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
  }

  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  /* Discrete/modern scrollbar styling for a premium look */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
  }

  /* For dark themes/sidebars */
  .sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
  }
  .sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
  }

  body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
  }

  /* SIDEBAR */
  .sidebar {
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: var(--shadow-lg);
    z-index: 10;
  }

  .sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  }

  .sidebar-logo-text h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
  }

  .sidebar-logo-text p {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    font-weight: 500;
  }

  .sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .menu-group-title {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    font-weight: 600;
    padding-left: 12px;
    margin: 16px 0 8px 0;
    letter-spacing: 1px;
  }

  .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-white);
  }

  .menu-item.active {
    background: var(--primary);
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  }

  .menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    background: hsl(222, 20%, 30%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-white);
  }

  .user-info h4 {
    font-size: 13px;
    font-weight: 600;
  }

  .user-info p {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
  }

  /* MAIN CONTENT */
  .main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .top-navbar {
    height: 70px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
  }

  .navbar-left h2 {
    font-size: 20px;
    font-weight: 600;
  }

  .navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .badge-btn {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: background var(--transition-fast);
  }

  .badge-btn:hover {
    background: hsl(222, 89%, 90%);
  }

  /* ─── Bouton Retour global (navbar) ─── */
  #btn-global-back {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    height: 38px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
  }

  #btn-global-back:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
  }

  #btn-global-back svg {
    transition: transform var(--transition-fast);
  }

  #btn-global-back:hover svg {
    transform: translateX(-3px);
  }

  .content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 32px;
    min-height: 0;
  }

  /* CARDS AND GRIDS */
  .tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
  }

  .tab-content.active {
    display: block;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
  }

  .kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .kpi-details p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
  }

  .kpi-details h3 {
    font-size: 28px;
    font-weight: 700;
  }

  .kpi-details > span,
  .kpi-details h3 span {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
  }

  .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Dossier Client — pleine hauteur */
  #dossier-client.active { display: flex; flex-direction: column; height: calc(100vh - 70px); }
  #dossier-client.active > div:first-child { flex: 1; min-height: 0; }
  #dossier-client.active .panel-card:first-child { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #dossier-client.active .panel-card:first-child .panel-body { flex: 1; overflow: hidden; min-height: 0; }
  #dossier-client.active #dossier-of-tree-container { height: 100%; max-height: none; overflow-y: auto; }
  #dossier-client.active .panel-card:last-child { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #dossier-client.active .panel-card:last-child .panel-body { flex: 1; overflow-y: auto; min-height: 0; }

  /* Dossier Client — tabs */
  .dossier-tab-btn {
    padding: 10px 20px; border: none; background: transparent;
    font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-muted);
    border-bottom: 3px solid transparent; transition: all .2s; font-family: inherit;
  }
  .dossier-tab-btn:hover { color: var(--text-main); background: var(--primary-light); }
  .dossier-tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: transparent; }
  .dossier-tab-pane { display: none; }
  .dossier-tab-pane.active { display: block; }
  .relance-tab-btn {
    padding: 10px 20px; border: none; background: transparent;
    font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-muted);
    border-bottom: 3px solid transparent; transition: all .2s; font-family: inherit;
  }
  .relance-tab-btn:hover { color: var(--text-main); background: var(--primary-light); }
  .relance-tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
  .relance-tab-pane { display: none; }
  .relance-tab-pane.active { display: block; }

  /* Colors helper */
  .bg-primary { background-color: var(--primary-light); color: var(--primary); }
  .bg-success { background-color: var(--success-light); color: var(--success); }
  .bg-warning { background-color: var(--warning-light); color: var(--warning); }
  .bg-danger { background-color: var(--danger-light); color: var(--danger); }
  
  .text-success { color: var(--success); background-color: var(--success-light); }
  .text-warning { color: var(--warning); background-color: var(--warning-light); }
  .text-danger { color: var(--danger); background-color: var(--danger-light); }
  .text-primary { color: var(--primary); background-color: var(--primary-light); }
  .text-muted-badge { color: var(--text-muted); background-color: hsl(222, 15%, 92%); }

  /* MOCKUP DESIGN COMPONENTS */
  .panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
  }

  @media (max-width: 1024px) {
    .panel-grid { grid-template-columns: 1fr; }
  }

  .panel-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
  }

  .panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .panel-header h3 {
    font-size: 16px;
    font-weight: 600;
  }

  .panel-body {
    padding: 24px;
  }

  /* Table styling */
  .data-table-wrapper {
    overflow-x: auto;
  }

  .data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
  }

  .data-table th {
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
  }

  .data-table th.sortable-th {
    transition: background var(--transition-fast), color var(--transition-fast);
  }

  .data-table th.sortable-th:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
  }

  .data-table th.sortable-th.sort-asc,
  .data-table th.sortable-th.sort-desc {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
  }

  .sort-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.4;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
  }

  .sort-asc  .sort-indicator { opacity: 1; content: '↑'; }
  .sort-desc .sort-indicator { opacity: 1; content: '↓'; }

  .data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
  }

  .data-table tr:last-child td {
    border-bottom: none;
  }

  .status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
  }

  .user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  /* SEARCH BAR MOCK */
  .search-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
  }

  .search-input-mock {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-main);
  }

  /* PROGRESS BAR */
  .progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .progress-track {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
  }

  .progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
  }

  /* WORKFLOW STEPPER */
  .workflow-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    position: relative;
    padding: 0 40px;
  }

  .workflow-container::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 80px;
    right: 80px;
    height: 3px;
    background: var(--border-color);
    z-index: 1;
  }

  .workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 2;
  }

  .step-bubble {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-muted);
    transition: all var(--transition-normal);
  }

  .workflow-step.active .step-bubble {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
  }

  .workflow-step.completed .step-bubble {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
  }

  .step-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
  }

  .workflow-step.active .step-label {
    color: var(--primary-dark);
  }

  /* DRAG DROP ZONE MOCK */
  .upload-zone-mock {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-main);
    transition: border-color var(--transition-fast);
  }

  .upload-zone-mock:hover {
    border-color: var(--primary);
  }

  .upload-zone-mock svg {
    width: 48px;
    height: 48px;
    stroke: var(--text-muted);
    margin-bottom: 12px;
  }

  /* NOTIFICATION LIST */
  .notification-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .notification-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    border-left: 4px solid var(--primary);
  }

  .notification-item.warning { border-left-color: var(--warning); }
  .notification-item.danger { border-left-color: var(--danger); }
  .notification-item.success { border-left-color: var(--success); }

  .notification-text h5 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
  }

  .notification-text p {
    font-size: 12px;
    color: var(--text-muted);
  }

  /* GENERAL TAB SPECIFICS */
  .grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
  }

  /* BUTTONS & ACTIONS */
  .btn-group {
    display: flex;
    gap: 8px;
  }

  .action-btn-mock {
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
  }

  .action-btn-mock:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
  }

  /* SETTINGS PAGE LAYOUT & STYLES */

  /* Paramètres Globaux — pleine hauteur */
  #parametres { display: none; }
  #parametres.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .settings-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 30px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    margin-top: 8px;
  }

  .settings-nav {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    align-self: stretch;
  }

  .settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
  }

  .settings-nav-item:hover {
    background: var(--bg-main);
    color: var(--text-main);
  }

  .settings-nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
  }

  .settings-nav-item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
  }

  .settings-content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    box-shadow: var(--shadow-md);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    align-self: stretch;
  }

  .settings-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
  }

  .settings-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
  }

  .settings-form-group {
    margin-bottom: 20px;
  }

  .settings-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
  }

  .settings-form-group input,
  .settings-form-group select,
  .settings-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    transition: all var(--transition-fast);
  }

  .settings-form-group input:focus,
  .settings-form-group select:focus,
  .settings-form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }

  .db-console {
    background: hsl(222, 47%, 7%);
    color: hsl(120, 100%, 75%);
    font-family: "SFMono-Regular", Consolas, monospace;
    padding: 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,0.08);
  }

  .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
  }

  .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 24px;
  }

  .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
  }

  input:checked + .slider {
    background-color: var(--primary);
  }

  input:checked + .slider:before {
    transform: translateX(20px);
  }

  .settings-switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    margin-bottom: 12px;
  }

  .settings-switch-info h5 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
  }

  .settings-switch-info p {
    font-size: 12px;
    color: var(--text-muted);
  }

  /* =========================================================================
     MESSAGERIE PRO (COURRIEL) — Premium Styles
     ========================================================================= */
  .mail-layout {
    display: grid;
    grid-template-columns: 240px 1fr 2fr;
    gap: 0;
    height: calc(100vh - 70px);
    margin: -32px;
    background: var(--bg-card);
    overflow: hidden;
  }

  .mail-sidebar {
    background: hsl(210, 28%, 95%);
    color: var(--text-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
    height: 100%;
    min-height: 0;
  }

  .compose-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all var(--transition-fast);
  }
  .compose-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  }

  .folder-group-title {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin: 16px 0 8px 4px;
    letter-spacing: 0.8px;
  }

  .folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
  }
  .folder-item:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary-dark);
  }
  .folder-item.active {
    background: var(--primary);
    color: var(--text-white);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
  }

  .folder-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
  }

  /* Tiers Folders Tree */
  .tiers-tree {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .tiers-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
  }
  .tiers-node:hover {
    background: rgba(0,0,0,0.04);
  }
  .tiers-sublist {
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .tiers-subitem {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tiers-subitem:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
  }
  .tiers-subitem.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
  }
  .tiers-subitem-empty {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 10px;
    opacity: 0.7;
  }

  /* Col 2: Mail List Pane */
  .mail-list-pane {
    background: var(--bg-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .mail-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    background: var(--bg-card);
  }
  .mail-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    outline: none;
  }
  .sync-btn {
    padding: 8px 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .sync-btn:hover {
    background: hsl(222, 89%, 90%);
  }

  .mail-loading {
    padding: 12px;
    text-align: center;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 600;
  }

  .mail-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Mail list item */
  .mail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
  }
  .mail-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  .mail-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
  }
  .mail-card.unread::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 4px;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
  }
  .mail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .mail-sender {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }
  .mail-date {
    font-size: 11px;
    color: var(--text-muted);
  }
  .mail-subject {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mail-snippet {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .mail-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
  }

  /* Col 3: Reading Pane & Composer */
  .mail-content-pane {
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mail-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
  }
  .mail-empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
  }

  .mail-reader {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mail-reader-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-main);
  }
  .mail-reader-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .reader-action-btn {
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
  }
  .reader-action-btn:hover {
    background: var(--bg-main);
  }
  .reader-action-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .reader-action-btn.primary:hover {
    background: var(--primary-dark);
  }
  .reader-action-btn.danger {
    color: var(--danger);
  }
  .reader-action-btn.danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
  }

  .read-subject {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
  }

  .mail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 16px;
    margin-bottom: 12px;
  }
  .meta-row {
    font-size: 13px;
  }
  .meta-label {
    color: var(--text-muted);
    margin-right: 4px;
  }

  .binding-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 6px;
    font-size: 12.5px;
    margin-bottom: 8px;
  }

  .classification-box {
    display: flex;
    margin-bottom: 4px;
  }
  .classification-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(59, 130, 246, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
  }

  .mail-body-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-main);
  }

  .mail-attachments-section {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
  }
  .mail-attachments-section h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
  }
  .attachments-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
  }
  .attachment-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
  }
  .attachment-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 140px;
    overflow: hidden;
  }
  .attachment-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .attachment-size {
    color: var(--text-muted);
  }
  .attachment-actions {
    display: flex;
    gap: 4px;
  }

  /* Composer Panel */
  .mail-composer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .mail-composer-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
  }
  .composer-actions {
    display: flex;
    gap: 8px;
  }
  .composer-btn-send {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .composer-btn-send:hover {
    background: var(--primary-dark);
  }
  .composer-btn-cancel {
    padding: 8px 14px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  .composer-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
  }
  .composer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
  }
  .composer-row label {
    font-weight: 700;
    font-size: 13px;
    width: 60px;
    color: var(--text-muted);
  }
  .composer-input {
    flex: 1;
    border: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
  }
  .composer-binding-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: var(--bg-main);
    padding: 10px;
    border-radius: 6px;
  }
  .composer-select-group {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .composer-select-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
  }
  .composer-select {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
  }

  .composer-editor-wrapper {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  /* =========================================================================
     MODÈLES DE COURRIEL — Premium Styles
     ========================================================================= */
  .template-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    min-height: 600px;
  }
  .template-sidebar-tree {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .sidebar-tree-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-light);
    color: var(--primary-dark);
  }
  .sidebar-tree-header h4 {
    font-size: 14px;
    font-weight: 700;
  }
  .template-tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
  }

  .template-main-pane {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .template-pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
  }
  .template-pane-header h3 {
    font-size: 18px;
    font-weight: 700;
  }

  .template-editor-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
  }
  .editor-header h4 {
    font-size: 15px;
    font-weight: 700;
  }
  .editor-actions {
    display: flex;
    gap: 8px;
  }

  .template-editor-workspace {
    display: block;
  }
  .quill-editor-col {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
  }

  .variables-panel {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .variables-panel h5 {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
  }
  .vars-help {
    font-size: 10.5px;
    color: var(--text-muted);
    line-height: 1.4;
  }
  .variables-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 300px;
  }
  .var-badge {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .var-badge:hover {
    border-color: var(--primary);
    background: var(--primary-light);
  }
  .var-badge code {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-dark);
  }
  .var-badge span {
    font-size: 10px;
    color: var(--text-muted);
  }

  .templates-list-panel {
    flex: 1;
  }

  /* =========================================================================
     MENU CONTEXTUEL (clic droit) - Premium Styles
     ========================================================================= */
  .ctx-menu { font-family:'Segoe UI',-apple-system,sans-serif;font-size:12px;background:#fff;border:1px solid rgba(0,0,0,0.15);border-radius:6px;box-shadow:0 4px 24px rgba(0,0,0,0.12),0 1px 4px rgba(0,0,0,0.06);padding:4px 0;min-width:200px;user-select:none; }
  .ctx-item { position:relative;padding:5px 28px 5px 14px;color:#1f2937;cursor:pointer;display:flex;align-items:center;white-space:nowrap; }
  .ctx-item:hover { background:#e8f0fe;color:#1a73e8; }
  .ctx-item.has-sub::after { content:'\25B6';position:absolute;right:10px;font-size:9px;color:#9ca3af; }
  .ctx-item:hover.has-sub::after { color:#1a73e8; }
  .ctx-item .icon { width:18px;text-align:center;margin-right:10px;font-size:11px;color:#6b7280;flex-shrink:0; }
  .ctx-item .label { flex:1;overflow:hidden;text-overflow:ellipsis; }
  .ctx-item .type { font-size:10px;color:#9ca3af;margin-left:8px;font-family:monospace; }
  .ctx-item .sep { border-top:1px solid #e5e7eb;margin:4px 14px; }
  .ctx-submenu { display:none;position:absolute;left:100%;top:-4px;z-index:10002;background:#fff;border:1px solid rgba(0,0,0,0.15);border-radius:6px;box-shadow:0 4px 20px rgba(0,0,0,0.12);padding:4px 0;min-width:220px; }
  .ctx-item:hover > .ctx-submenu { display:block; }
  .ctx-separator { height:1px;background:#e5e7eb;margin:4px 10px; }
  .ctx-header { padding:5px 14px 7px;font-size:10px;font-weight:600;color:#9ca3af;text-transform:uppercase;letter-spacing:0.6px; }
  .ctx-item .hl { font-weight:600;color:#374151; }
  .ctx-item .count { font-size:10px;color:#9ca3af;background:#f3f4f6;padding:0 6px;border-radius:3px;margin-left:6px; }

.doc-workspace {
                  display: flex;
                  gap: 20px;
                  height: calc(100vh - 260px);
                  min-height: 520px;
                  margin-top: 15px;
                }
                .doc-panel {
                  background: var(--bg-card);
                  border: 1px solid var(--border-color);
                  border-radius: var(--radius-md);
                  padding: 20px;
                  display: flex;
                  flex-direction: column;
                  overflow: hidden;
                  box-shadow: var(--shadow-sm);
                  transition: box-shadow var(--transition-normal);
                }
                .doc-panel:hover {
                  box-shadow: var(--shadow-md);
                }
                .doc-panel-title {
                  font-size: 14px;
                  font-weight: 700;
                  color: var(--text-main);
                  margin-bottom: 15px;
                  display: flex;
                  align-items: center;
                  gap: 8px;
                  border-bottom: 1px solid var(--border-color);
                  padding-bottom: 10px;
                  text-transform: uppercase;
                  letter-spacing: 0.5px;
                }
                .tree-container ul {
                  list-style: none;
                  padding-left: 18px;
                  margin: 0;
                }
                .tree-container > ul {
                  padding-left: 0;
                }
                .tree-item-doc {
                  display: flex;
                  align-items: center;
                  gap: 8px;
                  padding: 8px 10px;
                  border-radius: var(--radius-sm);
                  cursor: pointer;
                  transition: all var(--transition-fast);
                  margin: 2px 0;
                  color: var(--text-main);
                }
                .tree-item-doc:hover {
                  background: var(--primary-light);
                  color: var(--primary);
                }
                .tree-item-doc.active {
                  background: var(--primary);
                  color: #fff;
                }
                .tree-item-doc.active span {
                  color: #fff !important;
                }
                .tree-item-doc.active .icon-doc {
                  background: #fff;
                  color: var(--primary);
                }
                .toggle-icon {
                  display: inline-flex;
                  align-items: center;
                  justify-content: center;
                  width: 16px;
                  height: 16px;
                  font-size: 10px;
                  color: var(--text-muted);
                  cursor: pointer;
                  transition: transform 0.2s ease;
                  user-select: none;
                }
                .toggle-icon.collapsed {
                  transform: rotate(-90deg);
                }
                .toggle-spacer {
                  width: 16px;
                  height: 16px;
                  display: inline-block;
                }
                .icon-doc {
                  display: inline-flex;
                  align-items: center;
                  justify-content: center;
                  width: 20px;
                  height: 20px;
                  border-radius: 4px;
                  font-size: 11px;
                  font-weight: 700;
                  background: var(--primary-light);
                  color: var(--primary);
                  flex-shrink: 0;
                }
                .doc-list-item {
                  padding: 14px;
                  border: 1px solid var(--border-color);
                  border-radius: var(--radius-sm);
                  margin-bottom: 10px;
                  cursor: pointer;
                  transition: all var(--transition-fast);
                  background: var(--bg-card);
                }
                .doc-list-item:hover {
                  border-color: var(--primary);
                  background: var(--primary-light);
                  transform: translateY(-1px);
                  box-shadow: var(--shadow-sm);
                }
                .doc-list-item.active {
                  border-color: var(--primary);
                  background: var(--primary-light);
                  box-shadow: 0 0 0 2px var(--primary-light);
                }
                .doc-input {
                  padding: 10px 12px;
                  border: 1px solid var(--border-color);
                  border-radius: var(--radius-sm);
                  font-size: 13px;
                  transition: all var(--transition-fast);
                  width: 100%;
                  background: var(--bg-card);
                  color: var(--text-main);
                  font-family: inherit;
                }
                .doc-input:focus {
                  outline: none;
                  border-color: var(--primary);
                  box-shadow: 0 0 0 3px var(--primary-light);
                }
                .doc-input[readonly] {
                  background: rgba(0,0,0,0.02);
                  color: var(--text-muted);
                  cursor: not-allowed;
                }

/* ─── Liaison Structures <-> ArbreREF ─── */

.structure-row {
  transition: all var(--transition-fast);
}
.structure-row:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}
.structure-row.selected {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.linking-menu-item {
  transition: all var(--transition-fast);
}
.linking-menu-item:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}
.linking-menu-item.linking-selected {
  background: hsl(142, 71%, 95%) !important;
  border-color: var(--success) !important;
}

.linking-submenu-item {
  transition: all var(--transition-fast);
}
.linking-submenu-item:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}
.linking-submenu-item.linking-selected {
  background: hsl(142, 71%, 95%) !important;
  border-color: var(--success) !important;
}

.relance-row-highlight {
  background-color: var(--primary-light) !important;
}

.kpi-action-link {
  transition: transform 0.15s ease, background-color 0.15s ease !important;
}
.kpi-action-link:hover {
  background-color: var(--primary-light) !important;
  transform: translateY(-1px);
}

