/* ============================================
   Commune Connect — Design System
   Basé sur la charte graphique de Chevrières
   ============================================ */

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

/* --- Tokens --- */
:root {
  --primary: #1E3A5F;
  --primary-light: #2563EB;
  --primary-dark: #0F1D30;
  --accent: #C41E3A;
  --accent-light: #E8354F;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --surface-hover: #F1F5F9;
  --border: #E2E8F0;
  --text: #1A1A2E;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.15);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: .2s ease;
  --sidebar-width: 280px;
  --header-height: 64px;
  --badge-blue-bg: #DBEAFE; --badge-blue-fg: #1E40AF;
  --badge-red-bg: #FEE2E2;  --badge-red-fg: #991B1B;
  --badge-green-bg: #D1FAE5; --badge-green-fg: #065F46;
  --badge-orange-fg: #D97706;
}

/* ── Mode sombre ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-alt: #162032;
  --surface-hover: #263348;
  --border: #334155;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.55);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.65);
  --badge-blue-bg: #1E3A5F;  --badge-blue-fg: #93C5FD;
  --badge-red-bg: #3B1212;   --badge-red-fg: #FCA5A5;
  --badge-green-bg: #052E16; --badge-green-fg: #6EE7B7;
  --badge-orange-fg: #FCD34D;
}

/* Commission cards : mix sur fond sombre au lieu de blanc */
[data-theme="dark"] .commission-card {
  background: color-mix(in srgb, var(--card-color), #0F172A 84%);
  border-color: color-mix(in srgb, var(--card-color), #0F172A 62%);
}
[data-theme="dark"] .commission-card:hover {
  background: color-mix(in srgb, var(--card-color), #0F172A 76%);
  border-color: color-mix(in srgb, var(--card-color), #0F172A 45%);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--card-color), transparent 60%);
}
[data-theme="dark"] .commission-card .card-title { color: var(--text); }

/* Icône blanche en dark mode aussi */
[data-theme="dark"] .commission-card .card-icon {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  box-shadow: none;
}

/* Header data-table */
[data-theme="dark"] .data-table th {
  background: var(--surface-alt);
  color: var(--text-secondary);
}
[data-theme="dark"] .data-table tr:hover td { background: var(--surface-hover); }

/* Modal overlay */
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.75); }
[data-theme="dark"] .modal-close:hover { background: var(--surface-alt); }

/* Scrollbar en dark */
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--surface-alt); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); }

/* Select et inputs natifs */
[data-theme="dark"] select.form-input,
[data-theme="dark"] select {
  color-scheme: dark;
}

/* Transition douce lors du changement de thème */
body, .card, .app-header, .commission-card, .modal, .form-input, .btn-secondary {
  transition: background-color .25s ease, border-color .25s ease, color .15s ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* --- Typography --- */
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--text-secondary); }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px;
  font-size: 1rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  transition: all var(--transition);
  min-height: 48px;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary-light); color: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: .875rem; min-height: 36px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* --- Inputs --- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: .875rem; font-weight: 600; color: var(--text-secondary);
}
.form-input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 48px;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-input::placeholder { color: var(--text-muted); }

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: all .3s ease;
  border: 1px solid var(--border);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* --- Commission Cards --- */
.commission-card {
  position: relative;
  background: var(--surface);
  background: color-mix(in srgb, var(--card-color), white 84%);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  transition: all .3s ease;
  border: 1px solid color-mix(in srgb, var(--card-color), white 60%);
  overflow: hidden;
  text-align: center;
}
/* Barre colorée en haut de chaque carte */
.commission-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.commission-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--card-color), transparent 70%);
  background: color-mix(in srgb, var(--card-color), white 78%);
  border-color: color-mix(in srgb, var(--card-color), white 40%);
}
.commission-card .card-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), inset 0 -2px 0 rgba(0,0,0,0.05);
  border: 1px solid rgba(255,255,255,0.8);
}
.commission-card .card-icon span,
.commission-card .card-icon {
  text-shadow: 1px 1px 0px rgba(0,0,0,0.15), 2px 2px 6px rgba(0,0,0,0.2);
}
.commission-card .card-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}
.commission-card .card-stats {
  font-size: .8rem;
  color: color-mix(in srgb, var(--card-color), black 40%);
  font-weight: 500;
}

