:root {
  /* ── Couleurs fixes (inchangées entre modes) ── */
  --orange: #F26419;
  --orange-dark: #C74E10;
  --orange-light: #FF8C42;
  --blue: #1B3A5C;
  --blue-mid: #234E78;
  --blue-light: #2E6CA6;
  --blue-pale: #4A90C4;
  --steel: #8499A8;
  --green: #2ECC71;
  --red: #E74C3C;
  --yellow: #F39C12;

  /* ── Palettes sémantiques — Mode sombre (défaut) ── */
  --bg:           #111519;
  --card:         #161B22;
  --card2:        #1C2330;
  --gray-dark:    #1A1E24;
  --gray-mid:     #2A2F38;
  --gray:         #3D4552;
  --gray-light:   #5B6475;
  --border:       #2F3847;
  --text:         #D4DCE8;
  --text-muted:   #7A8A99;
  --text-dim:     #4A5568;
  --white:        #F0F4F8;

  /* ── Variables sémantiques d'interface ── */
  --surface-1:    var(--bg);           /* fond de page */
  --surface-2:    var(--card);         /* cartes, panneaux */
  --surface-3:    var(--card2);        /* header Gantt, topbar secondaire */
  --surface-input: var(--gray-mid);   /* inputs, selects */
  --text-primary:  var(--text);       /* texte principal */
  --text-secondary: var(--text-muted);/* sous-titres, labels */
  --text-disabled: var(--text-dim);   /* texte inactif */
  --text-strong:   var(--white);      /* valeurs KPI, titres forts */
  --border-subtle: var(--border);     /* bordures légères */
  --border-strong: #3D4552;           /* bordures tables en dark */
  --row-hover:  rgba(255,255,255,0.03); /* survol rangées tables */
  --overlay-bg: rgba(0,0,0,0.7);       /* fond modales */
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  --gantt-col-line: rgba(47,56,71,0.35);
  --gantt-row-line: rgba(47,56,71,0.5);
  --scrollbar-track: #1A1E24;
  --scrollbar-thumb: #3D4552;
  --theme-icon: '☀️';  /* icône pour passer en clair */
}

/* ════════════════════════════════════════════════
   MODE CLAIR — variables sémantiques redéfinies
   Contraste WCAG AA garanti (ratio ≥ 4.5:1)
   ════════════════════════════════════════════════ */
.light-mode {
  --bg:           #F0F4F8;
  --card:         #FFFFFF;
  --card2:        #E8EDF3;
  --gray-dark:    #E2E8F0;
  --gray-mid:     #EDF2F7;
  --gray:         #CBD5E0;
  --gray-light:   #A0AEC0;
  --border:       #CBD5E0;
  --text:         #1A202C;
  --text-muted:   #4A5568;
  --text-dim:     #718096;
  --white:        #1A202C;    /* "white" devient noir en mode clair pour les textes KPI */
  --steel:        #4A6375;

  /* Variables sémantiques — mode clair */
  --surface-1:    #F0F4F8;
  --surface-2:    #FFFFFF;
  --surface-3:    #E8EDF3;
  --surface-input: #F7FAFC;
  --text-primary:  #1A202C;
  --text-secondary: #4A5568;
  --text-disabled: #A0AEC0;
  --text-strong:   #1A202C;
  --border-subtle: #CBD5E0;
  --border-strong: #A0AEC0;
  --row-hover:  rgba(0,0,0,0.04);
  --overlay-bg: rgba(30,30,50,0.65);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.10);
  --gantt-col-line: rgba(160,174,192,0.5);
  --gantt-row-line: rgba(160,174,192,0.6);
  --scrollbar-track: #E2E8F0;
  --scrollbar-thumb: #A0AEC0;
  --theme-icon: '🌙';  /* icône pour repasser en sombre */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  visibility: hidden; /* Anti-flash i18n : levé par i18nApply() */
}

/* NOISE TEXTURE OVERLAY */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* SIDEBAR */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 72px;
  background: var(--gray-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  z-index: 100;
  transition: width 0.3s cubic-bezier(.4,0,.2,1);
}

.sidebar:hover {
  width: 220px;
}

.logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: white;
  letter-spacing: -1px;
  margin-bottom: 32px;
  flex-shrink: 0;
  position: relative;
}

.logo-text {
  position: absolute;
  left: 56px;
  white-space: nowrap;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--white);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.sidebar:hover .logo-text { opacity: 1; }

.nav-group {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-item {
  height: 46px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
  color: var(--steel);
}

.nav-item:hover, .nav-item.active {
  background: rgba(242,100,25,0.12);
  color: var(--orange);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--orange);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: color 0.2s;
}

