/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ══ Palette Geodiag-ANC — couleurs exactes du thème ══════════ */
  /* Teal éclatant — principal interactif (boutons, liens, focus)  */
  --blue:        #00b091;
  --blue-dark:   #008f74;
  --blue-light:  #d6f5f0;
  /* Orange — "-ANC", accents chauds                               */
  --accent:      #e36a00;
  --accent-dark: #b85500;
  --accent-light:#fdecd8;
  /* Vert vif — statut positif, réussite, envoyé                   */
  --vivid-green:       #36b000;
  --vivid-green-dark:  #2a8a00;
  --vivid-green-light: #e4f7d6;
  /* Vert forêt profond — titres, textes foncés                    */
  --forest:      #003c30;
  --forest-dark: #002520;
  --forest-light:#d6ede7;
  /* Bleu eau — goutte du logo, SPANC                              */
  --water:       #1976D2;
  --water-light: #ddeeff;
  /* Teal alias */
  --teal:        #00b091;
  --teal-light:  #d6f5f0;
  /* Sémantique */
  --green:       #36b000;
  --green-light: #e4f7d6;
  --amber:       #d97706;
  --amber-light: #fef3c7;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  /* Neutres */
  --slate-900:   #111111;
  --slate-800:   #222222;
  --slate-700:   #3a3a3a;
  --slate-600:   #555555;
  --slate-400:   #999999;
  --slate-300:   #cccccc;
  --slate-200:   #e4e4e4;
  --slate-100:   #f2f2f2;
  --slate-50:    #f8f8f8;
  --white:       #ffffff;
  /* Sidebar — charbon style carte de visite                       */
  --sidebar-bg:  #222222;
  --sidebar-w:   268px;
  /* Misc */
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 24px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.07);
}

html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--slate-100);
  color: var(--slate-800);
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout principal ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

/* ── Logo / En-tête sidebar ── */
.sidebar-logo {
  padding: 0 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: relative;
}

/* Bande de couleurs en haut de la sidebar (palette exacte carte de visite) */
.sidebar-logo::before {
  content: '';
  display: block;
  height: 4px;
  margin: 0 -16px 18px;
  background: linear-gradient(90deg, #00b091 0%, #36b000 35%, #e36a00 70%, #003c30 100%);
}

.sidebar-logo-inner {
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,.06);
  padding: 2px;
}

.sidebar-logo-img-fallback {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00b091, #e36a00);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -1px;
}

.sidebar-logo .logo-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -.4px;
  line-height: 1.2;
}

.sidebar-logo .logo-title .anc-part {
  color: var(--accent);
}

.sidebar-logo .logo-sub {
  font-size: .70rem;
  color: rgba(255,255,255,.45);
  margin-top: 2px;
  line-height: 1.3;
}

/* ── Navigation sidebar ── */
.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-section-label {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: rgba(255,255,255,.3);
  padding: 16px 18px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px 8px 14px;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  margin: 1px 0;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,.06);
  text-decoration: none;
}

.nav-item.active {
  color: var(--white);
  background: rgba(13,155,130,.20);
  border-left-color: var(--teal);
  font-weight: 600;
}

.nav-item svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: .75;
}

.nav-item.active svg { opacity: 1; }

/* Badge compteur dans le nav */
.nav-badge {
  margin-left: auto;
  background: rgba(13,155,130,.35);
  color: #7fe8d4;
  font-size: .63rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-badge:empty { display: none; }

/* ── Zone utilisateur bas de sidebar ── */
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #00b091, #e36a00);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  color: var(--white);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: .84rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: .70rem; color: rgba(255,255,255,.4); }

.btn-logout {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.35); padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.btn-logout:hover { color: var(--red); }

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

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  border-top: 3px solid #00b091;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--slate-800);
}

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

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

/* ═══════════════════════════════════════════════════════════════
   BOUTONS
═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #00b091 0%, #008f74 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0,176,145,.32);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #00967b 0%, #007560 100%);
  box-shadow: 0 4px 14px rgba(0,176,145,.45);
  text-decoration: none;
  color: var(--white);
}

.btn-accent  { background: var(--accent); color: var(--white); }
.btn-accent:hover { background: var(--accent-dark); text-decoration: none; color: var(--white); }

.btn-secondary { background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200); }
.btn-secondary:hover { background: var(--slate-200); text-decoration: none; color: var(--slate-800); }

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: var(--white); }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

.btn svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--slate-200);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { padding: 20px; }

/* ═══════════════════════════════════════════════════════════════
   STATS
═══════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue  { background: var(--blue-light);   color: var(--teal); }
.stat-icon.green { background: var(--green-light);  color: var(--green); }
.stat-icon.amber { background: var(--amber-light);  color: var(--amber); }
.stat-icon.red   { background: var(--red-light);    color: var(--red); }
.stat-icon.accent{ background: var(--accent-light); color: var(--accent); }
.stat-icon.teal  { background: var(--teal-light);   color: var(--teal); }

.stat-info .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-info .stat-label { font-size: .78rem; color: var(--slate-600); margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════════
   KANBAN
═══════════════════════════════════════════════════════════════ */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-col {
  background: var(--slate-100);
  border-radius: var(--radius);
  min-width: 240px;
  width: 240px;
  flex-shrink: 0;
  border: 1px solid var(--slate-200);
}

.kanban-col-header {
  padding: 12px 14px;
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--slate-200);
  border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-badge {
  background: var(--white);
  border: 1px solid var(--slate-300);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: .72rem;
  color: var(--slate-600);
}

.kanban-col-body {
  padding: 10px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
}

.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--slate-300); }