/* --- Badge Point Rouge --- */
.badge-new {
  position: absolute; top: 12px; right: 12px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 11px;
  border: 2px solid var(--surface);
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(196,30,58,.4);
  animation: pulse-badge 2s infinite;
  z-index: 2;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196,30,58,.4); }
  50% { box-shadow: 0 0 0 6px rgba(196,30,58,0); }
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-container {
  margin: auto;
  width: 100%; max-width: 440px;
  padding: 20px;
  position: relative; z-index: 1;
}
.login-card {
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-xl);
  animation: slideUp .6s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  width: 200px;
  margin: 0 auto 24px;
}
.login-title {
  text-align: center;
  font-size: 1.5rem; font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: 32px;
}
.login-error {
  background: #FEF2F2;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 16px;
  display: none;
  border: 1px solid #FECACA;
}
.login-error.visible { display: flex; align-items: center; gap: 8px; }
.password-wrapper {
  position: relative;
}
.password-toggle {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-muted); font-size: 1.2rem;
  padding: 4px; cursor: pointer;
}
.forgot-msg { font-size:.85rem; text-align:center; margin-top:8px; }
.forgot-msg.error { color: var(--danger); }
.forgot-msg.success { color: #059669; }

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

/* --- App Shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar-header {
  padding: 32px 20px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-align: center;
}
.sidebar-header img { width: 100px; height: auto; }
.sidebar-header h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,.7);
  font-size: .9rem; font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--primary-light);
}
.nav-item .material-symbols-outlined { font-size: 22px; }
.nav-item .nav-badge {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: auto;
}
.nav-section-title {
  padding: 16px 20px 8px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  font-weight: 600;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem;
}
.sidebar-user .user-name { font-size: .85rem; font-weight: 600; }
.sidebar-user .user-role { font-size: .7rem; color: rgba(255,255,255,.5); }

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}
.app-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 32px;
  position: sticky; top: 0;
  z-index: 50;
  gap: 16px;
}
.app-header .page-title { font-size: 1.25rem; font-weight: 700; flex: 1; }
.menu-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.5rem; color: var(--text);
  padding: 8px;
}
.app-body { padding: 32px; }

/* --- Dashboard Grid --- */
.dashboard-welcome {
  margin-bottom: 32px;
}
.dashboard-welcome h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}
.dashboard-welcome p { color: var(--text-secondary); }
.commissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* --- Dashboard — section alertes --- */
.dash-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}
.dash-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.dash-section-header h3 { margin: 0; font-size: .95rem; font-weight: 700; }
.dash-section-header .dash-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-secondary);
}
.dash-section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 12px 2px;
}
.dash-section-label.overdue { color: var(--danger); }
.dash-section-label.upcoming { color: var(--badge-orange-fg); }