.nav-icon svg {
  display: block;
  transition: stroke 0.2s;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar:hover .nav-label { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar:hover .nav-badge { opacity: 1; }

.user-section {
  padding: 10px;
  width: 100%;
}

.user-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

.user-info {
  opacity: 0;
  transition: opacity 0.2s;
  min-width: 0;
}
.sidebar:hover .user-info { opacity: 1; }

/* ===== MOBILE SIDEBAR DRAWER ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  .sidebar {
    display: flex !important;
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: 240px !important;
    transform: translateX(-100%) !important;
    z-index: 200;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1) !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .sidebar.open .nav-label { opacity: 1 !important; }
  .sidebar.open .nav-badge { opacity: 1 !important; }
  .sidebar.open .logo-text { opacity: 1 !important; }
  .sidebar.open .user-info { opacity: 1 !important; }
}

.user-name { font-size: 13px; font-weight: 600; color: var(--white); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* MAIN CONTENT */
.main {
  margin-left: 72px;
  min-height: 100vh;
  transition: margin-left 0.3s;
}

/* TOP BAR */
.topbar {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--white);
  letter-spacing: 0.5px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

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

.btn {
  height: 38px;
  padding: 0 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

.btn-primary {
  background: var(--orange);
  color: white;
}
.btn-primary:hover { background: var(--orange-dark); box-shadow: 0 2px 8px rgba(242,100,25,0.35); }
.btn-primary:active { background: var(--orange-dark); box-shadow: none; transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--gray-mid); color: var(--text); }
.btn-ghost:active { background: var(--gray); }

.notif-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
}

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--orange);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* PAGE CONTENT */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.kpi-card:hover { border-color: var(--blue-light); }

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.kpi-card.green::after { background: var(--green); }
.kpi-card.orange::after { background: var(--orange); }
.kpi-card.blue::after { background: var(--blue-light); }
.kpi-card.red::after { background: var(--red); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
  margin-bottom: 6px;
}

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

.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}

