/* =====================================================
   PCT.Planning - Styles CSS v2.2
   Planning Multi-Société EBP
   ===================================================== */

:root {
    /* Couleurs principales - Thème CLAIR */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-tertiary: #eef1f5;
    --bg-hover: #e4e8ef;
    
    --border-color: #dce1e9;
    --border-light: #c8cfd8;
    
    --text-primary: #1a2332;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    
    --accent-blue: #2563eb;
    --accent-green: #16a34a;
    --accent-purple: #7c3aed;
    --accent-orange: #d97706;
    --accent-red: #dc2626;
    --accent-pink: #db2777;
    --accent-cyan: #0891b2;
    --accent-yellow: #ca8a04;
    
    /* Couleurs des commandes (12 couleurs) */
    --order-1: #388bfd;
    --order-2: #3fb950;
    --order-3: #a371f7;
    --order-4: #d29922;
    --order-5: #f85149;
    --order-6: #db61a2;
    --order-7: #39c5cf;
    --order-8: #e3b341;
    --order-9: #58a6ff;
    --order-10: #56d364;
    --order-11: #bc8cff;
    --order-12: #f0883e;
    
    /* Dimensions */
    --header-height: 60px;
    --team-label-width: 200px;
    --day-cell-min-width: 120px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* =====================================================
   ÉCRAN DE CONNEXION
   ===================================================== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon.large {
    font-size: 64px;
    margin-bottom: 16px;
}

.login-header .logo-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color var(--transition-fast);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-login:hover {
    background: #1f6feb;
}

.login-error {
    color: var(--accent-red);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    min-height: 20px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* =====================================================
   APPLICATION PRINCIPALE
   ===================================================== */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Login Logo */
.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
    border-radius: 12px;
}

/* Header Logo */
.header-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-selector {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    min-width: 200px;
    cursor: pointer;
}

.company-selector:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.nav-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-tab.active {
    background: var(--accent-blue);
    color: white;
}

/* View Controls */
.view-controls {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.view-btn.active {
    background: var(--accent-blue);
    color: white;
}

/* Date Navigation */
.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav button {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-nav button:hover {
    background: var(--bg-hover);
}

.current-date {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 200px;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #1f6feb;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-danger {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.btn-export {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
}

.btn-export:hover {
    background: #2ea043;
}

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

.btn-logout {
    background: transparent;
    border: 1.5px solid #ef4444;
    color: #ef4444;
    font-size: 15px;
    border-radius: 6px;
    padding: 4px 8px !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
}

.btn-logout:hover {
    background: #ef4444;
    color: white;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    display: none;
}

.user-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.user-role.admin {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
}

.user-role.planner {
    background: rgba(56, 139, 253, 0.15);
    color: var(--accent-blue);
}

.user-role.reader {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

/* Form select */
.form-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* =====================================================
   MAIN CONTAINER (Sans sidebar)
   ===================================================== */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.main-container.no-sidebar {
    padding: 0;
}

/* =====================================================
   PLANNING CONTAINER
   ===================================================== */
.planning-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Wrapper unique qui gère le scroll horizontal */
.planning-scroll-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}



/* Planning Header */
.planning-header {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-width: max-content;
    z-index: 10;
}

.planning-header-spacer {
    width: var(--team-label-width);
    min-width: var(--team-label-width);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.planning-days {
    display: flex;
    flex: 1;
    min-width: max-content;
}

.day-header {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 8px;
    text-align: center;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.day-header:last-child {
    border-right: none;
}

.day-header.week-start {
    box-shadow: inset 3px 0 0 0 var(--accent-blue);
}

.day-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.day-date {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.day-header.today .day-date {
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.day-header.weekend {
    background: rgba(255, 255, 255, 0.02);
}

/* Planning Body */
.planning-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
    min-width: max-content;
    min-height: 0;
}

.planning-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    min-height: 80px;
    min-width: max-content;
}

.team-label {
    width: var(--team-label-width);
    min-width: var(--team-label-width);
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.team-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Groupe d'équipe avec header repliable */
.team-group {
    border-bottom: 1px solid var(--border-color);
}

.team-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-color);
}

.team-group-header:hover {
    background: var(--bg-secondary);
}

.team-group-toggle {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.team-group.collapsed .team-group-toggle {
    transform: rotate(-90deg);
}

.team-group-badge {
    font-weight: 600;
}

.team-group-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}

.team-group-content {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.team-group.collapsed .team-group-content {
    max-height: 0 !important;
    overflow: hidden;
}

/* Ligne collaborateur */
.collaborator-row .team-label {
    padding: 8px 16px 8px 32px;
}

.collaborator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: white;
    flex-shrink: 0;
}

.collaborator-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.collaborator-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collaborator-job {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.team-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-cells {
    display: flex;
    flex: 1;
    min-width: max-content;
}

.day-cell {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-primary);
    transition: background var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.day-cell:last-child {
    border-right: none;
}

.day-cell.week-start {
    box-shadow: inset 3px 0 0 0 var(--accent-blue);
}



.view-day1 .planning-block {
    max-width: 400px;
}

/* Vue mois : réduire la largeur minimale des cellules */
.view-month .day-header,
.view-month .day-cell {
    min-width: 60px;
}

/* Vue mois : correction alignement des indicateurs semaine */
.view-month .day-header.week-start,
.view-month .day-cell.week-start {
    position: relative;
    box-shadow: none;
}

.view-month .day-header.week-start::before,
.view-month .day-cell.week-start::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-blue);
    z-index: 1;
}

.day-cell:hover {
    background: var(--bg-tertiary);
}

.day-cell.drag-over {
    background: rgba(56, 139, 253, 0.15);
    outline: 2px dashed var(--accent-blue);
    outline-offset: -2px;
}

/* Zone de drop permanente en bas de cellule */
.drop-zone-spacer {
    min-height: 40px;
    flex-grow: 1;
    border-radius: 6px;
    border: 2px dashed transparent;
    transition: all var(--transition-fast);
}

.day-cell.drag-over .drop-zone-spacer {
    background: rgba(56, 139, 253, 0.15);
    border-color: var(--accent-blue);
}

.day-cell.weekend {
    background: rgba(255, 255, 255, 0.01);
}

/* Planning Block (dans la grille) */
.planning-block {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: grab;
    border-left: 4px solid var(--accent-blue);
    transition: all var(--transition-fast);
    position: relative;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    touch-action: pan-x pan-y; /* Permet scroll tactile */
}

.planning-block:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.planning-block:active {
    cursor: grabbing;
}

.planning-block.dragging {
    opacity: 0.5;
}

/* Indicateurs de réordonnancement */
.planning-block.drop-above {
    border-top: 3px solid var(--accent-blue) !important;
    margin-top: -2px;
}

.planning-block.drop-below {
    border-bottom: 3px solid var(--accent-blue) !important;
    margin-bottom: -2px;
}

.planning-block.drop-above::before,
.planning-block.drop-below::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-blue);
    z-index: 10;
}

.planning-block.drop-above::before {
    top: -3px;
}

.planning-block.drop-below::after {
    bottom: -3px;
}

.block-number {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block-customer {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block-day-indicator {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Couleurs par commande (basé sur data-order-color) */
.planning-block[data-order-color="0"]  { border-left-color:#2563eb; background:#dbeafe; color:#1e3a8a; }
.planning-block[data-order-color="1"]  { border-left-color:#16a34a; background:#dcfce7; color:#14532d; }
.planning-block[data-order-color="2"]  { border-left-color:#7c3aed; background:#ede9fe; color:#4c1d95; }
.planning-block[data-order-color="3"]  { border-left-color:#d97706; background:#fef3c7; color:#78350f; }
.planning-block[data-order-color="4"]  { border-left-color:#e11d48; background:#ffe4e6; color:#881337; }
.planning-block[data-order-color="5"]  { border-left-color:#db2777; background:#fce7f3; color:#831843; }
.planning-block[data-order-color="6"]  { border-left-color:#0891b2; background:#cffafe; color:#164e63; }
.planning-block[data-order-color="7"]  { border-left-color:#65a30d; background:#ecfccb; color:#365314; }
.planning-block[data-order-color="8"]  { border-left-color:#2563eb; background:#dbeafe; color:#1e3a8a; }
.planning-block[data-order-color="9"]  { border-left-color:#16a34a; background:#dcfce7; color:#14532d; }
.planning-block[data-order-color="10"] { border-left-color:#7c3aed; background:#ede9fe; color:#4c1d95; }
.planning-block[data-order-color="11"] { border-left-color:#d97706; background:#fef3c7; color:#78350f; }

.planning-block[data-order-color="6"] { border-left-color: var(--order-7); }
.planning-block[data-order-color="7"] { border-left-color: var(--order-8); }
.planning-block[data-order-color="8"] { border-left-color: var(--order-9); }
.planning-block[data-order-color="9"] { border-left-color: var(--order-10); }
.planning-block[data-order-color="10"] { border-left-color: var(--order-11); }
.planning-block[data-order-color="11"] { border-left-color: var(--order-12); }

/* Terminé = gris, APRÈS les couleurs pour écraser */
.planning-block.completed,
.planning-block[data-state="2"] {
    background: #e2e8f0 !important;
    border-left-color: #94a3b8 !important;
    color: #64748b !important;
    opacity: 1 !important;
}
.planning-block.completed:hover { transform: none; }
.planning-block.completed .block-customer-inline { text-decoration: line-through; }

.block-state-badge {
    font-size: 12px;
    margin-right: 3px;
    flex-shrink: 0;
}

.block-completed-badge { display: none !important; }

/* Bloc sélectionné (multi-sélection) */
.planning-block.selected {
    outline: 2px solid var(--accent-blue);
    outline-offset: 1px;
    background: rgba(56, 139, 253, 0.15);
}

.planning-block.selected::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =====================================================
   UNPLANNED SECTION
   ===================================================== */

/* Filter controls */
.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    color: var(--text-secondary);
    font-size: 13px;
}

.filter-date {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
}

.filter-date:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.unplanned-section {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.unplanned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
    gap: 16px;
    flex-wrap: wrap;
}

.unplanned-header:hover {
    background: var(--bg-tertiary);
}

.unplanned-header .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}

/* Navigation par période */
.period-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-nav {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-nav:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.btn-nav:active {
    transform: scale(0.95);
}

.unplanned-header .filter-group label {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.unplanned-header .filter-date {
    padding: 4px 8px;
    font-size: 12px;
    width: 130px;
}

.unplanned-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unplanned-title h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.unplanned-badge {
    background: var(--accent-blue);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.toggle-icon {
    color: var(--text-secondary);
    font-size: 12px;
    transition: transform var(--transition-fast);
}

.unplanned-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.unplanned-section.collapsed .unplanned-content {
    display: none;
}

.unplanned-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
}

.unplanned-cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 14px;
}

/* Unplanned Card */
.unplanned-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 180px;
    max-width: 220px;
    cursor: grab;
    position: relative;
    transition: all var(--transition-fast);
    touch-action: pan-x pan-y; /* Permet scroll tactile */
}

.unplanned-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.unplanned-card:active {
    cursor: grabbing;
}

.unplanned-card.dragging {
    opacity: 0.5;
}

.unplanned-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 8px 0 0 8px;
    background: var(--accent-blue);
}

/* Couleur par commande pour les cartes non planifiées */
.unplanned-card[data-order-color="0"]::before { background: var(--order-1); }
.unplanned-card[data-order-color="1"]::before { background: var(--order-2); }
.unplanned-card[data-order-color="2"]::before { background: var(--order-3); }
.unplanned-card[data-order-color="3"]::before { background: var(--order-4); }
.unplanned-card[data-order-color="4"]::before { background: var(--order-5); }
.unplanned-card[data-order-color="5"]::before { background: var(--order-6); }
.unplanned-card[data-order-color="6"]::before { background: var(--order-7); }
.unplanned-card[data-order-color="7"]::before { background: var(--order-8); }
.unplanned-card[data-order-color="8"]::before { background: var(--order-9); }
.unplanned-card[data-order-color="9"]::before { background: var(--order-10); }
.unplanned-card[data-order-color="10"]::before { background: var(--order-11); }
.unplanned-card[data-order-color="11"]::before { background: var(--order-12); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.card-number {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.card-date {
    font-size: 11px;
    color: var(--accent-blue);
    background: rgba(56, 139, 253, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.card-customer {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-city {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-warning {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--accent-orange);
}

/* =====================================================
   CONTEXT MENU
   ===================================================== */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    overflow: hidden;
    min-width: 200px;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-item.danger,
.context-menu-item[data-action="unplan"],
.context-menu-item[data-action="unplan-day"] {
    color: var(--accent-red);
}

.context-menu-item.danger:hover,
.context-menu-item[data-action="unplan"]:hover {
    background: rgba(248, 81, 73, 0.1);
}

.context-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* =====================================================
   TOOLTIP
   ===================================================== */
.block-tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 350px;
    pointer-events: none;
    transform: translateX(-50%);
    animation: tooltipFadeIn 0.15s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.block-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
}

.block-tooltip::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--bg-primary);
}

/* =====================================================
   USERS PANEL
   ===================================================== */
.users-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.users-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.users-table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.users-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.users-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-green { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); }
.badge-red { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); }
.badge-blue { background: rgba(56, 139, 253, 0.15); color: var(--accent-blue); }
.badge-gray { background: rgba(139, 148, 158, 0.15); color: var(--text-secondary); }

.companies-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.company-tag {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.action-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    margin-right: 4px;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-hover);
}

.action-btn.danger {
    color: var(--accent-red);
}

/* =====================================================
   MODALS
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Au-dessus de Leaflet (400-1000) */
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

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

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* User Form */
.user-form {
    padding: 24px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.user-form .form-group {
    margin-bottom: 16px;
}

.user-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-form input[type="text"],
.user-form input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.user-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.checkboxes-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* =====================================================
   NO COMPANY STATE
   ===================================================== */
.no-company-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px;
    text-align: center;
}

.no-company-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.no-company-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.no-company-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* =====================================================
   NOTIFICATIONS
   ===================================================== */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 300;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    border-left: 4px solid var(--accent-green);
}

.notification.error {
    border-left: 4px solid var(--accent-red);
}

.notification.info {
    border-left: 4px solid var(--accent-blue);
}

/* =====================================================
   PRINT / PDF
   ===================================================== */
@media print {
    .header,
    .filters-bar,
    .unplanned-section,
    .context-menu,
    .notification {
        display: none !important;
    }
    
    .main-container {
        padding: 0;
    }
    
    .planning-container {
        overflow: visible;
    }
    
    .planning-body {
        overflow: visible;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .planning-block {
        background: #f0f0f0;
        color: black;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    
    .header-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Permettre au header de défiler si nécessaire */
    .header-left,
    .header-center,
    .header-right {
        flex-shrink: 0;
    }
}

/* Tablettes intermédiaires (Surface 3, iPad) */
@media (max-width: 1400px) and (min-width: 1201px) {
    .header {
        padding: 10px 16px;
        gap: 12px;
    }
    
    .header-controls {
        gap: 10px;
    }
    
    .nav-tab {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .view-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .date-nav .current-date {
        font-size: 13px;
        min-width: 120px;
    }
    
    .company-selector {
        min-width: 160px;
        font-size: 13px;
    }
}

/* =====================================================
   RESPONSIVE TABLETTE (768px - 1024px)
   ===================================================== */
@media (max-width: 1024px) {
    :root {
        --team-label-width: 140px;
        --day-cell-min-width: 110px;
    }

    /* Header compact sur 2 lignes */
    .header {
        flex-wrap: wrap;
        padding: 6px 8px;
        gap: 4px;
        height: auto;
    }
    .header-left { flex-shrink: 0; }
    .logo-text { display: none; }
    .logo img { width: 32px; height: 32px; }

    /* Contrôles de vue - ligne 1 */
    .view-controls {
        display: flex;
        flex-wrap: nowrap;
        gap: 2px;
        order: 2;
    }
    .view-btn {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }

    /* Navigation date - ligne 1 */
    .date-nav { gap: 4px; order: 3; }
    .date-nav .current-date { font-size: 12px; min-width: auto; }
    #todayBtn { display: none; }

    /* Filtre collab compact */
    .collab-filter-btn { font-size: 11px; padding: 4px 8px; }

    /* Logout toujours visible */
    .user-name { display: none; }
    .user-role { display: none; }
    .btn-logout { display: flex !important; padding: 6px 10px !important; }

    /* Planning - scroll horizontal tactile */


    /* Timeline */
    .timeline-col { flex: 1; min-width: 0; }

    .menu-toggle { display: flex; }
    .unplanned-section { margin: 8px; }
}

/* =====================================================
   RESPONSIVE MOBILE (< 768px)
   ===================================================== */
@media (max-width: 768px) {
    :root {
        --team-label-width: 120px;
        --day-cell-min-width: 80px;
    }
    
    /* Header mobile */
    .header {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .header-left {
        flex: 0 0 auto;
    }
    
    .header-center {
        flex: 1;
        justify-content: center;
    }
    
    .header-right {
        flex: 0 0 auto;
    }
    
    .header-logo {
        width: 28px;
        height: 28px;
    }
    
    .nav-tabs {
        display: none;
    }
    
    .company-selector {
        min-width: 120px;
        max-width: 180px;
        font-size: 13px;
        padding: 8px;
    }
    
    .date-nav {
        display: none;
    }
    
    .btn-export {
        display: none;
    }
    
    .online-indicator .indicator-text {
        display: none;
    }
    
    .user-menu {
        gap: 4px;
    }
    
    .user-role {
        display: none;
    }
    
    .btn-logout {
        padding: 8px;
        min-width: 36px;
    }
    
    /* Navigation mobile par onglets en bas */
    .mobile-nav {
        display: flex;
    }
    
    /* Planning mobile */
    .main-container {
        padding-bottom: 60px;
    }
    
    .planning-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    

    
    .team-label {
        padding: 8px 10px;
    }
    
    .team-group-header {
        padding: 10px 12px;
    }
    
    .collaborator-row .team-label {
        padding: 8px 10px 8px 20px;
    }
    
    .collaborator-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .collaborator-name {
        font-size: 12px;
    }
    
    .collaborator-job {
        font-size: 10px;
    }
    
    /* Blocs planning plus compacts */
    .planning-block {
        padding: 4px 6px;
        font-size: 10px;
        min-height: 28px;
    }
    
    .block-content {
        gap: 2px;
    }
    
    .block-order {
        font-size: 10px;
    }
    
    .block-customer {
        font-size: 9px;
    }
    
    .block-badge {
        font-size: 8px;
        padding: 1px 4px;
    }
    
    /* Tâches non planifiées mobile */
    .unplanned-section {
        margin: 8px;
        border-radius: 8px;
    }
    
    .unplanned-header {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .unplanned-title h3 {
        font-size: 14px;
    }
    
    .filter-group {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-group label {
        display: none;
    }
    
    .filter-date {
        flex: 1;
        min-width: 0;
    }
    
    .unplanned-content {
        padding: 10px;
        gap: 8px;
        max-height: 200px;
    }
    
    .task-card {
        padding: 10px;
    }
    
    .task-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .task-customer {
        font-size: 13px;
    }
    
    .task-details {
        font-size: 11px;
    }
    
    /* Modals plein écran mobile */
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        padding: 16px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
        padding: 14px;
        font-size: 15px;
    }
    
    /* Formulaires tactiles */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 12px;
        font-size: 16px; /* Évite le zoom sur iOS */
    }
    
    /* Tables responsive */
    .users-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .users-table {
        min-width: 600px;
    }
    
    .users-table th,
    .users-table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .action-btn {
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }
}

/* =====================================================
   MENU BURGER & DRAWER MOBILE
   ===================================================== */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Drawer mobile */
.mobile-drawer {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
    overflow-y: auto;
}

.mobile-drawer.open {
    transform: translateX(0);
}

.drawer-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 99;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.drawer-content {
    padding: 16px;
}

.drawer-section {
    margin-bottom: 24px;
}

.drawer-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.drawer-view-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-view-controls .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.drawer-date-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-date-nav .btn {
    width: 100%;
    padding: 12px;
}

/* Navigation mobile en bas */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 12px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 10px;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s;
    }
    
    .mobile-nav-btn.active {
        color: var(--accent-green);
    }
    
    .mobile-nav-btn:hover {
        background: var(--bg-tertiary);
    }
    
    .mobile-nav-btn .nav-icon {
        font-size: 20px;
    }
}

/* =====================================================
   INDICATEUR ONLINE/OFFLINE
   ===================================================== */

.online-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.online-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.online-indicator.online {
    background: rgba(35, 134, 54, 0.2);
    color: var(--accent-green);
}

.online-indicator.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

.online-indicator.online .indicator-dot {
    background: var(--accent-green);
}

.online-indicator.offline .indicator-dot {
    background: var(--accent-red);
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.indicator-text {
    display: none;
}

@media (min-width: 768px) {
    .indicator-text {
        display: inline;
    }
}

.pending-sync-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-orange);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    animation: bounce-badge 1s ease-in-out infinite;
}

@keyframes bounce-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Toast de synchronisation */
.sync-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slide-up 0.3s ease;
}

@keyframes slide-up {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.sync-toast.success {
    border-color: var(--accent-green);
}

.sync-toast.error {
    border-color: var(--accent-red);
}

.sync-toast .sync-icon {
    font-size: 20px;
}

.sync-toast .sync-message {
    font-size: 14px;
    color: var(--text-primary);
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    z-index: 1000;
    animation: slide-up 0.3s ease;
}

.pwa-install-banner .banner-text {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pwa-install-banner .banner-icon {
    font-size: 24px;
}

.pwa-install-banner .banner-message {
    font-size: 14px;
}

.pwa-install-banner .banner-actions {
    display: flex;
    gap: 10px;
}

.pwa-install-banner .btn-install {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.pwa-install-banner .btn-dismiss {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* =====================================================
   MODAL NOTE
   ===================================================== */

.modal-note {
    max-width: 600px;
    width: 90%;
}

/* Onglets de la modale Note */
.note-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.note-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -2px;
}

.note-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.note-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: transparent;
}

.note-tab-content {
    display: none;
}

.note-tab-content.active {
    display: block;
}

/* Référence EBP */
.reference-display {
    background: var(--bg-tertiary);
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: monospace;
    border: 1px solid var(--border-color);
}

/* Conteneur détails commande */
.order-details-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 250px;
    overflow-y: auto;
}

.order-details-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.order-details-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.order-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.order-details-table th {
    background: var(--bg-secondary);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

.order-details-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.order-details-table tr:last-child td {
    border-bottom: none;
}

.order-details-table tr:hover {
    background: var(--bg-secondary);
}

.order-details-table .qty-cell {
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
    width: 50px;
}

.order-details-table .unit-cell {
    text-align: center;
    color: var(--text-secondary);
    width: 50px;
}

.order-details-table .desc-cell {
    word-break: break-word;
}

.order-details-table .price-cell {
    text-align: right;
    white-space: nowrap;
    width: 75px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.order-details-table .price-cell.amount-cell {
    font-weight: 700;
    color: var(--accent-green);
    font-size: 0.9rem;
}

/* Total TTC */
.order-total-ttc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--accent-green);
    border-radius: 8px;
}

.order-total-ttc .total-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.order-total-ttc .total-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-green);
}

/* Conteneur notes EBP */
.ebp-notes-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.ebp-notes-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.ebp-notes-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.ebp-notes-content {
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Infos client (Camion, Chariot rouge) */
.customer-info-section {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
}

.customer-info-section .form-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.customer-info-badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.customer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.badge-camion {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.badge-chariot {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.note-task-info {
    background: var(--bg-tertiary);
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    color: var(--text-secondary);
}

.note-task-info strong {
    color: var(--text-primary);
}

.note-input-container {
    position: relative;
    display: flex;
    gap: 10px;
}

.note-textarea {
    flex: 1;
    min-height: 180px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.note-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.note-textarea::placeholder {
    color: var(--text-muted);
}

.btn-voice {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    font-size: 24px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-voice:hover {
    background: var(--accent-blue);
    transform: scale(1.1);
}

.btn-voice.recording {
    background: var(--accent-red);
    animation: pulse-recording 1s infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.note-char-count {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Badge note sur le bloc */
.block-note-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    opacity: 0.7;
}

/* Indicateur visuel si note présente */
.planning-block.has-note {
    border-left-width: 4px;
}

.planning-block.has-note::after {
    content: '📝';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    opacity: 0.7;
}

/* Ajustement pour éviter chevauchement avec badge terminé */
.planning-block.has-note.completed::after {
    right: 22px;
}

/* Voice recognition status */
.voice-status {
    font-size: 12px;
    color: var(--accent-blue);
    margin-top: 5px;
    font-style: italic;
}

.voice-status.error {
    color: var(--accent-red);
}

/* =====================================================
   SIGNATURE - Styles pour la zone de signature
   ===================================================== */

/* Modale note + signature plus grande */
.modal-note-signature {
    max-width: 600px;
    width: 100%;
    height: 90vh;
    max-height: 90vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-note-signature .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-note-signature .note-tabs {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-note-signature .note-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
    min-height: 0;
}

/* Message de verrouillage quand commande terminée */
.lock-message {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    color: #92400e;
    font-weight: 500;
    text-align: center;
    font-size: 14px;
}

.modal-note-signature .note-tab-content {
    display: none;
}

.modal-note-signature .note-tab-content.active {
    display: block;
}

.modal-note-signature .note-modal-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    padding: 15px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 600px) {
    .modal-note-signature {
        max-width: 100%;
    }
}

/* Séparateur signature */
.signature-separator {
    display: flex;
    align-items: center;
    margin: 20px 0 15px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.signature-separator::before,
.signature-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.signature-separator span {
    padding: 0 15px;
    white-space: nowrap;
}

/* Checkbox Commande terminée */
.completed-checkbox-group {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.completed-checkbox-group:has(.completed-checkbox:checked) {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
}

.completed-checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 16px;
    font-weight: 500;
}

.completed-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: #22c55e;
}

.completed-checkbox-text {
    color: var(--text-primary);
}

.completed-checkbox:checked + .completed-checkbox-text {
    color: #22c55e;
}

/* Section signature */
.signature-section {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

/* Container du canvas */
.signature-container {
    position: relative;
    background: #ffffff;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    touch-action: none; /* Important pour tablettes */
}

.signature-container.has-signature {
    border-style: solid;
    border-color: var(--accent-green);
}

/* Canvas de signature */
.signature-canvas {
    display: block;
    width: 100%;
    height: 200px;
    cursor: crosshair;
    background: transparent;
}

/* Placeholder quand vide */
.signature-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 16px;
    pointer-events: none;
    user-select: none;
}

.signature-container.has-signature .signature-placeholder {
    display: none;
}

/* Actions signature */
.signature-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.signature-status {
    font-size: 12px;
    color: var(--text-muted);
}

.signature-status.signed {
    color: var(--accent-green);
}

/* Bouton petit */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Label de formulaire */
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Input de formulaire */
.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Indicateur signature sur bloc planning */
.planning-block.has-signature::before {
    content: '✍️';
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 10px;
    opacity: 0.8;
}

/* Ajustement position des badges */
.planning-block.has-note.has-signature::after {
    right: 2px;
}

.planning-block.has-note.has-signature.completed::after {
    right: 22px;
}

/* Responsive pour tablettes */
@media (max-width: 768px) {
    .modal-note-signature {
        max-width: 100%;
        width: 100%;
        margin: 10px;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .signature-canvas {
        height: 180px;
    }
    
    .signature-section {
        padding: 12px;
    }
}

/* Responsive pour tablettes intermédiaires (Surface, iPad) */
@media (max-width: 1024px) and (min-width: 769px) {
    .modal-note-signature {
        max-width: 90%;
        width: 90%;
        height: 85vh;
        max-height: 85vh;
    }
    
    .signature-canvas {
        height: 150px;
    }
    
    .note-textarea {
        min-height: 120px;
    }
}

/* Animation lors de la signature */
@keyframes signaturePulse {
    0% { box-shadow: 0 0 0 0 rgba(35, 134, 54, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(35, 134, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(35, 134, 54, 0); }
}

.signature-container.signing {
    animation: signaturePulse 0.5s ease-out;
}

/* =====================================================
   PANNEAU DE SYNCHRONISATION v2.7
   ===================================================== */

/* Rendre l'indicateur online cliquable */
.online-status {
    cursor: pointer;
    transition: opacity 0.2s;
}

.online-status:hover {
    opacity: 0.8;
}

/* Modal de synchronisation */
.modal-sync {
    max-width: 480px;
    width: 95%;
}

.sync-panel {
    padding: 0;
}

/* Section statut */
.sync-status-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

.sync-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.sync-status-indicator .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #28a745;
}

.sync-status-indicator.offline .status-dot {
    background: #dc3545;
}

.sync-status-indicator.online {
    color: #28a745;
}

.sync-status-indicator.offline {
    color: #dc3545;
}

.sync-last-update {
    font-size: 0.85rem;
    color: #333;
}

/* Sections repliables */
.sync-section {
    border-bottom: 1px solid #e9ecef;
}

.sync-section:last-child {
    border-bottom: none;
}

.sync-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: background 0.2s;
    color: #222;
}

.sync-section-header:hover {
    background: #f8f9fa;
}

.sync-section-header span:first-child {
    flex: 1;
    font-weight: 500;
    color: #222;
}

.section-arrow {
    color: #6c757d;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.sync-section-content {
    padding: 0 20px 16px;
    animation: slideDown 0.2s ease-out;
}

.sync-section-content.collapsed {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Compteur de modifications en attente */
.pending-count {
    background: #e9ecef;
    color: #495057;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.pending-count.has-pending {
    background: #dc3545;
    color: white;
}

/* Hint */
.sync-hint {
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Options de téléchargement */
.sync-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.sync-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.sync-option:hover {
    background: #e9ecef;
}

.sync-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #0d6efd;
}

.sync-option span {
    font-size: 0.9rem;
    color: #222;
}

/* Barre de progression */
.download-progress {
    margin-bottom: 16px;
}

.download-progress.hidden {
    display: none;
}

.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #0b5ed7);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: #333;
}

/* Liste des modifications en attente */
.pending-changes-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.pending-change-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.pending-change-item:last-child {
    margin-bottom: 0;
}

.pending-change-info {
    flex: 1;
}

.pending-change-type {
    font-weight: 500;
    color: #222;
}

.pending-change-time {
    font-size: 0.75rem;
    color: #555;
}

.pending-change-delete {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.1rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.pending-change-delete:hover {
    opacity: 1;
}

/* Historique des syncs */
.sync-history-list {
    max-height: 200px;
    overflow-y: auto;
}

.sync-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #222;
}

.sync-history-item:last-child {
    margin-bottom: 0;
}

.sync-history-icon {
    font-size: 1.1rem;
}

.sync-history-details {
    flex: 1;
}

.sync-history-type {
    font-weight: 500;
    color: #222;
}

.sync-history-time {
    font-size: 0.75rem;
    color: #555;
}

.sync-history-result {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.sync-history-result.success {
    background: #d4edda;
    color: #155724;
}

.sync-history-result.error {
    background: #f8d7da;
    color: #721c24;
}

/* Statistiques de stockage */
.storage-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.storage-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.storage-label {
    color: #222;
}

.storage-value {
    font-weight: 600;
    color: #222;
}

/* Message vide */
.sync-empty {
    text-align: center;
    color: #555;
    font-size: 0.9rem;
    padding: 20px;
    margin: 0;
}

/* Boutons */
.btn-block {
    display: block;
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* État désactivé */
#syncNowBtn:disabled,
#downloadBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .modal-sync {
        max-width: 100%;
        margin: 10px;
        max-height: 90vh;
    }
    
    .sync-status-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .sync-section-header {
        padding: 12px 16px;
    }
    
    .sync-section-content {
        padding: 0 16px 14px;
    }
}

/* Amélioration toast sync */
.sync-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 0.9rem;
}

.sync-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sync-toast.success {
    background: #28a745;
}

.sync-toast.error {
    background: #dc3545;
}

.sync-toast .sync-icon {
    font-size: 1.2rem;
}

.sync-toast .sync-message {
    flex: 1;
}

/* =====================================================
   ALERTE DONNÉES PÉRIMÉES v2.7
   ===================================================== */

.stale-data-alert {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 10002;
    max-width: 450px;
    width: 90%;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}

.stale-data-alert.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.stale-alert-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
}

.stale-alert-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.stale-alert-text {
    flex: 1;
}

.stale-alert-text strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
}

.stale-alert-text p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.9;
}

.stale-alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.stale-alert-close:hover {
    opacity: 1;
}

/* Alerte Warning (orange) */
.stale-alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 1px solid #ffc107;
    color: #856404;
}

.stale-alert-warning .stale-alert-close {
    color: #856404;
}

/* Alerte Critique (rouge) */
.stale-alert-critical {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 1px solid #dc3545;
    color: #721c24;
}

.stale-alert-critical .stale-alert-close {
    color: #721c24;
}

/* Animation pulse pour critique */
.stale-alert-critical .stale-alert-icon {
    animation: alertPulse 1s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Responsive */
@media (max-width: 480px) {
    .stale-data-alert {
        top: 60px;
        width: 95%;
        max-width: none;
    }
    
    .stale-alert-content {
        padding: 14px 16px;
    }
    
    .stale-alert-icon {
        font-size: 1.5rem;
    }
    
    .stale-alert-text strong {
        font-size: 0.95rem;
    }
    
    .stale-alert-text p {
        font-size: 0.85rem;
    }
}

/* =====================================================
   BADGE VERSION (v2.7)
   ===================================================== */

.version-badge {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(13, 17, 23, 0.8);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    z-index: 50;
    transition: all 0.2s;
}

.version-badge:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Cacher sur mobile (barre de nav en bas) */
@media (max-width: 768px) {
    .version-badge {
        bottom: 70px;
    }
}

/* Section version dans le panneau sync */
.sync-version-section {
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
    padding-top: 10px;
}

.version-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.version-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.version-value {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    font-family: monospace;
}

/* =====================================================
   CORRECTIONS TABLETTES SURFACE / iPad (v2.7)
   ===================================================== */

/* Cacher la vue Mois sur appareils tactiles (tablette/mobile) */
/* .touch-device .view-btn[data-view="month"] { display: none; } -- activé */

/* =====================================================
   DRAG & DROP TACTILE (v2.17)
   ===================================================== */

/* Sur appareil tactile, désactiver le drag HTML5 natif */
.touch-device .planning-block,
.touch-device .unplanned-card {
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-touch-callout: none;
}

/* Élément en cours de drag tactile */
.touch-dragging {
    opacity: 0.4 !important;
    transform: scale(0.95) !important;
}

/* Clone de drag tactile */
.touch-drag-clone {
    border-radius: 8px;
    transition: none !important;
}

/* Cellule survolée pendant le drag tactile */
.day-cell.touch-drag-over {
    background: rgba(59, 130, 246, 0.15) !important;
    box-shadow: inset 0 0 0 2px var(--accent-blue);
}

/* Feedback visuel pour appui long */
@keyframes longpress-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

.touch-device .planning-block:active,
.touch-device .unplanned-card:active {
    animation: longpress-pulse 0.3s ease-in-out;
}

/* =====================================================
   HISTORIQUE DES CONNEXIONS (v2.7)
   ===================================================== */

.users-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.modal-login-history {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
}

.modal-login-history .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.login-history-filters {
    display: flex;
    gap: 15px;
    padding: 15px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: flex-end;
}

.login-history-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.login-history-filters .filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.login-history-filters .form-input {
    min-width: 150px;
}

.login-history-table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.login-history-table {
    width: 100%;
    border-collapse: collapse;
}

.login-history-table th,
.login-history-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.login-history-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.login-history-table td {
    font-size: 13px;
    color: var(--text-primary);
}

.login-history-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.login-history-table .date-cell {
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.login-history-table .user-cell {
    font-weight: 500;
}

.login-history-table .device-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}

.login-history-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* =====================================================
   JOURNAL DES MODIFICATIONS (Activity Log)
   ===================================================== */

.modal-activity-log {
    max-width: 1100px;
    width: 95%;
}

.modal-activity-log .modal-body {
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.activity-log-filters {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.activity-log-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.activity-log-filters .filter-group label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.activity-log-filters .form-input {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 120px;
}

.activity-log-table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.activity-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.activity-log-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.activity-log-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.activity-log-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.activity-log-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.activity-log-table .date-cell {
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.activity-log-table .user-cell {
    font-weight: 500;
}

.activity-log-table .action-cell {
    white-space: nowrap;
}

.activity-log-table .doc-cell {
    font-family: monospace;
    font-size: 12px;
}

.activity-log-table .details-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}

.activity-log-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-login-history {
        max-width: 100%;
        width: 100%;
        max-height: 95vh;
        margin: 10px;
    }
    
    .login-history-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .login-history-filters .form-input {
        width: 100%;
    }
    
    .login-history-table th,
    .login-history-table td {
        padding: 10px;
        font-size: 12px;
    }
    
    .login-history-table .device-cell {
        display: none;
    }
}

/* Surface 3, iPad Pro, tablettes avec scaling Windows */
@media (max-width: 1400px) {
    /* Header - éviter troncature */
    .header {
        min-height: var(--header-height);
        height: auto;
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .header-controls {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    
    /* Réduire les boutons de vue */
    .view-controls {
        gap: 2px;
        padding: 3px;
    }
    
    .view-btn {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    /* Navigation date plus compacte */
    .date-nav {
        gap: 4px;
    }
    
    .date-nav .current-date {
        min-width: 100px;
        font-size: 12px;
    }
    
    .date-nav button {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    /* Sélecteur société */
    .company-selector {
        min-width: 140px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    /* Onglets navigation */
    .nav-tabs {
        gap: 2px;
        padding: 3px;
    }
    
    .nav-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Tablettes en mode portrait ou petites tablettes */
@media (max-width: 1100px) {
    /* Header sur 2 lignes si nécessaire */
    .header {
        flex-wrap: wrap;
        padding: 8px 10px;
    }
    
    .header-left {
        order: 1;
        flex: 1;
    }
    
    .header-center {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
    
    .header-right {
        order: 2;
    }
    
    /* Cacher le texte du logo */
    .logo-text {
        display: none;
    }
    
    /* Vue mois : cellules plus petites */
    .view-month .day-header,
    .view-month .day-cell {
        min-width: 50px;
        padding: 4px;
    }
    
    .view-month .day-date {
        font-size: 14px;
    }
    
    .view-month .day-name {
        font-size: 10px;
    }
    
    .view-month .planning-block {
        padding: 4px 6px;
    }
    
    .view-month .block-number {
        font-size: 10px;
    }
    
    .view-month .block-customer {
        display: none;
    }
}

/* Modal note/signature - corrections hauteur tablettes */
@media (max-height: 800px) {
    .modal-note-signature {
        height: 95vh;
        max-height: 95vh;
    }
    
    .note-textarea {
        min-height: 100px;
    }
    
    .signature-canvas {
        height: 120px;
    }
    
    .signature-section {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
}

/* Très petits écrans en hauteur (tablette paysage) */
@media (max-height: 600px) {
    .modal-note-signature {
        height: 98vh;
        max-height: 98vh;
        margin: 5px;
    }
    
    .modal-note-signature .note-modal-body {
        padding: 10px;
    }
    
    .modal-header {
        padding: 10px 15px;
    }
    
    .modal-note-signature .note-modal-footer {
        padding: 10px 15px;
    }
    
    .note-textarea {
        min-height: 80px;
    }
    
    .signature-canvas {
        height: 100px;
    }
    
    .signature-section {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .signature-separator {
        margin: 10px 0;
    }
}

/* Fix spécifique vue mois - alignement lignes bleues */
@media (max-width: 1400px) {
    
    
    .view-month .day-cells {
        position: relative;
    }
    
    .view-month .day-cell {
        position: relative;
    }
}

/* =====================================================
   ONGLET CARTE - Visualisation géographique v2.20
   ===================================================== */

.map-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 60px);
    padding: 16px;
    gap: 16px;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.map-header-left h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.map-header-center {
    display: flex;
    align-items: center;
    gap: 12px;
}

.map-date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-date-display {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 180px;
    text-align: center;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.map-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.map-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-filter label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.map-filter select {
    min-width: 180px;
}

.map-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-stat-badge {
    padding: 6px 12px;
    background: var(--accent-blue);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Conteneur de la carte Leaflet */
.map-leaflet-container {
    flex: 1;
    min-height: 400px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#mapContainer {
    width: 100%;
    height: 100%;
}

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    z-index: 1000;
}

.map-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Légende de la carte */
.map-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.legend-marker.depot {
    background: #f85149;
}

.legend-marker.delivery {
    background: #388bfd;
}

.legend-marker.completed {
    background: #3fb950;
}

.legend-marker.approximate {
    background: #58a6ff;
    border: 2px dashed #d29922;
}

/* Personnalisation des popups Leaflet */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-content {
    margin: 12px 16px;
    min-width: 200px;
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
}

.map-popup {
    font-size: 0.875rem;
}

.map-popup-order {
    display: inline-block;
    background: var(--accent-blue);
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}

.map-popup-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--accent-blue);
}

.map-popup-customer {
    font-weight: 500;
    margin-bottom: 4px;
}

.map-popup-address {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.map-popup-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.map-popup-status.pending {
    background: rgba(56, 139, 253, 0.2);
    color: var(--accent-blue);
}

.map-popup-status.completed {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
}

.map-popup-colleague {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.map-popup-warning {
    background: rgba(210, 153, 34, 0.2);
    color: var(--accent-orange);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 8px;
}

/* Marqueurs personnalisés */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    font-weight: bold;
    font-size: 0.75rem;
    color: white;
}

.custom-marker.depot {
    background: #f85149;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
}

.custom-marker.delivery {
    background: #388bfd;
}

.custom-marker.completed {
    background: #3fb950;
}

/* Message si pas de livraisons */
.map-no-deliveries {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    z-index: 1000;
    background: var(--bg-secondary);
    padding: 24px 32px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.map-no-deliveries h3 {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
}

.map-no-deliveries p {
    margin: 0;
    font-size: 0.875rem;
}

/* Commandes non géocodées */
.map-failed-geocode {
    position: absolute;
    bottom: 60px;
    left: 10px;
    right: 10px;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-orange);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.failed-geocode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(210, 153, 34, 0.2);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent-orange);
}

.failed-geocode-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
}

.failed-geocode-close:hover {
    color: var(--text-primary);
}

.failed-geocode-list {
    overflow-y: auto;
    max-height: 150px;
    padding: 8px 12px;
}

.failed-geocode-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

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

.failed-geocode-item small {
    color: var(--text-muted);
}

/* Responsive carte */
@media (max-width: 1024px) {
    .map-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .map-header-left,
    .map-header-center,
    .map-header-right {
        justify-content: center;
    }
    
    .map-date-display {
        min-width: 150px;
    }
    
    .map-filter select {
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .map-container {
        height: calc(100vh - var(--header-height) - 120px);
        padding: 8px;
        gap: 8px;
    }
    
    .map-header {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .map-header-left h2 {
        font-size: 1rem;
    }
    
    .map-date-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .map-date-display {
        min-width: 140px;
        font-size: 0.875rem;
        padding: 6px 12px;
    }
    
    .map-filter {
        flex-direction: column;
        align-items: stretch;
    }
    
    .map-filter select {
        min-width: 100%;
    }
    
    .map-legend {
        flex-wrap: wrap;
        gap: 12px;
        padding: 8px 12px;
    }
    
    .legend-item {
        font-size: 0.75rem;
    }
    
    .leaflet-popup-content {
        min-width: 180px;
    }
}

/* Cacher les attributions Leaflet sur mobile */
@media (max-width: 480px) {
    .leaflet-control-attribution {
        font-size: 8px;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ===== FILTRE COLLABORATEUR ===== */
.collab-filter-group {
    display: flex;
    align-items: center;
}
.filter-collab-select {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #c8d0da;
    border-radius: 6px;
    background: #ffffff;
    color: #1a2332;
    font-size: 13px;
    cursor: pointer;
    min-width: 160px;
    max-width: 220px;
}
.filter-collab-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* ===== TIMELINE VUE 1 JOUR ===== */
.timeline-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
    background: #fff;
    border: 1px solid #dce1e9;
    border-radius: 8px;
}

.timeline-header-row {
    display: flex;
    align-items: stretch;
    border-bottom: 2px solid #dce1e9;
    background: #f5f7fa;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 68px;
    flex-shrink: 0;
}

.timeline-time-gutter {
    width: 60px;
    min-width: 60px;
    background: #f5f7fa;
    border-right: 1px solid #dce1e9;
    flex-shrink: 0;
}

.timeline-col-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-right: 1px solid #dce1e9;
    gap: 3px;
    flex: 1;
    min-width: 0;
    background: #f5f7fa;
}
.timeline-col-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.timeline-col-name {
    font-size: 12px;
    font-weight: 700;
    color: #1a2332;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.timeline-col-team {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.timeline-scroll {
    display: flex;
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    background: #fff;
}

.timeline-gutter {
    width: 60px;
    min-width: 60px;
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f5f7fa;
    border-right: 1px solid #dce1e9;
    flex-shrink: 0;
}

.timeline-gutter-label {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-right: 8px;
    padding-top: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #4a5568;
    box-sizing: border-box;
}

.timeline-grid {
    flex: 1;
    min-width: 0;
    position: relative;
}

.timeline-slot {
    position: absolute;
    left: 0;
    right: 0;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 0;
}
.timeline-slot.slot-hour {
    border-top: 1px solid #c4cdd6;
    background: rgba(0,0,0,0.015);
}
.timeline-slot.slot-half {
    border-top: 1px dashed #dde3ea;
}

.timeline-col-bg {
    position: absolute;
    top: 0;
    border-right: 1px solid #dce1e9;
    background: #fff;
    box-sizing: border-box;
    z-index: 1;
}
/* Events and slots above col-bg */
.timeline-event { z-index: 3 !important; }
.timeline-slot { z-index: 2 !important; }
.timeline-col-bg:nth-child(even) {
    background: #fafbfc;
}

.timeline-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #dc2626;
    z-index: 8;
    pointer-events: none;
}
.timeline-now-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc2626;
}

/* Couleurs des événements timeline */
.timeline-event {
    position: absolute;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    overflow: hidden;
    cursor: pointer;
    z-index: 4;
    box-sizing: border-box;
    border-left: 4px solid #2563eb;
    background: #dbeafe;
    color: #1e3a8a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.15s, transform 0.1s;
    left: 4px;
    right: 4px;
}
/* tl-color = même palette que data-order-color pour cohérence vue 1j / autres vues */
.tl-color-0 { background:#dbeafe; border-color:#2563eb; color:#2563eb; }
.tl-color-1 { background:#dcfce7; border-color:#16a34a; color:#16a34a; }
.tl-color-2 { background:#ede9fe; border-color:#7c3aed; color:#7c3aed; }
.tl-color-3 { background:#fef3c7; border-color:#d97706; color:#d97706; }
.tl-color-4 { background:#ffe4e6; border-color:#e11d48; color:#e11d48; }
.tl-color-5 { background:#fce7f3; border-color:#db2777; color:#db2777; }
.tl-color-6 { background:#cffafe; border-color:#0891b2; color:#0891b2; }
.tl-color-7 { background:#ecfccb; border-color:#65a30d; color:#65a30d; }
.timeline-event:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(1px);
    z-index: 6;
    filter: brightness(0.97);
}
.timeline-event.completed {
    background: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #64748b !important;
    opacity: 1 !important;
}
.timeline-event.completed .tl-card-header { color: #64748b !important; }
.timeline-event.completed .tl-client-inline {
    color: #64748b !important;
    text-decoration: line-through;
}
.timeline-event-time {
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 2px;
    opacity: 0.85;
}
.timeline-event-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}
.timeline-event-customer {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.timeline-event-addr {
    font-size: 10px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.timeline-event-done {
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 13px;
    font-weight: 700;
    color: #16a34a;
}

/* ===== RESPONSIVE - TABLETTE ET MOBILE ===== */

/* Timeline responsive */
.timeline-wrapper {
    height: calc(100vh - 110px);
}

.timeline-col-header {
    min-width: 0 !important;
}

/* Planning body responsive */
/* Header responsive */
@media (max-width: 1024px) {
    .header-controls.header-right .btn-export,
    .header-controls.header-right #exportPdfBtn {
        display: none;
    }
    .view-controls {
        gap: 2px;
    }
    .view-controls .view-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    .collab-filter-group .filter-collab-select {
        min-width: 120px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    /* Header compact */
    .header-controls.header-center .nav-tabs {
        display: none;
    }
    .header-controls.header-right {
        gap: 4px;
    }
    /* Timeline : colonnes plus étroites */
    .timeline-wrapper {
        height: calc(100vh - 100px);
    }
    .timeline-col-header {
        min-width: 0 !important;
        padding: 4px 2px;
    }
    .timeline-col-name {
        font-size: 10px;
    }
    .timeline-event-title {
        font-size: 11px;
    }
    .timeline-gutter {
        width: 44px;
        min-width: 44px;
    }
    .timeline-gutter-label {
        font-size: 10px;
        padding-right: 4px;
    }
    /* Planning grille : réduire */
    .team-label {
        min-width: 120px !important;
        max-width: 120px !important;
    }

}

@media (max-width: 480px) {
    .timeline-col-header {
        min-width: 0 !important;
    }
    .timeline-gutter {
        width: 36px;
        min-width: 36px;
    }
    .view-controls .view-btn[data-view="fortnight"],
    .view-controls .view-btn[data-view="month"] {
        display: none;
    }
}

/* ===== FILTRE MULTI-SELECT COLLABORATEURS ===== */
.filter-collab-btn {
    height: 34px;
    padding: 0 12px;
    border: 1px solid #c8d0da;
    border-radius: 6px;
    background: #ffffff;
    color: #1a2332;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-width: 140px;
    max-width: 220px;
}
.filter-collab-btn:hover {
    border-color: #2563eb;
    background: #f0f4ff;
}
.filter-arrow { font-size: 10px; margin-left: auto; }

.collab-filter-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #dce1e9;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 200px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px 0;
}
.collab-filter-dropdown.hidden { display: none; }

.collab-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #1a2332;
    white-space: nowrap;
}
.collab-filter-item:hover { background: #f0f4ff; }
.collab-filter-item input[type=checkbox] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2563eb;
}

/* ===== MODALE DÉTAIL ÉVÉNEMENT ===== */
.modal-large {
    width: 90%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
}

.event-detail-body {
    padding: 16px;
}

.event-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.event-detail-section {
    background: #f8f9fa;
    border: 1px solid #dce1e9;
    border-radius: 8px;
    padding: 14px;
}

.event-detail-section.event-detail-full {
    grid-column: 1 / -1;
}

.event-detail-section h4 {
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #dce1e9;
}

.event-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.event-detail-table td {
    padding: 5px 6px;
    vertical-align: top;
}

.event-detail-table td:first-child {
    color: #4a5568;
    width: 130px;
    font-size: 12px;
    white-space: nowrap;
}

.event-detail-table tr:hover td {
    background: #eef1f5;
}

.event-detail-table.event-detail-list thead th {
    background: #eef1f5;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 8px;
    text-align: left;
    color: #4a5568;
}

.event-detail-table.event-detail-list td {
    border-top: 1px solid #eef1f5;
    width: auto;
}

.event-detail-note {
    font-size: 13px;
    color: #1a2332;
    margin-bottom: 10px;
    line-height: 1.5;
}

.event-state-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.event-state-badge.done { background: #dcfce7; color: #16a34a; }
.event-state-badge.todo { background: #fef3c7; color: #d97706; }

/* Carte timeline enrichie */
.timeline-event-code {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.75;
    margin-bottom: 1px;
}
.timeline-event-label {
    font-size: 11px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.timeline-event-phone {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 1px;
}

@media (max-width: 600px) {
    .event-detail-grid { grid-template-columns: 1fr; }
    .event-detail-section.event-detail-full { grid-column: 1; }
}

/* ===== SIGNATURE CANVAS ===== */
.signature-zone {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.signature-name-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sig-name-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #dce1e9;
    border-radius: 6px;
    font-size: 13px;
    color: #1a2332;
    background: #fff;
    max-width: 320px;
}
.sig-name-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.sig-canvas-wrapper {
    position: relative;
    border: 2px solid #dce1e9;
    border-radius: 8px;
    background: #fff;
    cursor: crosshair;
    overflow: hidden;
    touch-action: none;
}

.sig-canvas {
    display: block;
    width: 100%;
    height: 160px;
    touch-action: none;
}

.sig-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #c8d0da;
    pointer-events: none;
    font-style: italic;
}

.sig-canvas-wrapper:hover {
    border-color: #2563eb;
}

.sig-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.sig-clear-btn {
    font-size: 12px;
    padding: 6px 14px;
}

.sig-save-btn {
    font-size: 12px;
    padding: 6px 16px;
}

.sig-status {
    font-size: 12px;
    min-height: 20px;
}

.sig-saved {
    color: #16a34a;
    font-weight: 600;
}

.sig-error {
    color: #dc2626;
    font-weight: 600;
}

/* ===== CARTE TIMELINE AMÉLIORÉE ===== */
.tl-card-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    overflow: hidden;
}

.tl-card-header {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.tl-time {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.85;
    white-space: nowrap;
}

.tl-code {
    font-size: 10px;
    font-weight: 700;
    background: rgba(0,0,0,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.tl-done-badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}

.tl-client {
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.tl-label {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
}

.tl-addr {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.tl-phone {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Masquer les anciens styles de carte devenus inutiles */
.timeline-event-code,
.timeline-event-label,
.timeline-event-phone { display: none; }

/* Section incident */
.incident-section {
    border-left: 4px solid #dc2626 !important;
    background: #fff5f5 !important;
}
.incident-section h4 {
    color: #dc2626 !important;
}

.tl-incident {
    font-size: 10px;
    font-weight: 700;
    color: #dc2626;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bloc planning vue semaine/mois */
.block-header-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
    flex-wrap: wrap;
    overflow: hidden;
}
.block-time {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.85;
    white-space: nowrap;
}
.block-number {
    font-size: 10px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.block-label {
    font-size: 10px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.block-incident {
    font-size: 10px;
    font-weight: 700;
    color: #dc2626;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nom client inline dans l'en-tête */
.tl-state-emoji {
    font-size: 12px;
    flex-shrink: 0;
    margin-right: 2px;
}
.tl-client-inline {
    font-weight: 800;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Ligne 2 : incident / produit / libellé */
.tl-line2 {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
    margin-top: 1px;
}

/* Bloc semaine/mois - même style que timeline */
.block-horaire {
    font-size: 10px;
    color: var(--accent-blue);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.block-customer-inline {
    font-weight: 800;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}
.block-line2 {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
    margin-top: 1px;
}
.block-addr {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.block-phone {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spare-total-row td {
    border-top: 2px solid #dce1e9 !important;
    background: #f5f7fa;
    padding: 8px 6px !important;
}

/* ===== TABLEAU FACTURATION ===== */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 10px;
}
.invoice-table thead th {
    background: #eef1f5;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 10px;
    text-align: left;
    color: #4a5568;
    border-bottom: 2px solid #dce1e9;
}
.invoice-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: middle;
}
.invoice-table tbody tr:hover td {
    background: #f8f9fa;
}
.inv-label-col { width: 45%; }
.inv-num-col { width: 18%; }
.inv-input {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #dce1e9;
    border-radius: 4px;
    font-size: 13px;
    color: #1a2332;
    background: #fff;
    text-align: right;
}
.inv-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}
.inv-total {
    text-align: right;
    font-weight: 600;
    color: #1a2332;
    padding-right: 10px !important;
}
.inv-footer-row td {
    border-top: 2px solid #dce1e9 !important;
    background: #f5f7fa;
    padding: 8px 10px !important;
}
.inv-grand-total {
    font-size: 15px;
    font-weight: 800;
    color: #2563eb;
}
.inv-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}
.inv-save-btn {
    font-size: 12px;
    padding: 6px 16px;
}

.doc-row:hover td { background: #f0f4ff !important; }
.doc-type-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e0f2fe;
    color: #0369a1;
}

/* ===== HEADER COMPACT - FIT 100% ZOOM ===== */
.header {
    padding: 0 12px;
    gap: 8px;
}

.header-controls {
    gap: 6px;
}

.header-controls.header-right {
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    max-width: fit-content;
}

.header-controls.header-center {
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.logo-text {
    display: none; /* Masquer le texte logo pour gagner de la place */
}

.company-selector {
    min-width: 140px;
    max-width: 200px;
    font-size: 12px;
    padding: 6px 8px;
}

.view-controls {
    gap: 2px;
    display: flex;
}

.view-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    min-width: 0 !important;
}

.filter-collab-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    white-space: nowrap;
}

.nav-tab {
    padding: 6px 10px !important;
    font-size: 12px !important;
}

.btn-logout {
    padding: 4px 10px !important;
    font-size: 11px !important;
    white-space: nowrap;
}

.header-logo {
    width: 28px;
    height: 28px;
}

#hoursConfigGroup .filter-collab-btn {
    font-size: 11px !important;
    padding: 4px 7px !important;
}

.date-nav {
    gap: 4px !important;
}

.date-nav .btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
}

#currentDateLabel {
    font-size: 12px !important;
    min-width: 80px;
}

/* ===== SECTION EXPORT EBP ===== */
.ebp-export-section {
    border-left: 4px solid #2563eb !important;
    background: #f0f4ff !important;
}
.ebp-export-section h4 {
    color: #2563eb !important;
}
.ebp-export-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}
.ebp-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ebp-label {
    font-size: 12px;
    font-weight: 700;
    color: #4a5568;
}
.ebp-state-btn {
    padding: 8px 18px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: all 0.2s;
    width: fit-content;
}
.state-done {
    background: #dcfce7 !important;
    color: #16a34a !important;
    border: 2px solid #16a34a !important;
}
.state-todo {
    background: #fef3c7 !important;
    color: #d97706 !important;
    border: 2px dashed #d97706 !important;
}
.state-done:hover { background: #bbf7d0 !important; }
.state-todo:hover { background: #fde68a !important; }

.ebp-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dce1e9;
    border-radius: 6px;
    font-size: 13px;
    font-family: Arial, sans-serif;
    color: #1a2332;
    background: #fff;
    resize: vertical;
    min-height: 80px;
}
.ebp-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}
.ebp-export-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.ebp-export-btn {
    font-size: 13px !important;
    padding: 8px 20px !important;
    font-weight: 700 !important;
}

/* ===== RESPONSIVE MOBILE TÉLÉPHONE ===== */
@media (max-width: 480px) {

    /* Header - une seule ligne compacte */
    .header {
        padding: 0 8px;
        height: auto;
        min-height: 48px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .header-left {
        flex-shrink: 0;
    }

    .header-controls.header-center {
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px 0;
        gap: 4px;
        flex-wrap: nowrap;
    }

    .header-controls.header-right {
        flex-wrap: wrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 3px;
        max-width: calc(100vw - 60px);
    }

    /* Sélecteur société pleine largeur */
    .company-selector {
        min-width: 0;
        width: 120px;
        font-size: 11px;
    }

    /* Boutons de vue plus petits */
    .view-btn {
        padding: 3px 6px !important;
        font-size: 10px !important;
    }

    /* Masquer 15j et Mois sur mobile */
    .view-btn[data-view="fortnight"],
    .view-btn[data-view="month"] {
        display: none;
    }

    /* Navigation date compacte */
    .date-nav .btn {
        padding: 3px 6px !important;
        font-size: 11px !important;
    }
    #currentDateLabel {
        font-size: 11px !important;
        min-width: 60px !important;
    }

    /* Onglets de navigation */
    .nav-tabs {
        gap: 2px;
    }
    .nav-tab {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    /* Timeline - colonnes plus larges sur téléphone */
    .timeline-wrapper {
        height: calc(100vh - 160px);
    }

    .timeline-col {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .timeline-col-header {
        min-width: 0 !important;
    }

    /* Gutter heures plus étroit */
    .timeline-gutter {
        width: 44px !important;
        min-width: 44px !important;
    }

    .timeline-gutter-label {
        font-size: 9px !important;
        width: 44px !important;
    }

    /* Cartes événements plus lisibles */
    .timeline-event {
        font-size: 11px;
    }

    .tl-time {
        font-size: 10px !important;
    }

    .tl-client-inline {
        font-size: 12px !important;
    }

    .tl-line2, .tl-addr, .tl-phone {
        font-size: 10px !important;
    }

    /* Modale plein écran */
    .modal-content {
        width: 98% !important;
        max-width: 100% !important;
        max-height: 95vh;
        margin: 8px auto;
    }

    .modal-large {
        width: 99% !important;
    }

    .event-detail-grid {
        grid-template-columns: 1fr !important;
    }

    /* Boutons logout et filtre */
    .btn-logout span {
        display: none;
    }
    .btn-logout::after {
        content: '⏻';
    }

    /* Heures config */
    #hoursConfigGroup .filter-collab-btn {
        font-size: 10px !important;
        padding: 3px 6px !important;
    }
}

.inv-remise-row td {
    background: #fffbf0 !important;
    border-top: 1px dashed #d97706 !important;
}

/* Remise inline par ligne */
.inv-remise-inline {
    display: flex;
    align-items: center;
    gap: 3px;
}
.inv-remise-input {
    width: 55px !important;
    min-width: 55px !important;
}
.inv-remise-type {
    width: 42px !important;
    min-width: 42px !important;
    padding: 0 2px !important;
}

/* TVA - colonne plus large et input visible */
.inv-tva-col { min-width: 70px; }
.inv-tva-input {
    width: 60px !important;
    min-width: 60px !important;
    text-align: center !important;
    font-weight: 600 !important;
}

/* Colonnes numériques plus larges */
.inv-num-col { min-width: 80px; }

.inv-del-btn {
    background: none !important;
    border: none !important;
    color: #dc2626;
    font-size: 13px;
    padding: 2px 6px !important;
    cursor: pointer;
    opacity: 0.6;
}
.inv-del-btn:hover { opacity: 1; }

/* Select état EBP */
.ebp-state-select {
    height: 38px;
    padding: 0 12px;
    border: 2px solid #dce1e9;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1a2332;
    background: #fff;
    cursor: pointer;
    min-width: 200px;
}
.ebp-state-select:focus {
    outline: none;
    border-color: #2563eb;
}

/* Badges état dynamiques */
.event-state-badge.state-0 { background:#fef3c7;color:#d97706; }
.event-state-badge.state-1 { background:#dbeafe;color:#2563eb; }
.event-state-badge.state-2 { background:#dcfce7;color:#16a34a; }
.event-state-badge.state-3 { background:#fee2e2;color:#dc2626; }
.event-state-badge.state-4 { background:#e0f2fe;color:#0369a1; }
.event-state-badge.state-5 { background:#f3e8ff;color:#7c3aed; }
.event-state-badge.state-6 { background:#d1fae5;color:#065f46; }
.event-state-badge.state-7 { background:#fef9c3;color:#854d0e; }
.event-state-badge.state-8 { background:#fce7f3;color:#9d174d; }

/* Vue 15 jours : largeur minimale des colonnes */
.view-fortnight .day-header,
.view-fortnight .day-cell {
    min-width: 90px;
}

/* Vue 15 jours et mois : colonnes fixes pour éviter le débordement */
.view-fortnight .day-header,
.view-fortnight .day-cell,
.view-month .day-header,
.view-month .day-cell {
    flex: 0 0 var(--day-cell-min-width);
    min-width: var(--day-cell-min-width);
    max-width: var(--day-cell-min-width);
    width: var(--day-cell-min-width);
    overflow: hidden;
}

/* ===== VUES 15J ET MOIS : colonnes à largeur fixe (tablette/mobile seulement) ===== */
@media (max-width: 1024px) {
    .view-fortnight .day-header,
    .view-fortnight .day-cell,
    .view-month .day-header,
    .view-month .day-cell {
        flex: 0 0 var(--day-cell-min-width) !important;
        min-width: var(--day-cell-min-width) !important;
        max-width: var(--day-cell-min-width) !important;
        width: var(--day-cell-min-width) !important;
        box-sizing: border-box;
        overflow: hidden;
    }
}

/* ============================================
   TABLETTE/MOBILE - écran CSS < 768px
   (Samsung Tab Active 3: 300px CSS en portrait)
   ============================================ */
@media (max-width: 768px) {

    /* Burger visible sur tablette */
    .menu-toggle {
        display: flex !important;
    }

    /* Header : masquer les éléments qui débordent */
    .view-controls,
    .hours-config-group,
    #exportPdfBtn,
    .online-status,
    .user-name,
    .user-role {
        display: none !important;
    }
    .collab-filter-group {
        display: flex !important;
    }

    /* Garder uniquement : logo, burger, date-nav, logout */
    .header {
        flex-wrap: nowrap !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        justify-content: space-between !important;
    }

    .header-left {
        flex-shrink: 0;
        gap: 6px;
    }

    .header-controls.header-center {
        display: none !important;
    }

    .header-controls.header-right {
        display: flex !important;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }

    .date-nav {
        display: flex !important;
        align-items: center;
        gap: 4px;
    }

    .date-nav button {
        font-size: 20px !important;
        padding: 6px 12px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        touch-action: manipulation !important;
    }

    #currentDate {
        font-size: 12px !important;
        min-width: 80px !important;
        text-align: center;
    }

    .btn-logout {
        display: flex !important;
        min-width: 40px !important;
        min-height: 40px !important;
        touch-action: manipulation !important;
    }

    /* Planning : scroll horizontal forcé */
    .planning-container {
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .planning-scroll-wrapper {
        flex: 1 !important;
        overflow-x: scroll !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .planning-header {
        display: flex !important;
        flex-shrink: 0 !important;
        min-width: max-content !important;
    }

    .planning-body {
        overflow-y: auto !important;
        overflow-x: visible !important;
        min-width: max-content !important;
    }

    .planning-row {
        min-width: max-content !important;
    }

    .day-cells {
        min-width: max-content !important;
    }

    /* Vue 15j et Mois : colonnes plus petites */
    .view-fortnight .day-header,
    .view-fortnight .day-cell,
    .view-month .day-header,
    .view-month .day-cell {
        min-width: 100px !important;
        max-width: 100px !important;
        width: 100px !important;
        flex: 0 0 100px !important;
    }

    /* Label équipe */
    .team-label,
    .planning-header-spacer {
        min-width: 80px !important;
        max-width: 80px !important;
        width: 80px !important;
        flex-shrink: 0 !important;
    }
}

/* ============================================
   CORRECTIONS TABLETTE/MOBILE - PRIORITÉS
   ============================================ */

/* 1. Taille des événements sur vues multi-jours */
@media (max-width: 768px) {
    .planning-block {
        padding: 6px 8px !important;
        font-size: 11px !important;
        min-height: 0 !important;
    }
    .block-customer-inline {
        font-size: 12px !important;
        font-weight: 700 !important;
    }
    .block-line2 {
        font-size: 11px !important;
    }
    .block-addr, .block-phone {
        font-size: 10px !important;
    }
    
}

/* 2. Modale intervention : plein écran tablette */
@media (max-width: 768px) {
    .modal-large {
        width: 99% !important;
        max-width: 99vw !important;
        max-height: 95vh !important;
        margin: 4px auto !important;
    }
    .event-detail-grid {
        grid-template-columns: 1fr !important;
    }
    .event-detail-table {
        font-size: 12px !important;
    }
    .invoice-table {
        font-size: 11px !important;
    }
    .invoice-table th, .invoice-table td {
        padding: 4px 3px !important;
    }
    .inv-input {
        width: 50px !important;
        min-width: 50px !important;
        font-size: 11px !important;
    }
    .inv-tva-input {
        width: 45px !important;
    }
}

/* 3. Interface admin sur tablette */
@media (max-width: 768px) {
    /* Formulaire utilisateur */
    .user-form {
        padding: 12px !important;
    }
    .form-row {
        flex-direction: column !important;
    }
    .form-group input,
    .form-group select {
        font-size: 14px !important;
        padding: 8px !important;
        min-height: 40px !important;
    }
    .form-actions .btn {
        min-height: 44px !important;
        font-size: 14px !important;
        padding: 10px 16px !important;
    }
    /* Liste utilisateurs */
    .users-table {
        font-size: 12px !important;
    }
    .users-table td, .users-table th {
        padding: 6px 4px !important;
    }
}

/* 4. Vue 1 jour sur tablette - colonnes alignées */
@media (max-width: 768px) {
    .timeline-col {
        min-width: 160px !important;
        flex: 1 !important;
    }
    .timeline-gutter {
        width: 44px !important;
        min-width: 44px !important;
    }
    .timeline-col-header {
        min-width: 0 !important;
    }
}

/* ===== VUES MULTI-JOURS MOBILE : événements plus lisibles ===== */
@media (max-width: 768px) {
    .planning-block {
        padding: 5px 6px !important;
        font-size: 12px !important;
        min-height: 50px !important;
        line-height: 1.4 !important;
    }
    .block-customer-inline {
        font-size: 12px !important;
        font-weight: 800 !important;
        white-space: normal !important;
        overflow: visible !important;
        line-height: 1.3 !important;
    }
    .block-line2 {
        font-size: 11px !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    .block-addr {
        font-size: 10px !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    .block-phone {
        font-size: 10px !important;
    }
    .block-time-inline {
        font-size: 11px !important;
        font-weight: 700 !important;
    }

}

/* ===== CORRECTIONS MOBILES v2.27 ===== */
@media (max-width: 768px) {

    
    .view-day1 .timeline-col {
        min-width: 0 !important;
        max-width: 100% !important;
        width: calc(100% - 44px) !important;
        flex: 1 !important;
    }
    .view-day1 .timeline-col-header {
        min-width: 0 !important;
        flex: 1 !important;
    }



    /* Nom client non coupé */
    .block-customer-inline {
        font-size: 13px !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        line-height: 1.4 !important;
        display: block !important;
    }

    /* Modale : zoom initial réduit pour voir sans scroller */
    .modal-large {
        width: 100% !important;
        max-width: 100vw !important;
        max-height: 98vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        font-size: 12px !important;
    }
    .modal-large .event-detail-body {
        padding: 8px !important;
    }
    .modal-large .event-detail-section {
        padding: 8px !important;
        font-size: 12px !important;
    }
    .modal-large .event-detail-table td {
        font-size: 11px !important;
        padding: 4px 6px !important;
    }
    .modal-large h4 {
        font-size: 13px !important;
    }
    /* Facturation compacte */
    .invoice-table {
        font-size: 10px !important;
    }
    .invoice-table th, .invoice-table td {
        padding: 3px 2px !important;
    }
    .inv-input {
        width: 40px !important;
        font-size: 10px !important;
        padding: 2px !important;
    }
    .inv-tva-input {
        width: 35px !important;
    }
    /* Section export EBP compacte */
    .ebp-export-section {
        padding: 8px !important;
    }
    .ebp-textarea {
        font-size: 12px !important;
        min-height: 60px !important;
    }
    /* Signature compacte */
    .sig-canvas {
        height: 100px !important;
    }
}



/* En-tête de jour cliquable */
.day-header-clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.day-header-clickable:hover {
    background: rgba(37, 99, 235, 0.08) !important;
}
.day-header-clickable:hover .day-date {
    color: var(--accent-blue);
}


/* ================================================================
   MOBILE/TABLETTE - UN SEUL BLOC PROPRE
   Samsung Tab Active 3 portrait = 300px CSS
   Samsung Tab Active 3 paysage = 480px CSS
   ================================================================ */
@media (max-width: 768px) {

    /* HEADER */
    .menu-toggle { display: flex !important; }
    .view-controls, .hours-config-group,
    #exportPdfBtn, .online-status, .user-name, .user-role { display: none !important; }
    .collab-filter-group { display: flex !important; }
    #myColorBtn { display: flex !important; padding: 6px 8px !important; min-height: 40px !important; }
    .header { flex-wrap: nowrap !important; padding: 6px 8px !important; gap: 8px !important; justify-content: space-between !important; }
    .header-controls.header-center { display: none !important; }
    .header-controls.header-right { display: flex !important; align-items: center; gap: 4px; flex-wrap: wrap; }
    .date-nav { display: flex !important; align-items: center; gap: 4px; justify-content: center !important; }
    .date-nav button { font-size: 20px !important; padding: 6px 12px !important; min-width: 40px !important; min-height: 40px !important; touch-action: manipulation !important; }
    #currentDate { font-size: 12px !important; text-align: center; }
    .btn-logout { display: flex !important; min-width: 40px !important; min-height: 40px !important; }

    /* PLANNING SCROLL */
    .planning-container { overflow: hidden !important; display: flex !important; flex-direction: column !important; }
    .planning-scroll-wrapper { flex: 1 !important; overflow-x: scroll !important; overflow-y: hidden !important; -webkit-overflow-scrolling: touch !important; }
    .planning-header { display: flex !important; flex-shrink: 0 !important; min-width: max-content !important; }
    .planning-body { overflow-y: auto !important; overflow-x: visible !important; min-width: max-content !important; }
    .planning-row { min-width: max-content !important; }
    .planning-days, .day-cells { display: flex !important; min-width: max-content !important; }

    /* VUE 1 JOUR */
    .view-day1 .planning-header { display: none !important; }
    
    .view-day1 .timeline-col { flex: 1 !important; min-width: 0 !important; max-width: none !important; }
    .view-day1 .timeline-col-header { flex: 1 !important; min-width: 0 !important; }

    /* COLONNES PORTRAIT (300px CSS) */
    .planning-header-spacer { min-width: 80px !important; max-width: 80px !important; width: 80px !important; flex: 0 0 80px !important; box-sizing: border-box !important; }
    .team-label { min-width: 80px !important; max-width: 80px !important; width: 80px !important; flex: 0 0 80px !important; box-sizing: border-box !important; }
    .day-header { min-width: 210px !important; max-width: 210px !important; width: 210px !important; flex: 0 0 210px !important; box-sizing: border-box !important; overflow: hidden !important; }
    .day-cell { min-width: 210px !important; max-width: 210px !important; width: 210px !important; flex: 0 0 210px !important; box-sizing: border-box !important; overflow: hidden !important; }
    .view-fortnight .day-header, .view-fortnight .day-cell,
    .view-month .day-header, .view-month .day-cell { min-width: 130px !important; max-width: 130px !important; width: 130px !important; flex: 0 0 130px !important; }

    /* ÉVÉNEMENTS */
    .planning-block { padding: 5px 6px !important; font-size: 11px !important; }
    .block-customer-inline { font-size: 12px !important; font-weight: 800 !important; white-space: normal !important; overflow: visible !important; text-overflow: unset !important; display: block !important; }
    .block-line2 { font-size: 11px !important; white-space: normal !important; overflow: visible !important; }
    .block-addr, .block-phone { font-size: 10px !important; }

    /* MODALE */
    .modal { padding: 0 !important; align-items: flex-start !important; }
    .modal-large { font-size: 11px !important; margin: 0 !important; border-radius: 0 !important; width: 100% !important; max-width: 100vw !important; max-height: 100vh !important; height: 100vh !important; overflow-y: auto !important; overflow-x: hidden !important; }
    .modal-header { padding: 10px 12px !important; }
    .modal-header h3 { font-size: 14px !important; }
    .event-detail-body { padding: 6px !important; }
    .event-detail-grid { grid-template-columns: 1fr !important; gap: 6px !important; }
    .event-detail-section { padding: 6px !important; margin-bottom: 6px !important; }
    .event-detail-full { overflow-x: auto !important; }
    .invoice-table { min-width: 600px !important; font-size: 12px !important; }
    .invoice-table th, .invoice-table td { padding: 4px 4px !important; }
    .inv-input { width: 70px !important; font-size: 12px !important; padding: 4px !important; min-height: 32px !important; }
    .inv-input[type="text"] { width: 120px !important; }
    .ebp-export-actions { flex-wrap: wrap !important; gap: 6px !important; }
    .ebp-export-btn { width: 100% !important; }
    /* Barre actions facturation tablette */
    [style*="display:flex"][style*="background:var(--bg-secondary)"] button.btn-sm {
        min-height: 40px !important; font-size: 12px !important; padding: 8px 10px !important;
    }
    .ebp-textarea { min-height: 50px !important; font-size: 12px !important; }
    .sig-canvas { height: 80px !important; }

    /* ADMIN */
    .form-row { flex-direction: column !important; }
    .form-group input, .form-group select { font-size: 14px !important; padding: 8px !important; min-height: 40px !important; }
    .form-actions .btn { min-height: 44px !important; font-size: 14px !important; }
    .users-table { font-size: 12px !important; }
    .users-table td, .users-table th { padding: 6px 4px !important; }
}

/* PAYSAGE (480px CSS) - APRÈS portrait pour l'écraser */
@media (max-width: 768px) and (orientation: landscape) {
    .planning-header-spacer { min-width: 60px !important; max-width: 60px !important; width: 60px !important; flex: 0 0 60px !important; }
    .team-label { min-width: 60px !important; max-width: 60px !important; width: 60px !important; flex: 0 0 60px !important; }
    .day-header { min-width: 150px !important; max-width: 150px !important; width: 150px !important; flex: 0 0 150px !important; }
    .day-cell { min-width: 150px !important; max-width: 150px !important; width: 150px !important; flex: 0 0 150px !important; }
    .view-fortnight .day-header, .view-fortnight .day-cell,
    .view-month .day-header, .view-month .day-cell { min-width: 90px !important; max-width: 90px !important; width: 90px !important; flex: 0 0 90px !important; }
}

/* En-tête de jour cliquable */
.day-header-clickable { cursor: pointer; transition: background 0.15s; }
.day-header-clickable:hover { background: rgba(37, 99, 235, 0.08) !important; }
.day-header-clickable:hover .day-date { color: var(--accent-blue); }

/* ===== ONGLETS MODALE DÉTAIL ===== */
.detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
    flex-shrink: 0;
}
.detail-tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    white-space: nowrap;
}
.detail-tab-btn:hover {
    color: var(--accent-blue);
    background: rgba(37,99,235,0.05);
}
.detail-tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: transparent;
}
.detail-tab-content {
    overflow-y: auto;
    padding-bottom: 80px;
}
@media (max-width: 768px) {
    .detail-tab-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        flex: 1;
        text-align: center;
    }
}

/* Paysage : forcer alignement planning-days et day-cells */
@media (max-width: 768px) and (orientation: landscape) {
    .planning-days,
    .day-cells {
        display: flex !important;
        min-width: max-content !important;
    }
    .view-week5 .day-header, .view-week5 .day-cell,
    .view-week7 .day-header, .view-week7 .day-cell {
        min-width: 150px !important;
        max-width: 150px !important;
        width: 150px !important;
        flex: 0 0 150px !important;
    }
}

/* Tablette paysage (769-1024px) : alignement 5j/7j/15j/mois */
@media (min-width: 769px) and (max-width: 1366px) {
    .planning-days,
    .day-cells {
        display: flex !important;
        min-width: max-content !important;
    }
    .planning-scroll-wrapper {
        overflow-x: auto !important;
    }
    .view-week5 .day-header, .view-week5 .day-cell { flex: 0 0 var(--day-cell-min-width) !important; }
    .view-week7 .day-header, .view-week7 .day-cell { flex: 0 0 var(--day-cell-min-width) !important; }
    .view-fortnight .day-header, .view-fortnight .day-cell { flex: 0 0 80px !important; }
    .view-month .day-header, .view-month .day-cell { flex: 0 0 60px !important; }
    .planning-header-spacer, .team-label { flex-shrink: 0 !important; }
}


/* =====================================================
   HEADER TABLETTE ≤1024px — Ultra compact
   ===================================================== */
@media (max-width: 1024px) {
    /* Éléments déplacés dans le drawer ou inutiles sur tablette */
    #clientSearchWrapper { display: none !important; }
    #exportPdfBtn { display: none !important; }
    .hours-config-group { display: none !important; }
    #notifBell { display: none !important; }
    .user-name { display: none !important; }
    .user-role { display: none !important; }
    #todayBtn { display: none !important; }
    /* Onglets admin masqués sur tablette - gérés depuis PC */
    #collaboratorsTab { display: none !important; }
    #usersTab { display: none !important; }
    #companiesTab { display: none !important; }
    #teamsTab { display: none !important; }

    .header {
        padding: 4px 6px !important;
        gap: 4px !important;
        height: auto !important;
        min-height: 0 !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    .header-left { flex-shrink: 0; }
    .logo-text { display: none !important; }
    .header-logo { width: 26px !important; height: 26px !important; }

    .header-controls.header-center {
        flex: 1 !important;
        min-width: 0 !important;
        gap: 4px !important;
    }
    .company-selector {
        min-width: 0 !important;
        max-width: 130px !important;
        font-size: 11px !important;
        padding: 3px 4px !important;
    }
    .nav-tab {
        padding: 5px 8px !important;
        font-size: 12px !important;
    }

    .header-controls.header-right {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 3px !important;
        flex-shrink: 0 !important;
    }
    .view-controls { gap: 2px !important; }
    .view-btn { font-size: 11px !important; padding: 4px 5px !important; }
    .filter-collab-btn { font-size: 11px !important; padding: 4px 5px !important; }
    .collab-filter-group { display: flex !important; }
    .date-nav { gap: 2px !important; }
    .current-date { font-size: 11px !important; min-width: 70px !important; text-align:center; }
    #prevPeriod, #nextPeriod { padding: 4px 6px !important; font-size: 14px !important; }
    #refreshBtn { font-size: 13px !important; padding: 4px 5px !important; }
    #syncBtn { font-size: 13px !important; padding: 4px 5px !important; }
    .btn-logout { padding: 4px 8px !important; }
}