/* --- Dashboard — ligne tâche --- */
.dash-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.dash-task-row:hover, .dash-task-row:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.dash-task-row .task-title {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-task-row .task-subtitle {
  font-size: .75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-task-row .task-meta-chips {
  display: none;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.dash-task-row .task-date {
  font-size: .75rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Stat badges (commission cards) --- */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
}
.stat-badge-blue  { background: var(--badge-blue-bg);  color: var(--badge-blue-fg); }
.stat-badge-red   { background: var(--badge-red-bg);   color: var(--badge-red-fg); }
.stat-badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.stat-badge-red.pulse-urgent { animation: pulse 1.5s ease 3; }

/* --- Project List / Cards --- */
.project-list { display: flex; flex-direction: column; gap: 12px; }
.project-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.project-item:hover { box-shadow: var(--shadow-md); border-color: var(--primary-light); }

/* --- Projects Grid --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 8px;
}

.projects-section { margin-bottom: 28px; }
.projects-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* --- Project Card --- */
.project-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .18s, border-color .18s, transform .18s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.project-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}
.project-card.pinned { border-color: var(--primary); border-left: 4px solid var(--primary); }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.project-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  color: var(--text-primary);
}

.project-card-desc {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.project-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.project-card-tag {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.project-card-stats { display: flex; gap: 12px; font-size: .8rem; color: var(--text-secondary); font-weight: 600; }
.project-card-date { font-size: .72rem; color: var(--text-secondary); margin-top: 4px; }

.project-card-avatars { display: flex; gap: -4px; }
.project-card-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  margin-left: -6px;
}
.project-card-avatar:first-child { margin-left: 0; }
.project-card-avatar.more { background: var(--border); color: var(--text-secondary); }

.project-card-pin-mark {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 14px;
}
.project-card-pin-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .15s;
}
.project-card:hover .project-card-pin-btn { opacity: 1; }

/* --- Data Table --- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; }

/* --- Calendar --- */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.cal-title {
  margin: 0;
  text-transform: capitalize;
  font-size: 1.1rem;
}
.cal-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .75rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.cal-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day-name {
  padding: 8px 4px;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--primary);
  color: #fff;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-header-cell {
  padding: 8px 4px;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--primary);
  color: #fff;
}
.cal-cell {
  min-height: 90px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  cursor: pointer;
  transition: background .12s;
  font-size: .8rem;
}
.cal-cell:hover { background: color-mix(in srgb, var(--primary), transparent 97%); }
.cal-cell.out-month { background: var(--surface-alt); color: var(--text-secondary); }
.cal-cell.today { background: color-mix(in srgb, var(--primary), transparent 93%); font-weight: 700; }
.cal-cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.cal-day-num {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.cal-day-badge {
  font-size: .6rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 1px 5px;
  line-height: 1.4;
}
.cal-cell.today .cal-day-num {
  background: var(--primary);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-event {
  font-size: .68rem;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  cursor: pointer;
}
.cal-event-time { font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.cal-event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.cal-event-more {
  font-size: .68rem;
  color: var(--primary-light);
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  margin-top: 2px;
}
.cal-event-more:hover { background: color-mix(in srgb, var(--primary), transparent 88%); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .85; transform: scale(1.05); }
}

/* --- Responsive mobile --- */
@media (max-width: 1024px) {
  /* Sidebar repliée par défaut sur tablette/mobile */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 30px rgba(0,0,0,.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  /* Le contenu principal occupe toute la largeur */
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  /* Afficher le bouton burger */
  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
  }
  .menu-toggle:hover {
    background: rgba(0,0,0,.05);
  }
  .menu-toggle:active {
    background: rgba(0,0,0,.1);
  }
}

@media (max-width: 768px) {
  /* Bouton recherche : icône seule sur mobile */
  .search-btn-label, #search-btn kbd { display: none; }
  #search-btn { padding: 7px 9px; }

  /* Header plus compact */
  .app-header {
    padding: 0 12px;
    gap: 8px;
  }
  .app-header .page-title {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-body {
    padding: 16px 12px;
  }
  /* Sidebar plus large pour mieux remplir l'écran mobile */
  .sidebar {
    width: 85%;
    max-width: 320px;
  }
  /* Grilles */
  .projects-grid { grid-template-columns: 1fr; }
  .commissions-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .commission-card { padding: 18px 12px; }
  .commission-card .card-icon { width: 48px; height: 48px; font-size: 24px; margin-bottom: 10px; }
  .commission-card .card-title { font-size: .9rem; }
  /* Calendrier */
  .cal-toolbar { gap: 6px; }
  .cal-title { font-size: 1rem; }
  .cal-legend { gap: 6px; font-size: .7rem; }
  .cal-day-name { font-size: .62rem; padding: 6px 2px; letter-spacing: 0; }
  .cal-cell { min-height: 60px; padding: 3px; }
  .cal-event { font-size: .6rem; }
  /* Cards */
  .card { padding: 16px; }
  /* Login */
  .login-card { padding: 32px 24px; }
  /* Boutons header → empilés ou compacts */
  #header-actions .btn-sm {
    padding: 6px 10px;
    font-size: .8rem;
    min-height: 32px;
  }
  /* Tableaux : scroll horizontal */
  .data-table {
    font-size: .8rem;
  }
  /* Dashboard welcome */
  .dashboard-welcome h1 { font-size: 1.35rem; }
  .dashboard-welcome { margin-bottom: 20px; }
}

/* Desktop : masquer les cartes mobile */
@media (min-width: 641px) {
  .mobile-cards { display: none; }
}

/* Empêcher le scroll du body quand la sidebar mobile est ouverte */
body.sidebar-open {
  overflow: hidden;
}

/* --- Carte Géoportail / Leaflet --- */
.map-layer-btn {
  transition: background var(--transition), color var(--transition);
  color: var(--text-secondary);
}
.map-layer-btn:last-child { border-right: none !important; }
.map-layer-btn:hover {
  background: rgba(37,99,235,.06) !important;
  color: var(--primary);
}
.map-layer-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
}
.map-search-item:hover {
  background: var(--surface-alt);
}
#project-map {
  z-index: 0;
}
/* Sur petit écran, on cache le label des fonds pour ne garder que les icônes */
@media (max-width: 640px) {
  .map-layer-btn .map-layer-label { display: none; }
  .map-layer-btn { padding: 8px 10px !important; font-size: 1rem !important; }

  /* Boutons agenda — icône seule, texte masqué */
  .agenda-btn-label { display: none; }

  /* Calendrier mobile — style Google Calendar (points de couleur) */
  .cal-toolbar { flex-direction: column; align-items: stretch; }
  .cal-legend { display: none; }
  .cal-title { text-align: center; font-size: .95rem; }
  .cal-day-name { font-size: .6rem; padding: 6px 1px; letter-spacing: 0; font-weight: 700; }
  .cal-cell { min-height: 44px; padding: 4px 2px; cursor: pointer; }
  .cal-cell-header { justify-content: center; }
  .cal-day-num { font-size: .75rem; text-align: center; }
  .cal-cell.today .cal-day-num { width: 22px; height: 22px; font-size: .72rem; }

  /* Tableaux : version desktop masquée, cartes affichées */
  .desktop-table { display: none !important; }

  /* Tâches dashboard — version mobile */
  .dash-task-row .task-date { display: none; }
  .dash-task-row .task-subtitle { font-size: .72rem; }
  .dash-task-row .task-meta-chips { display: flex; }

  /* Commission — activité récente : éviter le débordement */
  .comm-hist-item { flex-wrap: wrap; row-gap: 2px; }
  .comm-hist-item .comm-hist-time { margin-left: 0 !important; flex-basis: 100%; }
  .comm-hist-item .comm-hist-action { white-space: normal !important; overflow: hidden; text-overflow: ellipsis; }
}