.kanban-card-ref   { font-size: .72rem; color: var(--slate-400); margin-bottom: 4px; }
.kanban-card-title { font-size: .85rem; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.kanban-card-sub   { font-size: .78rem; color: var(--slate-600); }

.kanban-card-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-etude    { background: var(--forest-light); color: var(--forest-dark); }
.badge-controle { background: var(--green-light);  color: #15803d; }
.badge-diag     { background: var(--accent-light); color: var(--accent-dark); }
.badge-dossier  { background: #e0f2fe;             color: #0369a1; }

/* Couleurs colonnes Kanban — palette exacte Geodiag-ANC */
.kanban-col[data-statut="a_planifier"]     .kanban-col-header { background: #d6ede7;  color: #003c30; }
.kanban-col[data-statut="terrain"]          .kanban-col-header { background: #d6f5f0;  color: #008f74; }
.kanban-col[data-statut="rapport_en_cours"] .kanban-col-header { background: #fef3c7;  color: #92400e; }
.kanban-col[data-statut="envoye_client"]    .kanban-col-header { background: #e4f7d6;  color: #2a8a00; }
.kanban-col[data-statut="attente_spanc"]    .kanban-col-header { background: #ddeeff;  color: #1565C0; }
.kanban-col[data-statut="facture"]          .kanban-col-header { background: #fdecd8;  color: #b85500; }
.kanban-col[data-statut="archive"]          .kanban-col-header { background: #f2f2f2;  color: #777777; }

/* ═══════════════════════════════════════════════════════════════
   FORMULAIRES
═══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 5px; color: var(--slate-700); }
.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--slate-800);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: #00b091;
  box-shadow: 0 0 0 3px rgba(0,176,145,.20);
}

.form-control::placeholder { color: var(--slate-400); }

/* ═══════════════════════════════════════════════════════════════
   TABLEAUX
═══════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate-600);
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
}
tbody td { padding: 12px 14px; font-size: .88rem; border-bottom: 1px solid var(--slate-100); }
tbody tr:hover td { background: var(--slate-50); }
tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════
   ALERTES
═══════════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error   { background: var(--red-light);    color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--green-light);  color: #166534; border: 1px solid #86efac; }
.alert-info    { background: var(--blue-light);   color: var(--blue-dark); border: 1px solid #6ecfc0; }
.alert-warning { background: var(--amber-light);  color: #92400e; border: 1px solid #fcd34d; }

/* ═══════════════════════════════════════════════════════════════
   PAGE DE CONNEXION
═══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 85%, rgba(227,106,0,.28) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 10%, rgba(0,176,145,.32) 0%, transparent 45%),
    radial-gradient(ellipse at 30% 30%, rgba(54,176,0,.15) 0%, transparent 50%),
    linear-gradient(160deg, #111111 0%, #222222 60%, #003c30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(0,0,0,.35);
  overflow: hidden;
}

.login-header {
  background: linear-gradient(160deg, #111111 0%, #222222 60%, #003c30 100%);
  padding: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid #00b091;
}

/* Bande palette exacte en haut du header */
.login-header::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #00b091 0%, #36b000 35%, #e36a00 70%, #003c30 100%);
}

.login-header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(0,176,145,.20);
}

.login-logo-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.login-logo-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,.35));
}

.login-logo-fallback {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #00b091, #e36a00);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0,176,145,.40);
}
.login-logo-fallback svg { width: 38px; height: 38px; fill: var(--white); }

.login-app-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -1px;
  line-height: 1;
}

.login-app-name .anc-part { color: var(--accent); }

.login-app-sub {
  font-size: .78rem;
  color: rgba(255,255,255,.5);
  margin-top: 6px;
  letter-spacing: .02em;
}

.login-body { padding: 28px 32px 32px; }

.login-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 4px;
}

.login-hint { font-size: .83rem; color: var(--slate-500); margin-bottom: 22px; }

.login-body .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: .95rem;
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: .02em;
}

.login-footer {
  padding: 14px 32px;
  background: var(--slate-50);
  border-top: 1px solid var(--slate-200);
  font-size: .73rem;
  color: var(--slate-400);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITAIRES
═══════════════════════════════════════════════════════════════ */
.text-muted   { color: var(--slate-500); }
.text-small   { font-size: .8rem; }
.text-primary { color: var(--blue); }
.text-accent  { color: var(--accent); }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-1         { margin-top: 4px; }
.mt-2         { margin-top: 8px; }
.mt-4         { margin-top: 16px; }
.mb-4         { margin-bottom: 16px; }
.mb-6         { margin-bottom: 24px; }

/* ── Loading spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════
   MODALES
═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(7,24,16,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in .15s ease;
}
@keyframes modal-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--slate-200);
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--slate-900); }
.modal-close {
  width: 30px; height: 30px;
  border: none; background: none; cursor: pointer;
  color: var(--slate-400); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s, color .1s;
}
.modal-close:hover { background: var(--slate-100); color: var(--slate-700); }
.modal-close svg { width: 18px; height: 18px; fill: currentColor; }
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   CHIPS / BADGES
═══════════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 12px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.chip.blue   { background: var(--blue-light);   color: var(--blue-dark); }
.chip.green  { background: var(--green-light);  color: #15803d; }
.chip.amber  { background: var(--amber-light);  color: #b45309; }
.chip.red    { background: var(--red-light);    color: #dc2626; }
.chip.slate  { background: var(--slate-100);    color: var(--slate-600); }
.chip.accent { background: var(--accent-light); color: var(--accent-dark); }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--slate-400);
}
.empty-state svg {
  width: 48px; height: 48px;
  opacity: .2;
  display: block;
  margin: 0 auto 14px;
  fill: currentColor;
}
.empty-state p { margin-bottom: 16px; font-size: .95rem; }

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR personnalisée
═══════════════════════════════════════════════════════════════ */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