.badge-up { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-down { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-warn { background: rgba(243,156,18,0.15); color: var(--yellow); }

.kpi-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* ── KantiirBrain — KPI Santé & Dérive ── */
.kpi-card.brain::after { background: linear-gradient(90deg, #F26419, #C74E10); }
.kpi-card.brain-time::after { background: linear-gradient(90deg, #1B3A5C, #2E6CA6); }

.brain-gauge {
  position: relative;
  height: 6px;
  background: var(--gray-mid);
  border-radius: 3px;
  margin: 10px 0 6px;
  overflow: visible;
}
.brain-gauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}
.brain-gauge-cursor {
  position: absolute;
  top: -5px;
  width: 2px;
  height: 16px;
  background: var(--orange);
  border-radius: 1px;
  transform: translateX(-50%);
}
.brain-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.brain-trend {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.brain-derive-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.brain-derive-track {
  flex: 1;
  height: 6px;
  background: var(--gray-mid);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.brain-derive-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}
/* Light mode overrides */
.light-mode .brain-gauge { background: var(--gray); }
.light-mode .brain-derive-track { background: var(--gray); }

/* GRID LAYOUTS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
  flex: 1;
}

.card-body { padding: 20px; }

/* CHANTIER CARDS */
.chantier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.chantier-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s;
}

.chantier-card:hover {
  border-color: var(--blue-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.chantier-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chantier-code {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.chantier-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--white);
  margin: 2px 0 4px;
  line-height: 1.2;
}

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

.status-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-encours { background: rgba(46,110,166,0.2); color: var(--blue-pale); border: 1px solid rgba(46,110,166,0.3); }
.status-alerte { background: rgba(231,76,60,0.15); color: #E74C3C; border: 1px solid rgba(231,76,60,0.3); }
.status-termine { background: rgba(46,204,113,0.15); color: var(--green); border: 1px solid rgba(46,204,113,0.3); }
.status-planifie { background: rgba(243,156,18,0.15); color: var(--yellow); border: 1px solid rgba(243,156,18,0.3); }

.chantier-body { padding: 16px 18px; }

.chantier-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.meta-item { }
.meta-key { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.meta-val { font-size: 12px; font-weight: 500; color: var(--text); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.progress-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--gray);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

.fill-green { background: linear-gradient(90deg, #2ECC71, #27AE60); }
.fill-orange { background: linear-gradient(90deg, var(--orange), var(--orange-dark)); }
.fill-red { background: linear-gradient(90deg, #E74C3C, #C0392B); }
.fill-blue { background: linear-gradient(90deg, var(--blue-light), var(--blue)); }

.progress-pct { font-size: 11px; font-weight: 700; color: var(--white); min-width: 32px; text-align: right; }

.chantier-footer {
  padding: 10px 18px;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-avatars { display: flex; }
.team-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--card);
  margin-left: -6px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.team-avatar:first-child { margin-left: 0; }
.av1 { background: #3498DB; }
.av2 { background: #E74C3C; }
.av3 { background: #2ECC71; }
.av4 { background: #9B59B6; }
.av5 { background: var(--orange); }

.footer-info { font-size: 11px; color: var(--text-muted); margin-left: 6px; }

/* GANTT CHART */
.gantt-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
}

.gantt-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--card2);
  position: sticky;
  top: 0;
}

.gantt-task-col {
  width: 220px;
  flex-shrink: 0;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-right: 1px solid var(--border);
}

.gantt-timeline-header {
  flex: 1;
  display: flex;
  min-width: 900px;
}

.gantt-month {
  flex: 1;
  padding: 6px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-right: 1px solid var(--border);
}

.gantt-row {
  display: flex;
  border-bottom: 1px solid var(--gantt-row-line);
  min-height: 44px;
  transition: background 0.15s;
}

.gantt-row:hover { background: var(--row-hover); }

.gantt-task-info {
  width: 220px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.gantt-task-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.gantt-task-team {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.gantt-timeline-row {
  flex: 1;
  position: relative;
  min-width: 900px;
  display: flex;
  align-items: center;
}

.gantt-col-bg {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid var(--gantt-col-line);
}

.gantt-bar {
  position: absolute;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.bar-blue { background: linear-gradient(90deg, var(--blue-light), var(--blue-mid)); }
.bar-orange { background: linear-gradient(90deg, var(--orange), var(--orange-dark)); }
.bar-green { background: linear-gradient(90deg, #27AE60, #229954); }
.bar-purple { background: linear-gradient(90deg, #8E44AD, #7D3C98); }
.bar-red { background: linear-gradient(90deg, #E74C3C, #C0392B); }
.bar-steel { background: linear-gradient(90deg, var(--steel), #6B7A8A); }

.today-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--orange);
  z-index: 10;
  opacity: 0.7;
}

.today-line::before {
  content: t('g_today_label');
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
}

/* BUDGET TABLE */
.budget-table {
  width: 100%;
  border-collapse: collapse;
}

.budget-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--card2);
}

.budget-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid rgba(47,56,71,0.4);
}

.budget-table tr:hover td { background: var(--row-hover); }

.amount { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 600; }
.amount-prevu { color: var(--blue-pale); }
.amount-reel { color: var(--white); }
.amount-ecart-pos { color: var(--green); }
.amount-ecart-neg { color: var(--red); }

.category-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-right: 8px;
}

/* TEAM TABLE */
.team-table {
  width: 100%;
  border-collapse: collapse;
}

.team-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--card2);
}

.team-table td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(47,56,71,0.4);
}

.team-table tr:hover td { background: var(--row-hover); }

.member-cell { display: flex; align-items: center; gap: 10px; }
.member-info-name { font-size: 13px; font-weight: 500; color: var(--white); }
.member-info-role { font-size: 11px; color: var(--text-muted); }

.presence-dots { display: flex; gap: 4px; }
.presence-dot {
  width: 18px; height: 18px;
  border-radius: 4px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.present { background: rgba(46,204,113,0.2); color: var(--green); }
.absent { background: rgba(231,76,60,0.15); color: var(--red); }
.conge { background: rgba(243,156,18,0.15); color: var(--yellow); }

/* DOCUMENT GRID */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.doc-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card:hover {
  border-color: var(--blue-light);
  transform: translateY(-2px);
}

.doc-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.doc-icon-pdf { background: rgba(231,76,60,0.15); }
.doc-icon-img { background: rgba(46,110,166,0.15); }
.doc-icon-xls { background: rgba(46,204,113,0.15); }
.doc-icon-dwg { background: rgba(242,100,25,0.15); }

.doc-name { font-size: 12px; font-weight: 600; color: var(--white); line-height: 1.3; }
.doc-meta { font-size: 10px; color: var(--text-muted); }
.doc-size { font-size: 10px; color: var(--text-dim); }

/* PERFORMANCE CHARTS */
.perf-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.perf-label { font-size: 12px; color: var(--text); min-width: 140px; }
.perf-bar-wrap { flex: 1; height: 8px; background: var(--gray); border-radius: 4px; overflow: hidden; }
.perf-bar-fill { height: 100%; border-radius: 4px; }
.perf-val { font-size: 12px; font-weight: 600; color: var(--white); min-width: 40px; text-align: right; }

/* ALERTS */
.alert-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid;
}

.alert-red { background: rgba(231,76,60,0.08); border-color: var(--red); }
.alert-yellow { background: rgba(243,156,18,0.08); border-color: var(--yellow); }
.alert-blue { background: rgba(46,110,166,0.08); border-color: var(--blue-light); }

.alert-icon { font-size: 16px; margin-top: 1px; }
.alert-content { flex: 1; }
.alert-title { font-size: 12px; font-weight: 600; color: var(--white); }
.alert-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.alert-time { font-size: 10px; color: var(--text-dim); margin-top: 4px; }

/* SPARKLINE */
.mini-chart {
  height: 40px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.mini-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: opacity 0.2s;
}

.mini-bar:hover { opacity: 0.7; }

/* SECTION TITLE */
.section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* FORM ELEMENTS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

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

.form-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }

.form-input, .form-select {
  height: 38px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 0 12px;
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus, .form-select:focus { border-color: var(--blue-light); }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 20, 0.72);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 16px;
  box-sizing: border-box;
}

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

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
}

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

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

.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
  flex: 1;
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

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

/* ARCH DOC */
.arch-section {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.arch-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.arch-text { font-size: 13px; color: var(--text); line-height: 1.7; }
.arch-text strong { color: var(--white); }

.code-block {
  background: #0A0D12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #A8D8A8;
  overflow-x: auto;
  line-height: 1.6;
  margin-top: 12px;
}

.code-comment { color: #5B7A5B; }
.code-key { color: #7EC8E3; }
.code-val { color: #F0A500; }
.code-str { color: #F0A500; }
.code-endpoint { color: #FF6B9D; }
.code-method { color: #7EC8E3; }
.code-type { color: #C792EA; }

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page.active > * {
  animation: fadeIn 0.3s ease both;
}

.page.active > *:nth-child(1) { animation-delay: 0.05s; }
.page.active > *:nth-child(2) { animation-delay: 0.1s; }
.page.active > *:nth-child(3) { animation-delay: 0.15s; }
.page.active > *:nth-child(4) { animation-delay: 0.2s; }

/* PULSE */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.live-indicator {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
  margin-right: 6px;
}

/* SEARCH */
.search-bar {
  height: 36px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  min-width: 200px;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  width: 100%;
}

/* FILTERS */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.15s;
}

.filter-chip:hover, .filter-chip.active {
  background: rgba(242,100,25,0.15);
  border-color: var(--orange);
  color: var(--orange);
}

/* RESPONSIVE */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chantier-grid { grid-template-columns: repeat(2, 1fr); }
  .doc-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: flex; position: fixed; left: 0; top: 0; bottom: 0; width: 240px; transform: translateX(-100%); z-index: 200; transition: transform 0.28s cubic-bezier(.4,0,.2,1); }
  .sidebar.open { transform: translateX(0) !important; }
  .main { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .chantier-grid { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 16px; }
}

/* Vertical separator */
.vsep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

  .alert-item{position:relative;transition:opacity .25s,transform .25s,max-height .35s,padding .35s,margin .35s;max-height:120px;overflow:hidden;}
  .alert-item.dismissing{opacity:0;transform:translateX(16px);max-height:0!important;padding:0!important;margin:0!important;}

/* ===== PWA INSTALL BANNER ===== */


/* ===== MOBILE BOTTOM NAV ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--gray-dark);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-inner {
  display: flex;
  align-items: center;
  height: 60px;
}
.mobile-nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  height: 100%;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  border: none; background: none;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item.active { color: var(--orange); }
.mobile-nav-item .nav-ico { font-size: 20px; line-height: 1; }

/* ===== MOBILE TOPBAR ===== */
.mobile-topbar {
  display: none;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  gap: 12px;
  position: sticky; top: 0; z-index: 150;
}
.mobile-topbar-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800; font-size: 13px; color: white;
}
.mobile-topbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px; font-weight: 700; color: var(--white);
  flex: 1;
}
.mobile-menu-btn {
  width: 34px; height: 34px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

/* ===== MOBILE OFFLINE BANNER ===== */
.offline-banner {
  display: none;
  background: rgba(242,100,25,0.15);
  border-bottom: 1px solid var(--orange);
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  text-align: center;
}
.offline-banner.show { display: block; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: flex; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .main { margin-left: 0 !important; }
  .topbar { display: none !important; }
  .mobile-topbar { display: flex !important; }
  .mobile-nav { display: flex !important; }
  body { padding-bottom: 60px; }
  .page { padding: 14px; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi-value { font-size: 28px !important; }
  .kpi-card { padding: 14px !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }
  .chantier-grid { grid-template-columns: 1fr !important; }
  .doc-grid { grid-template-columns: 1fr 1fr !important; }
  .filter-row { gap: 6px !important; overflow-x: auto; padding-bottom: 4px; flex-wrap: nowrap !important; }
  .filter-chip { flex-shrink: 0; }
  .budget-table, .team-table { font-size: 11px !important; }
  .team-table th:nth-child(n+5), .team-table td:nth-child(n+5) { display: none; }
  .form-grid { grid-template-columns: 1fr !important; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 40px; }
  #page-planning { display: block !important; height: auto !important; padding: 0 !important; }
  #page-planning > div:not(.mobile-gantt-mini) { display: none !important; }
  .mobile-gantt-mini { touch-action: pan-y pinch-zoom; overscroll-behavior: contain; }
  .mobile-gantt-mini .gantt-task-bar { min-height: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .mobile-gantt-mini { display: block !important; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .doc-grid { grid-template-columns: 1fr !important; }
}

@supports (padding: max(0px)) {
  .mobile-nav {
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
    height: calc(60px + env(safe-area-inset-bottom));
  }
  .mobile-topbar {
    padding-top: max(env(safe-area-inset-top), 0px);
    height: calc(56px + env(safe-area-inset-top));
  }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ===== MOBILE GANTT MINI ===== */
.mobile-gantt-mini { display: none; padding: 14px; }
.mgm-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.mgm-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.mgm-task-name { font-size: 13px; font-weight: 600; color: var(--white); flex: 1; }
.mgm-team { font-size: 11px; color: var(--text-muted); }
.mgm-body { padding: 10px 14px; }
.mgm-dates { display: flex; gap: 16px; margin-bottom: 8px; font-size: 11px; color: var(--text-muted); }
.mgm-progress-row { display: flex; align-items: center; gap: 10px; }
.mgm-bar { flex: 1; height: 8px; background: var(--gray); border-radius: 4px; overflow: hidden; }
.mgm-bar-fill { height: 100%; border-radius: 4px; }
.mgm-pct { font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; min-width: 36px; text-align: right; }
.mgm-phase-header { padding: 8px 14px; background: rgba(27,58,92,0.4); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--blue-pale); margin-bottom: 8px; border-radius: 6px; }


/* ===== AUTH SCREEN ===== */
.auth-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow', sans-serif;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.auth-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900; font-size: 22px; color: white;
  margin: 0 auto 20px;
}
.auth-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px; font-weight: 800;
  color: var(--white); text-align: center; margin-bottom: 4px;
}
.auth-sub {
  font-size: 13px; color: var(--text-muted);
  text-align: center; margin-bottom: 28px;
}
.auth-tabs {
  display: flex; gap: 0;
  background: var(--gray-mid);
  border-radius: 8px; padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 8px;
  border-radius: 6px; border: none;
  font-family: 'Barlow', sans-serif;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  background: transparent; color: var(--text-muted);
  transition: all 0.2s;
}
.auth-tab.active { background: var(--card2); color: var(--white); }
.auth-field { margin-bottom: 14px; }
.auth-label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.auth-input {
  width: 100%; height: 42px;
  background: var(--gray-mid); border: 1px solid var(--border);
  border-radius: 8px; color: var(--white);
  padding: 0 14px; font-family: 'Barlow', sans-serif;
  font-size: 14px; outline: none; transition: border-color 0.2s;
  box-sizing: border-box;
}
.auth-input:focus { border-color: var(--orange); }
.auth-btn {
  width: 100%; height: 44px;
  background: var(--orange); color: white; border: none;
  border-radius: 8px; font-family: 'Barlow', sans-serif;
  font-size: 14px; font-weight: 700; cursor: pointer;
  margin-top: 8px; transition: background 0.2s;
}
.auth-btn:hover { background: var(--orange-dark); }
.auth-error {
  background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.3);
  border-radius: 7px; padding: 10px 14px;
  font-size: 12px; color: var(--red); margin-bottom: 14px;
  display: none;
}
.auth-footer {
  text-align: center; font-size: 11px;
  color: var(--text-dim); margin-top: 20px;
}


/* ===== RAPPORTS ===== */
.rp-tool-btn {
  width:32px;height:32px;border-radius:6px;border:1px solid var(--border);
  background:var(--gray-mid);color:var(--text);cursor:pointer;font-size:14px;
  display:flex;align-items:center;justify-content:center;transition:all .15s;
}
.rp-tool-btn:hover { border-color:var(--orange);color:var(--orange); }
.rp-tool-btn.active { background:rgba(242,100,25,0.2);border-color:var(--orange);color:var(--orange); }
.rp-color-btn {
  width:22px;height:22px;border-radius:50%;cursor:pointer;border:2px solid transparent;
  transition:transform .15s;flex-shrink:0;
}
.rp-color-btn:hover { transform:scale(1.2); }
.rp-color-btn.active { border-color:white;transform:scale(1.15); }
.rp-thumb {
  position:relative;border-radius:8px;overflow:hidden;aspect-ratio:4/3;
  border:2px solid var(--border);cursor:pointer;transition:border-color .15s;background:var(--gray);
}
.rp-thumb:hover { border-color:var(--orange); }
.rp-thumb img { width:100%;height:100%;object-fit:cover;display:block; }
.rp-thumb-del {
  position:absolute;top:4px;right:4px;width:22px;height:22px;border-radius:50%;
  background:rgba(239,68,68,0.85);color:white;border:none;cursor:pointer;
  font-size:13px;display:flex;align-items:center;justify-content:center;
  opacity:0;transition:opacity .15s;
}
.rp-thumb:hover .rp-thumb-del { opacity:1; }
.rp-thumb-badge {
  position:absolute;bottom:4px;left:4px;right:4px;background:rgba(0,0,0,0.7);
  color:white;font-size:9px;padding:2px 4px;border-radius:3px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.rp-rapport-card {
  background:var(--card);border:1px solid var(--border);border-radius:10px;
  padding:12px 14px;cursor:pointer;transition:border-color .15s;
}
.rp-rapport-card:hover { border-color:var(--orange); }
.rp-rapport-card.active { border-color:var(--orange);background:rgba(242,100,25,0.06); }
.rp-pres-row {
  display:flex;align-items:center;gap:10px;padding:6px 10px;
  background:var(--card2);border-radius:6px;border:1px solid var(--border);
}

/* ===== MODALE RAPPORT PREMIUM ===== */
#rp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: rp-overlay-in 0.22s ease;
}
#rp-modal-overlay.open { display: flex; }
@keyframes rp-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#rp-modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  animation: rp-modal-in 0.26s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
@keyframes rp-modal-in {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* — Header — */
#rp-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rp-modal-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(242,100,25,0.22), rgba(242,100,25,0.08));
  border: 1px solid rgba(242,100,25,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.rp-modal-title-block { flex: 1; min-width: 0; }
.rp-modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px; font-weight: 800;
  color: var(--white); letter-spacing: 0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rp-modal-subtitle {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
}
.rp-modal-close-btn {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: var(--gray-mid); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; line-height: 1;
}
.rp-modal-close-btn:hover { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #EF4444; }

/* — Scrollable body — */
#rp-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
#rp-modal-body::-webkit-scrollbar { width: 5px; }
#rp-modal-body::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* — Section blocks — */
.rp-section {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.rp-section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
}
.rp-section-title span { color: var(--orange); }

/* — Field groups — */
.rp-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.rp-field {
  display: flex; flex-direction: column; gap: 5px;
}
.rp-field-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.rp-input {
  background: var(--surface-input);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
  box-sizing: border-box;
}
.rp-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242,100,25,0.14);
}
.rp-input::placeholder { color: var(--text-dim); }
.rp-input.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select.rp-input { cursor: pointer; }

/* — Footer — */
#rp-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}
.rp-btn-cancel {
  height: 40px; padding: 0 18px; border-radius: 9px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: 'Barlow', sans-serif;
  transition: all 0.15s;
}
.rp-btn-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.rp-btn-save {
  height: 40px; padding: 0 22px; border-radius: 9px;
  background: linear-gradient(135deg, #F26419, #C74E10);
  border: none; color: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: 'Barlow', sans-serif;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.18s;
  box-shadow: 0 2px 12px rgba(242,100,25,0.35);
}
.rp-btn-save:hover {
  background: linear-gradient(135deg, #FF7A35, #D45A18);
  box-shadow: 0 4px 20px rgba(242,100,25,0.50);
  transform: translateY(-1px);
}
.rp-btn-save:active { transform: translateY(0); box-shadow: 0 1px 6px rgba(242,100,25,0.3); }
.rp-btn-save:disabled {
  opacity: 0.7; cursor: not-allowed;
  transform: none; box-shadow: none;
}
.rp-btn-save .rp-spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff; border-radius: 50%;
  animation: rp-spin 0.7s linear infinite;
  display: none;
}
.rp-btn-save.loading .rp-spinner { display: block; }
.rp-btn-save.loading .rp-save-icon { display: none; }
@keyframes rp-spin { to { transform: rotate(360deg); } }

.rp-btn-pdf {
  height: 40px; padding: 0 18px; border-radius: 9px;
  background: var(--gray-mid); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: 'Barlow', sans-serif;
  display: flex; align-items: center; gap: 7px;
  transition: all 0.15s;
  margin-right: auto;
}
.rp-btn-pdf:hover { border-color: var(--orange); color: var(--orange); }
.rp-btn-pdf .rp-pdf-spinner {
  width: 13px; height: 13px; border: 2px solid rgba(242,100,25,0.3);
  border-top-color: var(--orange); border-radius: 50%;
  animation: rp-spin 0.7s linear infinite; display: none;
}
.rp-btn-pdf.loading .rp-pdf-spinner { display: block; }
.rp-btn-pdf.loading .rp-pdf-icon { display: none; }

/* Light mode adjustments */
.light-mode #rp-modal-box {
  box-shadow: 0 24px 60px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
}
.light-mode .rp-input {
  background: #fff;
  border-color: #CBD5E0;
}
.light-mode .rp-input:focus { border-color: var(--orange); }
.light-mode .rp-section { background: var(--surface-3); }


/* ═══════════════════════════════════════════════════════════
   LIGHT MODE — Overrides éléments graphiques
   (variables sémantiques couvrent 90% — overrides pour le reste)
   ═══════════════════════════════════════════════════════════ */

/* Scrollbar */
body {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* Sidebar */
.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border-subtle);
}
.light-mode .sidebar { box-shadow: 2px 0 12px rgba(0,0,0,0.08); }
.light-mode .nav-item { color: var(--text-secondary); }
.light-mode .nav-item:hover,
.light-mode .nav-item.active { background: rgba(242,100,25,0.10); color: var(--orange); }
.light-mode .user-name { color: var(--text-primary) !important; }
.light-mode .user-role { color: var(--text-secondary) !important; }

/* Cards */
.light-mode .card { box-shadow: var(--shadow-card); }
.light-mode .card-header { background: var(--surface-2); }
.light-mode .kpi-card {
  background: var(--surface-2);
  box-shadow: var(--shadow-card);
}
.light-mode .kpi-value { color: var(--text-primary) !important; }
.light-mode .kpi-label { color: var(--text-secondary) !important; }

/* Topbar */
.light-mode .topbar { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.light-mode .mobile-topbar { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.light-mode .mobile-topbar-title { color: var(--text-primary) !important; }

/* Inputs / Selects */
.light-mode .form-input,
.light-mode .form-select {
  background: var(--surface-input);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.light-mode .form-input::placeholder { color: var(--text-disabled); }
.light-mode .form-input:focus,
.light-mode .form-select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,100,25,0.15); }
.light-mode textarea {
  background: var(--surface-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}

/* Boutons */
.light-mode .btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.light-mode .btn-ghost:hover { background: var(--gray-mid); color: var(--text-primary); }
.light-mode .btn-primary { background: var(--orange); color: #fff; }
.light-mode .mobile-menu-btn { background: var(--gray-mid); border-color: var(--border-strong); }

/* Modales */
.light-mode .modal-overlay,
.light-mode .modal { background: var(--overlay-bg) !important; }
.light-mode .modal-content,
.light-mode .g-detailPanel,
.light-mode [id="modalDepense"] .modal-content,
.light-mode [id="modalEditPostes"] .modal-content {
  background: var(--surface-2) !important;
  border-color: var(--border-strong) !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important;
  color: var(--text-primary) !important;
}
.light-mode label, .light-mode .form-label { color: var(--text-secondary) !important; }

/* ── Gantt ── */
.light-mode .gantt-wrapper { background: var(--surface-2); border-color: var(--border-strong); }
.light-mode .gantt-header { background: var(--surface-3); border-bottom-color: var(--border-strong); }
.light-mode .gantt-task-col { color: var(--text-secondary); border-right-color: var(--border-subtle); }
.light-mode .gantt-month { color: var(--text-secondary); border-right-color: var(--border-subtle); }
.light-mode .gantt-row { border-bottom: 1px solid var(--gantt-row-line); }
.light-mode .gantt-row:hover { background: var(--row-hover); }
.light-mode .gantt-task-info { border-right-color: var(--border-subtle); }
.light-mode .gantt-task-name { color: var(--text-primary); }
.light-mode .gantt-col-bg { border-right: 1px solid var(--gantt-col-line); }
.light-mode .gantt-phase-row { background: var(--surface-3) !important; color: var(--text-primary) !important; }
.light-mode .g-detailPanel { background: var(--surface-2) !important; border-color: var(--border-strong) !important; }
.light-mode #g-detailTeam,
.light-mode #g-detailStatus,
.light-mode #g-detailStart,
.light-mode #g-detailEnd,
.light-mode #g-detailPct,
.light-mode #g-detailNotes {
  background: var(--surface-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}

/* ── Tables (Budget, Équipes) ── */
.light-mode .budget-table th,
.light-mode .team-table th {
  background: var(--surface-3);
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-strong);
}
.light-mode .budget-table td,
.light-mode .team-table td {
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.light-mode .budget-table tr:hover td,
.light-mode .team-table tr:hover td { background: var(--row-hover); }
.light-mode .amount { color: var(--text-primary); }
.light-mode .amount-prevu { color: var(--blue-light) !important; }
.light-mode .amount-reel  { color: var(--orange) !important; }
.light-mode .amount-ecart-pos { color: #1A6B3C !important; }
.light-mode .amount-ecart-neg { color: #C0392B !important; }

/* ── Chantier cards ── */
.light-mode .chantier-card { box-shadow: var(--shadow-card); }
.light-mode .chantier-code { color: var(--text-secondary) !important; }
.light-mode .chantier-name { color: var(--text-primary) !important; }
.light-mode .chantier-client { color: var(--text-secondary) !important; }
.light-mode .meta-key { color: var(--text-disabled) !important; }
.light-mode .meta-val { color: var(--text-primary) !important; }

/* ── Documents ── */
.light-mode .doc-card { background: var(--surface-2); border-color: var(--border-strong); }
.light-mode .doc-name { color: var(--text-primary) !important; }
.light-mode .doc-meta { color: var(--text-secondary) !important; }

/* ── Rapports ── */
.light-mode .rp-thumb { border-color: var(--border-strong) !important; }

/* ── Auth screen ── */
.light-mode #authScreen { background: linear-gradient(135deg, #E8EDF3 0%, #F0F4F8 100%); }
.light-mode .auth-card { background: var(--surface-2); box-shadow: 0 24px 64px rgba(0,0,0,0.12); }
.light-mode .auth-input { background: var(--surface-input) !important; color: var(--text-primary) !important; border-color: var(--border-strong) !important; }
.light-mode .auth-tab { color: var(--text-secondary) !important; }
.light-mode .auth-tab.active { color: var(--orange) !important; border-bottom-color: var(--orange) !important; }

/* ── Page architecture (code) ── */
.light-mode .arch-section { background: var(--surface-2) !important; border-color: var(--border-subtle) !important; }
.light-mode .code-block { background: #F7FAFC !important; color: #2D3748 !important; border: 1px solid var(--border-strong); }
.light-mode .arch-title { color: var(--orange) !important; }
.light-mode .arch-text { color: var(--text-primary) !important; }

/* ── Filter chips ── */
.light-mode .filter-chip { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-secondary); }
.light-mode .filter-chip.active { background: rgba(242,100,25,0.12); color: var(--orange); border-color: rgba(242,100,25,0.4); }
.light-mode .search-bar { background: var(--surface-2); border-color: var(--border-strong); }
.light-mode .search-bar input { color: var(--text-primary); background: transparent; }
.light-mode .search-bar svg { color: var(--text-secondary); }

/* ── Status pills ── */
.light-mode .status-encours { background: rgba(46,204,113,0.15); color: #166534; border-color: rgba(46,204,113,0.4); }
.light-mode .status-alerte  { background: rgba(231,76,60,0.12);  color: #9B1C1C; border-color: rgba(231,76,60,0.35); }
.light-mode .status-planifie { background: rgba(46,110,166,0.12); color: #1E40AF; border-color: rgba(46,110,166,0.3); }
.light-mode .status-termine  { background: rgba(107,114,128,0.12); color: #374151; }

/* ── KPI badges ── */
.light-mode .badge-up   { background: rgba(46,204,113,0.15); color: #166534; }
.light-mode .badge-down { background: rgba(231,76,60,0.12);  color: #9B1C1C; }
.light-mode .badge-warn { background: rgba(243,156,18,0.15); color: #92400E; }

/* ── Progress bars ── */
.light-mode .progress-bar { background: var(--gray-mid); }

/* ── Offline banner ── */
.light-mode .offline-banner { background: rgba(242,100,25,0.1); color: var(--orange-dark); }


/* ── Sélecteur de langue ── */
.kt-lang-select {
  height: 36px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--gray-mid);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  min-width: 44px;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}
.kt-lang-select:hover {
  border-color: var(--orange);
  color: var(--orange);
}
@media (max-width: 768px) {
  .kt-lang-select { height: 32px; font-size: 14px; padding: 0 6px; min-width: 40px; }
}

/* ── Bouton toggle thème dans la sidebar ── */
.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Barlow', sans-serif;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle-btn:hover { background: rgba(242,100,25,0.10); color: var(--orange); }
.theme-toggle-icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.theme-toggle-label { opacity: 0; transition: opacity 0.2s; font-size: 12px; }
.sidebar:hover .theme-toggle-label { opacity: 1; }
.sidebar.open .theme-toggle-label { opacity: 1; }

/* Topbar desktop : indicateur mode */
.theme-toggle-topbar {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle-topbar:hover { background: var(--gray-mid); color: var(--orange); border-color: var(--orange); }


/* ═══════════════════════════════════════
   PASTILLE STATUT SYNCHRONISATION
   ═══════════════════════════════════════ */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: default;
  transition: all 0.3s;
  white-space: nowrap;
  user-select: none;
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
/* États */
.sync-status.synced   { background: rgba(46,204,113,0.12); color: #27AE60; border: 1px solid rgba(46,204,113,0.3); }
.sync-status.syncing  { background: rgba(243,156,18,0.12);  color: #E67E22; border: 1px solid rgba(243,156,18,0.3); }
.sync-status.offline  { background: rgba(231,76,60,0.12);   color: #E74C3C; border: 1px solid rgba(231,76,60,0.3); }
.sync-status.local    { background: rgba(74,144,196,0.12);  color: #4A90C4; border: 1px solid rgba(74,144,196,0.3); }
.sync-dot.synced   { background: #27AE60; box-shadow: 0 0 0 3px rgba(46,204,113,0.25); }
.sync-dot.syncing  { background: #E67E22; animation: syncPulse 1.2s ease-in-out infinite; }
.sync-dot.offline  { background: #E74C3C; }
.sync-dot.local    { background: #4A90C4; }
@keyframes syncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}
/* Light mode */
.light-mode .sync-status.synced  { background: rgba(22,101,52,0.08);  color: #166534; border-color: rgba(22,101,52,0.25); }
.light-mode .sync-status.syncing { background: rgba(146,64,14,0.08);  color: #92400E; border-color: rgba(146,64,14,0.25); }
.light-mode .sync-status.offline { background: rgba(153,27,27,0.08);  color: #991B1B; border-color: rgba(153,27,27,0.25); }
.light-mode .sync-status.local   { background: rgba(29,78,216,0.08);  color: #1D4ED8; border-color: rgba(29,78,216,0.25); }


/* ── Calendrier custom Kantiir ─────────────────────────── */
.kt-datepicker-wrap { position:relative; }
.kt-date-btn {
  width:100%; background:var(--gray-mid); border:1px solid var(--border);
  border-radius:6px; color:var(--text); padding:6px 10px;
  font-family:'Barlow',sans-serif; font-size:12px; outline:none;
  cursor:pointer; text-align:left; display:flex; align-items:center; gap:6px;
  transition:border-color 0.15s;
}
.kt-date-btn:hover, .kt-date-btn:focus { border-color:var(--orange); }
.kt-date-btn .kt-date-ico { font-size:13px; flex-shrink:0; }
.kt-date-btn .kt-date-val { flex:1; }
.kt-date-btn .kt-date-val.empty { color:var(--text-muted); }
.kt-cal {
  position:fixed; z-index:2000; background:var(--card2);
  border:1px solid var(--border); border-radius:10px;
  padding:10px; width:248px; box-shadow:0 12px 40px rgba(0,0,0,0.6);
  display:none; flex-direction:column; gap:6px;
}
.kt-cal.open { display:flex; }
.kt-cal-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:2px; }
.kt-cal-nav button {
  width:26px; height:26px; border:none; border-radius:5px;
  background:var(--gray-mid); color:var(--text); cursor:pointer;
  font-size:14px; display:flex; align-items:center; justify-content:center;
}
.kt-cal-nav button:hover { background:var(--orange); color:#fff; }
.kt-cal-title {
  font-family:'Barlow Condensed'; font-size:13px; font-weight:700;
  color:var(--white); text-transform:uppercase; letter-spacing:0.5px;
  padding:2px 6px; border-radius:4px;
}
.kt-cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.kt-cal-dow { text-align:center; font-size:9px; font-weight:700; color:var(--text-muted); padding:3px 0; text-transform:uppercase; }
.kt-cal-day { text-align:center; font-size:11px; padding:5px 2px; border-radius:5px; cursor:pointer; color:var(--text); border:1px solid transparent; transition:all 0.1s; }
.kt-cal-day:hover { background:var(--gray-mid); border-color:var(--orange); }
.kt-cal-day.today { color:var(--orange); font-weight:700; }
.kt-cal-day.selected { background:var(--orange); color:#fff; font-weight:700; border-color:var(--orange); }
.kt-cal-day.other-month { color:var(--text-dim); opacity:0.4; }
.kt-cal-actions { display:flex; gap:6px; margin-top:2px; }
.kt-cal-actions button { flex:1; height:28px; border-radius:6px; font-size:11px; font-family:'Barlow',sans-serif; font-weight:600; cursor:pointer; border:none; }
.kt-cal-clear { background:var(--gray-mid); color:var(--text-muted); }
.kt-cal-clear:hover { color:var(--red); }
.kt-cal-today-btn { background:rgba(242,100,25,0.15); color:var(--orange); }
.kt-cal-today-btn:hover { background:var(--orange); color:#fff; }