/* Palette de couleurs pour les dessins */
.map-color-btn {
  position: relative;
}
.map-color-btn:hover {
  transform: scale(1.1);
  outline-color: rgba(0,0,0,.15) !important;
}
.map-color-btn.active {
  outline-color: var(--text) !important;
  outline-offset: 2px;
  transform: scale(1.15);
}
/* Le contrôle Geoman doit rester au-dessus des tuiles mais sous les modales */
.leaflet-pm-toolbar { z-index: 500 !important; }

/* ── Modales ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideDown { from { opacity:0;transform:translateY(-12px) } to { opacity:1;transform:translateY(0) } }
@keyframes slideInRight { from { opacity:0;transform:translateX(40px) } to { opacity:1;transform:translateX(0) } }

/* Cloche notifications */
#notif-btn:hover { background:var(--surface-alt) !important; border-color:var(--primary-light) !important; }
#notif-badge { display:none; }
#notif-badge[style*="flex"] { display:flex !important; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUpModal .2s ease;
}
@keyframes slideUpModal { from { transform: translateY(16px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-body .form-group:last-child { margin-bottom: 0; }

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

/* Modales sur mobile */
@media (max-width: 640px) {
  .modal { max-width: calc(100vw - 32px); }
  .modal-overlay { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-footer { padding: 12px 16px; }
}

/* ── Bannière Notes (tableau de bord) ────────────────────────────── */
.dash-notes-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  border-radius: var(--radius-lg);
  color: #fff;
  cursor: pointer;
  margin-bottom: 20px;
  box-shadow: 0 4px 18px rgba(245,158,11,.35);
  transition: transform .2s ease, box-shadow .2s ease;
  text-decoration: none;
  border: none;
  width: 100%;
}
.dash-notes-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(245,158,11,.45);
  color: #fff;
}
.dash-notes-banner-icon { font-size: 34px; flex-shrink: 0; }
.dash-notes-banner-title { font-size: 1.1rem; font-weight: 700; }
.dash-notes-banner-sub   { font-size: .82rem; opacity: .85; margin-top: 3px; }
.dash-notes-banner-arrow { margin-left: auto; font-size: 28px; opacity: .7; font-weight: 300; flex-shrink: 0; }

/* ── Page Notes — liste ──────────────────────────────────────────── */
.notes-list {
  padding: 0;
  overflow: visible;
}
.note-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.note-row:last-child { border-bottom: none; }
.note-row:hover { background: var(--surface-hover); }

/* Ligne 1 : chips + kebab */
.note-row-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.note-row-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.note-chip {
  font-size: .75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.note-status-pill {
  border: none;
  border-radius: 12px;
  padding: 2px 9px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  max-width: 100px;
}

/* Ligne 2 : texte */
.note-row-line2 {
  font-size: .88rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.note-row-line2--long { cursor: pointer; }
.note-row-line2--long:hover { text-decoration: underline dotted; }

/* Kebab menu */
.note-kebab-wrapper {
  position: relative;
  flex-shrink: 0;
}
.note-kebab {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background .12s, color .12s;
}
.note-kebab:hover { background: var(--surface-hover); color: var(--text); }
.note-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 170px;
  z-index: 50;
  overflow: hidden;
}
.note-dropdown.open { display: block; }
.note-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: none;
  border: none;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.note-dropdown button:hover { background: var(--surface-hover); }
.note-dropdown-danger { color: var(--danger) !important; }

/* Note assignée à l'utilisateur courant */
.note-row--assigned {
  border-left: 3px solid var(--primary);
  background: rgba(37,99,235,.04);
}
.note-row--assigned:hover { background: rgba(37,99,235,.07); }

/* Barre de filtres */
.notes-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.notes-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-alt);
  font-size: .8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
.notes-filter-chip:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}
.notes-filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Audit de modification */
.note-row-modified {
  font-size: .73rem;
  color: var(--text-secondary);
  opacity: .75;
  margin-top: 5px;
}

/* Checkboxes Pour qui (modal) */
.note-pourqui-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.note-pourqui-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: .9rem;
}
.note-pourqui-item input[type=checkbox] { cursor: pointer; }

/* Badge sidebar Notes */
.nav-notes-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 4px;
}

/* Compteurs sur le banner Notes (dashboard) */
.notes-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 13px;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.notes-count-badge--red  { background: rgba(220,38,38,.85); }
.notes-count-badge--blue { background: rgba(37,99,235,.85); }

/* Section suivi */
.note-suivi { margin-top: 8px; }
.note-suivi-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}
.note-suivi-toggle:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--surface-hover);
}
.note-suivi-toggle[aria-expanded="true"] {
  border-color: var(--primary-light);
  color: var(--primary);
  background: rgba(37,99,235,.06);
}
.note-suivi-toggle.has-comments {
  border-color: var(--primary-light);
  color: var(--primary);
  background: rgba(37,99,235,.08);
  font-weight: 600;
}
.note-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1;
}
.note-suivi-loading {
  padding: 8px 0;
  font-size: .82rem;
  color: var(--text-secondary);
}
.note-suivi-content {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Toolbar suivi (compteur + refresh) */
.note-suivi-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.note-suivi-count {
  font-size: .75rem;
  color: var(--text-secondary);
}
.note-suivi-refresh-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .8rem;
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 5px;
  transition: color .12s, background .12s;
}
.note-suivi-refresh-btn:hover { color: var(--primary); background: var(--surface-hover); }

/* Commentaires */
.note-comments-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.note-comment {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.note-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.note-comment-author { font-size: .78rem; font-weight: 600; color: var(--text); }
.note-comment-date   { font-size: .73rem; color: var(--text-secondary); flex: 1; }
.note-comment-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: .78rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .1s, background .1s;
  margin-left: auto;
  opacity: .6;
}
.note-comment-delete:hover { color: var(--danger); background: rgba(220,38,38,.08); opacity: 1; }
.note-suivi-arrow {
  font-size: .65rem;
  margin-left: 4px;
  opacity: .6;
  transition: transform .15s;
}
.note-comment-text  { font-size: .85rem; line-height: 1.45; color: var(--text); word-break: break-word; }
.note-comment-empty { font-size: .82rem; color: var(--text-secondary); padding: 4px 0; }
.note-comment-add   { display: flex; flex-direction: column; gap: 6px; }
.note-comment-input { font-size: .85rem; resize: vertical; }

/* Archive toggle */
.notes-archive-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .88rem;
  color: var(--text-secondary);
  transition: color .15s, border-color .15s;
  user-select: none;
  list-style: none;
}
.notes-archive-toggle:hover { color: var(--text); border-color: var(--primary-light); }
.notes-archive-details summary::-webkit-details-marker { display: none; }

/* Bouton micro dictée */
.notes-mic-btn {
  background: none;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
  flex-shrink: 0;
}
.notes-mic-btn:hover { border-color: #F59E0B; background: rgba(245,158,11,.08); }
.notes-mic-btn.recording {
  border-color: #EF4444;
  background: rgba(239,68,68,.1);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.45); }
  50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

@media (max-width: 640px) {
  .dash-notes-banner { padding: 16px 18px; gap: 12px; }
  .dash-notes-banner-icon { font-size: 26px; }
  .dash-notes-banner-title { font-size: 1rem; }
  .note-chip { font-size: .7rem; }
}

